Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 1 | # |
| 2 | # Copyright OpenEmbedded Contributors |
| 3 | # |
| 4 | # SPDX-License-Identifier: MIT |
| 5 | # |
| 6 | |
| 7 | # fitImage kernel compression algorithm |
| 8 | FIT_KERNEL_COMP_ALG ?= "gzip" |
| 9 | FIT_KERNEL_COMP_ALG_EXTENSION ?= ".gz" |
| 10 | |
| 11 | # Kernel image type passed to mkimage (i.e. kernel kernel_noload...) |
| 12 | UBOOT_MKIMAGE_KERNEL_TYPE ?= "kernel" |
| 13 | |
| 14 | uboot_prep_kimage() { |
| 15 | if [ -e arch/${ARCH}/boot/compressed/vmlinux ]; then |
| 16 | vmlinux_path="arch/${ARCH}/boot/compressed/vmlinux" |
| 17 | linux_suffix="" |
| 18 | linux_comp="none" |
| 19 | elif [ -e arch/${ARCH}/boot/vmlinuz.bin ]; then |
| 20 | rm -f linux.bin |
| 21 | cp -l arch/${ARCH}/boot/vmlinuz.bin linux.bin |
| 22 | vmlinux_path="" |
| 23 | linux_suffix="" |
| 24 | linux_comp="none" |
| 25 | else |
| 26 | vmlinux_path="vmlinux" |
| 27 | # Use vmlinux.initramfs for linux.bin when INITRAMFS_IMAGE_BUNDLE set |
| 28 | # As per the implementation in kernel.bbclass. |
| 29 | # See do_bundle_initramfs function |
| 30 | if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ] && [ -e vmlinux.initramfs ]; then |
| 31 | vmlinux_path="vmlinux.initramfs" |
| 32 | fi |
| 33 | linux_suffix="${FIT_KERNEL_COMP_ALG_EXTENSION}" |
| 34 | linux_comp="${FIT_KERNEL_COMP_ALG}" |
| 35 | fi |
| 36 | |
Andrew Geissler | 6aa7eec | 2023-03-03 12:41:14 -0600 | [diff] [blame] | 37 | [ -n "${vmlinux_path}" ] && ${KERNEL_OBJCOPY} -O binary -R .note -R .comment -S "${vmlinux_path}" linux.bin |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 38 | |
| 39 | if [ "${linux_comp}" != "none" ] ; then |
| 40 | if [ "${linux_comp}" = "gzip" ] ; then |
| 41 | gzip -9 linux.bin |
| 42 | elif [ "${linux_comp}" = "lzo" ] ; then |
| 43 | lzop -9 linux.bin |
| 44 | fi |
| 45 | mv -f "linux.bin${linux_suffix}" linux.bin |
| 46 | fi |
| 47 | |
| 48 | echo "${linux_comp}" |
| 49 | } |