diff --git a/tool/run/boot_dir/hw b/tool/run/boot_dir/hw index 8c846c1194..b98d16a129 100644 --- a/tool/run/boot_dir/hw +++ b/tool/run/boot_dir/hw @@ -155,6 +155,10 @@ proc run_boot_dir {binaries} { if {[have_include "image/uboot"]} { exec {*}[load_tftp_inst_cmd] [pwd]/[run_dir]/uImage [load_tftp_base_dir][load_tftp_offset_dir] } + + if {[have_include "image/uboot_fit"]} { + exec {*}[load_tftp_inst_cmd] [pwd]/[run_dir]/image.itb [load_tftp_base_dir][load_tftp_offset_dir] + } } if {[have_spec x86] && [have_include "load/tftp"]} { diff --git a/tool/run/image/uboot_fit b/tool/run/image/uboot_fit new file mode 100644 index 0000000000..801777a24f --- /dev/null +++ b/tool/run/image/uboot_fit @@ -0,0 +1,50 @@ +## +# 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] } + + +## +# 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 --best --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 +}