Skip to content

Commit 46d7112

Browse files
SConawaywill-v-pi
authored andcommitted
pico_flash: Support FreeRTOS Static Allocation (raspberrypi#2229)
1 parent 4d12569 commit 46d7112

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/rp2_common/pico_flash/flash.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,16 @@ 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 fails
150+
#if 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 = xTaskCreateStaticAffinitySet(flash_lockout_task, "flash lockout", configMINIMAL_STACK_SIZE, (void *)core_num, 0, flash_lockout_stack, &flash_lockout_task_tcb, 1u << (core_num ^ 1));
156+
if (task_handle == NULL) {
157+
#endif
149158
return PICO_ERROR_INSUFFICIENT_RESOURCES;
150159
}
151160
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) {
216225
#endif
217226
}
218227
return PICO_OK;
219-
}
228+
}

0 commit comments

Comments
 (0)