pico_flash: Support FreeRTOS Static Allocation (#2229)

This commit is contained in:
Steven Conaway 2025-02-07 11:08:12 -07:00 committed by GitHub
parent 1ee91e1039
commit 876c09cbfa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -145,7 +145,16 @@ static int default_enter_safe_zone_timeout_ms(__unused uint32_t timeout_ms) {
uint core_num = get_core_num(); uint core_num = get_core_num();
// create at low priority on other core // create at low priority on other core
TaskHandle_t task_handle; TaskHandle_t task_handle;
// when FreeRTOS dynamic allocation is disabled (configSUPPORT_DYNAMIC_ALLOCATION == 0), the following fails
#if configSUPPORT_DYNAMIC_ALLOCATION
if (pdPASS != xTaskCreateAffinitySet(flash_lockout_task, "flash lockout", configMINIMAL_STACK_SIZE, (void *)core_num, 0, 1u << (core_num ^ 1), &task_handle)) { if (pdPASS != xTaskCreateAffinitySet(flash_lockout_task, "flash lockout", configMINIMAL_STACK_SIZE, (void *)core_num, 0, 1u << (core_num ^ 1), &task_handle)) {
#else
static StackType_t flash_lockout_stack[configMINIMAL_STACK_SIZE];
static StaticTask_t flash_lockout_task_tcb;
task_handle = xTaskCreateStaticAffinitySet(flash_lockout_task, "flash lockout", configMINIMAL_STACK_SIZE, (void *)core_num, 0, flash_lockout_stack, &flash_lockout_task_tcb, 1u << (core_num ^ 1));
if (task_handle == NULL) {
#endif
return PICO_ERROR_INSUFFICIENT_RESOURCES; return PICO_ERROR_INSUFFICIENT_RESOURCES;
} }
lockout_state[core_num] = FREERTOS_LOCKOUT_LOCKER_WAITING; lockout_state[core_num] = FREERTOS_LOCKOUT_LOCKER_WAITING;
@ -216,4 +225,4 @@ static int default_exit_safe_zone_timeout_ms(__unused uint32_t timeout_ms) {
#endif #endif
} }
return PICO_OK; return PICO_OK;
} }