From bcd880c8e4085c943a055bcb2e2dc78feda33bea Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 19 May 2019 19:04:07 +0300 Subject: Modularise image handling Signed-off-by: Laurent Pinchart --- images/CrOS.sh | 48 ++++++++++++++++++++++++++++++++ images/FIT.sh | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ images/srec.sh | 18 ++++++++++++ images/uImage.sh | 9 ++++++ 4 files changed, 158 insertions(+) create mode 100644 images/CrOS.sh create mode 100644 images/FIT.sh create mode 100644 images/srec.sh create mode 100644 images/uImage.sh (limited to 'images') diff --git a/images/CrOS.sh b/images/CrOS.sh new file mode 100644 index 0000000..eb9ff05 --- /dev/null +++ b/images/CrOS.sh @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: GPL-2.0+ + +if [[ $arch != arm64 && $arch != x86 ]] ; then + echo "CrOS image unsupported on architecture $arch" + exit 1 +fi + +source "${kbuild_root}/images/FIT.sh" || exit 1 + +make_CrOS_image() { + local boot_dir=$output_dir/arch/$arch/boot + local bootloader + local config + local vmlinuz + + if [[ $arch == arm64 ]] ; then + make_FIT_image + vmlinuz=$boot_dir/kernel_fdt.itb + elif [[ $arch == x86 ]] ; then + vmlinuz=$boot_dir/bzImage + fi + + if [[ -f $opt_bootloader ]] ; then + bootloader=$opt_bootloader + else + dd if=/dev/zero of=$boot_dir/bootloader bs=512 count=1 + bootloader=$boot_dir/bootloader + fi + + if [[ -f $opt_cmdline_file ]] ; then + config=$opt_cmdline_file + else + echo "$CMDLINE" > $boot_dir/cmdline + config=$boot_dir/cmdline + fi + + vbutil_kernel \ + --pack $boot_dir/vmlinuz.image \ + --version 1 \ + --vmlinuz $vmlinuz \ + --arch $arch \ + --keyblock /usr/share/vboot/devkeys/kernel.keyblock \ + --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk \ + --config $config \ + --bootloader $bootloader +} + +image_file=$output_dir/arch/$arch/boot/vmlinuz.image diff --git a/images/FIT.sh b/images/FIT.sh new file mode 100644 index 0000000..0ed5482 --- /dev/null +++ b/images/FIT.sh @@ -0,0 +1,83 @@ +# SPDX-License-Identifier: GPL-2.0+ + +make_FIT_image() { + local kernel_its=$output_dir/arch/$arch/boot/kernel_fdt.its + + cat < $kernel_its +/dts-v1/; +/ { + description = "Kernel + FDT image for $board board"; + #address-cells = <1>; + + images { + kernel { + description = "Linux kernel"; + data = /incbin/("$output_dir/arch/$arch/boot/$image_kernel"); + type = "kernel"; + arch = "$arch"; + os = "linux"; + compression = "none"; + load = <$LOADADDR>; + entry = <$LOADADDR>; + hash-1 { + algo = "crc32"; + }; + hash-2 { + algo = "sha1"; + }; + }; +EOF + + local dtb + + for dtb in $DTBS ; do + local src=${dtb/:*/} + local dst=${dtb/*:/} + dst=${dst/*\//} + + cat <> $kernel_its + fdt-$dst { + description = "Flattened Device Tree blob $dst"; + data = /incbin/("$output_dir/arch/$arch/boot/dts/$src"); + type = "flat_dt"; + arch = "$arch"; + compression = "none"; + hash-1 { + algo = "crc32"; + }; + hash-2 { + algo = "sha1"; + }; + }; +EOF + done + + local config=$(echo $DTBS | sed 's/.*[:/]//') + cat <> $kernel_its + }; + + configurations { + default = "conf-$config"; +EOF + for dtb in $DTBS ; do + local dst=${dtb/*:/} + dst=${dst/*\//} + + cat <> $kernel_its + conf-$dst { + description = "Boot Linux kernel with $dst blob"; + kernel = "kernel"; + fdt = "fdt-$dst"; + }; +EOF + done + + cat <> $kernel_its + }; +}; +EOF + + PATH="$output_dir/scripts/dtc:$PATH" mkimage -f $kernel_its ${kernel_its/its/itb} +} + +image_file=$output_dir/arch/$arch/boot/kernel_fdt.itb diff --git a/images/srec.sh b/images/srec.sh new file mode 100644 index 0000000..6f89b92 --- /dev/null +++ b/images/srec.sh @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: GPL-2.0+ + +make_srec_image() { + local image=$output_dir/arch/$arch/boot/$image_kernel + + cat $image | lzma -z -e > $image.xz + objcopy -I binary -O srec --srec-forceS3 --srec-len 516 \ + $image.xz $image.xz.srec + + for dtb in $DTBS ; do + local src=${dtb/:*/} + + objcopy -I binary -O srec --srec-forceS3 --srec-len 516 \ + $src $src.srec + done +} + +image_file=$output_dir/arch/$arch/boot/$kernel_image.xz.srec diff --git a/images/uImage.sh b/images/uImage.sh new file mode 100644 index 0000000..40e7cf3 --- /dev/null +++ b/images/uImage.sh @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0+ + +make_uImage_image() { + mkimage -A $arch -O linux -T kernel -C none -a $LOADADDR -e $LOADADDR \ + -n "Linux-${version}" -d $output_dir/arch/$arch/boot/$kernel_image \ + $output_dir/arch/$arch/boot/uImage +} + +image_file=$output_dir/arch/$arch/boot/uImage -- cgit v1.2.3