Scriptable mode in openocd?

Hello!

Is there a way to make openocd read commands from stdin and/or a file instead of starting

a server? Such a mode would be very convenient to control the target from a makefile.

This is possible by making use of the reset_init and run_and_init reset modes. The difference is whether the target is halted immediately out of reset (reset_init) or whether it is allowed to run for some time (run_and_init). The latter is necessary for targets that can’t be debugged out of reset, like the LPCs or STR7s.

  • The target line for a LPC2000 should look like this:

target arm7tdmi little run_and_init 0 arm7tdmi-s_r4

  • The daemon_startup mode has to be reset, instead of attach.

  • The script that should be run is specified like this:

target_script 0 reset h2294_init.script

The 0 selects the first target, reset is the event that the script should be attached to, and h2294_init.script is a script I’m using for a H2294 board from Olimex.

You should use a “halt” followed by a “wait_halt” command to make sure the target is halted by the time the script is run. A “shutdown” command at the end of the script kills the server once execution is finished.

Regards,

Dominic

Thanks Dominic! I’ll try it.