From b05507295d2c13713c03bff54b9a5effe413b7de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=85strand?= Date: Wed, 18 May 2022 13:56:26 +0200 Subject: Move taskparams out of main stack FreeRTOS resets the stack to the running tasks. Move the task parameters to avoid the parameters to be overwritten. Change-Id: Ib22b3d49451ea8c97c6faf24bafc8bf0952b38a9 --- applications/message_handler/main.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/applications/message_handler/main.cpp b/applications/message_handler/main.cpp index 73eb398..0b4860a 100644 --- a/applications/message_handler/main.cpp +++ b/applications/message_handler/main.cpp @@ -173,6 +173,7 @@ int ethosu_semaphore_give(void *sem) { /**************************************************************************** * Application ****************************************************************************/ +namespace { struct TaskParams { TaskParams() : @@ -192,8 +193,6 @@ struct InferenceTaskParams { uint8_t *arena; }; -namespace { - #ifdef MHU_IRQ void mailboxIrqHandler() { mailbox.handleMessage(); @@ -233,6 +232,13 @@ void messageTask(void *pvParameters) { process.run(); } +/* + * Keep task parameters as global data as FreeRTOS resets the stack when the + * scheduler is started. + */ +TaskParams taskParams; +InferenceTaskParams infParams[NUM_PARALLEL_TASKS]; + } // namespace // FreeRTOS application. NOTE: Additional tasks may require increased heap size. @@ -244,8 +250,6 @@ int main() { return 1; } - TaskParams taskParams; - // Task for handling incoming /outgoing messages from the remote host ret = xTaskCreate(messageTask, "messageTask", 1024, &taskParams, 2, nullptr); if (ret != pdPASS) { @@ -253,8 +257,6 @@ int main() { return ret; } - InferenceTaskParams infParams[NUM_PARALLEL_TASKS]; - // One inference task for each NPU for (size_t n = 0; n < NUM_PARALLEL_TASKS; n++) { infParams[n].taskParams = &taskParams; -- cgit v1.2.1