run-tool: enable image loading via openocd

By adding: "--target jtag \
            --jtag-debugger <debugger configuration> \
            --jtag-board <board configuration>" to the RUN_OPTs
this commits enables the run-tool to load and execute an ELF image
via JTAG to the target platform.

Fixes #1191
This commit is contained in:
Stefan Kalkowski 2014-06-25 14:35:10 +02:00 committed by Norman Feske
parent e45fc7f0d7
commit 5385ada7a4

View File

@ -719,6 +719,33 @@ proc exit {{status 0}} {
}
##
# Load image to target hardware via JTAG
#
proc jtag_load { } {
if {![have_spec arm] || ![have_installed openocd]} {
puts "No support for JTAG detected."
exit -1
}
set debugger [get_cmd_arg --jtag-debugger 1]
set board [get_cmd_arg --jtag-board 1]
set elf_img "[run_dir]/image.elf"
# 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 jtag_spawn_id $spawn_id
set timeout 210
expect {
"downloaded" { }
eof { puts stderr "openocd command process died unexpectedly" }
timeout { puts stderr "Loading timed out" }
}
}
##
# Execute scenario expecting output via serial device
#
@ -734,6 +761,10 @@ proc spawn_serial { wait_for_re timeout_value kernel_msg } {
power_plug_reset
}
if {[regexp "jtag" $run_target]} {
jtag_load
}
eval spawn $serial_cmd
set serial_spawn_id $spawn_id