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.
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`
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()
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.
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.
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.
- 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.
- Move vTaskStartSchedulerOtherCores()
- implementation to freertos_tasks_c_additions.h
- declaration to freertos_idf_additions_priv.h as API is private
- Rename vTaskStartSchedulerOtherCores() -> prvStartSchedulerOtherCores() to
indicate that the function is private.
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.
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.
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.
- Uncrustified IDF addition related header/source files
- Reorganized functions into groups
- linker_common.lf updated to adhere to new function organization
Previously, Task Snapshot could be conditionally built based on the
CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT option. However, there is no overhead
with always enabling Task Snapshot functions, as the linker will remove any
functions if they are not called.
This commit...
- removes all ESP-IDF dependencies on the CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT
option so that Task Snapshot functions are always available.
- Makes CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT a hidden option to maintain
compatibility with user code.
- adds documentation regarding Task Snapshot.
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.
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.
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
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.
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
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.
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.
- 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
This commit adds a "CONFIG_FREERTOS_USE_KERNEL_10_5_1" hidden option to enable
building of the v10.5.1 kernel for development/testing purposes. Currently
enabling this option will just cause CMake to error out.
Also added a markdown file to record the code changes made to the V10.5.1 source
when porting over SMP behavior.
This commit adds the source files for the FreeRTOS Kernel V10.5.1 in
preparation for upgrading ESP-IDF FreeRTOS Kernel version (files copied from
https://github.com/FreeRTOS/FreeRTOS-Kernel/tree/V10.5.1)
The following modifications were made to the files when copying
- Added "SPDX-FileCopyrightText" and "SPDX-FileContributor" tags to all files
to pass ESP-IDF pre-commit checks.
- Left out some files unnecessary to ESP-IDF (e.g., URLs, "History.txt", and
"portable" folder).
freertos: Updated vTaskRemoveFromUnorderedEventList() to consider scheduler state before adding task to ready list
Closes IDF-5785
See merge request espressif/esp-idf!23482
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.
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.
This commit refactors the "freertos" component's structure as follows:
- "FreeRTOSConfig.h" related files moved to "./config" directory
- Refactored CMakeLists.txt file in preparation for v10.5.1 upgrade
- Grouped list appends based on component organization
- Removed some unecessarily public "include_dirs"
- Removed FreeRTOS-openocd.c
- uxTopUsedPriority has been added back to tasks.c since v10.4.2
- Thus the workaround in FreeRTOS-openocd.c is no longer needed and can
be removed.
linux/lwip: Wrap some IO posix functions
* to workaourd the FreeRTOS EINTR issue (when building without lwip)
* to correctly choose the sub-system based on fd (when building with
lwip) -- passing control to either linux/system or to lwip
This commit also addapts tapio-if to provide DHCP client by default and
configurable settings for static IP
This commit refactors port_systick.c so that all ports (RISC-V vs Xtensa) of
all FreeRTOS implementations (IDF vs Amazon SMP FreeRTOS) use the same set of
tick interrupt functions. Thus, these funcitons are now common:
- vPortSetupTimer() to setup the tick interrupt's timer
- xPortSysTickHandler() that is called on each tick interrupt
* 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.
This commit adds the corresponding CreateWithCaps functions for tasks:
- xTaskCreatePinnedToCoreWithCaps()
- xTaskCreateWithCaps()
- vTaskDeleteWithCaps()
Documentation and migraiton guide have been updated accordingly.
Closes https://github.com/espressif/esp-idf/issues/11216
This commit adds "bare metal stubs" xtensa_rtos.h glue layer to mimic a bare
metal OS port. The bare metal stubs don't access any components outside of the
G0 group.
The previous commit moved the OS agnostic files from the IDF FreeRTOS port to
the xtensa component, thus can be accessed by both IDF and Amazon SMP FreeRTOS.
This commit removes the redudant copies in the Amazon SMP FreeRTOS port.
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.
When building for CONFIG_FREERTOS_SMP, "idf_additions.h" was previously
implicitly included by "task.h" so that other ESP-IDF components still have
access to IDF API additions without needing to include "idf_additions.h"
directly.
However, some FreeRTOS headers (e.g., queue.h) will include task.h before
declaring any types (e.g., QueueHandle_t). Thus if any of those types are used
in idf_additions.h, we get a missing type error.
This commit moves the implicity include of idf_additions.h to FreeRTOS.h
Previously, some IDF FreeRTOS API additions that were meant to be private were
exposed through the same "idf_additions.h" header. This commit moves those
functions to a separate header included via
"esp_private/freertos_idf_additions_priv.h" so that they are not mistaken as
public API by users.
This commit also fixes some missing include and C++ guards in idf_additions.h
freertos_tasks_c_additions.h is technically included as source file. This
commit removes the "private_include" directory of "freertos_tasks_c_additions.h"
and treats it as a source file of "esp_additions".
This commit fixes the failing test - Test vTaskSuspendAll allows
scheduling on other cores.
The commit also adds a new test to test the scenario where in an
unpinned task, when unblocked by an ISR can be scheduled on the core
which has the scheduler running.
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.