diff options
author | Adrian Freihofer <adrian.freihofer@siemens.com> | 2025-06-03 10:23:21 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-06-05 11:02:21 +0100 |
commit | ceee2575537cfeabb99f76057416701d6cf0fc8b (patch) | |
tree | 8a6ff4c5993c43c39e0992b2307eb19ba92a53b9 | |
parent | 8263346476eaf7f063402ff17cce02eb17f62dee (diff) | |
download | poky-ceee2575537cfeabb99f76057416701d6cf0fc8b.tar.gz |
kernel-uboot.bbclass: do not require the kernel build folder
The function must be executed in CWD. Make it more flexible by
specifying the kernel build folder as a parameter.
This is a refactoring without functional change. But later this change
will allow to use this function also with a kernel from the sstate-cache
instead of requiring the full kernel build folder structure.
Another preparation for using a kernel from sstate-cache is to persist
the linux_comp variable in a file next to the linux.bin file rather than
using a global shell variable.
This change also requires to adapt the kernel-uimage.bbclass
accordingly. This change also fixes a minor detail:
the kernel-uimage.bbclass used ${ instead of $ for evaluatiing a local
shell variable.
(From OE-Core rev: 8ea95cd419ee4efac5f54124e2ce98304262e8c1)
Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes-recipe/kernel-uboot.bbclass | 40 | ||||
-rw-r--r-- | meta/classes-recipe/kernel-uimage.bbclass | 3 |
2 files changed, 26 insertions, 17 deletions
diff --git a/meta/classes-recipe/kernel-uboot.bbclass b/meta/classes-recipe/kernel-uboot.bbclass index 6d4aff6b11..d2a63524ec 100644 --- a/meta/classes-recipe/kernel-uboot.bbclass +++ b/meta/classes-recipe/kernel-uboot.bbclass | |||
@@ -12,19 +12,27 @@ FIT_KERNEL_COMP_ALG_EXTENSION ?= ".gz" | |||
12 | UBOOT_MKIMAGE_KERNEL_TYPE ?= "kernel" | 12 | UBOOT_MKIMAGE_KERNEL_TYPE ?= "kernel" |
13 | 13 | ||
14 | uboot_prep_kimage() { | 14 | uboot_prep_kimage() { |
15 | if [ -e arch/${ARCH}/boot/compressed/vmlinux ]; then | 15 | output_dir=$1 |
16 | # For backward compatibility with kernel-fitimage.bbclass and kernel-uboot.bbclass | ||
17 | # support calling without parameter as well | ||
18 | if [ -z "$output_dir" ]; then | ||
19 | output_dir='.' | ||
20 | fi | ||
21 | |||
22 | linux_bin=$output_dir/linux.bin | ||
23 | if [ -e "arch/${ARCH}/boot/compressed/vmlinux" ]; then | ||
16 | vmlinux_path="arch/${ARCH}/boot/compressed/vmlinux" | 24 | vmlinux_path="arch/${ARCH}/boot/compressed/vmlinux" |
17 | linux_suffix="" | 25 | linux_suffix="" |
18 | linux_comp="none" | 26 | linux_comp="none" |
19 | elif [ -e arch/${ARCH}/boot/vmlinuz.bin ]; then | 27 | elif [ -e "arch/${ARCH}/boot/vmlinuz.bin" ]; then |
20 | rm -f linux.bin | 28 | rm -f "$linux_bin" |
21 | cp -l arch/${ARCH}/boot/vmlinuz.bin linux.bin | 29 | cp -l "arch/${ARCH}/boot/vmlinuz.bin" "$linux_bin" |
22 | vmlinux_path="" | 30 | vmlinux_path="" |
23 | linux_suffix="" | 31 | linux_suffix="" |
24 | linux_comp="none" | 32 | linux_comp="none" |
25 | else | 33 | else |
26 | vmlinux_path="vmlinux" | 34 | vmlinux_path="vmlinux" |
27 | # Use vmlinux.initramfs for linux.bin when INITRAMFS_IMAGE_BUNDLE set | 35 | # Use vmlinux.initramfs for $linux_bin when INITRAMFS_IMAGE_BUNDLE set |
28 | # As per the implementation in kernel.bbclass. | 36 | # As per the implementation in kernel.bbclass. |
29 | # See do_bundle_initramfs function | 37 | # See do_bundle_initramfs function |
30 | if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ] && [ -e vmlinux.initramfs ]; then | 38 | if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ] && [ -e vmlinux.initramfs ]; then |
@@ -34,18 +42,18 @@ uboot_prep_kimage() { | |||
34 | linux_comp="${FIT_KERNEL_COMP_ALG}" | 42 | linux_comp="${FIT_KERNEL_COMP_ALG}" |
35 | fi | 43 | fi |
36 | 44 | ||
37 | [ -n "${vmlinux_path}" ] && ${KERNEL_OBJCOPY} -O binary -R .note -R .comment -S "${vmlinux_path}" linux.bin | 45 | [ -n "$vmlinux_path" ] && ${KERNEL_OBJCOPY} -O binary -R .note -R .comment -S "$vmlinux_path" "$linux_bin" |
38 | 46 | ||
39 | if [ "${linux_comp}" != "none" ] ; then | 47 | if [ "$linux_comp" != "none" ] ; then |
40 | if [ "${linux_comp}" = "gzip" ] ; then | 48 | if [ "$linux_comp" = "gzip" ] ; then |
41 | gzip -9 linux.bin | 49 | gzip -9 "$linux_bin" |
42 | elif [ "${linux_comp}" = "lzo" ] ; then | 50 | elif [ "$linux_comp" = "lzo" ] ; then |
43 | lzop -9 linux.bin | 51 | lzop -9 "$linux_bin" |
44 | elif [ "${linux_comp}" = "lzma" ] ; then | 52 | elif [ "$linux_comp" = "lzma" ] ; then |
45 | xz --format=lzma -f -6 linux.bin | 53 | xz --format=lzma -f -6 "$linux_bin" |
46 | fi | 54 | fi |
47 | mv -f "linux.bin${linux_suffix}" linux.bin | 55 | mv -f "$linux_bin$linux_suffix" "$linux_bin" |
48 | fi | 56 | fi |
49 | 57 | ||
50 | echo "${linux_comp}" | 58 | printf "$linux_comp" > "$output_dir/linux_comp" |
51 | } | 59 | } \ No newline at end of file |
diff --git a/meta/classes-recipe/kernel-uimage.bbclass b/meta/classes-recipe/kernel-uimage.bbclass index 1a599e656c..e353232a0e 100644 --- a/meta/classes-recipe/kernel-uimage.bbclass +++ b/meta/classes-recipe/kernel-uimage.bbclass | |||
@@ -29,6 +29,7 @@ python __anonymous () { | |||
29 | do_uboot_mkimage[dirs] += "${B}" | 29 | do_uboot_mkimage[dirs] += "${B}" |
30 | do_uboot_mkimage() { | 30 | do_uboot_mkimage() { |
31 | uboot_prep_kimage | 31 | uboot_prep_kimage |
32 | linux_comp="$(cat linux_comp)" | ||
32 | 33 | ||
33 | ENTRYPOINT=${UBOOT_ENTRYPOINT} | 34 | ENTRYPOINT=${UBOOT_ENTRYPOINT} |
34 | if [ -n "${UBOOT_ENTRYSYMBOL}" ]; then | 35 | if [ -n "${UBOOT_ENTRYSYMBOL}" ]; then |
@@ -36,6 +37,6 @@ do_uboot_mkimage() { | |||
36 | awk '$3=="${UBOOT_ENTRYSYMBOL}" {print "0x"$1;exit}'` | 37 | awk '$3=="${UBOOT_ENTRYSYMBOL}" {print "0x"$1;exit}'` |
37 | fi | 38 | fi |
38 | 39 | ||
39 | 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 | 40 | 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 |
40 | rm -f linux.bin | 41 | rm -f linux.bin |
41 | } | 42 | } |