openocd/src/helper
Antonio Borneo cc75aa37c5 openocd: add post-init and pre-shutdown helpers
It is a common requirement to automatically execute some command
after "init".
This can be achieved, either in scripts or through OpenOCD command
line, by explicitly calling "init" followed by the commands.
But this approach fails if the request for post-init commands is
spread across configuration files; only one of the files can split
pre-init and post-init status by calling "init".
The common workaround is to "rename" the command "init" and
replace it with a TCL proc that calls the original "init" and the
post-init commands. E.g. in Zephyr script [1].

To simplify and formalize the post-init execution, use a TCL list
that contains the list of commands to be executed. Every script
can contribute adding new commands, e.g. using "lappend".

In the same way, formalize the pre-shutdown execution with a TCL
list of user commands to be executed before OpenOCD exit.

Document them and add trivial examples.

Drop from documentation the suggestion to rename "shutdown".

Change-Id: I9464fb40ccede3e7760d425873adca363b49a64f
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Link: [1] https://github.com/zephyrproject-rtos/zephyr/blob/zephyr-v2.7.1/boards/arm/nucleo_h743zi/support/openocd.cfg#L15
Reviewed-on: https://review.openocd.org/c/openocd/+/6851
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
2022-05-14 08:58:36 +00:00
..
Makefile.am Makefile: drop warning suppression on win build 2021-08-30 13:52:12 +00:00
align.h helper: add align.h 2021-08-14 13:29:43 +01:00
bin2char.sh helper: fix minor typos 2020-09-05 17:10:54 +01:00
binarybuffer.c openocd: fix Yoda conditions with checkpatch 2021-07-24 10:38:31 +01:00
binarybuffer.h Fix debug prints when loading to flash 2020-09-05 16:48:08 +01:00
bits.h helper/bits: add BIT_ULL and GENMASK macros 2022-03-26 13:35:55 +00:00
command.c openocd: add keep_alive during command sleep 2021-12-18 17:23:34 +00:00
command.h command: document enum command_mode 2021-10-25 16:10:28 +00:00
configuration.c openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
configuration.h helper/configuration: free script_search_dirs and config_file_names 2018-03-07 23:47:31 +00:00
fileio.c openocd: manually remove NULL comparisons 2021-07-24 10:38:19 +01:00
fileio.h Cleanup of config/includes. 2021-05-01 14:35:09 +01:00
jep106.c jep106: use packed jedec manufacturer code 2021-08-22 20:26:06 +00:00
jep106.h jep106: use packed jedec manufacturer code 2021-08-22 20:26:06 +00:00
jep106.inc jep106.inc: Update to revision JEP106BC 2021-09-18 15:27:31 +00:00
jim-nvp.c openocd: include config.h in every file .c 2022-03-26 13:32:57 +00:00
jim-nvp.h helper/jim-nvp: comply with coding style [1/2] 2021-06-04 17:40:39 +01:00
list.h helper/list: add list_for_each_entry_direction() 2022-02-14 15:10:41 +00:00
log.c keep-alive: drop link with log framework 2022-03-19 09:10:39 +00:00
log.h log: fix memory leak when log to file is enabled 2022-01-22 10:15:48 +00:00
options.c openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
replacements.c helper: remove fix for libusb pre-v1.0.9 2021-08-30 13:51:46 +00:00
replacements.h helper: remove fix for libusb pre-v1.0.9 2021-08-30 13:51:46 +00:00
startup.tcl openocd: add post-init and pre-shutdown helpers 2022-05-14 08:58:36 +00:00
system.h Cleanup of config/includes. 2021-05-01 14:35:09 +01:00
time_support.c openocd: fix Yoda conditions with checkpatch 2021-07-24 10:38:31 +01:00
time_support.h openocd: fix some minor typo 2021-05-22 10:06:51 +01:00
time_support_common.c Fix usage of timeval_ms() 2016-07-19 10:45:16 +01:00
types.h helper/types: remove type '_Bool' 2021-05-01 13:36:58 +01:00
update_jep106.pl helper: fix minor typos 2020-09-05 17:10:54 +01:00
util.c helper: rename camelcase symbols 2021-07-02 17:10:03 +01:00
util.h Make #include guard naming consistent 2016-05-24 22:30:55 +01:00