Skip to content

Commit 0285d58

Browse files
committed
pico_flash: Support FreeRTOS Static Allocation
fixes: #2120
1 parent 5288585 commit 0285d58

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/rp2_common/pico_flash/flash.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,18 @@ static int default_enter_safe_zone_timeout_ms(__unused uint32_t timeout_ms) {
145145
uint core_num = get_core_num();
146146
// create at low priority on other core
147147
TaskHandle_t task_handle;
148+
149+
// when FreeRTOS dynamic allocation is disabled (configSUPPORT_DYNAMIC_ALLOCATION == 0), the following instruction fails
150+
#ifndef configSUPPORT_DYNAMIC_ALLOCATION
148151
if (pdPASS != xTaskCreateAffinitySet(flash_lockout_task, "flash lockout", configMINIMAL_STACK_SIZE, (void *)core_num, 0, 1u << (core_num ^ 1), &task_handle)) {
152+
#else
153+
static StackType_t flash_lockout_stack[configMINIMAL_STACK_SIZE];
154+
static StaticTask_t flash_lockout_task_tcb;
155+
task_handle = xTaskCreateStatic(flash_lockout_task, "flash lockout", configMINIMAL_STACK_SIZE, (void *)core_num, 0, flash_lockout_stack, &flash_lockout_task_tcb);
156+
if (task_handle != NULL) {
157+
vTaskCoreAffinitySet(task_handle, 1u << (core_num ^ 1));
158+
} else {
159+
#endif
149160
return PICO_ERROR_INSUFFICIENT_RESOURCES;
150161
}
151162
lockout_state[core_num] = FREERTOS_LOCKOUT_LOCKER_WAITING;

0 commit comments

Comments
 (0)