omap3-pandora-kernel: bump and enable ipfilter modules
[openpandora.oe.git] / recipes / linux / linux.inc
1 DESCRIPTION = "Linux Kernel"
2 SECTION = "kernel"
3 LICENSE = "GPLv2"
4
5 inherit kernel siteinfo
6
7 RPSRC = "http://www.rpsys.net/openzaurus/patches/archive"
8
9 # Enable OABI compat for people stuck with obsolete userspace
10 ARM_KEEP_OABI ?= "1"
11
12 # Quirk for udev greater or equal 141
13 UDEV_GE_141 ?= "0"
14
15 # Specify the commandline for your device
16
17 # Boot from mmc
18 CMDLINE_at91sam9263ek = "mem=64M console=ttyS0,115200 root=/dev/mmcblk0p1 rootfstype=ext2 rootdelay=5"
19 # Boot from nfs
20 #CMDLINE_at91sam9263ek = "mem=64M console=ttyS0,115200 root=301 root=/dev/nfs nfsroot=172.20.3.1:/data/at91 ip=172.20.0.5:::255.255.0.0"
21
22 # Set the verbosity of kernel messages during runtime
23 # You can define CMDLINE_DEBUG in your local.conf or distro.conf to override this behaviour  
24 CMDLINE_DEBUG ?= '${@base_conditional("DISTRO_TYPE", "release", "quiet", "debug", d)}'
25 CMDLINE_append = " ${CMDLINE_DEBUG} "
26
27 # Support for binary device tree generation
28
29 FILES_kernel-devicetree = "/boot/devicetree*"
30
31 KERNEL_DEVICETREE_boc01 = "${WORKDIR}/boc01.dts"
32 KERNEL_DEVICETREE_calamari = "arch/${ARCH}/boot/dts/mpc8536ds.dts"
33 KERNEL_DEVICETREE_canyonlands = "arch/${ARCH}/boot/dts/canyonlands.dts"
34 KERNEL_DEVICETREE_kilauea = "arch/${ARCH}/boot/dts/kilauea.dts"
35 KERNEL_DEVICETREE_lite5200 = "arch/${ARCH}/boot/dts/lite5200.dts"
36 KERNEL_DEVICETREE_lsppchd = "arch/${ARCH}/boot/dts/kuroboxHD.dts"
37 KERNEL_DEVICETREE_lsppchg = "arch/${ARCH}/boot/dts/kuroboxHG.dts"
38 KERNEL_DEVICETREE_mpc8313e-rdb = "arch/${ARCH}/boot/dts/mpc8313erdb.dts"
39 KERNEL_DEVICETREE_mpc8315e-rdb = "arch/${ARCH}/boot/dts/mpc8315erdb.dts"
40 KERNEL_DEVICETREE_mpc8323e-rdb = "arch/${ARCH}/boot/dts/mpc832x_rdb.dts"
41 KERNEL_DEVICETREE_mpc8544ds = "arch/${ARCH}/boot/dts/mpc8544ds.dts"
42 KERNEL_DEVICETREE_mpc8641-hpcn = "arch/${ARCH}/boot/dts/mpc8641_hpcn.dts"
43 KERNEL_DEVICETREE_p1020rdb = "arch/${ARCH}/boot/dts/p1020rdb.dts"
44 KERNEL_DEVICETREE_p2020ds = "arch/${ARCH}/boot/dts/p2020ds.dts"
45 KERNEL_DEVICETREE_sequoia = "arch/${ARCH}/boot/dts/sequoia.dts"
46 KERNEL_DEVICETREE_tqm8540 = "arch/${ARCH}/boot/dts/tqm8540.dts"
47 KERNEL_DEVICETREE_xilinx-ml507 = "arch/${ARCH}/boot/dts/virtex440-ml507.dts"
48
49 KERNEL_DEVICETREE_FLAGS = "-R 8 -S 0x3000"
50
51 python __anonymous () {
52
53     import bb
54     
55     devicetree = bb.data.getVar('KERNEL_DEVICETREE', d, 1) or ''
56     if devicetree:
57         depends = bb.data.getVar("DEPENDS", d, 1)
58         bb.data.setVar("DEPENDS", "%s dtc-native" % depends, d)
59         packages = bb.data.getVar("PACKAGES", d, 1)
60         bb.data.setVar("PACKAGES", "%s kernel-devicetree" % packages, d)
61 }
62
63 do_configure_prepend() {
64
65         # Rename getline in ./scripts/unifdef.c
66         # Kernels up to 2.6.29 are currently failing to build unifdef.c,
67         # clashing with exposed getline() from <stdio.h>
68         # see https://patchwork.kernel.org/patch/11166/
69         # committed in 2.6.29 (commit d15bd1067b1fcb2b7250d22bc0c7c7fea0b759f7)
70
71         sed -i -e 's/getline/parseline/g' ${S}/scripts/unifdef.c
72
73
74         echo "" > ${S}/.config
75
76         #
77         # logo support, if you supply logo_linux_clut224.ppm in SRC_URI, then it's going to be used
78         #
79         if [ -e ${WORKDIR}/logo_linux_clut224.ppm ]; then
80                 install -m 0644 ${WORKDIR}/logo_linux_clut224.ppm drivers/video/logo/logo_linux_clut224.ppm
81                 echo "CONFIG_LOGO=y"                    >> ${S}/.config
82                 echo "CONFIG_LOGO_LINUX_CLUT224=y"      >> ${S}/.config
83         fi
84
85         #
86         # oabi / eabi support
87         #
88         if [ "${TARGET_OS}" = "linux-gnueabi" -o  "${TARGET_OS}" = "linux-uclibceabi" ]; then
89                 echo "CONFIG_AEABI=y"                   >> ${S}/.config
90                 if [ "${ARM_KEEP_OABI}" = "1" ] ; then
91                         echo "CONFIG_OABI_COMPAT=y"             >> ${S}/.config
92                 else
93                         echo "# CONFIG_OABI_COMPAT is not set"  >> ${S}/.config
94                 fi
95         else
96                 echo "# CONFIG_AEABI is not set"        >> ${S}/.config
97                 echo "# CONFIG_OABI_COMPAT is not set"  >> ${S}/.config
98         fi
99
100         # When enabling thumb for userspace we also need thumb support in the kernel
101         if [ "${ARM_INSTRUCTION_SET}" = "thumb" ] ; then
102             sed -i -e /CONFIG_ARM_THUMB/d ${WORKDIR}/defconfig 
103             echo "CONFIG_ARM_THUMB=y" >> ${S}/.config
104         fi
105
106         # Enable thumb2 fixup for specific issue in angstrom toolchains when used on A8 r1p[012] silicon
107         if [ "${DISTRO_NAME}" = "Angstrom" ] ; then
108             sed -i -e /CONFIG_ARM_ERRATA_430973/d ${WORKDIR}/defconfig
109             echo "CONFIG_ARM_ERRATA_430973=y" >> ${S}/.config
110         fi
111
112         #
113         # endian support
114         #
115         if [ "${SITEINFO_ENDIANNESS}" = "be" ]; then
116                 echo "CONFIG_CPU_BIG_ENDIAN=y"          >> ${S}/.config
117         fi
118
119         echo "CONFIG_CMDLINE=\"${CMDLINE}\"" >> ${S}/.config
120
121         sed -e '/CONFIG_AEABI/d' \
122             -e '/CONFIG_OABI_COMPAT=/d' \
123             -e '/CONFIG_CMDLINE=/d' \
124             -e '/CONFIG_CPU_BIG_ENDIAN/d' \
125             -e '/CONFIG_LOGO=/d' \
126             -e '/CONFIG_LOGO_LINUX_CLUT224=/d' \
127             -e '/CONFIG_LOCALVERSION/d' \
128             -e '/CONFIG_LOCALVERSION_AUTO/d' \
129             < '${WORKDIR}/defconfig' >>'${S}/.config'
130
131         echo 'CONFIG_LOCALVERSION=""' >>${S}/.config
132         echo '# CONFIG_LOCALVERSION_AUTO is not set' >>${S}/.config
133
134         #
135         # Udev quirks
136         #
137
138         # Newer versions of udev mandate that sysfs doesn't have deprecated entries
139         if [ "${UDEV_GE_141}" = "1" ] ; then
140             sed -e /CONFIG_SYSFS_DEPRECATED/d \
141                 -e /CONFIG_SYSFS_DEPRECATED_V2/d \
142                 -e /CONFIG_HOTPLUG/d \
143                 -e /CONFIG_UEVENT_HELPER_PATH/d \
144                 -e /CONFIG_UNIX/d \
145                 -e /CONFIG_SYSFS/d \
146                 -e /CONFIG_PROC_FS/d \
147                 -e /CONFIG_TMPFS/d \
148                 -e /CONFIG_INOTIFY_USER/d \
149                 -e /CONFIG_SIGNALFD/d \
150                 -e /CONFIG_TMPFS_POSIX_ACL/d \
151                 -e /CONFIG_BLK_DEV_BSG/d \
152                 -i '${S}/.config'
153
154             echo '# CONFIG_SYSFS_DEPRECATED is not set' >> ${S}/.config
155             echo '# CONFIG_SYSFS_DEPRECATED_V2 is not set' >> ${S}/.config
156             echo 'CONFIG_HOTPLUG=y' >> ${S}/.config
157             echo 'CONFIG_UEVENT_HELPER_PATH=""' >> ${S}/.config
158             echo 'CONFIG_UNIX=y' >> ${S}/.config
159             echo 'CONFIG_SYSFS=y' >> ${S}/.config
160             echo 'CONFIG_PROC_FS=y' >> ${S}/.config
161             echo 'CONFIG_TMPFS=y' >> ${S}/.config
162             echo 'CONFIG_INOTIFY_USER=y' >> ${S}/.config
163             echo 'CONFIG_SIGNALFD=y' >> ${S}/.config
164             echo 'CONFIG_TMPFS_POSIX_ACL=y' >> ${S}/.config
165             echo 'CONFIG_BLK_DEV_BSG=y' >> ${S}/.config
166             echo 'CONFIG_DEVTMPFS=y' >> ${S}/.config
167             echo 'CONFIG_DEVTMPFS_MOUNT=y' >> ${S}/.config
168         fi
169
170         # Newer inits like systemd need cgroup support
171         if [ "${KERNEL_ENABLE_CGROUPS}" = "1" ] ; then
172             sed -e /CONFIG_CGROUP_SCHED/d \
173                 -e /CONFIG_CGROUPS/d \
174                 -i '${S}/.config'
175             
176             echo 'CONFIG_CGROUP_SCHED=y' >> ${S}/.config
177             echo 'CONFIG_CGROUPS=y' >> ${S}/.config
178             echo 'CONFIG_CGROUP_NS=y' >> ${S}/.config
179             echo 'CONFIG_CGROUP_FREEZER=y' >> ${S}/.config
180             echo 'CONFIG_CGROUP_DEVICE=y' >> ${S}/.config
181             echo 'CONFIG_CPUSETS=y' >> ${S}/.config
182             echo 'CONFIG_PROC_PID_CPUSET=y' >> ${S}/.config
183             echo 'CONFIG_CGROUP_CPUACCT=y' >> ${S}/.config
184             echo 'CONFIG_RESOURCE_COUNTERS=y' >> ${S}/.config
185         fi
186
187         #
188         # root-over-nfs-over-usb-eth support. Limited, but should cover some cases.
189         # Enable this by setting a proper CMDLINE_NFSROOT_USB.
190         #
191         if [ ! -z "${CMDLINE_NFSROOT_USB}" ]; then
192                 oenote "Configuring the kernel for root-over-nfs-over-usb-eth with CMDLINE ${CMDLINE_NFSROOT_USB}"
193                 sed -e '/CONFIG_INET/d' \
194                     -e '/CONFIG_IP_PNP=/d' \
195                     -e '/CONFIG_USB_GADGET=/d' \
196                     -e '/CONFIG_USB_GADGET_SELECTED=/d' \
197                     -e '/CONFIG_USB_ETH=/d' \
198                     -e '/CONFIG_NFS_FS=/d' \
199                     -e '/CONFIG_ROOT_NFS=/d' \
200                     -e '/CONFIG_CMDLINE=/d' \
201                     -i ${S}/.config
202                 echo "CONFIG_INET=y"                     >> ${S}/.config
203                 echo "CONFIG_IP_PNP=y"                   >> ${S}/.config
204                 echo "CONFIG_USB_GADGET=y"               >> ${S}/.config
205                 echo "CONFIG_USB_GADGET_SELECTED=y"      >> ${S}/.config
206                 echo "CONFIG_USB_ETH=y"                  >> ${S}/.config
207                 echo "CONFIG_NFS_FS=y"                   >> ${S}/.config
208                 echo "CONFIG_ROOT_NFS=y"                 >> ${S}/.config
209                 echo "CONFIG_CMDLINE=\"${CMDLINE_NFSROOT_USB}\"" >> ${S}/.config
210         fi
211                 yes '' | oe_runmake oldconfig
212 }
213
214 do_configure_append() {
215         if test -e scripts/Makefile.fwinst ; then
216                 sed -i -e "s:-m0644:-m 0644:g" scripts/Makefile.fwinst
217         fi
218 }
219
220 do_install_append() {
221         oe_runmake headers_install INSTALL_HDR_PATH=${D}${exec_prefix}/src/linux-${KERNEL_VERSION} ARCH=$ARCH
222 }
223
224 PACKAGES =+ "kernel-headers"
225 FILES_kernel-headers = "${exec_prefix}/src/linux*"
226
227 do_devicetree_image() {
228     if test -n "${KERNEL_DEVICETREE}" ; then
229         dtc -I dts -O dtb ${KERNEL_DEVICETREE_FLAGS} -o devicetree ${KERNEL_DEVICETREE}
230         install -m 0644 devicetree ${D}/boot/devicetree-${KERNEL_VERSION}
231         install -d ${DEPLOY_DIR_IMAGE}
232         install -m 0644 devicetree ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE_BASE_NAME}.dtb
233         package_stagefile_shell ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE_BASE_NAME}.dtb
234         cd ${DEPLOY_DIR_IMAGE}
235         rm -f ${KERNEL_IMAGE_SYMLINK_NAME}.dtb
236         ln -sf ${KERNEL_IMAGE_BASE_NAME}.dtb ${KERNEL_IMAGE_SYMLINK_NAME}.dtb
237         package_stagefile_shell ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE_SYMLINK_NAME}.dtb
238     fi
239 }
240
241 addtask devicetree_image after do_install before do_package do_deploy
242
243 pkg_postinst_kernel-devicetree () {
244         cd /${KERNEL_IMAGEDEST}; update-alternatives --install /${KERNEL_IMAGEDEST}/devicetree devicetree devicetree-${KERNEL_VERSION} ${KERNEL_PRIORITY} || true
245 }
246
247 pkg_postrm_kernel-devicetree () {
248         cd /${KERNEL_IMAGEDEST}; update-alternatives --remove devicetree devicetree-${KERNEL_VERSION} || true
249 }
250