run-tool: unify building of u-boot image (fix #807)

This commit is contained in:
Stefan Kalkowski 2013-07-15 11:06:31 +02:00
parent 6c7a25d08c
commit 09d81759ee
3 changed files with 34 additions and 56 deletions

View File

@ -124,37 +124,6 @@ proc bin_dir { } {
exit 1
}
#
# Parse entry point address out of final elf image for u-boot
#
proc entrypoint { } {
global _entrypoint
set _entrypoint [exec [cross_dev_prefix]readelf -h [run_dir]/image.elf | grep "Entry point" | sed -e "s/.*Entry point address: *//"]
return $_entrypoint
}
#
# Parse load address out of final elf image for u-boot
#
proc loadaddr { } {
global _loadaddr
set _loadaddr [regexp -inline -all -- {\S+} [exec [cross_dev_prefix]readelf -l [run_dir]/image.elf | grep -m 1 "LOAD"]]
return [lindex $_loadaddr 3]
}
#
# Create an u-boot image if appropriated SPEC is set
#
proc build_boot_uimage { } {
if {[have_spec uboot]} {
exec [cross_dev_prefix]objcopy -O binary [run_dir]/image.elf [run_dir]/image.bin
exec gzip --best --force [run_dir]/image.bin
exec mkimage -A arm -O linux -T kernel -C gzip -a [loadaddr] -e [entrypoint] -d [run_dir]/image.bin.gz [run_dir]/uImage
}
}
set fiasco_serial_esc_arg "-serial_esc "
proc build_boot_image_x86 {binaries} {
@ -277,7 +246,7 @@ proc build_boot_image_arm {binaries} {
}
exec cp [bin_dir]/bootstrap.elf [run_dir]/image.elf
build_boot_uimage
build_uboot_image [run_dir]/image.elf
puts "\nboot image: [run_dir]/image.elf\n"

View File

@ -172,29 +172,7 @@ proc build_boot_image {binaries} {
exec cp -L bin/core $elf_img
exec [cross_dev_prefix]strip $elf_img
# target specific ops
if {[regexp "uboot" $run_target]} {
# 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]
# compress ELF
set bin_img "[run_dir]/image.bin"
exec [cross_dev_prefix]objcopy -O binary $elf_img $bin_img
exec gzip --best --force $bin_img
# create compressed uImage
set uboot_img [run_dir]/uImage
exec mkimage -A arm -O linux -T kernel -C gzip -a $load_addr \
-e $entrypoint -d $bin_img.gz $uboot_img
exec rm -rf $bin_img.gz
}
build_uboot_image $elf_img
# set symbolic link to image.elf file in TFTP directory for PXE boot
if {[info exists ::env(PXE_TFTP_DIR_BASE)] &&

View File

@ -718,6 +718,38 @@ proc gdb { } {
}
##
# U-boot bootloader specific uImage
#
# \param elf_img ELF binary to build uImage from
#
proc build_uboot_image {elf_img} {
global run_target
if {[regexp "uboot" $run_target]} {
# 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]
# compress ELF
set bin_img "[run_dir]/image.bin"
exec [cross_dev_prefix]objcopy -O binary $elf_img $bin_img
exec gzip --best --force $bin_img
# create compressed uImage
set uboot_img [run_dir]/uImage
exec mkimage -A arm -O linux -T kernel -C gzip -a $load_addr \
-e $entrypoint -d $bin_img.gz $uboot_img
exec rm -rf $bin_img.gz
}
}
##
## Execution of run scripts
##
@ -730,4 +762,3 @@ foreach include_name [get_cmd_arg --include ""] {
puts "using run script $include_name"
source $include_name
}