Skip to content

Commit

Permalink
pico_flash: Support FreeRTOS Static Allocation (#2229)
Browse files Browse the repository at this point in the history
  • Loading branch information
SConaway authored Feb 7, 2025
1 parent 1ee91e1 commit 876c09c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/rp2_common/pico_flash/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,16 @@ static int default_enter_safe_zone_timeout_ms(__unused uint32_t timeout_ms) {
uint core_num = get_core_num();
// create at low priority on other core
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)) {
#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;
}
lockout_state[core_num] = FREERTOS_LOCKOUT_LOCKER_WAITING;
Expand Down Expand Up @@ -216,4 +225,4 @@ static int default_exit_safe_zone_timeout_ms(__unused uint32_t timeout_ms) {
#endif
}
return PICO_OK;
}
}

0 comments on commit 876c09c

Please sign in to comment.