Files
esp-idf/components/freertos/linker.lf
Sudeep Mohanty 71a79ac0b1 feat(freertos): Add config to move additional functions into Flash
This commit adds a new Kconfig option, viz.,
CONFIG_FREERTOS_PLACE_ISR_FUNCTIONS_INTO_FLASH, which places
additional FreeRTOS functions, such as those which can be called from
and ISR context, into Flash memory. This feature utilizes the Flash auto
suspend/resume feature of the Flash chip.
2025-03-24 09:19:28 +01:00

377 lines
21 KiB
Plaintext

# ----------------------------------------------------------------------------------------------------------------------
# Linker fragment file for IDF FreeRTOS (i.e., CONFIG_FREERTOS_SMP=n)
# Flash function placements are listed per source file, in the order that they appear in the source file.
#
# Placement Rules:
# - Default: Place all functions in internal RAM.
# - CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH:
# - Place functions in flash if they are never called from an ISR context (directly or indirectly).
# - Some functions that are called often (such as critical sections) are placed in internal RAM for speed.
# - CONFIG_FREERTOS_PLACE_ISR_FUNCTIONS_INTO_FLASH:
# - Place additional functions such as the FromISR() variants in flash as well.
#
# TODO: In IDF 6.0, evaluate the possibility of (IDF-12695):
# 1. Default behavior: All FreeRTOS functions should be placed in flash by default, except for:
# - FromISR() functions
# - Performance-critical functions, such as critical section APIs and code related to context switching
# 2. Deprecate the FREERTOS_PLACE_FUNCTIONS_INTO_FLASH Kconfig option and unhide the FREERTOS_IN_IRAM Kconfig
# option. Present FREERTOS_IN_IRAM config option to users as a performance optimization feature, with the
# trade-off of reduced internal RAM availability. This option would be disabled by default.
# 3. FREERTOS_IN_IRAM config option should be user-configurable only if SPI_FLASH_AUTO_SUSPEND is supported.
# If not supported, it should be enabled by default and follow the placement rules stated above.
# 4. If SPI_FLASH_AUTO_SUSPEND is supported, place additional FreeRTOS functions - including FromISR()
# variants, in Flash. Control this behavior using the FREERTOS_PLACE_ISR_FUNCTIONS_INTO_FLASH
# config option.
# ----------------------------------------------------------------------------------------------------------------------
[mapping:freertos_idf]
archive: libfreertos.a
entries:
if FREERTOS_IN_IRAM = y:
* (noflash_text) # All FreeRTOS functions to IRAM
#else
# TODO: Enable in IDF 6.0
# * (default) # All FreeRTOS functions to Flash
if FREERTOS_PLACE_FUNCTIONS_INTO_FLASH = y:
# --------------------------------------------------------------------------------------------------------------
# event_groups.c
# - Exclude all ...FromISR() functions and their dependents
# --------------------------------------------------------------------------------------------------------------
event_groups:xEventGroupCreateStatic (default)
event_groups:xEventGroupCreate (default)
event_groups:xEventGroupSync (default)
event_groups:xEventGroupWaitBits (default)
event_groups:xEventGroupClearBits (default)
event_groups:xEventGroupSetBits (default)
event_groups:vEventGroupDelete (default)
event_groups: xEventGroupGetStaticBuffer (default)
event_groups:vEventGroupSetBitsCallback (default)
event_groups:vEventGroupClearBitsCallback (default)
event_groups:prvTestWaitCondition (default)
if FREERTOS_USE_TRACE_FACILITY = y:
event_groups: uxEventGroupGetNumber (default)
event_groups: vEventGroupSetNumber (default)
if FREERTOS_PLACE_ISR_FUNCTIONS_INTO_FLASH = y:
event_groups: xEventGroupClearBitsFromISR (default)
event_groups: xEventGroupGetBitsFromISR (default)
event_groups: xEventGroupSetBitsFromISR (default)
# --------------------------------------------------------------------------------------------------------------
# list.c
# - List/List Item initialization functions are never called from ISR
# - vListInsert is never called from an ISR context
# - Remaining List insertion/removal functions can be called from an ISR context and hence place them in flash
# only when CONFIG_FREERTOS_PLACE_ISR_FUNCTIONS_INTO_FLASH is enabled
# --------------------------------------------------------------------------------------------------------------
list:vListInitialise (default)
list:vListInitialiseItem (default)
list:vListInsert (default)
if FREERTOS_PLACE_ISR_FUNCTIONS_INTO_FLASH = y:
list:vListInsertEnd (default)
list:uxListRemove (default)
# --------------------------------------------------------------------------------------------------------------
# queue.c
# - Keep all ...FromISR() functions (and their prv... calls) in internal RAM
# - All other functions can be moved to flash
# - Queue lock related functions are only used in single core builds
# - If CONFIG_FREERTOS_PLACE_ISR_FUNCTIONS_INTO_FLASH is enabled, place all FromISR() functions and their
# dependents in flash as well
# --------------------------------------------------------------------------------------------------------------
queue:xQueueGenericReset (default)
queue:xQueueGenericCreateStatic (default)
queue:xQueueGenericGetStaticBuffers (default)
queue:xQueueGenericCreate (default)
queue:prvInitialiseNewQueue (default)
queue:prvInitialiseMutex (default)
queue:xQueueCreateMutex (default)
queue:xQueueCreateMutexStatic (default)
queue:xQueueGetMutexHolder (default)
queue:xQueueGiveMutexRecursive (default)
queue:xQueueTakeMutexRecursive (default)
queue:xQueueCreateCountingSemaphoreStatic (default)
queue:xQueueCreateCountingSemaphore (default)
queue:xQueueGenericSend (default)
queue:xQueueReceive (default)
queue:xQueueSemaphoreTake (default)
queue:xQueuePeek (default)
queue:uxQueueMessagesWaiting (default)
queue:uxQueueSpacesAvailable (default)
queue:vQueueDelete (default)
if FREERTOS_USE_TRACE_FACILITY = y:
queue:uxQueueGetQueueNumber (default)
queue:vQueueSetQueueNumber (default)
queue:ucQueueGetQueueType (default)
queue:prvGetDisinheritPriorityAfterTimeout (default)
if FREERTOS_UNICORE = y:
queue:prvUnlockQueue (default)
queue:prvIsQueueEmpty (default)
queue:prvIsQueueFull (default)
if FREERTOS_QUEUE_REGISTRY_SIZE > 0:
queue:vQueueAddToRegistry (default)
queue:pcQueueGetName (default)
queue:vQueueUnregisterQueue (default)
queue:vQueueWaitForMessageRestricted (default)
queue:xQueueCreateSet (default)
queue:xQueueAddToSet (default)
queue:xQueueRemoveFromSet (default)
queue:xQueueSelectFromSet (default)
if FREERTOS_PLACE_ISR_FUNCTIONS_INTO_FLASH = y:
queue:xQueueGetMutexHolderFromISR (default)
queue:xQueueGenericSendFromISR (default)
queue:prvCopyDataToQueue (default)
queue:prvNotifyQueueSetContainer (default)
queue:xQueueGiveFromISR (default)
queue:xQueueReceiveFromISR (default)
queue:prvCopyDataFromQueue (default)
queue:xQueuePeekFromISR (default)
queue:uxQueueMessagesWaitingFromISR (default)
queue:xQueueIsQueueEmptyFromISR (default)
queue:xQueueIsQueueFullFromISR (default)
queue:xQueueSelectFromSetFromISR (default)
# --------------------------------------------------------------------------------------------------------------
# stream_buffer.c
# - If CONFIG_FREERTOS_PLACE_ISR_FUNCTIONS_INTO_FLASH is enabled, place all FromISR() functions and their
# dependents in flash as well
# --------------------------------------------------------------------------------------------------------------
stream_buffer:xStreamBufferGenericCreate (default)
stream_buffer:xStreamBufferGenericCreateStatic (default)
stream_buffer:xStreamBufferGetStaticBuffers (default)
stream_buffer:vStreamBufferDelete (default)
stream_buffer:xStreamBufferReset (default)
stream_buffer:xStreamBufferSetTriggerLevel (default)
stream_buffer:xStreamBufferSpacesAvailable (default)
stream_buffer:xStreamBufferBytesAvailable (default)
stream_buffer:xStreamBufferSend (default)
stream_buffer:xStreamBufferReceive (default)
stream_buffer:xStreamBufferNextMessageLengthBytes (default)
stream_buffer:xStreamBufferIsEmpty (default)
stream_buffer:xStreamBufferIsFull (default)
stream_buffer:prvWriteBytesToBuffer (default)
stream_buffer:prvReadBytesFromBuffer (default)
stream_buffer:prvInitialiseNewStreamBuffer (default)
if FREERTOS_USE_TRACE_FACILITY = y:
stream_buffer:uxStreamBufferGetStreamBufferNumber (default)
stream_buffer:vStreamBufferSetStreamBufferNumber (default)
stream_buffer:ucStreamBufferGetStreamBufferType (default)
if FREERTOS_PLACE_ISR_FUNCTIONS_INTO_FLASH = y:
stream_buffer:xStreamBufferSendFromISR (default)
stream_buffer:prvWriteMessageToBuffer (default)
stream_buffer:xStreamBufferReceiveFromISR (default)
stream_buffer:prvReadMessageFromBuffer (default)
stream_buffer:xStreamBufferSendCompletedFromISR (default)
stream_buffer:xStreamBufferReceiveCompletedFromISR (default)
stream_buffer:prvBytesInBuffer (default)
# --------------------------------------------------------------------------------------------------------------
# tasks.c
# - The following functions are always kept in internal RAM as they are frequently called during context switches
# - xTaskIncrementTick
# - prvSelectHighestPriorityTaskSMP
# - vTaskSwitchContext
# - Tickless idle functions (i.e., step tick) are left in internal RAM for speed unless
# CONFIG_FREERTOS_PLACE_ISR_FUNCTIONS_INTO_FLASH is enabled
# - Place all functions that are called from an ISR context into Flash if
# CONFIG_FREERTOS_PLACE_ISR_FUNCTIONS_INTO_FLASH is enabled
# - The following functions are called when the cache is disabled, thus they are excluded from the list below
# (i.e., called after "spi_flash_disable_interrupts_caches_and_other_cpu()" is called).
# - "xTaskGetSchedulerState"
# - "xTaskGetTickCount"
# --------------------------------------------------------------------------------------------------------------
tasks:xTaskCreateRestrictedStatic (default)
tasks:xTaskCreateRestricted (default)
tasks:prvInitialiseNewTask (default)
tasks:prvAddNewTaskToReadyList (default)
tasks:vTaskDelete (default)
tasks:xTaskDelayUntil (default)
tasks:vTaskDelay (default)
tasks:eTaskGetState (default)
tasks:uxTaskPriorityGet (default)
tasks:vTaskPrioritySet (default)
tasks:vTaskSuspend (default)
tasks:vTaskResume (default)
tasks:prvCreateIdleTasks (default)
tasks:vTaskStartScheduler (default)
tasks:vTaskEndScheduler (default)
tasks:vTaskSuspendAll (default)
if FREERTOS_USE_TICKLESS_IDLE = y:
tasks:prvGetExpectedIdleTime (default)
tasks:eTaskConfirmSleepModeStatus (default)
tasks:xTaskResumeAll (default)
tasks:uxTaskGetNumberOfTasks (default)
tasks:pcTaskGetName (default)
tasks:prvSearchForNameWithinSingleList (default)
tasks:xTaskGetHandle (default)
tasks:xTaskGetStaticBuffers (default)
tasks:xTaskGetIdleTaskHandle (default)
tasks:xTaskCatchUpTicks (default)
tasks:xTaskAbortDelay (default)
if FREERTOS_USE_APPLICATION_TASK_TAG = y:
tasks:vTaskSetApplicationTaskTag (default)
tasks:xTaskGetApplicationTaskTag (default)
tasks:xTaskCallApplicationTaskHook (default)
tasks:vTaskPlaceOnEventList (default)
tasks:vTaskPlaceOnUnorderedEventList (default)
tasks:vTaskPlaceOnEventListRestricted (default)
tasks:vTaskRemoveFromUnorderedEventList (default)
tasks:vTaskSetTimeOutState (default)
tasks:vTaskInternalSetTimeOutState (default)
tasks:xTaskCheckForTimeOut (default)
tasks:vTaskMissedYield (default)
tasks:prvIdleTask (default)
if FREERTOS_THREAD_LOCAL_STORAGE_POINTERS != 0:
tasks:vTaskSetThreadLocalStoragePointer (default)
tasks:pvTaskGetThreadLocalStoragePointer (default)
tasks:prvInitialiseTaskLists (default)
tasks:prvCheckTasksWaitingTermination (default)
tasks:prvTaskCheckFreeStackSpace (default)
tasks:uxTaskGetStackHighWaterMark2 (default)
tasks:uxTaskGetStackHighWaterMark (default)
tasks:prvDeleteTCB (default)
tasks:xTaskGetCurrentTaskHandle (default)
tasks:xTaskPriorityInherit (default)
tasks:xTaskPriorityDisinherit (default)
tasks:vTaskPriorityDisinheritAfterTimeout (default)
if FREERTOS_USE_TRACE_FACILITY = y && FREERTOS_USE_STATS_FORMATTING_FUNCTIONS = y:
tasks:prvWriteNameToBuffer (default)
tasks:vTaskList (default)
if FREERTOS_GENERATE_RUN_TIME_STATS = y && FREERTOS_USE_STATS_FORMATTING_FUNCTIONS = y:
tasks:vTaskGetRunTimeStats (default)
tasks:uxTaskResetEventItemValue (default)
tasks:pvTaskIncrementMutexHeldCount (default)
tasks:ulTaskGenericNotifyTake (default)
tasks:xTaskGenericNotifyWait (default)
tasks:xTaskGenericNotify (default)
tasks:xTaskGenericNotifyStateClear (default)
tasks:ulTaskGenericNotifyValueClear (default)
if FREERTOS_GENERATE_RUN_TIME_STATS = y:
tasks:ulTaskGetIdleRunTimeCounter (default)
tasks:ulTaskGetIdleRunTimePercent (default)
tasks:prvAddCurrentTaskToDelayedList (default)
if FREERTOS_USE_TRACE_FACILITY = y:
tasks:uxTaskGetSystemState (default)
tasks:uxTaskGetTaskNumber (default)
tasks:vTaskSetTaskNumber (default)
tasks:vTaskGetInfo (default)
tasks:prvListTasksWithinSingleList (default)
if FREERTOS_PLACE_ISR_FUNCTIONS_INTO_FLASH = y:
tasks:prvIsYieldRequiredSMP (default)
tasks:prvCheckTaskCanBeScheduledSMP (default)
tasks:uxTaskPriorityGetFromISR (default)
tasks:prvTaskIsTaskSuspended (default)
tasks:xTaskResumeFromISR (default)
tasks:xTaskGetTickCountFromISR (default)
tasks:xTaskGetApplicationTaskTagFromISR (default)
tasks:xTaskRemoveFromEventList (default)
tasks:prvResetNextTaskUnblockTime (default)
tasks:xTaskGenericNotifyFromISR (default)
tasks:vTaskGenericNotifyGiveFromISR (default)
if FREERTOS_USE_TICKLESS_IDLE = y:
tasks:vTaskStepTick (default)
# --------------------------------------------------------------------------------------------------------------
# timers.c
# - xTimerGenericCommand() is used for ISR calls as well. Thus leave it (and its dependents) in internal RAM
# unless CONFIG_FREERTOS_PLACE_ISR_FUNCTIONS_INTO_FLASH is enabled
# --------------------------------------------------------------------------------------------------------------
timers:xTimerCreateTimerTask (default)
timers:xTimerCreate (default)
timers:xTimerCreateStatic (default)
timers:prvInitialiseNewTimer (default)
timers:xTimerGetTimerDaemonTaskHandle (default)
timers:xTimerGetPeriod (default)
timers:vTimerSetReloadMode (default)
timers:xTimerGetReloadMode (default)
timers:uxTimerGetReloadMode (default)
timers:xTimerGetExpiryTime (default)
timers:xTimerGetStaticBuffer (default)
timers:pcTimerGetName (default)
timers:prvReloadTimer (default)
timers:prvProcessExpiredTimer (default)
timers:prvTimerTask (default)
timers:prvProcessTimerOrBlockTask (default)
timers:prvGetNextExpireTime (default)
timers:prvSampleTimeNow (default)
timers:prvInsertTimerInActiveList (default)
timers:prvProcessReceivedCommands (default)
timers:prvSwitchTimerLists (default)
timers:prvCheckForValidListAndQueue (default)
timers:xTimerIsTimerActive (default)
timers:pvTimerGetTimerID (default)
timers:vTimerSetTimerID (default)
timers:xTimerPendFunctionCall (default)
if FREERTOS_USE_TRACE_FACILITY = y:
timers:uxTimerGetTimerNumber (default)
timers:vTimerSetTimerNumber (default)
if FREERTOS_PLACE_ISR_FUNCTIONS_INTO_FLASH = y:
timers:xTimerGenericCommand (default)
timers:xTimerPendFunctionCallFromISR (default)
# --------------------------------------------------------------------------------------------------------------
# portable/xtensa/port.c
# - Most functions are called from an ISR context, except for scheduler/task init/deinit functions. Functions
# called from ISR context are placed in flash only when CONFIG_FREERTOS_PLACE_ISR_FUNCTIONS_INTO_FLASH
# is enabled
# - Critical sections functions are always placed in internal RAM for better performance
# - The following functions are also placed in internal RAM as they are called from vTaskSwitchContext, which is
# also always placed in internal RAM
# - vApplicationStackOverflowHook
# - vPortSetStackWatchpoint
# --------------------------------------------------------------------------------------------------------------
if IDF_TARGET_ARCH_XTENSA = y:
port:xPortStartScheduler (default)
port:vPortEndScheduler (default)
if FREERTOS_TASK_FUNCTION_WRAPPER = y:
port:vPortTaskWrapper (default)
if SOC_CPU_COPROC_NUM > 0:
port:uxInitialiseStackCPSA (default)
port:uxInitialiseStackTLS (default)
port:uxInitialiseStackFrame (default)
port:pxPortInitialiseStack (default)
port:xPortGetTickRateHz (default)
if FREERTOS_TLSP_DELETION_CALLBACKS = y:
port:vPortTLSPointersDelCb (default)
if SOC_CPU_COPROC_NUM > 0:
port:vPortCleanUpCoprocArea (default)
port:vPortTCBPreDeleteHook (default)
if FREERTOS_PLACE_ISR_FUNCTIONS_INTO_FLASH = y:
port:xPortInIsrContext (default)
port:vPortAssertIfInISR (default)
port:xPortInterruptedFromISRContext (default)
port:vPortYieldOtherCore (default)
# --------------------------------------------------------------------------------------------------------------
# portable/riscv/port.c
# - Most functions are called from an ISR context, except for scheduler/task init/deinit functions. Functions
# called from ISR context are placed in flash only when CONFIG_FREERTOS_PLACE_ISR_FUNCTIONS_INTO_FLASH
# is enabled
# - Critical sections functions are always placed in internal RAM for better performance
# - The following functions are also placed in internal RAM as they are called from vTaskSwitchContext, which is
# also always placed in internal RAM
# - vApplicationStackOverflowHook
# - vPortSetStackWatchpoint
# - vPortCoprocUsedInISR is directly called from RISC-V assembly code with a direct branch instruction which
# may be too far when placed in Flash. Hence, it is always placed in internal RAM
# --------------------------------------------------------------------------------------------------------------
if IDF_TARGET_ARCH_RISCV = y:
port:xPortStartScheduler (default)
port:vPortEndScheduler (default)
port:uxInitialiseStackTLS (default)
if FREERTOS_TASK_FUNCTION_WRAPPER = y:
port:vPortTaskWrapper (default)
if SOC_CPU_COPROC_NUM > 0:
port:pxRetrieveCoprocSaveAreaFromStackPointer (default)
port:uxInitialiseCoprocSaveArea (default)
port:vPortCleanUpCoprocArea (default)
port:pxPortGetCoprocArea (default)
port:pxPortUpdateCoprocOwner (default)
if FREERTOS_UNICORE = n:
port:vPortTaskPinToCore (default)
port:uxInitialiseStackFrame (default)
port:pxPortInitialiseStack (default)
port:vPortYield (default)
port:xPortGetTickRateHz (default)
if FREERTOS_TLSP_DELETION_CALLBACKS = y:
port:vPortTLSPointersDelCb (default)
port:vPortTCBPreDeleteHook (default)
if FREERTOS_PLACE_ISR_FUNCTIONS_INTO_FLASH = y:
port:xPortInIsrContext (default)
port:vPortAssertIfInISR (default)
port:xPortInterruptedFromISRContext (default)
port:vPortYieldFromISR (default)
port:vPortYieldOtherCore (default)