From 5385ada7a497df35bd375801fb5a63b13c9bf427 Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Wed, 25 Jun 2014 14:35:10 +0200 Subject: [PATCH] run-tool: enable image loading via openocd By adding: "--target jtag \ --jtag-debugger \ --jtag-board " 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 --- tool/run | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tool/run b/tool/run index 30bc922c7..e9caa8eb7 100755 --- a/tool/run +++ b/tool/run @@ -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