I am trying to debug a FreeRTOS application scheduling on a RP2040 Raspberry Pico using the functions vTaskList or vTaskLists and can't get any output on my serial line (minicom).
This is my main() on the source code:
char pcWriteBuffer[0xFFFF];
stdio_init_all();
if (cyw43_arch_init()) {
return -1;
}
xTaskCreate(external_led_task, "External_LED_Task", 256, NULL, 3, NULL);
xTaskCreate(onboard_led_task, "Onboard_LED_Task", 256, NULL, 3, NULL);
vTaskStartScheduler();
vTaskList(pcWriteBuffer);
printf("%s\n", pcWriteBuffer);
while(1){};
My serial output via USB is already enabled on CMakeLists.txt and i have tested other printfs on the same code, showed properly on minicom.
pico_enable_stdio_usb(${ProjectName} 1)
pico_enable_stdio_uart(${ProjectName} 0)
I have already defined the two FreeRTOSConfig.h macros required to use these functions:
#define configUSE_TRACE_FACILITY 1
#define configUSE_STATS_FORMATTING_FUNCTIONS 1
I also tried using vTaskListTasks this way:
char pcWriteBuffer[1024];
vTaskListTasks(pcWriteBuffer, 1024);
printf("%s\n", pcWriteBuffer);
I tried creating a task only for the vTaskList or vTaskListTasks, I don't know why but the program don't even run when I try this, tried the same task priority for all tasks.
The buffer
pcWriteBufferis a 64KB object on the stack, on a part with only 256KB of RAM. Apart from being far larger than reasonably necessary for the task list (the documentation suggests 40 bytes per task), it is also larger than your likely main stack size, which will typically be a few KB. Make the buffer smaller and declare itstatic.vTaskList()blocks the scheduler, so there are no reentrancy issues with using astatic.However that is not the reason for your issue (although it is an issue). The primary issue is here:
vTaskList()will never be called becausevTaskStartScheduler()never returns as the documentation states:It only makes sense to call
vTaskListfrom a task context (or after creating tasks and before callingvTaskStartScheduler()perhaps, though that serves little purpose)