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.
xTaskRemoveFromUnorderedEventList is a scheduler internal function, thus will
never be called by users. Therefore, the compatbility define is not necessary.
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.
The task snapshot tests use esp_cpu_stall() to stall the other CPU before
manually walking the task lists. However, it is possible that the other CPU
was also accessing the task lists when esp_cpu_stall() is called, leading to
flakey tests
This commit fixes the test by using a 2-way handshake instead of
esp_cpu_stall().
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.
This commit adds a common macro for the differing configASSERT() calls that
check if the scheduler is suspended outside a critical section. This macro
allows vanilla behavior to be restored for single core builds. Also added
comments explaining why xTaskGetSchedulerState() is called instead when
building for SMP.
Vanilla FreeRTOS expects applications to use one of the heap implementations
provided by FreeRTOS (i.e., heap_x.c), where functions such as pvPortMalloc()
and vPortFree() are defined in the heap implementation.
However, ESP-IDF already provides its own heap implementation
(i.e., esp_heap_caps.h). Thus, the pvPortMallc()/vPortFree() functions were
previously overriden by macro to call esp_heap functions directly.
This commit refactors the FreeRTOS port's heap as such:
- Added a heap_idf.c that implements all of the heap related functions required
by FreeRTOS source
- All dynamic memory allocated by FreeRTOS is from internal memory. Thus, the
FreeRTOS heap is the internal memory subset of the ESP-IDF heap.
- Removed some old macros to reduce diff from upstream source code.
The stream buffer send-receive test preivously contained the following bugs:
- "sender" task would send 101 bytes instead of 100
- The main task would return before "sender" task sends its 101st item. Thus
the sender task would cause memory corruption when accessing "tc" structure
allocated on the main task's stack
This commit fixes and simplifies the stream buffer test.
This commit updates the linker fragment file for IDF FreeRTOS.
- Linker fragment file's formatting was updated
- Placement rules of functions is now clearly specified inside the linker
fragment file.
- Some extra functions are now placed in flash in accordance to the new
placement rules.
This commit updates the linker fragment file for Amazon SMP FreeRTOS.
- Linker fragment file's formatting was updated
- Placement rules of functions is now clearly specified inside the linker
fragment file.
- Some extra functions are now placed in flash in accordance to the new
placement rules.
This commit adds a separate linker fragment file "linker_common.lf" for the
functions in "port_common.c". The placement rules are now clearly specified
inside the linker fragment file.
This commit updates the FreeRTOS port FPU unit tests so that they run for
multiple iterations, thus checking that a task's FPU context is properly
cleaned up on deletion.
Previously, IDF FreeRTOS would restrict the clean up of task memory (done by
vTaskDelete() or the Idle task) to only tasks pinned to the current core or
unpinned tasks. This was due to the need to clear the task's coprocessor
ownership on the other core (i.e., "_xt_coproc_owner_sa"). But this restriction
can be lifted by simply protecting access of "_xt_coproc_owner_sa" with a
spinlock.
This commit implements a "_xt_coproc_owner_sa_lock" to protect the access of
"_xt_coproc_owner_sa", thus vTaskDelete() and prvDeleteTCB() can now delete
tasks pinned to the other core so long as that task is not currently running.
Note: This fix was copied from the Xtensa port of Amazon SMP FreeRTOS
This commit removes the dependency on portUSING_MPU_WRAPPERS on the Xtensa port
of IDF FreeRTOS. This dependency was added due to a hack implemented in the
upstream port that required the usage of the "xMPUSettings" member of the TCB.
The "xMPUSettings" would be used as a pointer to the task's coprocessor save
area on the stack, even though FreeRTOS MPU support was not available.
The hack has now been removed, and the CPSA pointer is now calculated using
a combination of constant offsets values and the pxEndOfStack member of the
TCB.
Note: This impelemtation was copied from the Xtensa port of Amazon SMP FreeRTOS.
This commit refactors the FPU handling code on the Xtensa port of Amazon SMP
FreeRTOS in the following ways:
Auto-pinning via XT_RTOS_CP_EXC_HOOK
------------------------------------
The "_xt_coproc_exc" exception would previously automatically pin a task that
uses the FPU to the current core (to ensure that we can lazy save the task's FPU
context). However, this would mean that "xtensa_vectors.S" would need to be
OS-aware (to read the task's TCB structure).
This is now refactored so that "_xt_coproc_exc" calls a CP exception hook
function ("XT_RTOS_CP_EXC_HOOK") implemented in "portasm.S", thus allowing
"xtensa_vectors.S" to remain OS agnostic.
Using macros to acquire owner spinlock
--------------------------------------
The taking and relasing of the "_xt_coproc_owner_sa_lock" is now mostly
abstracted as the "spinlock_take" and "spinlock_release" macro. As a result,
"_xt_coproc_release" and "_xt_coproc_exc" are refactored so that:
- They are closer to their upstream (original) versions
- The spinlock is only taken when building for multicore
- The spinlock held region is shortened (now only protects the instructions
that access the "_xt_coproc_owner_sa" array
Other Changes
-------------
- Updated placing and comments of various "offset_..." constants used by
portasm.S
- Update description of "get_cpsa_from_tcb" assembly macro
- Tidied up some typos in the ".S" files
This commit fixes the following FPU/Coprocessor bugs in the Xtensa port of
Amazon SMP FreeRTOS:
- vPortCleanUpCoprocArea() does not calculate the correct pointer to the
task's CPSA (located on the task's stack). This can result in
- _xt_coproc_release() not releasing the task's CP ownership
- The next coprocessor exception will write the current CP owner (i.e., the
deleted task's CPSA) leading to memory corruption
- _xt_coproc_release() writes xCoreID instead of 0 when clearing a CP owner.
This results in the next CP exception trying to load the CP owner's CPSA at
the address of "xCoreID", leading to a double exception.
This commit updates variousf pytest scripts to expect
"main_task: Calling app_main()" instead of "cpu_start: Starting scheduler" as
indicator of the start of an application.
This commit refactors port_common.c so that it only contains implementation of
FreeRTOS port functions that are common to all FreeRTOS ports (i.e., on all
architectures and on all FreeRTOS implementations).
This commit refactors the OS startup functions as follows:
- Moved the OS/app startup functions listed below to "app_startup.c". Their
implementations are now common to all ports (RISC-V and Xtensa) of all
FreeRTOS implementations (IDF and Amazon SMP).
- esp_startup_start_app()
- esp_startup_start_app_other_cores()
- Removed esp_startup_start_app_common() as app startup functions are now
already common to all ports.
- Added extra logs to "main_task" to help with user debugging
Note: Increased startup delay on "unity_task". The "unity_run_menu()" is non
blocking, thus if the main task or other startup tasks have not been freed
by the time "unity_run_menu()" is run, those tasks will be freed the next time
"unity_task" blocks. This could cause some tests to have a memory leak, thus
the "unity_task" startup delay has increased.