pandora-scripts: Clean up recipe and rename some scripts to what the recipe expects.
[openpandora.oe.git] / recipes / linux / linux.inc
1 DESCRIPTION = "Linux Kernel"
2 SECTION = "kernel"
3 LICENSE = "GPL"
4
5 inherit kernel
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_lsppchd = "arch/${ARCH}/boot/dts/kuroboxHD.dts"
36 KERNEL_DEVICETREE_lsppchg = "arch/${ARCH}/boot/dts/kuroboxHG.dts"
37 KERNEL_DEVICETREE_mpc8313e-rdb = "arch/${ARCH}/boot/dts/mpc8313erdb.dts"
38 KERNEL_DEVICETREE_mpc8315e-rdb = "arch/${ARCH}/boot/dts/mpc8315erdb.dts"
39 KERNEL_DEVICETREE_mpc8323e-rdb = "arch/${ARCH}/boot/dts/mpc832x_rdb.dts"
40 KERNEL_DEVICETREE_sequoia = "arch/${ARCH}/boot/dts/sequoia.dts"
41
42 KERNEL_DEVICETREE_FLAGS = "-R 8 -S 0x3000"
43
44 python __anonymous () {
45
46     import bb
47     
48     devicetree = bb.data.getVar('KERNEL_DEVICETREE', d, 1) or ''
49     if devicetree:
50         depends = bb.data.getVar("DEPENDS", d, 1)
51         bb.data.setVar("DEPENDS", "%s dtc-native" % depends, d)
52         packages = bb.data.getVar("PACKAGES", d, 1)
53         bb.data.setVar("PACKAGES", "%s kernel-devicetree" % packages, d)
54 }
55
56 do_configure_prepend() {
57         echo "" > ${S}/.config
58
59         #
60         # logo support, if you supply logo_linux_clut224.ppm in SRC_URI, then it's going to be used
61         #
62         if [ -e ${WORKDIR}/logo_linux_clut224.ppm ]; then
63                 install -m 0644 ${WORKDIR}/logo_linux_clut224.ppm drivers/video/logo/logo_linux_clut224.ppm
64                 echo "CONFIG_LOGO=y"                    >> ${S}/.config
65                 echo "CONFIG_LOGO_LINUX_CLUT224=y"      >> ${S}/.config
66         fi
67
68         #
69         # oabi / eabi support
70         #
71         if [ "${TARGET_OS}" = "linux-gnueabi" -o  "${TARGET_OS}" = "linux-uclibceabi" ]; then
72                 echo "CONFIG_AEABI=y"                   >> ${S}/.config
73                 if [ "${ARM_KEEP_OABI}" = "1" ] ; then
74                         echo "CONFIG_OABI_COMPAT=y"             >> ${S}/.config
75                 else
76                         echo "# CONFIG_OABI_COMPAT is not set"  >> ${S}/.config
77                 fi
78         else
79                 echo "# CONFIG_AEABI is not set"        >> ${S}/.config
80                 echo "# CONFIG_OABI_COMPAT is not set"  >> ${S}/.config
81         fi
82
83         # When enabling thumb for userspace we also need thumb support in the kernel
84         if [ "${ARM_INSTRUCTION_SET}" = "thumb" ] ; then
85             sed -i -e /CONFIG_ARM_THUMB/d ${WORKDIR}/defconfig 
86             echo "CONFIG_ARM_THUMB=y" >> ${S}/.config
87         fi
88
89         #
90         # endian support
91         #
92         if [ "${SITEINFO_ENDIANESS}" = "be" ]; then
93                 echo "CONFIG_CPU_BIG_ENDIAN=y"          >> ${S}/.config
94         fi
95
96         echo "CONFIG_CMDLINE=\"${CMDLINE}\"" >> ${S}/.config
97
98         sed -e '/CONFIG_AEABI/d' \
99             -e '/CONFIG_OABI_COMPAT=/d' \
100             -e '/CONFIG_CMDLINE=/d' \
101             -e '/CONFIG_CPU_BIG_ENDIAN/d' \
102             -e '/CONFIG_LOGO=/d' \
103             -e '/CONFIG_LOGO_LINUX_CLUT224=/d' \
104             -e '/CONFIG_LOCALVERSION/d' \
105             -e '/CONFIG_LOCALVERSION_AUTO/d' \
106             < '${WORKDIR}/defconfig' >>'${S}/.config'
107
108         echo 'CONFIG_LOCALVERSION=""' >>${S}/.config
109         echo '# CONFIG_LOCALVERSION_AUTO is not set' >>${S}/.config
110
111         #
112         # Udev quirks
113         #
114
115         # Newer versions of udev mandate that sysfs doesn't have deprecated entries
116         if [ "${UDEV_GE_141}" = "1" ] ; then
117             sed -e /CONFIG_SYSFS_DEPRECATED/d \
118                 -e /CONFIG_SYSFS_DEPRECATED_V2/d \
119                 -i '${S}/.config'
120             echo '# CONFIG_SYSFS_DEPRECATED is not set' >> ${S}/.config
121             echo '# CONFIG_SYSFS_DEPRECATED_V2 is not set' >> ${S}/.config
122         fi
123
124         #
125         # root-over-nfs-over-usb-eth support. Limited, but should cover some cases.
126         # Enable this by setting a proper CMDLINE_NFSROOT_USB.
127         #
128         if [ ! -z "${CMDLINE_NFSROOT_USB}" ]; then
129                 oenote "Configuring the kernel for root-over-nfs-over-usb-eth with CMDLINE ${CMDLINE_NFSROOT_USB}"
130                 sed -e '/CONFIG_INET/d' \
131                     -e '/CONFIG_IP_PNP=/d' \
132                     -e '/CONFIG_USB_GADGET=/d' \
133                     -e '/CONFIG_USB_GADGET_SELECTED=/d' \
134                     -e '/CONFIG_USB_ETH=/d' \
135                     -e '/CONFIG_NFS_FS=/d' \
136                     -e '/CONFIG_ROOT_NFS=/d' \
137                     -e '/CONFIG_CMDLINE=/d' \
138                     -i ${S}/.config
139                 echo "CONFIG_INET=y"                     >> ${S}/.config
140                 echo "CONFIG_IP_PNP=y"                   >> ${S}/.config
141                 echo "CONFIG_USB_GADGET=y"               >> ${S}/.config
142                 echo "CONFIG_USB_GADGET_SELECTED=y"      >> ${S}/.config
143                 echo "CONFIG_USB_ETH=y"                  >> ${S}/.config
144                 echo "CONFIG_NFS_FS=y"                   >> ${S}/.config
145                 echo "CONFIG_ROOT_NFS=y"                 >> ${S}/.config
146                 echo "CONFIG_CMDLINE=\"${CMDLINE_NFSROOT_USB}\"" >> ${S}/.config
147         fi
148                 yes '' | oe_runmake oldconfig
149 }
150
151 do_configure_append_avr32() {
152         sed -i -e s:-mno-pic::g arch/avr32/Makefile
153 }
154
155 do_configure_append() {
156         if test -e scripts/Makefile.fwinst ; then
157                 sed -i -e "s:-m0644:-m 0644:g" scripts/Makefile.fwinst
158         fi
159 }
160
161 do_devicetree_image() {
162     if test -n "${KERNEL_DEVICETREE}" ; then
163         dtc -I dts -O dtb ${KERNEL_DEVICETREE_FLAGS} -o devicetree ${KERNEL_DEVICETREE}
164         install -m 0644 devicetree ${D}/boot/devicetree-${KERNEL_VERSION}
165         install -d ${DEPLOY_DIR_IMAGE}
166         install -m 0644 devicetree ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGE_BASE_NAME}.dtb
167         cd ${DEPLOY_DIR_IMAGE}
168         rm -f ${KERNEL_IMAGE_SYMLINK_NAME}.dtb
169         ln -sf ${KERNEL_IMAGE_BASE_NAME}.dtb ${KERNEL_IMAGE_SYMLINK_NAME}.dtb
170     fi
171 }
172
173 addtask devicetree_image after do_install before do_package do_deploy
174
175 pkg_postinst_kernel-devicetree () {
176         cd /${KERNEL_IMAGEDEST}; update-alternatives --install /${KERNEL_IMAGEDEST}/devicetree devicetree devicetree-${KERNEL_VERSION} ${KERNEL_PRIORITY} || true
177 }
178
179 pkg_postrm_kernel-devicetree () {
180         cd /${KERNEL_IMAGEDEST}; update-alternatives --remove devicetree devicetree-${KERNEL_VERSION} || true
181 }
182