openocd: prevent target polling during 'init' 07/7007/4
authorAntonio Borneo <borneo.antonio@gmail.com>
Mon, 30 May 2022 13:32:24 +0000 (15:32 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Mon, 15 Aug 2022 13:22:18 +0000 (13:22 +0000)
The command 'init' causes the execution of few lower level
commands, e.g. 'target init', and switches from command mode
COMMAND_CONFIG to COMMAND_EXEC, with an intermediate switch back
to mode COMMAND_CONFIG.

A timed target polling can occur during the execution of 'init'
and the target's status can trigger the execution of some events.
E.g. if a target has been left halted by a previous execution of
OpenOCD, the first poll will find the target halted, calling the
corresponding 'halted' event.
The event handler can use commands that can only be executed in
mode COMMAND_EXEC. If the poll happens while OpenOCD is in mode
COMMAND_CONFIG, the triggered handler will fail.

Prevent the target polling to operate during the execution of the
'init' command.

Change-Id: Ia435a5d2039be9b247e2336616dab53ed5d983ac
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7007
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
src/openocd.c

index 43c8523056406da01bbbdbffdd966fa4ccdadf28..b65d4715288cd3eacdb340f2481bd2dddb6d7567 100644 (file)
@@ -119,6 +119,8 @@ COMMAND_HANDLER(handle_init_command)
 
        initialized = 1;
 
+       bool save_poll_mask = jtag_poll_mask();
+
        retval = command_run_line(CMD_CTX, "target init");
        if (retval != ERROR_OK)
                return ERROR_FAIL;
@@ -166,6 +168,8 @@ COMMAND_HANDLER(handle_init_command)
        if (command_run_line(CMD_CTX, "tpiu init") != ERROR_OK)
                return ERROR_FAIL;
 
+       jtag_poll_unmask(save_poll_mask);
+
        /* initialize telnet subsystem */
        gdb_target_add_all(all_targets);
 

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 https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

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