summaryrefslogtreecommitdiffstats
path: root/meta/classes/kernel.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/kernel.bbclass')
-rw-r--r--meta/classes/kernel.bbclass69
1 files changed, 55 insertions, 14 deletions
diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index 83a574efcd..ca7530095e 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -75,7 +75,7 @@ python __anonymous () {
75 # KERNEL_IMAGETYPES may contain a mixture of image types supported directly 75 # KERNEL_IMAGETYPES may contain a mixture of image types supported directly
76 # by the kernel build system and types which are created by post-processing 76 # by the kernel build system and types which are created by post-processing
77 # the output of the kernel build system (e.g. compressing vmlinux -> 77 # the output of the kernel build system (e.g. compressing vmlinux ->
78 # vmlinux.gz in kernel_do_compile()). 78 # vmlinux.gz in kernel_do_transform_kernel()).
79 # KERNEL_IMAGETYPE_FOR_MAKE should contain only image types supported 79 # KERNEL_IMAGETYPE_FOR_MAKE should contain only image types supported
80 # directly by the kernel build system. 80 # directly by the kernel build system.
81 if not d.getVar('KERNEL_IMAGETYPE_FOR_MAKE'): 81 if not d.getVar('KERNEL_IMAGETYPE_FOR_MAKE'):
@@ -91,6 +91,8 @@ python __anonymous () {
91 imagedest = d.getVar('KERNEL_IMAGEDEST') 91 imagedest = d.getVar('KERNEL_IMAGEDEST')
92 92
93 for type in types.split(): 93 for type in types.split():
94 if bb.data.inherits_class('nopackages', d):
95 continue
94 typelower = type.lower() 96 typelower = type.lower()
95 d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower)) 97 d.appendVar('PACKAGES', ' %s-image-%s' % (kname, typelower))
96 d.setVar('FILES_' + kname + '-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/' + type) 98 d.setVar('FILES_' + kname + '-image-' + typelower, '/' + imagedest + '/' + type + '-${KERNEL_VERSION_NAME}' + ' /' + imagedest + '/' + type)
@@ -104,6 +106,8 @@ python __anonymous () {
104 # standalone for use by wic and other tools. 106 # standalone for use by wic and other tools.
105 if image: 107 if image:
106 d.appendVarFlag('do_bundle_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete') 108 d.appendVarFlag('do_bundle_initramfs', 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete')
109 if image and bb.utils.to_boolean(d.getVar('INITRAMFS_IMAGE_BUNDLE')):
110 bb.build.addtask('do_transform_bundled_initramfs', 'do_deploy', 'do_bundle_initramfs', d)
107 111
108 # NOTE: setting INITRAMFS_TASK is for backward compatibility 112 # NOTE: setting INITRAMFS_TASK is for backward compatibility
109 # The preferred method is to set INITRAMFS_IMAGE, because 113 # The preferred method is to set INITRAMFS_IMAGE, because
@@ -139,13 +143,14 @@ do_unpack[cleandirs] += " ${S} ${STAGING_KERNEL_DIR} ${B} ${STAGING_KERNEL_BUILD
139do_clean[cleandirs] += " ${S} ${STAGING_KERNEL_DIR} ${B} ${STAGING_KERNEL_BUILDDIR}" 143do_clean[cleandirs] += " ${S} ${STAGING_KERNEL_DIR} ${B} ${STAGING_KERNEL_BUILDDIR}"
140python do_symlink_kernsrc () { 144python do_symlink_kernsrc () {
141 s = d.getVar("S") 145 s = d.getVar("S")
142 if s[-1] == '/':
143 # drop trailing slash, so that os.symlink(kernsrc, s) doesn't use s as directory name and fail
144 s=s[:-1]
145 kernsrc = d.getVar("STAGING_KERNEL_DIR") 146 kernsrc = d.getVar("STAGING_KERNEL_DIR")
146 if s != kernsrc: 147 if s != kernsrc:
147 bb.utils.mkdirhier(kernsrc) 148 bb.utils.mkdirhier(kernsrc)
148 bb.utils.remove(kernsrc, recurse=True) 149 bb.utils.remove(kernsrc, recurse=True)
150 if s[-1] == '/':
151 # drop trailing slash, so that os.symlink(kernsrc, s) doesn't use s as
152 # directory name and fail
153 s = s[:-1]
149 if d.getVar("EXTERNALSRC"): 154 if d.getVar("EXTERNALSRC"):
150 # With EXTERNALSRC S will not be wiped so we can symlink to it 155 # With EXTERNALSRC S will not be wiped so we can symlink to it
151 os.symlink(s, kernsrc) 156 os.symlink(s, kernsrc)
@@ -194,6 +199,8 @@ UBOOT_LOADADDRESS ?= "${UBOOT_ENTRYPOINT}"
194KERNEL_EXTRA_ARGS ?= "" 199KERNEL_EXTRA_ARGS ?= ""
195 200
196EXTRA_OEMAKE = " HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" HOSTCPP="${BUILD_CPP}"" 201EXTRA_OEMAKE = " HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" HOSTCPP="${BUILD_CPP}""
202EXTRA_OEMAKE += " HOSTCXX="${BUILD_CXX} ${BUILD_CXXFLAGS} ${BUILD_LDFLAGS}""
203
197KERNEL_ALT_IMAGETYPE ??= "" 204KERNEL_ALT_IMAGETYPE ??= ""
198 205
199copy_initramfs() { 206copy_initramfs() {
@@ -276,6 +283,14 @@ do_bundle_initramfs () {
276} 283}
277do_bundle_initramfs[dirs] = "${B}" 284do_bundle_initramfs[dirs] = "${B}"
278 285
286kernel_do_transform_bundled_initramfs() {
287 # vmlinux.gz is not built by kernel
288 if (echo "${KERNEL_IMAGETYPES}" | grep -wq "vmlinux\.gz"); then
289 gzip -9cn < ${KERNEL_OUTPUT_DIR}/vmlinux.initramfs > ${KERNEL_OUTPUT_DIR}/vmlinux.gz.initramfs
290 fi
291}
292do_transform_bundled_initramfs[dirs] = "${B}"
293
279python do_devshell_prepend () { 294python do_devshell_prepend () {
280 os.environ["LDFLAGS"] = '' 295 os.environ["LDFLAGS"] = ''
281} 296}
@@ -307,6 +322,10 @@ kernel_do_compile() {
307 export KBUILD_BUILD_TIMESTAMP="$ts" 322 export KBUILD_BUILD_TIMESTAMP="$ts"
308 export KCONFIG_NOTIMESTAMP=1 323 export KCONFIG_NOTIMESTAMP=1
309 bbnote "KBUILD_BUILD_TIMESTAMP: $ts" 324 bbnote "KBUILD_BUILD_TIMESTAMP: $ts"
325 else
326 ts=`LC_ALL=C date`
327 export KBUILD_BUILD_TIMESTAMP="$ts"
328 bbnote "KBUILD_BUILD_TIMESTAMP: $ts"
310 fi 329 fi
311 # The $use_alternate_initrd is only set from 330 # The $use_alternate_initrd is only set from
312 # do_bundle_initramfs() This variable is specifically for the 331 # do_bundle_initramfs() This variable is specifically for the
@@ -325,12 +344,17 @@ kernel_do_compile() {
325 for typeformake in ${KERNEL_IMAGETYPE_FOR_MAKE} ; do 344 for typeformake in ${KERNEL_IMAGETYPE_FOR_MAKE} ; do
326 oe_runmake ${typeformake} CC="${KERNEL_CC} $cc_extra " LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS} $use_alternate_initrd 345 oe_runmake ${typeformake} CC="${KERNEL_CC} $cc_extra " LD="${KERNEL_LD}" ${KERNEL_EXTRA_ARGS} $use_alternate_initrd
327 done 346 done
347}
348
349kernel_do_transform_kernel() {
328 # vmlinux.gz is not built by kernel 350 # vmlinux.gz is not built by kernel
329 if (echo "${KERNEL_IMAGETYPES}" | grep -wq "vmlinux\.gz"); then 351 if (echo "${KERNEL_IMAGETYPES}" | grep -wq "vmlinux\.gz"); then
330 mkdir -p "${KERNEL_OUTPUT_DIR}" 352 mkdir -p "${KERNEL_OUTPUT_DIR}"
331 gzip -9cn < ${B}/vmlinux > "${KERNEL_OUTPUT_DIR}/vmlinux.gz" 353 gzip -9cn < ${B}/vmlinux > "${KERNEL_OUTPUT_DIR}/vmlinux.gz"
332 fi 354 fi
333} 355}
356do_transform_kernel[dirs] = "${B}"
357addtask transform_kernel after do_compile before do_install
334 358
335do_compile_kernelmodules() { 359do_compile_kernelmodules() {
336 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE 360 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
@@ -348,6 +372,10 @@ do_compile_kernelmodules() {
348 export KBUILD_BUILD_TIMESTAMP="$ts" 372 export KBUILD_BUILD_TIMESTAMP="$ts"
349 export KCONFIG_NOTIMESTAMP=1 373 export KCONFIG_NOTIMESTAMP=1
350 bbnote "KBUILD_BUILD_TIMESTAMP: $ts" 374 bbnote "KBUILD_BUILD_TIMESTAMP: $ts"
375 else
376 ts=`LC_ALL=C date`
377 export KBUILD_BUILD_TIMESTAMP="$ts"
378 bbnote "KBUILD_BUILD_TIMESTAMP: $ts"
351 fi 379 fi
352 if (grep -q -i -e '^CONFIG_MODULES=y$' ${B}/.config); then 380 if (grep -q -i -e '^CONFIG_MODULES=y$' ${B}/.config); then
353 cc_extra=$(get_cc_option) 381 cc_extra=$(get_cc_option)
@@ -377,8 +405,8 @@ kernel_do_install() {
377 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE 405 unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MACHINE
378 if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then 406 if (grep -q -i -e '^CONFIG_MODULES=y$' .config); then
379 oe_runmake DEPMOD=echo MODLIB=${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION} INSTALL_FW_PATH=${D}${nonarch_base_libdir}/firmware modules_install 407 oe_runmake DEPMOD=echo MODLIB=${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION} INSTALL_FW_PATH=${D}${nonarch_base_libdir}/firmware modules_install
380 rm "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build" 408 rm -f "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/build"
381 rm "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/source" 409 rm -f "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/source"
382 # If the kernel/ directory is empty remove it to prevent QA issues 410 # If the kernel/ directory is empty remove it to prevent QA issues
383 rmdir --ignore-fail-on-non-empty "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel" 411 rmdir --ignore-fail-on-non-empty "${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel"
384 else 412 else
@@ -390,12 +418,26 @@ kernel_do_install() {
390 # 418 #
391 install -d ${D}/${KERNEL_IMAGEDEST} 419 install -d ${D}/${KERNEL_IMAGEDEST}
392 install -d ${D}/boot 420 install -d ${D}/boot
421
422 #
423 # When including an initramfs bundle inside a FIT image, the fitImage is created after the install task
424 # by do_assemble_fitimage_initramfs.
425 # This happens after the generation of the initramfs bundle (done by do_bundle_initramfs).
426 # So, at the level of the install task we should not try to install the fitImage. fitImage is still not
427 # generated yet.
428 # After the generation of the fitImage, the deploy task copies the fitImage from the build directory to
429 # the deploy folder.
430 #
431
393 for imageType in ${KERNEL_IMAGETYPES} ; do 432 for imageType in ${KERNEL_IMAGETYPES} ; do
394 install -m 0644 ${KERNEL_OUTPUT_DIR}/${imageType} ${D}/${KERNEL_IMAGEDEST}/${imageType}-${KERNEL_VERSION} 433 if [ $imageType != "fitImage" ] || [ "${INITRAMFS_IMAGE_BUNDLE}" != "1" ] ; then
395 if [ "${KERNEL_PACKAGE_NAME}" = "kernel" ]; then 434 install -m 0644 ${KERNEL_OUTPUT_DIR}/${imageType} ${D}/${KERNEL_IMAGEDEST}/${imageType}-${KERNEL_VERSION}
396 ln -sf ${imageType}-${KERNEL_VERSION} ${D}/${KERNEL_IMAGEDEST}/${imageType} 435 if [ "${KERNEL_PACKAGE_NAME}" = "kernel" ]; then
436 ln -sf ${imageType}-${KERNEL_VERSION} ${D}/${KERNEL_IMAGEDEST}/${imageType}
437 fi
397 fi 438 fi
398 done 439 done
440
399 install -m 0644 System.map ${D}/boot/System.map-${KERNEL_VERSION} 441 install -m 0644 System.map ${D}/boot/System.map-${KERNEL_VERSION}
400 install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION} 442 install -m 0644 .config ${D}/boot/config-${KERNEL_VERSION}
401 install -m 0644 vmlinux ${D}/boot/vmlinux-${KERNEL_VERSION} 443 install -m 0644 vmlinux ${D}/boot/vmlinux-${KERNEL_VERSION}
@@ -403,7 +445,6 @@ kernel_do_install() {
403 install -d ${D}${sysconfdir}/modules-load.d 445 install -d ${D}${sysconfdir}/modules-load.d
404 install -d ${D}${sysconfdir}/modprobe.d 446 install -d ${D}${sysconfdir}/modprobe.d
405} 447}
406do_install[prefuncs] += "package_get_auto_pr"
407 448
408# Must be ran no earlier than after do_kernel_checkout or else Makefile won't be in ${S}/Makefile 449# Must be ran no earlier than after do_kernel_checkout or else Makefile won't be in ${S}/Makefile
409do_kernel_version_sanity_check() { 450do_kernel_version_sanity_check() {
@@ -569,11 +610,11 @@ do_savedefconfig() {
569do_savedefconfig[nostamp] = "1" 610do_savedefconfig[nostamp] = "1"
570addtask savedefconfig after do_configure 611addtask savedefconfig after do_configure
571 612
572inherit cml1 613inherit cml1 pkgconfig
573 614
574KCONFIG_CONFIG_COMMAND_append = " LD='${KERNEL_LD}' HOSTLDFLAGS='${BUILD_LDFLAGS}'" 615KCONFIG_CONFIG_COMMAND_append = " LD='${KERNEL_LD}' HOSTLDFLAGS='${BUILD_LDFLAGS}'"
575 616
576EXPORT_FUNCTIONS do_compile do_install do_configure 617EXPORT_FUNCTIONS do_compile do_transform_kernel do_transform_bundled_initramfs do_install do_configure
577 618
578# kernel-base becomes kernel-${KERNEL_VERSION} 619# kernel-base becomes kernel-${KERNEL_VERSION}
579# kernel-image becomes kernel-image-${KERNEL_VERSION} 620# kernel-image becomes kernel-image-${KERNEL_VERSION}
@@ -679,7 +720,7 @@ do_sizecheck() {
679 at_least_one_fits= 720 at_least_one_fits=
680 for imageType in ${KERNEL_IMAGETYPES} ; do 721 for imageType in ${KERNEL_IMAGETYPES} ; do
681 size=`du -ks ${B}/${KERNEL_OUTPUT_DIR}/$imageType | awk '{print $1}'` 722 size=`du -ks ${B}/${KERNEL_OUTPUT_DIR}/$imageType | awk '{print $1}'`
682 if [ $size -ge ${KERNEL_IMAGE_MAXSIZE} ]; then 723 if [ $size -gt ${KERNEL_IMAGE_MAXSIZE} ]; then
683 bbwarn "This kernel $imageType (size=$size(K) > ${KERNEL_IMAGE_MAXSIZE}(K)) is too big for your device." 724 bbwarn "This kernel $imageType (size=$size(K) > ${KERNEL_IMAGE_MAXSIZE}(K)) is too big for your device."
684 else 725 else
685 at_least_one_fits=y 726 at_least_one_fits=y
@@ -718,7 +759,7 @@ kernel_do_deploy() {
718 fi 759 fi
719 760
720 if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then 761 if [ ! -z "${INITRAMFS_IMAGE}" -a x"${INITRAMFS_IMAGE_BUNDLE}" = x1 ]; then
721 for imageType in ${KERNEL_IMAGETYPE_FOR_MAKE} ; do 762 for imageType in ${KERNEL_IMAGETYPES} ; do
722 if [ "$imageType" = "fitImage" ] ; then 763 if [ "$imageType" = "fitImage" ] ; then
723 continue 764 continue
724 fi 765 fi