xref: /OK3568_Linux_fs/yocto/poky/meta/classes/kernel-uimage.bbclass (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1inherit kernel-uboot
2
3python __anonymous () {
4    if "uImage" in d.getVar('KERNEL_IMAGETYPES'):
5        depends = d.getVar("DEPENDS")
6        depends = "%s u-boot-tools-native" % depends
7        d.setVar("DEPENDS", depends)
8
9        # Override KERNEL_IMAGETYPE_FOR_MAKE variable, which is internal
10        # to kernel.bbclass . We override the variable here, since we need
11        # to build uImage using the kernel build system if and only if
12        # KEEPUIMAGE == yes. Otherwise, we pack compressed vmlinux into
13        # the uImage .
14        if d.getVar("KEEPUIMAGE") != 'yes':
15            typeformake = d.getVar("KERNEL_IMAGETYPE_FOR_MAKE") or ""
16            if "uImage" in typeformake.split():
17                d.setVar('KERNEL_IMAGETYPE_FOR_MAKE', typeformake.replace('uImage', 'vmlinux'))
18
19            # Enable building of uImage with mkimage
20            bb.build.addtask('do_uboot_mkimage', 'do_install', 'do_kernel_link_images', d)
21}
22
23do_uboot_mkimage[dirs] += "${B}"
24do_uboot_mkimage() {
25	uboot_prep_kimage
26
27	ENTRYPOINT=${UBOOT_ENTRYPOINT}
28	if [ -n "${UBOOT_ENTRYSYMBOL}" ]; then
29		ENTRYPOINT=`${HOST_PREFIX}nm ${B}/vmlinux | \
30			awk '$3=="${UBOOT_ENTRYSYMBOL}" {print "0x"$1;exit}'`
31	fi
32
33	uboot-mkimage -A ${UBOOT_ARCH} -O linux -T ${UBOOT_MKIMAGE_KERNEL_TYPE} -C "${linux_comp}" -a ${UBOOT_LOADADDRESS} -e $ENTRYPOINT -n "${DISTRO_NAME}/${PV}/${MACHINE}" -d linux.bin ${B}/arch/${ARCH}/boot/uImage
34	rm -f linux.bin
35}
36