Hi there,
I am struggling to understand what such a simple piece of code would not work, see below…
I am using an RP2040 with SDK v2.1.1. FreeRTOS_Config is the one from the pico examples repository.
You can see the BlinkTask is pinned to core 1, while the main one is running on core 0.
Let’s consider two cases: task creation at POSITION 1 or POSITION 2.
When POSITION 1 is active, stdout is filled with “BlinkingLED…”, the delay is not held (not waiting 1000 ticks) and the main task never outputs.
When POSITION 2 is active, the BlinkTask prints once then never again. The main task outputs as expected.
If I pin the BlinkTask to core 0 then everything is fine.
What is fundamentally wrong with my thinking? Should this work? Bug?
I thank you very much already for any tips!
static constexpr UBaseType_t kCore0 = 1UL;
static constexpr UBaseType_t kCore1 = 2UL;
void blink_task(void* params) {
while (true) {
printf("Blinking LED...\n");
vTaskDelay(1000);
}
}
void main_task(__unused void* params) {
// POSITION 1
xTaskCreateAffinitySet(blink_task, "BlinkTask", 2048, NULL, 1, kCore1, NULL);
int count = 0;
while (true) {
printf("Hello from main task count=%u\n", count++);
vTaskDelay(3000);
}
}
void VLaunch(void) {
xTaskCreateAffinitySet(main_task, "MainThread", 2048, NULL, 1, kCore0, NULL);
// POSITION 2
// xTaskCreateAffinitySet(blink_task, "BlinkTask", 2048, NULL, 1, kCore1, NULL);
vTaskStartScheduler();
}
int main(void) {
if (!stdio_init_all()) {
return 1;
}
busy_wait_ms(1000);
printf("Starting FreeRTOS SMP on both cores...\n");
VLaunch();
return 0;
}
I originally posted this question in the Pico forum, but maybe it is a fundamental flaw in my understanding of the SMP concept.