ssh user@host some-command some-arguments
~/bin/openocd-git/{bin,share}
~/bin/openocd-git/{bin,share}
(corresponding directories).~/bin/openocd-git/
~/bin/openocd-git/
. In ~/bin/
~/bin/
a symlink is made on the executable #!/bin/sh ssh user@host -T killall -9 openocd exec ssh -TC user@host bin/openocd $@
#!/bin/sh gdbcfg=fx3_gdb.ini elf=some-code.elf cat > $gdbcfg << EOF set prompt (arm-gdb) set remotetimeout 30 target remote 192.168.100.1:3333 monitor halt monitor soft_reset_halt monitor adapter_khz 1000 set endian little load EOF arm-none-eabi-gdb -x $gdbcfg $elf
load_image
.load
, then everything starts fine.load
: Start address 0x40035948, load size 298456
load
and via load_image
(via OpenOCD) and before starting ( continue
) the contents of the $pc
register. And ... the difference is found: after load
$pc
installed exactly at this “Start address”, whereas after load_image
in $pc
at the moment of which the download was started. After installing pc
to the correct value, the load became stable. The question remains: magic numbers are not good. But it helped that in GDB you can specify a character and its address will be taken. In the case of FX3, this symbol: CyU3PFirmwareEntry
(by the way, on local applications it will most likely be _start
) and the $pc
setup command has turned into this: set $pc = CyU3PFirmwareEntry
In addition, GDB has the ability to call shell commands, so we can easily and naturally, at startup, upload the elf file to a remote server and give the command to the running OpenOCD to load it (any command for OpenOCD can be given from GDB by preceding it with the word monitor
). #!/bin/sh gdbcfg=fx3_gdb.ini elf=some-code.elf # GDB cat > $gdbcfg << EOF set prompt (arm-gdb) set remotetimeout 30 target remote 192.168.100.1:3333 shell scp $elf user@192.168.100.1: monitor halt monitor soft_reset_halt monitor sleep 1000 monitor load_image %elf 0x00 elf set $pc = CyU3PFirmwareEntry EOF arm-none-eabi-gdb -x $gdbcfg $elf
The script for running OpenOCD remains the same. monitor echo "Upload image..." shell scp %{DebuggedExecutable:NativeFilePath} user@192.168.100.1: monitor halt monitor soft_reset_halt monitor sleep 1000 monitor echo "Load image..." monitor load_image %{DebuggedExecutable:FileName} 0x00 elf set $pc = CyU3PFirmwareEntry monitor echo "Run image..."
As you can see, completely repeats the code from the script, only with macro substitutions, so as not to rewrite for each target.monitor reset halt
(leave by default). ###################################### # Target: CYPRESS FX3 ARM926-ejs # Common part ###################################### if { [info exists CHIPNAME] } { set _CHIPNAME $CHIPNAME } else { set _CHIPNAME fx3 } if { [info exists ENDIAN] } { set _ENDIAN $ENDIAN } else { set _ENDIAN little } if { [info exists CPUTAPID] } { set _CPUTAPID $CPUTAPID } else { set _CPUTAPID 0x07926069 } #delays on reset lines adapter_nsrst_delay 200 jtag_ntrst_delay 200 adapter_khz 1000 #reset_config trst_only #reset_config trst_only combined #reset_config trst_and_srst combined #reset_config trst_and_srst srst_pulls_trst # From the Cypress SDK reset_config trst_and_srst srst_pulls_trst # My own well worked #reset_config trst_only jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID jtag_rclk 3
###################################### # Target: CYPRESS FX3 ARM926-ejs ###################################### #source [find fx3-common.inc] ###################### # Target configuration ###################### set _TARGETNAME $_CHIPNAME.cpu target create $_TARGETNAME arm926ejs -endian $_ENDIAN -chain-position $_TARGETNAME -rtos ThreadX adapter_khz 1000
###################################### # Target: CYPRESS FX3 ARM926-ejs ###################################### #source [find fx3-common.inc] ###################### # Target configuration ###################### set _TARGETNAME $_CHIPNAME.cpu target create $_TARGETNAME arm926ejs -endian $_ENDIAN -chain-position $_TARGETNAME adapter_khz 1000
Source: https://habr.com/ru/post/274179/
All Articles