linux-kexecboot: add initial ben-nanonote support
[openembedded.git] / recipes / linux / linux-kexecboot.inc
blob90ee7c28ce9273a767f5ad90c2f54e7104aca0cb
1 # We set INC_PR here, since a change in the kexecboot recipe will need to get picked up by *all* the kernels:
2 INC_PR = "r30"
4 inherit kernel siteinfo
6 # Additional Sources for 2.6.24 and 2.6.26
7 RPSRC = "http://www.rpsys.net/openzaurus/patches/archive"
8 TKSRC = "http://www.informatik.hu-berlin.de/~tkunze/zaurus/patches"
10 # Kernel bootlogo is distro-specific (default is OE logo).
11 # Logo resolution (qvga, vga, ...) is machine-specific.
12 LOGO_SIZE ?= "."
13 SRC_URI = "file://${LOGO_SIZE}/logo_linux_clut224.ppm.bz2"
15 # Note how we set master console on serial to protect bootlogo.
16 CMDLINE_c7x0 = "console=tty1 console=ttyS0,115200n8"
17 CMDLINE_tosa = "console=tty1 console=ttyS0,115200n8"
18 CMDLINE_poodle = "console=tty1 console=ttyS0,115200n8 fbcon=rotate:1"
19 CMDLINE_akita = "console=tty1 console=ttyS0,115200n8 fbcon=rotate:1"
20 CMDLINE_collie = "console=tty1 console=ttySA0,115200n8 fbcon=rotate:1 mem=64M"
21 CMDLINE_spitz = "console=tty1 console=ttyS0,115200n8 fbcon=rotate:1"
22 CMDLINE_hx4700 = "console=tty1 console=ttyS0,115200n8 fbcon=rotate:1"
23 CMDLINE_ben-nanonote = "console=tty0 console=ttyS0,57600n8 mem=32M"
26 # Set the verbosity of kernel messages during runtime
27 # You can define CMDLINE_DEBUG in your local.conf or distro.conf to override this behaviour..
28 CMDLINE_DEBUG ?= '${@base_conditional("DISTRO_TYPE", "release", "loglevel=3", "debug", d)}'
29 CMDLINE += "${CMDLINE_DEBUG}"
31 PACKAGES = ""
32 PROVIDES = ""
34 # Zaurus machines need kernel size-check
35 KERNEL_IMAGE_MAXSIZE_akita = "1294336"
36 KERNEL_IMAGE_MAXSIZE_c7x0 = "1294336"
37 KERNEL_IMAGE_MAXSIZE_collie = "1048576"
38 KERNEL_IMAGE_MAXSIZE_poodle = "1294336"
39 KERNEL_IMAGE_MAXSIZE_tosa = "1294336"
40 KERNEL_IMAGE_MAXSIZE_spitz = "1294336"
42 KERNEL_IMAGE_BASE_NAME = "${KERNEL_IMAGETYPE}-kexecboot-${PV}-${PR}-${MACHINE}"
43 KERNEL_IMAGE_SYMLINK_NAME = "${KERNEL_IMAGETYPE}-kexecboot-${MACHINE}"
45 LOCALVERSION ?= ""
47 # we want the smallest size
48 INITRAMFS_IMAGE = "initramfs-kexecboot-klibc-image"
50 # use custom function until base_version_less_or_equal is fixed
52 def kernel_version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
53     from bb import utils
54     result = bb.utils.vercmp_part(bb.data.getVar(variable,d,True), checkvalue)
55     if result <= 0:
56         return truevalue
57     else:
58         return falsevalue
60 # force lzma compression for kernel (linux-kexecboot >= 2.6.32)
61 # force lzma compression for initramfs (linux-kexecboot >= 2.6.30)
62 DEPENDS += '${@kernel_version_less_or_equal("PV", "2.6.29", "", "lzma-native", d)}'
64 KERNEL_COMPRESSION = '${@kernel_version_less_or_equal("PV", "2.6.31", "", "CONFIG_KERNEL_LZMA=y", d)}'
66 INITRAMFS_COMPRESSION = '${@kernel_version_less_or_equal("PV", "2.6.29", "", "CONFIG_INITRAMFS_COMPRESSION_LZMA=y", d)}'
67 INITRAMFS_COMPRESSION_SUFFIX = '${@kernel_version_less_or_equal("PV", "2.6.29", "gz", "lzma", d)}'
68 RD_COMPRESSION = '${@kernel_version_less_or_equal("PV", "2.6.29", "", "CONFIG_RD_LZMA=y", d)}'
70 do_configure_prepend() {
72         # Rename getline in ./scripts/unifdef.c
73         # Kernels up to 2.6.29 are currently failing to build unifdef.c,
74         # clashing with exposed getline() from <stdio.h>
75         # see https://patchwork.kernel.org/patch/11166/
76         # committed in 2.6.29 (commit d15bd1067b1fcb2b7250d22bc0c7c7fea0b759f7)
78         if [ -e ${S}/scripts/unifdef.c ]; then
79                 sed -i -e 's/getline/parseline/g' ${S}/scripts/unifdef.c
80         fi
82         echo "" > ${S}/.config
84         echo "CONFIG_CMDLINE=\"${CMDLINE}\"" >> ${S}/.config
86         #
87         # endian support
88         #
89         if [ "${SITEINFO_ENDIANNESS}" = "be" ]; then
90                 echo "CONFIG_CPU_BIG_ENDIAN=y"          >> ${S}/.config
91         fi
93         #
94         # logo support, if you supply logo_linux_clut224.ppm in SRC_URI, then it is going to be used
95         #
96         if [ -e ${WORKDIR}/${LOGO_SIZE}/logo_linux_clut224.ppm ]; then
97                 install -m 0644 ${WORKDIR}/${LOGO_SIZE}/logo_linux_clut224.ppm drivers/video/logo/logo_linux_clut224.ppm
98                 echo "CONFIG_LOGO=y"                    >> ${S}/.config
99                 echo "CONFIG_LOGO_LINUX_CLUT224=y"      >> ${S}/.config
100         fi
102         # When enabling thumb for userspace we also need thumb support in the kernel
103         if [ "${ARM_INSTRUCTION_SET}" = "thumb" ] ; then
104             sed -i -e /CONFIG_ARM_THUMB/d ${WORKDIR}/defconfig 
105             echo "CONFIG_ARM_THUMB=y" >> ${S}/.config
106         fi
108         sed -e '/CONFIG_CMDLINE=/d' \
109             -e '/CONFIG_CPU_BIG_ENDIAN/d' \
110             -e '/CONFIG_LOGO=/d' \
111             -e '/CONFIG_LOGO_LINUX_CLUT224=/d' \
112             -e '/CONFIG_LOCALVERSION/d' \
113             -e '/CONFIG_LOCALVERSION_AUTO/d' \
114             < '${WORKDIR}/defconfig' >>'${S}/.config'
116         echo 'CONFIG_LOCALVERSION="${LOCALVERSION}"' >>${S}/.config
117         echo '# CONFIG_LOCALVERSION_AUTO is not set' >>${S}/.config
119         # Force sane defaults for kexec-enabled kernels and keep size small
120         sed -i -e /CONFIG_BLK_DEV_INITRD/d \
121                -e /CONFIG_KEXEC/d \
122                -e /CONFIG_KERNEL/d \
123                -e /CONFIG_INITRAMFS_COMPRESSION/d \
124                -e /CONFIG_INITRAMFS_SOURCE/d \
125                -e /CONFIG_RD/d \
126                -e /=m/d \
127                -e /CONFIG_MODULES/d \
128                -e /CONFIG_DEBUG_ERRORS/d \
129                -e /CONFIG_DEBUG_BUGVERBOSE/d \
130                -e /CONFIG_DEBUG_KERNEL/d \
131                ${S}/.config
133                echo 'CONFIG_BLK_DEV_INITRD=y' >>${S}/.config
134                echo 'CONFIG_KEXEC=y' >>${S}/.config
135                echo '${KERNEL_COMPRESSION}' >>${S}/.config
136                echo '"${INITRAMFS_COMPRESSION}"' >>${S}/.config
137                echo 'CONFIG_INITRAMFS_SOURCE="initramfs.cpio.${INITRAMFS_COMPRESSION_SUFFIX}"' >>${S}/.config
138                echo '"${RD_COMPRESSION}"' >>${S}/.config
139                echo 'CONFIG_MODULES=n' >> ${S}/.config
141         yes '' | oe_runmake oldconfig
144 do_populate_sysroot() {
147 do_install() {
150 python do_package() {
154 # With 2.6.37 mips has no uImage target upstream.
155 # use custom task in the meantime
157 do_uboot_mkimage_ben-nanonote() {
158         cd ${S}
159         kernel_entry=`nm vmlinux | grep " kernel_entry" | cut -d' ' -f1`
161         cd ${S}/arch/mips/boot
162         rm -f vmlinux.bin.gz
163         gzip -c9 vmlinux.bin > vmlinux.bin.gz
165         mkimage -A mips -O linux -T kernel -C gzip -a 0x80010000 -e 0x${kernel_entry} \
166         -n 'MIPS' -d vmlinux.bin.gz uImage-kexecboot-${PV}-${PR}-${MACHINE}.bin
168         install -d ${DEPLOY_DIR_IMAGE}
169         install -m 0644 uImage-kexecboot-${PV}-${PR}-${MACHINE}.bin ${DEPLOY_DIR_IMAGE}