blob: 1bc98e042d8b2809c241427932d9b2cb37779d15 [file] [log] [blame]
Andrew Geissler6ce62a22020-11-30 19:58:47 -06001# fitImage kernel compression algorithm
2FIT_KERNEL_COMP_ALG ?= "gzip"
3FIT_KERNEL_COMP_ALG_EXTENSION ?= ".gz"
4
Andrew Geissler615f2f12022-07-15 14:00:58 -05005# Kernel image type passed to mkimage (i.e. kernel kernel_noload...)
6UBOOT_MKIMAGE_KERNEL_TYPE ?= "kernel"
7
Patrick Williamsc124f4f2015-09-15 14:41:29 -05008uboot_prep_kimage() {
Brad Bishop6e60e8b2018-02-01 10:27:11 -05009 if [ -e arch/${ARCH}/boot/compressed/vmlinux ]; then
Patrick Williamsc124f4f2015-09-15 14:41:29 -050010 vmlinux_path="arch/${ARCH}/boot/compressed/vmlinux"
11 linux_suffix=""
12 linux_comp="none"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050013 elif [ -e arch/${ARCH}/boot/vmlinuz.bin ]; then
14 rm -f linux.bin
15 cp -l arch/${ARCH}/boot/vmlinuz.bin linux.bin
16 vmlinux_path=""
17 linux_suffix=""
18 linux_comp="none"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050019 else
20 vmlinux_path="vmlinux"
Andrew Geissler615f2f12022-07-15 14:00:58 -050021 # Use vmlinux.initramfs for linux.bin when INITRAMFS_IMAGE_BUNDLE set
22 # As per the implementation in kernel.bbclass.
23 # See do_bundle_initramfs function
24 if [ "${INITRAMFS_IMAGE_BUNDLE}" = "1" ] && [ -e vmlinux.initramfs ]; then
25 vmlinux_path="vmlinux.initramfs"
26 fi
Andrew Geissler6ce62a22020-11-30 19:58:47 -060027 linux_suffix="${FIT_KERNEL_COMP_ALG_EXTENSION}"
28 linux_comp="${FIT_KERNEL_COMP_ALG}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050029 fi
30
Brad Bishop6e60e8b2018-02-01 10:27:11 -050031 [ -n "${vmlinux_path}" ] && ${OBJCOPY} -O binary -R .note -R .comment -S "${vmlinux_path}" linux.bin
Patrick Williamsc124f4f2015-09-15 14:41:29 -050032
33 if [ "${linux_comp}" != "none" ] ; then
Patrick Williams213cb262021-08-07 19:21:33 -050034 if [ "${linux_comp}" = "gzip" ] ; then
35 gzip -9 linux.bin
36 elif [ "${linux_comp}" = "lzo" ] ; then
37 lzop -9 linux.bin
38 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -050039 mv -f "linux.bin${linux_suffix}" linux.bin
40 fi
41
42 echo "${linux_comp}"
43}