tool: support new u-boot FIT image format

Fixes genodelabs/genode#4250
This commit is contained in:
Johannes Schlatow 2021-08-20 14:09:16 +02:00 committed by Christian Helmuth
parent c54473abea
commit 50cc51f132
2 changed files with 54 additions and 0 deletions

View File

@ -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"]} {

50
tool/run/image/uboot_fit Normal file
View File

@ -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
}