2015-01-08 21:08:48 +00:00
|
|
|
##
|
2022-12-01 11:18:42 +00:00
|
|
|
# Build U-boot bootloader specific uImage/image.itb
|
2015-01-08 21:08:48 +00:00
|
|
|
#
|
|
|
|
# \param --image-uboot-no-gzip do not gzip the uImage
|
2022-12-01 11:18:42 +00:00
|
|
|
# \param --image-uboot-fit build image.itb FIT image
|
2015-01-08 21:08:48 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
# Check if the uImage should be gzipped
|
|
|
|
#
|
|
|
|
proc image_uboot_use_no_gzip { } { return [get_cmd_switch --image-uboot-no-gzip] }
|
|
|
|
|
2022-12-01 11:18:42 +00:00
|
|
|
proc image_uboot_use_fit { } { return [get_cmd_switch --image-uboot-fit] }
|
|
|
|
|
2015-01-08 21:08:48 +00:00
|
|
|
|
2022-11-30 16:02:59 +00:00
|
|
|
##
|
|
|
|
# Make gzip compression more aggressive
|
|
|
|
#
|
|
|
|
# Using this option reduces the image size by circa 10%. But it comes at the
|
|
|
|
# cost of significantly slowing down the gzip step for large images (e.g., 6
|
|
|
|
# seconds instead of 2 seconds for a image of 13 MiB). The option is suitable
|
|
|
|
# when building a release. But for quick build-test cycles, it is best keep
|
|
|
|
# it disabled.
|
|
|
|
#
|
|
|
|
proc image_uboot_gzip_opt { } {
|
|
|
|
if {[get_cmd_switch --image-uboot-gzip-best]} {
|
|
|
|
return "--best"
|
|
|
|
} else {
|
|
|
|
return "--fast"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-08 21:08:48 +00:00
|
|
|
##
|
|
|
|
# Build U-boot bootloader specific uImage
|
|
|
|
#
|
2023-01-18 15:56:28 +00:00
|
|
|
proc run_image { } {
|
|
|
|
|
|
|
|
set elf_img [file join [run_dir] boot image.elf]
|
2022-11-30 16:02:59 +00:00
|
|
|
|
2015-01-08 21:08:48 +00:00
|
|
|
# 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]
|
|
|
|
|
2023-01-18 16:23:14 +00:00
|
|
|
set bin_img [file join [run_dir] boot image.bin]
|
2015-01-08 21:08:48 +00:00
|
|
|
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 {
|
2022-11-30 16:02:59 +00:00
|
|
|
exec gzip [image_uboot_gzip_opt] --force $bin_img
|
2015-01-08 21:08:48 +00:00
|
|
|
set bin_ext .gz
|
|
|
|
set compress_type gzip
|
|
|
|
}
|
|
|
|
|
2019-03-29 10:08:06 +00:00
|
|
|
set arch "arm"
|
|
|
|
if {[have_spec arm_64]} { set arch "arm64" }
|
|
|
|
|
2022-12-01 11:18:42 +00:00
|
|
|
if {[image_uboot_use_fit]} {
|
|
|
|
# create image.itb
|
2023-01-18 16:23:14 +00:00
|
|
|
set uboot_img [file join [run_dir] boot image.itb]
|
2022-12-01 11:18:42 +00:00
|
|
|
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
|
2023-01-18 16:23:14 +00:00
|
|
|
set uboot_img [file join [run_dir] boot uImage]
|
2022-12-01 11:18:42 +00:00
|
|
|
exec mkimage -A $arch -O linux -T kernel -C $compress_type -a $load_addr \
|
|
|
|
-e $entrypoint -d $bin_img$bin_ext $uboot_img
|
|
|
|
}
|
2023-01-18 16:23:14 +00:00
|
|
|
exec rm -rf $bin_img$bin_ext $elf_img
|
2015-01-08 21:08:48 +00:00
|
|
|
}
|