From ed9a8299b2c024b1e3c9611e919e1a09081ae8a2 Mon Sep 17 00:00:00 2001 From: Christian Helmuth Date: Thu, 1 Dec 2022 12:18:42 +0100 Subject: [PATCH] run/image/uboot: merge with uboot_fit Both modules were quite similar except the the name of the FIT image (image.itb) and the mkimage command line. FIT images are now produced by the following RUN_OPT. RUN_OPT += --include image/uboot --image-uboot-fit Issue #4693 --- tool/run/image/uboot | 20 +++++++++---- tool/run/image/uboot_fit | 63 ---------------------------------------- 2 files changed, 15 insertions(+), 68 deletions(-) delete mode 100644 tool/run/image/uboot_fit diff --git a/tool/run/image/uboot b/tool/run/image/uboot index d17e21fa40..abc3bf8b0a 100644 --- a/tool/run/image/uboot +++ b/tool/run/image/uboot @@ -1,7 +1,8 @@ ## -# Build U-boot bootloader specific uImage +# Build U-boot bootloader specific uImage/image.itb # # \param --image-uboot-no-gzip do not gzip the uImage +# \param --image-uboot-fit build image.itb FIT image # @@ -10,6 +11,8 @@ # proc image_uboot_use_no_gzip { } { return [get_cmd_switch --image-uboot-no-gzip] } +proc image_uboot_use_fit { } { return [get_cmd_switch --image-uboot-fit] } + ## # Make gzip compression more aggressive @@ -61,9 +64,16 @@ proc run_image {elf_img} { set arch "arm" if {[have_spec arm_64]} { set arch "arm64" } - # create uImage - set uboot_img [run_dir]/uImage - exec mkimage -A $arch -O linux -T kernel -C $compress_type -a $load_addr \ - -e $entrypoint -d $bin_img$bin_ext $uboot_img + if {[image_uboot_use_fit]} { + # create image.itb + set uboot_img [run_dir]/image.itb + exec mkimage -f auto -A $arch -O linux -T kernel -C $compress_type -a $load_addr \ + -e $entrypoint -d $bin_img$bin_ext $uboot_img + } else { + # create uImage + set uboot_img [run_dir]/uImage + exec mkimage -A $arch -O linux -T kernel -C $compress_type -a $load_addr \ + -e $entrypoint -d $bin_img$bin_ext $uboot_img + } exec rm -rf $bin_img$bin_ext } diff --git a/tool/run/image/uboot_fit b/tool/run/image/uboot_fit deleted file mode 100644 index 51309cdc6c..0000000000 --- a/tool/run/image/uboot_fit +++ /dev/null @@ -1,63 +0,0 @@ -## -# Build U-boot bootloader specific image.itb (FIT image) -# -# \param --image-uboot-no-gzip do not gzip the image.itb -# - - -## -# Check if the image.itb should be gzipped -# -proc image_uboot_use_no_gzip { } { return [get_cmd_switch --image-uboot-no-gzip] } - -## -# Make gzip compression more aggressive -# -# Please refer to the comment in run/image/uboot. -# -proc image_uboot_gzip_opt { } { - if {[get_cmd_switch --image-uboot-gzip-best]} { - return "--best" - } else { - return "--fast" - } -} - - -## -# Build U-boot bootloader specific image.itb -# -# \param elf_img ELF binary to build image.itb from -# -proc run_image {elf_img} { - # parse ELF entrypoint and load address - set entrypoint [exec [cross_dev_prefix]readelf -h $elf_img | \ - grep "Entry point address: " | \ - sed -e "s/.*Entry point address: *//"] - set load_addr [exec [cross_dev_prefix]readelf -l $elf_img | \ - grep -m 1 "LOAD"] - set load_addr [lindex [regexp -inline -all -- {\S+} $load_addr] 3] - - set bin_img "[run_dir]/image.bin" - exec [cross_dev_prefix]objcopy -O binary $elf_img $bin_img - - set use_gzip [expr ![image_uboot_use_no_gzip]] - set compress_type none - set bin_ext "" - - # compress ELF - if $use_gzip { - exec gzip [image_uboot_gzip_opt] --force $bin_img - set bin_ext .gz - set compress_type gzip - } - - set arch "arm" - if {[have_spec arm_64]} { set arch "arm64" } - - # create image.itb - set uboot_img [run_dir]/image.itb - exec mkimage -f auto -A $arch -O linux -T kernel -C $compress_type -a $load_addr \ - -e $entrypoint -d $bin_img$bin_ext $uboot_img - exec rm -rf $bin_img$bin_ext -}