FreeRTOS: pico_flash/flash.c calls xTaskCreateAffinitySet which is not available using static memory allocation #2120

Closed
opened 2024-12-03 10:28:21 -06:00 by maqifrnswa · 1 comment
maqifrnswa commented 2024-12-03 10:28:21 -06:00 (Migrated from github.com)

pico_flash/flash.c uses xTaskCreateAffinitySet, which is only available in FreeRTOS if confiugred to support dynamic allocation.
github.com/raspberrypi/pico-sdk@95ea6acad1/src/rp2_common/pico_flash/flash.c (L148)

It's defined here:
github.com/FreeRTOS/FreeRTOS-Kernel@974351fe4a/tasks.c (L1758)

If one was trying to use pure static FreeRTOS

#define configSUPPORT_DYNAMIC_ALLOCATION    0
#define configKERNEL_PROVIDED_STATIC_MEMORY     1

you'll get the following compilation warning:
pico_flash/flash.c:148:23: warning: implicit declaration of function 'xTaskCreateAffinitySet'; did you mean 'vTaskCoreAffinitySet'? [-Wimplicit-function-declaration]

For static allocation, it looks like you'd first have to create the static task then use vTaskCoreAffinitySet.

Perhaps it doesn't need to change (as pico sdk does other dynamic allocation, I believe), so maybe just outputting a warning during compilation that says "pico sdk requires configSUPPORT_DYNAMIC_ALLOCATION to be 1" would be enough

pico_flash/flash.c uses xTaskCreateAffinitySet, which is only available in FreeRTOS if confiugred to support dynamic allocation. https://github.com/raspberrypi/pico-sdk/blob/95ea6acad131124694cda1c162c52cd30e0aece0/src/rp2_common/pico_flash/flash.c#L148 It's defined here: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/974351fe4aec19779f5be774007810c6ab36a8ab/tasks.c#L1758 If one was trying to use pure static FreeRTOS ``` #define configSUPPORT_DYNAMIC_ALLOCATION 0 #define configKERNEL_PROVIDED_STATIC_MEMORY 1 ``` you'll get the following compilation warning: pico_flash/flash.c:148:23: warning: implicit declaration of function 'xTaskCreateAffinitySet'; did you mean 'vTaskCoreAffinitySet'? [-Wimplicit-function-declaration] For static allocation, it looks like you'd first have to create the static task then use ```vTaskCoreAffinitySet```. Perhaps it doesn't need to change (as pico sdk does other dynamic allocation, I believe), so maybe just outputting a warning during compilation that says "pico sdk requires configSUPPORT_DYNAMIC_ALLOCATION to be 1" would be enough
kilograham commented 2025-02-07 12:11:23 -06:00 (Migrated from github.com)

merged into develop - note the impl is not safe for multiple concurrent calls though

merged into develop - note the impl is not safe for multiple concurrent calls though
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk#2120
No description provided.