FreeRTOS: Always show current execution before scheduler is started
[openocd.git] / src / rtos / FreeRTOS.c
index 5f779ef70cf30636f27c48db5ab51f8abb669cc9..afea9db90c89509be0cee9dadfa2abae01700e32 100644 (file)
@@ -116,6 +116,7 @@ enum freertos_symbol_values {
        FREERTOS_VAL_X_SUSPENDED_TASK_LIST = 8,
        FREERTOS_VAL_UX_CURRENT_NUMBER_OF_TASKS = 9,
        FREERTOS_VAL_UX_TOP_USED_PRIORITY = 10,
+       FREERTOS_VAL_X_SCHEDULER_RUNNING = 11,
 };
 
 struct symbols {
@@ -135,6 +136,7 @@ static const struct symbols freertos_symbol_list[] = {
        { "xSuspendedTaskList", true }, /* Only if INCLUDE_vTaskSuspend */
        { "uxCurrentNumberOfTasks", false },
        { "uxTopUsedPriority", true }, /* Unavailable since v7.5.3 */
+       { "xSchedulerRunning", false },
        { NULL, false }
 };
 
@@ -194,7 +196,20 @@ static int freertos_update_threads(struct rtos *rtos)
                                                                                rtos->symbols[FREERTOS_VAL_PX_CURRENT_TCB].address,
                                                                                rtos->current_thread);
 
-       if ((thread_list_size  == 0) || (rtos->current_thread == 0)) {
+       /* read scheduler running */
+       uint32_t scheduler_running;
+       retval = target_read_u32(rtos->target,
+                       rtos->symbols[FREERTOS_VAL_X_SCHEDULER_RUNNING].address,
+                       &scheduler_running);
+       if (retval != ERROR_OK) {
+               LOG_ERROR("Error reading FreeRTOS scheduler state");
+               return retval;
+       }
+       LOG_DEBUG("FreeRTOS: Read xSchedulerRunning at 0x%" PRIx64 ", value 0x%" PRIx32,
+                                                                               rtos->symbols[FREERTOS_VAL_X_SCHEDULER_RUNNING].address,
+                                                                               scheduler_running);
+
+       if ((thread_list_size  == 0) || (rtos->current_thread == 0) || (scheduler_running != 1)) {
                /* Either : No RTOS threads - there is always at least the current execution though */
                /* OR     : No current thread - all threads suspended - show the current execution
                 * of idling */

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)