Commit Graph

197 Commits

Author SHA1 Message Date
Sudeep Mohanty
a76a1465b6 fix(freertos): Updated IDLE task names for each core to have the coreID as a suffix
This commit updates the IDLE task names for each core by concatenating
the respective coreIDs to the names.

Closes https://github.com/espressif/esp-idf/issues/12204
2023-09-20 10:31:08 +02:00
Darian Leung
b09462eae8 feat(freertos): Add beta support for FreeRTOS v10.5.1 kernel
This commit adds beta support for the FreeRTOS v10.5.1 kernel which can be
enabled by enabling the CONFIG_FREERTOS_USE_KERNEL_10_5_1 option.

The following changes have been made:

- Updated freertos/CMakeLists.txt to build v10.5.1 kernel with v10.4.3. ports
- Updated existing Xtensa and RISC-V ports to work with V10.5.1
- Modifications to other ESP-IDF components to work with v10.5.1
- Added some ESP-IDF specific tracing changes to v10.5.1 kernel
- Make CONFIG_FREERTOS_USE_KERNEL_10_5_1 a public option

Note: The beta release is missing some minor fixes, performance improvements,
and features. Using this beta release for production is not recommended.

Closes https://github.com/espressif/esp-idf/issues/7137
2023-09-18 21:32:14 +08:00
Konstantin Kondrashov
2557513fb5 Merge branch 'bugfix/esp32p4_usage_clic_int_thresh_reg' into 'master'
fix(freertos): Use INTERRUPT_CURRENT_CORE_INT_THRESH_REG for esp32p4

See merge request espressif/esp-idf!25840
2023-09-08 22:43:22 +08:00
Sudeep Mohanty
51846b497b Merge branch 'feature/freertos_add_sbom_file' into 'master'
feat(freertos): Added SBOM manifest file for SPDX file generation

Closes IDF-7979

See merge request espressif/esp-idf!25758
2023-09-08 18:21:46 +08:00
Zim Kalinowski
bee3ff952e fix(freertos): Added missing Linux port layer macros 2023-09-07 10:30:02 +02:00
KonstantinKondrashov
25c7a59e31 fix(freertos): Use INTERRUPT_CURRENT_CORE_INT_THRESH_REG for esp32p4 2023-09-07 15:25:35 +08:00
Sudeep Mohanty
2ddb47f533 feat(freertos): Added SBOM manifest file for SPDX file generation
This commit adds the SBOM manifest file for the FreeRTOS-Kernel to aid
SPDX file generation.
2023-09-05 18:30:30 +08:00
Darian Leung
035423eb37 refactor(freertos/idf): Move task creation "PinnedToCore" API to addition headers
This commit moves/merges the IDF FreeRTOS "PinnedToCore" task creation
functions from tasks.c/task.h to idf_additions.h/freertos_task_c_additions.h.

Also updated FreeRTOS Mock component to provide mocks for "idf_additions.h"
headers for our mock tests.
2023-09-05 16:20:59 +08:00
Darian Leung
e612db7d32 refactor(freertos/idf): Move weak xTimerCreateTimerTask() to IDF additions header
A weak xTimerCreateTimerTask() was added to tasks.c as a workaround in ESP-IDF
in order to prevent timers.c from being linked when unused.

This commit moves that workaround to `freertos_tasks_c_additions.h`
2023-09-05 16:20:59 +08:00
Darian Leung
a5f9a2505e refactor(freertos/idf): Remove application hook prototypes
The following application hook protoypes are defined in task.h from FreeRTOS
V10.4.0 onwwards and no longer need to be declared in tasks.c, thus have been
removed:

- vApplicationStackOverflowHook()
- vApplicationTickHook()
- vApplicationGetIdleTaskMemory()
2023-09-05 16:20:59 +08:00
Darian Leung
7b4dba4ffd refactor(freertos/idf): Move vTaskSetThreadLocalStoragePointerAndDelCallback()
This commit moves vTaskSetThreadLocalStoragePointerAndDelCallback() from
`tasks.c`/`task.h` to `freertos_tasks_c_additions.h`/`idf_additions.h`.
2023-09-05 16:20:59 +08:00
Darian Leung
5de6a9aff6 refactor(freertos/idf): Move compatibility functions
This function moves ulTaskNotifyTake()/xTaskNotifyWait() from IDF FreeRTOS
`tasks.c` to `freertos_compatibility.c`. These functions were kept for
pre-compiled library compatibilty. Move them reduces the kernel source code
difference when compared to upstream FreeRTOS.
2023-09-05 16:20:59 +08:00
Darian Leung
0db40f9e6c refactor(freertos/idf): Move IDF task utility functions to API addition headers
This commit combines various task utility API additions in IDF FreeRTOS and with
their Amazon SMP FreeRTOS addition counterparts. The folloiwng functions have
been moved to freertos_tasks_c_additions.h and idf_additions.h as these API
are considered public:

- xTaskGetCurrentTaskHandleForCPU()
- xTaskGetIdleTaskHandleForCPU()
- xTaskGetAffinity()
- pxTaskGetStackStart()

Also fixed in missing #if macros when vTaskCoreAffinityGet() is called in
Amazon SMP FreerTOS tests.
2023-09-05 16:20:59 +08:00
Darian Leung
db9d9658f9 refactor(freertos/idf): Move xTaskIncrementTickOtherCores() to IDF additition headers
This commit moves xTaskIncrementTickOtherCores() to freertos_tasks_c_additions.h
and freertos_idf_additions_priv.h (as API is private). This reduces the code
differences cmpared to upstream FreeRTOS.
2023-09-05 16:20:59 +08:00
Darian Leung
8825c8dda9 refactor(freertos/idf): Move critical section API to IDF addition headers
- The following IDF API additions are moved to freertos_tasks_c_additions.h
(implementation) and freertos_idf_additions_priv.h (declaration) as APIs are
private. This reduces the source code difference from upstream.
    - prvENTER_CRITICAL_OR_SUSPEND_ALL()
    - prvEXIT_CRITICAL_OR_RESUME_ALL()
    - prvENTER_CRITICAL_OR_MASK_ISR()
    - prvEXIT_CRITICAL_OR_UNMASK_ISR()
    - vTaskTakeKernelLock()
    - vTaskReleaseKernelLock()
- Rename vTask[Take/Release]KernelLock() to prv[Take/Release]KernelLock() to
indicate that the this API is private.
2023-09-05 16:20:59 +08:00
Darian Leung
5227616e57 refactor(freertos/idf): Implicitly include idf_additions.h from FreeRTOS.h
This commit adds an implicit inclusion of `idf_additions.h` to `FreeRTOS.h` in
preparation for moving some IDf specific API to `idf_additions.h`.

This implict inclusion allows existing code to be continue using these
relocated APIs without any changes in header inclusions.

Also removed "#pragma once" directive from "freertos_tasks_c_additions.h" since
that header is included as a source file.
2023-09-05 16:19:42 +08:00
Darian
bd9d6b82ab Merge branch 'bugfix/freertos_private_critical_section_macro' into 'master'
fix(freertos): Fixed bug with prvENTER/EXIT_CRITICAL_OR_MASK_ISR() macro

See merge request espressif/esp-idf!25705
2023-09-04 14:18:11 +08:00
Sudeep Mohanty
62ee4135e0 Merge branch 'bugfix/freertos_incorrect_xPortCanYield' into 'master'
fix(freertos): Corrected xPortCanYield() for esp32p4

See merge request espressif/esp-idf!25679
2023-09-04 09:33:25 +08:00
Darian Leung
75a3c99581 fix(freertos): Fixed bug with prvENTER/EXIT_CRITICAL_OR_MASK_ISR() macro
Fixed an undiscovered bug with prvENTER_CRITICAL_OR_MASK_ISR() and
prvEXIT_CRITICAL_OR_MASK_ISR() where the `uxInterruptStatus` argument was not
used.

However, all calls of this macro provide a local `uxSavedInterruptStatus`
variable, leading to this bug being hidden.
2023-09-02 02:27:09 +08:00
Sudeep Mohanty
d9a3e3bb86 fix(freertos): Corrected xPortCanYield() for esp32p4
This commit updates the xPortCanYield() for esp32p4 by correcting the
return condition. Previously, the API would return true if an ISR of
priority 1 was received which is incorrect.
2023-08-31 17:45:17 +08:00
Omar Chebib
8ca191e4c1 fix(esp32p4): Fixed interrupt handling to use the CLIC controller 2023-08-31 12:16:08 +08:00
Sudeep Mohanty
ec4cd2bb19 docs(freertos): Updated FreeRTOS documentation for ESP32-P4 2023-08-28 10:07:43 +08:00
Darian
ede131ce73 Merge branch 'refactor/freertos_tslfcb_and_coproc_cleanup' into 'master'
refactor(freertos): Remove portCLEAN_UP_COPROC() and TLSP deletion callback kernel changes from IDF FreeRTOS

See merge request espressif/esp-idf!25481
2023-08-25 15:34:40 +08:00
Marius Vikhammer
e07023292a Merge branch 'feature/p4_spinlocks' into 'master'
esp32p4: support spinlocks

Closes IDF-7771

See merge request espressif/esp-idf!25036
2023-08-25 11:43:38 +08:00
Darian Leung
57eb41ce83 refactor(freertos): Call TLSP deletion callback from portCLEAN_UP_TCB()
Previously, TLSP deletion callbacks were...

- Stored in a seprate TCB member "pvThreadLocalStoragePointersDelCallback"
- Called separately via multipole prvDeleteTLS() insertions in tasks.c

This commit refactors how TLSP deletion callbacks are stored and called:

- TLSP deletion callbacks are now stored in "pvThreadLocalStoragePointers"
directly. configNUM_THREAD_LOCAL_STORAGE_POINTERS is doubled in size so that
the deletion callbacks are stored in the latter half of the array

- The callbacks are now called via "portCLEAN_UP_TCB()". As such, the
prvDeleteTLS() additions are no longer needed and the function can be removed

- Removed some legacy TLSP tests using the old method of storing the callback
pointers.

This commit reduces the source code diff between IDF FreeRTOS and upstream
vanilla FreeRTOS, in preparation for v10.5.1 upgrade.
2023-08-24 19:32:06 +08:00
Darian Leung
5f2443b7d1 refactor(freertos): Remove portCLEAN_UP_COPROC()
portCLEAN_UP_COPROC() was an IDF specific addition to FreeRTOS, where the
macro was called from prvDeleteTCB() to clean up the coprocessor context of a
deleted task.

This commit removes portCLEAN_UP_COPROC(). The coprocessor cleanup routine
(i.e., vPortCleanUpCoprocArea()) is now called via portCLEAN_UP_TCB()->
vPortTCBPreDeleteHook().

This removes a minor code difference between IDF FreeRTOS and upstream.
2023-08-24 19:32:06 +08:00
Marius Vikhammer
0d9f9e6816 feat(core-systems): add support for spinlock/compare and set on esp32p4 2023-08-24 10:30:25 +08:00
Darian Leung
39cf3638ae change(freertos): Deprecate usage of vPortCleanUpTCB() by applications
Previously, if CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP was enabled, users
would provide a definition for a vPortCleanUpTCB() hook function that is called
right before a task's memory is freed in prvDeleteTCB(). However,
vPortCleanUpTCB() will be reclaimed by ESP-IDF for internal use in v6.0.

This commit introduces the following changes...

Introduced a new CONFIG_FREERTOS_TASK_PRE_DELETION_HOOK option:

- Provides the same pre-deletion hook functionality. But users now define
vTaskPreDeletionHook() instead.
- CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP still exists, but is marked as
deprecated. This is to maintain compatibility with existing applications
that already define vPortCleanUpTCB().
- Removed redundant --wl --wrap workaround with vPortCleanUpTCB()
- Added todo notes to remove support for user defined vPortCleanUpTCB()
completely in v6.0.
- Updated test cases to use new CONFIG_FREERTOS_TASK_PRE_DELETION_HOOK option

Freed up portCLEAN_UP_TCB() to call a new internal vPortTCBPreDeleteHook():

- vPortTCBPreDeleteHook() now replaces the previous "wrapped" implementation
of vPortCleanUpTCB().
- vPortTCBPreDeleteHook() is an internal task pre-delete hook for IDF FreeRTOS
ports to inject some pre-deletion operations.
- Internal pre-delete hook now invokes user provided vTaskPreDeletionHook()
if enabled.
- Relocated vPortTCBPreDeleteHook() to correct section in port.c
2023-08-23 17:50:08 +08:00
Sudeep Mohanty
4e51c6b049 feat(freertos): Added changes for multi-core RISC-V port for FreeRTOS
This commit updates the FreeRTOS port layer for multi-core RISC-V targets.
2023-08-22 15:35:15 +08:00
Darian Leung
1620d97299 change(freertos): Optimized xTaskRemoveFromEventList()
This commit optimizes xTaskRemoveFromEventList() by removing the
listLIST_IS_EMPTY() check from single core builds. The scenario of the event
list being empty when the function is called can only occur on multi-core
builds.
2023-08-09 16:43:52 +08:00
Darian Leung
5947314431 fix(freertos): Fix vTaskRemoveFromUnorderedEventList()
This commit fixes and optimizes vTaskRemoveFromUnorderedEventList() in the
following ways:

- Fixed bug in single core builds where the unblocked task would be placed on
xPendingReadyList.
    - If an ISR occurs while accessing xPendingReadyList, and the ISR also
      accesses the xPendingReadyList, xPendingReadyList would be corrupted.
    - In single core builds, this function is only called from event groups with
      the scheduler suspended. Thus the function should have exclusive access to
      pxReadyTasksLists instead of xPendingReadyList.
    - The function's single core logic has now been updated to match upstream
      behavior, by always placing the unblocked task on pxReadyTasksLists.

- Optimized the function for single core builds by removing the
taskCAN_BE_SCHEDULED() check.
    - In single core builds, given that the function is always called with the
      scheduler suspended
    - Thus, the taskCAN_BE_SCHEDULED (and the subsequent routine to place the
      unblocked task on the xPendingReadyList) is not necessary for single core
      builds.
    - The function now matches upstream behavior in single core builds.

Closes https://github.com/espressif/esp-idf/issues/11883
2023-08-09 16:43:52 +08:00
Darian Leung
fdcab76128 fix(freertos): taskCAN_BE_SCHEDULED macro parenthesis
This commit adds missing parenthesis around the taskCAN_BE_SCHEDULED macro so
that it can properly used with a negation operator.
2023-08-09 15:54:14 +08:00
Darian Leung
6fc935e584 refactor(freertos): Refactor usage of portBASE_TYPE to BaseType_t
portBASE_TYPE is an internal macro defined by the porting layer. This commit
changes all references to BaseType_t which is the official type exposed by
FreeRTOS.
2023-07-31 17:10:34 +02:00
Darian Leung
1e51387222 refactor(freertos): Refactor usage of portSTACK_TYPE to StackType_t
portSTACK_TYPE is an internal macro defined by the porting layer. This commit
changes all references to StackType_t which is the official type exposed by
FreeRTOS.
2023-07-31 16:59:41 +02:00
Armando
fd096c012d change(vector.S): port hw stack guard change to p4 2023-07-25 05:59:10 +00:00
Armando
5986e63c47 change(riscv): added fence after CLIC_INT_THRESH_REG is set 2023-07-25 05:59:10 +00:00
Armando
48ee1ba36e feat(freertos): base support on p4 2023-07-25 05:59:10 +00:00
Alexey Lapshin
4df3ff619e feat(esp_system): implement hw stack guard for riscv chips
- add hardware stack guard based on assist-debug module
- enable hardware stack guard by default
- disable hardware stack guard for freertos ci.release test
- refactor rtos_int_enter/rtos_int_exit to change SP register inside them
- fix panic_reason.h header for RISC-V
- update docs to include information about the new feature
2023-07-01 16:27:40 +00:00
Zim Kalinowski
54576b7528 Merge branch 'bugfix/freertos_fix_unordered_event_list' into 'master'
freertos: Updated vTaskRemoveFromUnorderedEventList() to consider scheduler state before adding task to ready list

Closes IDF-5785

See merge request espressif/esp-idf!23482
2023-05-10 01:48:47 +08:00
Sudeep Mohanty
abe5311a22 freertos: Updated vTaskRemoveFromUnorderedEventList() to consider scheduler state before adding task to ready list
vTaskRemoveFromUnorderedEventList() runs under the assumption that the
scheduler is suspended during the call. However, for IDF FreeRTOS, this
is not true. When dual-core system is active, this API call is made in
a critical section but without suspending the scheduler. This commit
updates the vTaskRemoveFromUnorderedEventList() function to now consider
the scheduler state on either cores before adding a task to the ready list.
2023-05-09 10:47:24 +02:00
Sudeep Mohanty
1acd2b5ce7 freertos-idf: Fixed incorrect scheduler suspension check in xTaskRemoveFromEventList()
This commit fixes a bug in xTaskRemoveFromEvenetList() where in the
check for scheduler suspension did not account for nested suspensions.
Additionally, this commit updates all checks for scheduler
suspension to follow a uniform way.
2023-05-09 10:28:02 +02:00
Darian Leung
cf595293af freertos: Move port_systick to common directory
This commit moves port_systick to a directory that ia accessible to both
IDF FreeRTOS and Amazon SMP FreeRTOS.
2023-04-28 23:03:00 +08:00
Jakob Hasse
550ecbe37a feat(freertos): added POSIX/Linux simulator port to FreeRTOS SMP
* Added a POSIX/Linux simulator that is compatible with the Amazon
  FreeRTOS SMP API. Note that the simulator itself is still
  single core, like the IDF FreeRTOS POSIX/Linux simulator.
2023-04-25 13:58:57 +08:00
Darian Leung
b2c074bb70 xtensa: Move Xtensa RTOS porting layer files to xtensa component
When porting an RTOS to the Xtensa architecture, there are a few files that
are common to all Xtensa RTOS ports. These files form the Xtensa RTOS porting
layer (e.g., "xtensa_vectors.S", "xtensa_context.S"). An Xtensa RTOS port is
expected to provide an RTOS specific "xtensa_rtos.h" header to interface with
the Xtensa RTOS porting layer.

Previously, the Xtensa RTOS porting layer files were placed in the FreeRTOS
component. This commit does the following:

1. Moves the Xtensa RTOS porting layer files from the `freertos` component to
the `xtensa` component. The following files were moved:

    - xtensa_asm_utils.h
    - xtensa_context.S
    - xtensa_loadstore_handler.S
    - xtensa_vectors.S

2. Refactored xtensa component include paths to separate Xtensa RTOS porting
layer headers.

- Xtensa HAL headers included via `#include <xtensa/...h>`
- Xtensa RTOS porting layer headers included via `#include <...h>`

Note: The xtensa files in the Amazon SMP FreeRTOS port are not moved/deleted in
this commit to ensure the moved files retain a clean diff history.
2023-04-18 15:28:05 +08:00
Darian Leung
478e041ce5 freertos: Add GetStaticBuffer functions
This commit adds the various ...GetStaticBuffer() functions from upstream
FreeRTOS. See https://github.com/FreeRTOS/FreeRTOS-Kernel/pull/641 for more
details.
2023-04-12 11:45:06 +08:00
Darian Leung
6895e92fd2 freertos: Combine Amazon SMP FreeRTOS and IDF FreeRTOS config files
This commit merges the "FreeRTOSConfig_smp.h" file into the "FreeRTOSConfig.h".
The configurations for all FreeRTOS implementations are now stored in a single
file.
2023-03-22 16:32:29 +08:00
Darian Leung
05bda6595d freertos: Move FreeRTOSConfig_arch.h
This commit moves the FreeRTOSConfig_arc.h to the "esp_additions" directory
so that they can also be used for SMP FreeRTOS builds.
2023-03-22 16:32:29 +08:00
Sudeep Mohanty
9b81e2b189 freertos: Schedule tasks unblocked by an ISR on a core with scheduler running if core affinity matches
FromISR APIs would put an unblocked task on the pending ready list if
the scheduler is suspended on the current core, irrespective of the
task's core affinity and the state of the scheduler on the other core.
This commit updates this behavior by allowing tasks to get scheduled on
a core which has the scheduler running as long as the task's core
affinity allows it.
2023-03-15 07:43:33 +00:00
Darian
a8948eb130 Merge branch 'refactor/xtensa_default_vectors' into 'master'
Xtensa: Move default vectors back into xtensa_vectors.S

Closes IDF-7022

See merge request espressif/esp-idf!20512
2023-03-11 01:00:48 +08:00
Darian Leung
29ec3fbacf xtensa: Move default vectors back into xtensa_vectors.S
The default implementation of some xtensa vectors were previously moved to
"xtensa_vector_defaults.S" as weak functions so that they could be overriden.

This commit moves these default vectors back into "xtensa_vectors.S" in
preparation for further refactoring of the xtensa component.
2023-03-10 13:59:01 +08:00