esp32s2: convert counted timeout to timeval_ms 20/7020/2
authorErhan Kurubas <erhan.kurubas@espressif.com>
Sat, 11 Jun 2022 23:04:08 +0000 (01:04 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Fri, 24 Jun 2022 21:47:07 +0000 (21:47 +0000)
Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Change-Id: Id685408281478cec0e7e886dbedb3b8972c7b652
Reviewed-on: https://review.openocd.org/c/openocd/+/7020
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Ian Thompson <ianst@cadence.com>
src/target/espressif/esp32s2.c

index 36980325b84800d3930fa82309c1ad0281b5e652..1bf56b9a77b2262632b9c5e33a55e626037ffee3 100644 (file)
@@ -21,6 +21,7 @@
 #include "config.h"
 #endif
 
+#include <helper/time_support.h>
 #include "assert.h"
 #include <target/target.h>
 #include <target/target_type.h>
@@ -482,15 +483,16 @@ static int esp32s2_soc_reset(struct target *target)
        }
        /* Wait for SoC to reset */
        alive_sleep(100);
-       int timeout = 100;
-       while (target->state != TARGET_RESET && target->state != TARGET_RUNNING && --timeout > 0) {
+       int64_t timeout = timeval_ms() + 100;
+       while (target->state != TARGET_RESET && target->state != TARGET_RUNNING) {
                alive_sleep(10);
                xtensa_poll(target);
+               if (timeval_ms() >= timeout) {
+                       LOG_TARGET_ERROR(target, "Timed out waiting for CPU to be reset, target state=%d", target->state);
+                       return ERROR_TARGET_TIMEOUT;
+               }
        }
-       if (timeout == 0) {
-               LOG_ERROR("Timed out waiting for CPU to be reset, target->state=%d", target->state);
-               return ERROR_TARGET_TIMEOUT;
-       }
+
        xtensa_halt(target);
        res = target_wait_state(target, TARGET_HALTED, 1000);
        if (res != ERROR_OK) {

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)