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
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 @@
 /****************************************************************************
  * Application
  ****************************************************************************/
+namespace {
 
 struct TaskParams {
     TaskParams() :
@@ -192,8 +193,6 @@
     uint8_t *arena;
 };
 
-namespace {
-
 #ifdef MHU_IRQ
 void mailboxIrqHandler() {
     mailbox.handleMessage();
@@ -233,6 +232,13 @@
     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 @@
         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 @@
         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;