tcl: introduce init_target_events and use it for gdb flashing events 62/2062/2
authorPaul Fertser <>
Sat, 22 Mar 2014 12:47:37 +0000 (16:47 +0400)
committerPaul Fertser <>
Sat, 29 Mar 2014 08:40:03 +0000 (08:40 +0000)
This introduces a new global Tcl procedure that is run just after
init_targets and before init_boards.

Its default behaviour is to assign gdb-flash-erase-start and
gdb-flash-write-end to reasonable defaults.

The rationale for doing "reset init" before gdb erases and flashes
memory is that all flash drivers are written in assumption that they
can safely be used only after chip reset (plus chip-specific
configuration in the init handler if any). The need to use "reset
halt" after flashing is because a user expects running firmware after
loading to be the same as running it from power-on-reset.

Change-Id: I9ddc4047611904ca4ca779b73376d2739611948a
Signed-off-by: Paul Fertser <>
Tested-by: jenkins
Reviewed-by: Spencer Oliver <>

index 455e6fbe84b1ebdd6eaa9adf78ad29fe592fa1f7..3977454bba8b7dae71b780cb222b3cf2df06e708 100644 (file)
@@ -2109,6 +2109,17 @@ For an example of this scheme see LPC2000 target config files.
 The @code{init_boards} procedure is a similar concept concerning board config files
 (@xref{theinitboardprocedure,,The init_board procedure}.)
+@subsection The init_target_events procedure
+@cindex init_target_events procedure
+A special procedure called @code{init_target_events} is run just after
+@code{init_targets} (@xref{theinittargetsprocedure,,The init_targets
+procedure}.) and before @code{init_board}
+(@xref{theinitboardprocedure,,The init_board procedure}.) It is used
+to set up default target events for the targets that do not have those
+events already assigned.
 @subsection ARM Core Specific Hacks
 If the chip has a DCC, enable it. If the chip is an ARM9 with some
@@ -4577,13 +4588,14 @@ depending on whether the breakpoint is in RAM or read only memory.
 @item @b{gdb-end}
 @* When the target has halted and GDB is not doing anything (see early halt)
 @item @b{gdb-flash-erase-start}
-@* Before the GDB flash process tries to erase the flash
+@* Before the GDB flash process tries to erase the flash (default is
+@code{reset init})
 @item @b{gdb-flash-erase-end}
 @* After the GDB flash process has finished erasing the flash
 @item @b{gdb-flash-write-start}
 @* Before GDB writes to the flash
 @item @b{gdb-flash-write-end}
-@* After GDB writes to the flash
+@* After GDB writes to the flash (default is @code{reset halt})
 @item @b{gdb-start}
 @* Before the target steps, gdb is trying to start/resume the target
 @item @b{halted}
index 56fcbaa7516083ddbf4313636ccd7e8d911dd982..033e9c9cfe10a95e1fdb21c811e11ca5463ddf31 100644 (file)
@@ -164,6 +164,21 @@ proc armv4_5 params {
 proc init_targets {} {
+proc set_default_target_event {t e s} {
+       if {[$t cget -event $e] == ""} {
+               $t configure -event $e $s
+       }
+proc init_target_events {} {
+       set targets [target names]
+       foreach t $targets {
+               set_default_target_event $t gdb-flash-erase-start "reset init"
+               set_default_target_event $t gdb-flash-write-end "reset halt"
+       }
 # Additionally board config scripts can define a procedure init_board that will be executed after init and init_targets
 proc init_board {} {
index f5a8666b6e2566b5bd49e950561bb49d784e0a35..9820155467b4176dfd0e6f5fe5d27f26adf23787 100644 (file)
@@ -1274,6 +1274,10 @@ COMMAND_HANDLER(handle_target_init_command)
        if (ERROR_OK != retval)
                return retval;
+       retval = command_run_line(CMD_CTX, "init_target_events");
+       if (ERROR_OK != retval)
+               return retval;
        retval = command_run_line(CMD_CTX, "init_board");
        if (ERROR_OK != retval)
                return retval;

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 (RSA)