mirror of
https://github.com/mmueller41/genode.git
synced 2026-01-21 12:32:56 +01:00
run: modularize run tool
This commit is contained in:
committed by
Christian Helmuth
parent
febca1b827
commit
c706b1c0a7
52
tool/run/load/jtag
Normal file
52
tool/run/load/jtag
Normal file
@@ -0,0 +1,52 @@
|
||||
##
|
||||
# Load image to target hardware via JTAG
|
||||
#
|
||||
# \param --load-jtag-debugger Debugger used
|
||||
# \param --load-jtag-board Set the used board
|
||||
#
|
||||
|
||||
source [genode_dir]/tool/run/load.inc
|
||||
|
||||
|
||||
proc load_jtag_debugger { } { return [get_cmd_arg --load-jtag-debugger 1] }
|
||||
|
||||
|
||||
proc load_jtag_board { } { return [get_cmd_arg --load-jtag-board 1] }
|
||||
|
||||
|
||||
proc run_load { } {
|
||||
global load_spawn_id
|
||||
|
||||
if {![have_spec arm] || ![have_installed openocd]} {
|
||||
puts "No support for JTAG detected."
|
||||
exit -1
|
||||
}
|
||||
|
||||
set debugger [load_jtag_debugger]
|
||||
set board [load_jtag_board]
|
||||
set elf_img "[run_dir]/image.elf"
|
||||
|
||||
# sleep a bit, board might need some time to come up
|
||||
sleep 8
|
||||
|
||||
# parse ELF entrypoint
|
||||
set entrypoint [exec [cross_dev_prefix]readelf -h $elf_img | \
|
||||
grep "Entry point address: " | \
|
||||
sed -e "s/.*Entry point address: *//"]
|
||||
|
||||
eval spawn openocd -f $debugger -f $board -c init -c halt \
|
||||
-c \"load_image $elf_img\" -c \"resume $entrypoint\"
|
||||
set load_spawn_id $spawn_id
|
||||
set timeout 360
|
||||
expect {
|
||||
"downloaded" { return true; }
|
||||
eof {
|
||||
puts stderr "openocd command process died unexpectedly";
|
||||
return false;
|
||||
}
|
||||
timeout {
|
||||
puts stderr "Loading timed out";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
64
tool/run/load/tftp
Normal file
64
tool/run/load/tftp
Normal file
@@ -0,0 +1,64 @@
|
||||
##
|
||||
# Load files needed by the scenario via TFTP
|
||||
#
|
||||
# \param --load-tftp-base-dir base directory of TFTP
|
||||
# \param --load-tftp-offset-dir offset directory within TFTP
|
||||
# \param --load-tftp-absolute path is absolute, i.e. /base_dir/offset_dir
|
||||
# instead of only /offset_dir is used
|
||||
#
|
||||
|
||||
source [genode_dir]/tool/run/load.inc
|
||||
|
||||
|
||||
##
|
||||
# The files are loaded implicitly via TFTP to the target machine
|
||||
#
|
||||
proc run_load { } {
|
||||
global load_spawn_id
|
||||
set load_spawn_id -1
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
proc load_tftp_base_dir { } { return [get_cmd_arg --load-tftp-base-dir ""] }
|
||||
|
||||
|
||||
proc load_tftp_offset_dir { } { return [get_cmd_arg --load-tftp-offset-dir ""] }
|
||||
|
||||
|
||||
proc load_tftp_use_absolute { } { return [get_cmd_switch --load-tftp-absolute] }
|
||||
|
||||
|
||||
##
|
||||
# Install files needed to boot via PXE
|
||||
#
|
||||
proc install_pxe_bootloader_to_run_dir { } {
|
||||
exec mkdir -p [run_dir]/boot
|
||||
exec cp [genode_dir]/tool/boot/pulsar [run_dir]/boot/pulsar
|
||||
exec cp [genode_dir]/tool/boot/bender [run_dir]/boot/bender
|
||||
}
|
||||
|
||||
|
||||
##
|
||||
# Generate pulsar config file used for loading files from TFTP
|
||||
#
|
||||
proc generate_tftp_config { } {
|
||||
set tftp_base_dir [load_tftp_base_dir]
|
||||
set tftp_offset_dir [load_tftp_offset_dir]
|
||||
|
||||
if {[string length $tftp_base_dir] > 0 && [string length $tftp_offset_dir] > 0} {
|
||||
exec ln -nfs "[pwd]" "$tftp_base_dir$tftp_offset_dir"
|
||||
|
||||
set tftp_base ""
|
||||
if {[load_tftp_use_absolute]} {
|
||||
set tftp_base $tftp_base_dir
|
||||
}
|
||||
|
||||
set fh [open "$tftp_base_dir$tftp_offset_dir/config-00-00-00-00-00-00" "WRONLY CREAT TRUNC"]
|
||||
puts $fh " root $tftp_base$tftp_offset_dir/[run_dir]"
|
||||
puts $fh " config config-52-54-00-12-34-56"
|
||||
close $fh
|
||||
} else {
|
||||
puts "Warning, TFTP base directory or TFTP offset directory not set."
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user