blob: 30a85ccc287e52d67411b7e8dd6f4fe5e7d9ce23 [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7# fitImage kernel compression algorithm
8FIT_KERNEL_COMP_ALG ?= "gzip"
9FIT_KERNEL_COMP_ALG_EXTENSION ?= ".gz"
10
11# Kernel image type passed to mkimage (i.e. kernel kernel_noload...)
12UBOOT_MKIMAGE_KERNEL_TYPE ?= "kernel"
13
14uboot_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 Geissler6aa7eec2023-03-03 12:41:14 -060037 [ -n "${vmlinux_path}" ] && ${KERNEL_OBJCOPY} -O binary -R .note -R .comment -S "${vmlinux_path}" linux.bin
Patrick Williams92b42cb2022-09-03 06:53:57 -050038
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}