adambujak wrote on Saturday, September 21, 2019:
Hi,
I’m very new to RTOS, so I’m sorry if this is something really obvious.
I’m working on an Apollo3 EVB.
When I flash my board and debug using GDB everything works as expected. If I power cycle my board and let the program boot from ROM something goes wrong; if I then connect with JLink and send a reset command, and then a go command, everything works as expected.
I can debug the issue only by flashing the board, then power cycling, then debugging by connecting to a running target.
I only noticed this issue when I added a sleep on program start feature, so I’m not sure if that’s causing some sort of issue, or just unmasking an existing issue.
Below are the functions where I start seeing issues:
static void setup_task ( void *pvParameters )
{
Events_Initialize();
// Run setup functions.
CLI_Task_Setup();
App_Task_Setup();
UI_Task_Setup();
Sensor_Task_Setup();
// Create the functional tasks
xTaskCreate(CLI_Task_Main, "CLI_Task", 512, 0, 4, &cliTaskHandle);
xTaskCreate(App_Task_Main, "AppTask", 512, 0, 0, &appTaskHandle);
xTaskCreate(UI_Task_Main, "UI_Task", 512, 0, 0, &uiTaskHandle);
xTaskCreate(Sensor_Task_Main, "SensorTask", 512, 0, 0, &sensorTaskHandle);
// The setup operations are complete, so suspend the setup task now.
vTaskSuspend(NULL);
while (1);
}
//*****************************************************************************
// Initializes all tasks
//*****************************************************************************
void run_tasks(void)
{
// Note: Timer priority is handled by the FreeRTOS kernel, so we won't
// touch it here.
// Create essential tasks.
xTaskCreate(setup_task, "Setup", 512, 0, 0, &xSetupTask);
// Start the scheduler.
vTaskStartScheduler();
}
When I comment out all but UI_Task_Setup() and the respective taskCreate everything works as expected.
Otherwise, I seem to be getting hard faults. I think I’ve narrowed it down to the pvPortMalloc function. Specifically the line:
while( ( pxBlock->xBlockSize < xWantedSize ) && ( pxBlock->pxNextFreeBlock != NULL ))
I did some debugging and found that this causes a hard fault becuase pxBlock->xBlockSize isn’t defined. Further investigation led me to find that the heap isn’t initialized using prvHeapInit, because xHeapHasBeenInitialised is some random value instead of 1 or 0.
I read somewhere that this may be due to priority issues, and I messed around with the priorities a little bit to no avail (like I said, I’m very new to RTOS).
Anyway, I’ve been scratching/banging my head for a few days, so I’d appreciate any help anyone can offer.
Thanks in advance.