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