diff --git a/components/freertos/CMakeLists.txt b/components/freertos/CMakeLists.txt index 911e232755..58a5babe12 100644 --- a/components/freertos/CMakeLists.txt +++ b/components/freertos/CMakeLists.txt @@ -7,7 +7,7 @@ endif() idf_build_get_property(target IDF_TARGET) if(CONFIG_FREERTOS_SMP) - set(ldfragments linker_smp.lf) + set(ldfragments linker_smp.lf linker_common.lf) if(CONFIG_IDF_TARGET_ARCH_XTENSA) set(srcs "FreeRTOS-Kernel-SMP/portable/xtensa/port.c" @@ -71,7 +71,7 @@ if(CONFIG_FREERTOS_SMP) endif() else() - set(ldfragments linker.lf) + set(ldfragments linker.lf linker_common.lf) if(CONFIG_IDF_TARGET_ARCH_XTENSA) set(srcs "FreeRTOS-Kernel/portable/xtensa/port.c" diff --git a/components/freertos/FreeRTOS-openocd.c b/components/freertos/FreeRTOS-openocd.c index 89e1374634..0395ea2bc3 100644 --- a/components/freertos/FreeRTOS-openocd.c +++ b/components/freertos/FreeRTOS-openocd.c @@ -1,9 +1,10 @@ - /* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 - * + */ + +/* * Since at least FreeRTOS V7.5.3 uxTopUsedPriority is no longer * present in the kernel, so it has to be supplied by other means for * OpenOCD's threads awareness. @@ -15,7 +16,6 @@ */ #include "FreeRTOS.h" -#include "esp_attr.h" #include "sdkconfig.h" #ifdef __GNUC__ @@ -25,5 +25,5 @@ #endif #ifdef CONFIG_FREERTOS_DEBUG_OCDAWARE -const int USED DRAM_ATTR uxTopUsedPriority = configMAX_PRIORITIES - 1; //will be removed +const int USED uxTopUsedPriority = configMAX_PRIORITIES - 1; //will be removed #endif diff --git a/components/freertos/linker.lf b/components/freertos/linker.lf index be1013bda7..598918b151 100644 --- a/components/freertos/linker.lf +++ b/components/freertos/linker.lf @@ -3,12 +3,6 @@ archive: libfreertos.a entries: * (noflash_text) - if FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH = y: - # vTaskGetSnapshot is omitted on purpose: as it is used to by the Task Watchdog (TWDT) interrupt - # handler, we want to always keep it in IRAM - tasks: pxTaskGetNext (default) - tasks: uxTaskGetSnapshotAll (default) - tasks: pxGetNextTaskList (default) if FREERTOS_PLACE_FUNCTIONS_INTO_FLASH = y: port: pxPortInitialiseStack (default) port: xPortStartScheduler (default) @@ -34,11 +28,7 @@ entries: tasks: vTaskRemoveFromUnorderedEventList (default) tasks: uxTaskPriorityGet (default) tasks: vTaskPrioritySet (default) - tasks: prvTaskPriorityRaise (default) - tasks: prvTaskPriorityRestore (default) - tasks: vTaskSetThreadLocalStoragePointerAndDelCallback (default) tasks: pvTaskGetThreadLocalStoragePointer (default) - tasks: xTaskGetCurrentTaskHandleForCPU (default) tasks: vTaskDelete (default) tasks: vTaskDelayUntil (default) tasks: xTaskDelayUntil (default) @@ -57,8 +47,6 @@ entries: tasks: vTaskEndScheduler (default) tasks: vTaskMissedYield (default) tasks: vTaskSetThreadLocalStoragePointer (default) - tasks: xTaskGetAffinity (default) - tasks: xTaskGetIdleTaskHandleForCPU (default) if FREERTOS_USE_TRACE_FACILITY = y: tasks: uxTaskGetSystemState (default) tasks: uxTaskGetTaskNumber (default) @@ -127,12 +115,3 @@ entries: queue: uxQueueGetQueueNumber (default) queue: vQueueSetQueueNumber (default) queue: ucQueueGetQueueType (default) - # app_startup.c - app_startup: esp_startup_start_app (default) - if CONFIG_FREERTOS_UNICORE = n: - app_startup: esp_startup_start_app_other_cores (default) - app_startup: other_cpu_startup_idle_hook_cb (default) - app_startup: main_task (default) - # port_common.c Functions - port_common:vApplicationGetIdleTaskMemory (default) - port_common:vApplicationGetTimerTaskMemory (default) diff --git a/components/freertos/linker_common.lf b/components/freertos/linker_common.lf new file mode 100644 index 0000000000..97165d0cc0 --- /dev/null +++ b/components/freertos/linker_common.lf @@ -0,0 +1,62 @@ +# Linker fragment file for common FreeRTOS files (i.e., both "port_common.c" and "esp_additions/..." +# Flash function placements are listed per source file, in the order that they appear in the source file. + +[mapping:freertos_common] +archive: libfreertos.a +entries: + # ------------------------------------------------------------------------------------------------------------------ + # esp_additions/private_include/freertos_tasks_c_additions.h + # Placement Rules (Task Snapshot): + # - Default: Place all functions in internal RAM. + # - CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH: Place functions in flash + # - vTaskGetSnapshot is omitted on purpose as it is used to by the Task Watchdog (TWDT) interrupt handler, we want + # to always keep it in IRAM + # Placement Rules (FreeRTOS API Additions): + # - 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). + # ------------------------------------------------------------------------------------------------------------------ + # Task Snapshot + if FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH = y: + tasks:pxGetNextTaskList (default) + tasks:pxTaskGetNext (default) + tasks:uxTaskGetSnapshotAll (default) + # FreeRTOS API Additions + if FREERTOS_PLACE_FUNCTIONS_INTO_FLASH = y: + if FREERTOS_SMP = y: + tasks:xTaskCreatePinnedToCore (default) + tasks:xTaskCreateStaticPinnedToCore (default) + tasks:xTaskGetCurrentTaskHandleForCPU (default) + tasks:xTaskGetIdleTaskHandleForCPU (default) + tasks:xTaskGetAffinity (default) + if FREERTOS_TLSP_DELETION_CALLBACKS = y: + tasks:vTaskSetThreadLocalStoragePointerAndDelCallback (default) + tasks:prvTaskPriorityRaise (default) + tasks:prvTaskPriorityRestore (default) + + # ------------------------------------------------------------------------------------------------------------------ + # app_startup.c + # Placement Rules: Functions always in flash as they are never called from an ISR + # ------------------------------------------------------------------------------------------------------------------ + app_startup (default) # Place functions (but not Data and BSS) to flash + + # ------------------------------------------------------------------------------------------------------------------ + # FreeRTOS-openocd.c + # Placement Rules: All functions/data in internal RAM as they are called/used by OpenOCD + # ------------------------------------------------------------------------------------------------------------------ + FreeRTOS-openocd (noflash) + + # ------------------------------------------------------------------------------------------------------------------ + # port_common.c + # 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). + # ------------------------------------------------------------------------------------------------------------------ + port_common (noflash_text) # Default all functions to internal RAM + if FREERTOS_PLACE_FUNCTIONS_INTO_FLASH = y: + if FREERTOS_SMP = n: + port_common:xPortCheckValidTCBMem (default) + port_common:xPortcheckValidStackMem (default) + port_common:vApplicationGetIdleTaskMemory (default) + port_common:vApplicationGetTimerTaskMemory (default) diff --git a/components/freertos/linker_smp.lf b/components/freertos/linker_smp.lf index 523c25bf85..6fcf5c998d 100644 --- a/components/freertos/linker_smp.lf +++ b/components/freertos/linker_smp.lf @@ -76,8 +76,6 @@ entries: tasks: eTaskGetState (default) tasks: uxTaskPriorityGet (default) tasks: vTaskPrioritySet (default) - tasks: prvTaskPriorityRaise (default) - tasks: prvTaskPriorityRestore (default) tasks: vTaskSuspend (default) tasks: vTaskResume (default) tasks: prvCreateIdleTasks (default) @@ -127,29 +125,9 @@ entries: tasks: xTaskGenericNotify (default) tasks: xTaskGenericNotifyStateClear (default) tasks: ulTaskGenericNotifyValueClear (default) - # tasks.c: Additions - if FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH = y: - tasks: non_ready_task_lists (default) - tasks: pxGetNextTaskList (default) - tasks: pxTaskGetNext (default) - tasks: vTaskGetSnapshot (default) - tasks: uxTaskGetSnapshotAll (default) - tasks: xTaskCreatePinnedToCore (default) - tasks: xTaskCreateStaticPinnedToCore (default) - tasks: xTaskGetCurrentTaskHandleForCPU (default) - tasks: xTaskGetIdleTaskHandleForCPU (default) - tasks: xTaskGetAffinity (default) - if FREERTOS_TLSP_DELETION_CALLBACKS = y: - tasks: vTaskSetThreadLocalStoragePointerAndDelCallback (default) # port port: pxPortInitialiseStack (default) port: xPortStartScheduler (default) - # app_startup.c - app_startup: esp_startup_start_app (default) - if CONFIG_FREERTOS_UNICORE = n: - app_startup: esp_startup_start_app_other_cores (default) - app_startup: other_cpu_startup_idle_hook_cb (default) - app_startup: main_task (default) # timers.c timers: xTimerCreateTimerTask (default) timers: xTimerCreate (default)