This commit adds a copy of upstream vanilla FreeRTOS uncrustify.cfg files from
the following upstream commit:
89e4823a49
Note: "pp_indent_brace" is commented out as that was enabled after v10.4.3
Also also added a note in the ESP-IDF style guide aobut formatting FreeRTOS
source code using Uncrustify.
This commit refactors the way stream buffers initialize their spinlock.
- "prvInitialiseNewStreamBuffer()" now initializes the stream buffer fields
manually (instead of using memset()) to avoid resetting the spin lock
- Stream buffer creation functions now manually initialize the spinlock after
the other fields are initialized using "prvInitialiseNewStreamBuffer()"
Also added comments to event group spinlock initializtion.
The llvm asm pasrser doesn't support some gnu asm extensions,
like using "&" with macro arguments. So, replace such code with
code which could be compiled by llvm.
An explicit check of the mutex owner during a mutex release operation is
not necessary for FreeRTOS SMP as this is checked by default. Hence, the
corresponding Kconfig option is removed.
This commit fixes/ignores flakey freertos unit tests after migrating them to
the test app:
- Added vTaskDelay() before teardown to prevent memory leaks
- Adjusted the "main" task's priority so that scheudling tasks would work
- pytest now only runs tests that are not ignored
- Reset tests are temporarily ignored. Will be enabled to dedicate reset tests.
- Some flakey tests are fixed by adjusting delays and stack sizes.
This commit adds the sdkconfig files for the FreeRTOS test app. These
configurations were dervied from the various legacy unit test app's
config files that included the FreeRTOS component.
This commit tries to keep a 1 to 1 config parity with the legacy test app.
Meaning, if FreeRTOS test were run on a particular target with a particular
config, that config will be represented in one of the test app's
sdkconfig.ci.XXX files.
However, the following configurations were removed for FreeRTOS tests:
- The "freertos_flash" option was removed due to redudancy (already tested in
freertos_options)
Some tests were placed in the incorrect test groups (i.e., kernel, port,
performance etc). This commit fixes those placements.
The following redundant tests were also removed:
- "test_panic.c" as behavior is already covered in esp_system tests
This commit fixes a bug where if an unpinned task is interrupted by a level 1
ISR that users the FPU, the FPU usage will cause the interrupted task to
become pinned to the current core.
Note: This bug was already fixed in SMP FreeRTOS in commit
d69361779e. This commit simply backports the
fix to IDF FreeRTOS.
This commit refactors the existing FPU unit tests as follows
- Rename them from coproc to FPU
- Reorganize test placement
- Make existing tests work on both IDF and SMP FreeRTOS
- Update test documentation
- Remove old "test_float_in_isr.c"
This commit refactors the pxPortInitialiseStack() function of the riscv
FreeRTOS ports (both IDF and SMP FreeRTOS).
- Each stack area is now separated into their own functions
- Each function will individually
- Push the stack pointer to allocate the stack area
- Initiaze the allocated stack area
- Each stack area's size and usage is now clearly documented in code
This commit refactors the pxPortInitialiseStack() function of the xtensa
FreeRTOS ports (both IDF and SMP FreeRTOS).
- Each stack area is now separated into their own functions
- Each function will individually
- Push the stack pointer to allocate the stack area
- Initiaze the allocated stack area
- Each stack area's size and usage is now clearly documented in code
* Added port layer from the FreeRTOS POSIX port, added
additional port code for ESP-IDF.
* Created another hello world example using that POSIX
port in tools/test_apps.
* Removed old linux app
This commit adds a priority scheduling unit test to test that the scheduler
always schedules the highest priority ready state task. Single core and SMP
variants of the test are both added.
This commit adds a README.md containing guidelines on how to refactor the
FreeRTOS unit tests for upstreaming. A portTestMacro.h header was also added
which contains port implementation specific macros used by the test cases.
This commit places some functions in port.c and port_common.c into flash by
default. These functions are mostly called once during startup, thus shouldn't
affect applications much when placed into flash instead of the default IRAM.
This commit synchronizes multiple functions in tasks.c with upstream v10.4.3
that contain minor differences.
The following functions have had their parameter names or code formatting
updated:
- xTaskCreateStaticPinnedToCore()
- xTaskCreatePinnedToCore()
- prvInitialiseNewTask()
- prvTaskIsTaskSuspended()
- vTaskStartScheduler()
- xTaskResumeAll()
- xTaskCheckForTimeOut()
- uxTaskResetEventItemValue()
The following functions have had their missing "xAlreadyYielded" restored
- xTaskDelayUntil()
- vTaskDelay()
The following functions have had their critical section/interrupt disdable
usage update
- vTaskSuspendAll()
- xTaskGetTickCountFromISR()
- xTaskGetApplicationTaskTagFromISR()
This commit synchronizes multiple functions that contain major differences with
upstream v10.4.3. Multi-core modifications are then reapplied to the function.
Vanilla code uses "pxTCB == pxCurrentTCB" to check whether a task is currently
running. This commit adds the following macros instead.
- taskIS_CURRENTLY_RUNNING()
- taskIS_CURRENTLY_RUNNING_ON_CORE()
The following functions have been updated to use those macros instead.
- eTaskGetState()
- vTaskPrioritySet()
- vTaskResume()
The following functions have been synchronized with upstream v10.4.3.
Multi-core modifications are then reapplied.
- vTaskSuspend()
- vTaskDelete()
- prvGetExpectedIdleTime()
This commit synchronizes multiple functions in queue.c with upstream v10.4.3.
Multi-core modifications are then reapplied to these functions. The following
functions were modified:
prvNotifyQueueSetContainer()
xQueueGenericCreateStatic()
xQueueGenericCreate()
xQueueGetMutexHolder()
xQueueCreateCountingSemaphoreStatic()
xQueueCreateCountingSemaphore()
xQueueGenericSend()
xQueueGenericSendFromISR()
xQueueReceiveFromISR()
uxQueueMessagesWaiting()
prvUnlockQueue()
prvIsQueueFull()
xQueueAddToSet()
xQueueRemoveFromSet()
prvNotifyQueueSetContainer()
Note: The SEGGER_SYSVIEW traceQUEUE_SEND() macro was updated as the
xCopyPosition argument is no longer available in scenarios where the
macro is called.
This commit fixes the function declaration naming from esprv_intc_set_threshold()
to esprv_intc_int_set_threshold(), thus allowing the underlying ROM funciton to be
exposed via the header.
This commit removes the riscv_interrupts.h header is it has become redundant. The previously
exposed API has been handled as follows:
- "riscv_interrupt_enable()" and "riscv_interrupt_disable()" have been removed. These functions
were declarations only and never had any implementation.
- "riscv_global_interrupts_enable()" and "riscv_global_interrupts_disable()" renamed to
"rv_utils_intr_global_enable()" and "rv_utils_intr_global_disable()" respectively and now
placed in rv_utils.h
ESP32-C2 has a single group timer, thus it will use it for the interrupt watchdog,
which is more critical than the task watchdog. The latter is implement in
software thanks to the `esp_timer`component.
This commit synchronizes multiple functions in tasks.c with upstream v10.4.3
that contain minor differences.
The following functions have had their parameter names or code formatting
updated:
- xTaskCreateStaticPinnedToCore()
- xTaskCreatePinnedToCore()
- prvInitialiseNewTask()
- prvTaskIsTaskSuspended()
- vTaskStartScheduler()
- xTaskResumeAll()
- xTaskCheckForTimeOut()
- uxTaskResetEventItemValue()
The following functions have had their missing "xAlreadyYielded" restored
- xTaskDelayUntil()
- vTaskDelay()
The following functions have had their critical section/interrupt disdable
usage update
- vTaskSuspendAll()
- xTaskGetTickCountFromISR()
- xTaskGetApplicationTaskTagFromISR()
This commit synchronizes multiple functions that contain major differences with
upstream v10.4.3. Multi-core modifications are then reapplied to the function.
Vanilla code uses "pxTCB == pxCurrentTCB" to check whether a task is currently
running. This commit adds the following macros instead.
- taskIS_CURRENTLY_RUNNING()
- taskIS_CURRENTLY_RUNNING_ON_CORE()
The following functions have been updated to use those macros instead.
- eTaskGetState()
- vTaskPrioritySet()
- vTaskResume()
The following functions have been synchronized with upstream v10.4.3.
Multi-core modifications are then reapplied.
- vTaskSuspend()
- vTaskDelete()
- prvGetExpectedIdleTime()
This commit synchronizes multiple functions in queue.c with upstream v10.4.3.
Multi-core modifications are then reapplied to these functions. The following
functions were modified:
prvNotifyQueueSetContainer()
xQueueGenericCreateStatic()
xQueueGenericCreate()
xQueueGetMutexHolder()
xQueueCreateCountingSemaphoreStatic()
xQueueCreateCountingSemaphore()
xQueueGenericSend()
xQueueGenericSendFromISR()
xQueueReceiveFromISR()
uxQueueMessagesWaiting()
prvUnlockQueue()
prvIsQueueFull()
xQueueAddToSet()
xQueueRemoveFromSet()
prvNotifyQueueSetContainer()
Note: The SEGGER_SYSVIEW traceQUEUE_SEND() macro was updated as the
xCopyPosition argument is no longer available in scenarios where the
macro is called.
This commit synchronizes the following xTaskRemoveFrom...EventList() with
upstream v10.4.3. Multi-core modifications are then reapplied to the
functions.
The functions updated are:
- xTaskRemoveFromEventList()
- vTaskRemoveFromUnorderedEventList()
The following multi-core macros have been removed as they are no longer
required.
- tskCAN_RUN_HERE()
- taskYIELD_OTHER_CORE()
This commit synchronizes the following vTaskPlaceOnEventList...() with
upstream v10.4.3.
The functions updated are:
- vTaskPlaceOnEventList()
- vTaskPlaceOnUnorderedEventList()
- vTaskPlaceOnEventListRestricted()
The traceTASK_DELAY_UNTIL() macro has also been updated.
This commit reverts the previous "taskENTER_CRTIICAL();" so that the argument
is now provided for better code readability. The names of the spinlocks have
also been updated.
This commit updates various FreeRTOS functions to call the newly added
prvCheckForYield() and prvCheckForYieldUsingPriority() when checking for
yielding. This allows the source code to match upstream more closely.
When a FreeRTOS function unblocks a task, that function will check whether
the unblocked task requires a yield to be called. This is currently done by
having each function individually check if the unblocked task has a higher
priority than the both cores, and yielding the appropriate core.
This commit adds the macros list below to abstract away the yielding checking
procedure. This will allow the code to match upstream more closely.
- prvCheckForYield()
- prvCheckForYieldUsingPriority()
The event group unit tests would previously use a single call bit (the
"BIT_CALL" macro) to unblock all the test tasks. However, if one or more tasks
were delayed in calling xEventGroupWaitBits(), the other tasks would clear the
test bits, leading to the test deadlocking.
This commit updates the bits used so that each task gets their own CALL and
RESPONSE bits.
For RISC-V and Xtensa targets, in case a panic needs to happen when
Task WDT is triggered (ESP_TASK_WDT_PANIC), the interruptee's stack
is now used for printing the backtrace.
Abort after Task Watchdog is triggered can happen on APP CPU (second core).
Closes https://github.com/espressif/esp-idf/issues/7207
The description of how the xTaskGenericNotifyWait parameter is handled in the
xTaskGenericNotifyWait() function was inaccurate.
In this commit, the description was updated to match the implementation of xTaskGenericNotifyWait().
This commit marks all functions in interrupt_controller_hal.h, cpu_ll.h and cpu_hal.h as deprecated.
Users should use functions from esp_cpu.h instead.
This function removes the following legacy atomic CAS functions:
From compare_set.h (file removed):
- compare_and_set_native()
- compare_and_set_extram()
From portmacro.h
- uxPortCompareSet()
- uxPortCompareSetExtram()
Users should call esp_cpu_compare_and_set() instead as this function hides the details
of atomic CAS on internal and external RAM addresses.
Due to the removal of compare_set.h, some missing header includes are also fixed in this commit.
This commit fixes vTaskSuspendAll() and xTaskResumeAll() in the following ways.
- For vTaskSuspendAll()
- Sync function source code with upstream single core version
- Clearly mark IDF additions
- For xTaskResumeAll()
- Sync function source code with upstream single core version
- Clearly mark IDF additions
- Fix bug where cores other than core 0 were allowed to unwind pended ticks
This commit fixes the following issues:
- Clearly mark IDF additions in vTaskStepTick() and xTaskCatchUpTicks()
- Add back vTaskSuspendAll()/xTaskResumeAll() to xTaskCatchUpTicks(). Scheduler
suspension and resumption is required to unwind the pended ticks.
Previously, xTaskIncrementTick() would always trigger a yield (i.e., return pdTRUE)
when called on core 1. This would mean core 1 would call vTaskSwitchContext() on
every tick, leading to uneccesary CPU overhead.
This commit fixes xTaskIncrementTick() in the following ways:
- Clearly mark IDF additions in xTaskIncrementTick()
- Moved esp_vApplicationTickHook() to be called direclty in xPortSysTickHandler() in order to
simplify xTaskIncrementTick().
- Only core 0 calls xTaskIncrementTick() in order to simplify the function's logic. Core 0 is
solely responsible for managing xTickCount and xPendedTicks
- All other cores call xTaskIncrementTickOtherCores() instead which is a simplified version of
xTaskIncrementTick() and handles the following:
- Check if core 0 has unblocked a higher priority task to run
- Check if the current core requires time slicing
- Call vApplicationTickHook()
This commit fixes the following:
- Fixes a bug wherein the timer status is active for oneshot timers that
expire before they are started.
- Callback calls for periodic timers where made before the timers were
auto-reloaded.
- Timer expiry trace was being set after the timer callback is called.
Closes https://github.com/espressif/esp-idf/issues/8014
Idle tick hook that indicates completion of scheduler init must be launched
on other core than the one where main task runs. Earlier it was assumed that
main task shall always run on PRO cpu but that behavior can be changed with
ESP_MAIN_TASK_AFFINITY_CPU1 and hence this fix.
Closes https://github.com/espressif/esp-idf/issues/9247
Closes IDFGH-7705
FreeRTOS uses a single "xSchedulerRunning" variable to tack whether the
scheduler has started, and this variable is set to "pdTRUE" by core 0
via calling vTaskStartScheduler().
However, with SMP FreeRTOS, there is a race condition where core 0 has
already started the scheduler and another core has not called xPortStartScheduler()
yet and calls some FreeRTOS API. Thus the resultant FreeRTOS API can
cause errors as it thinks the scheduler has started.
This commit adds a temporary workaround (by having each core maintain their
own "xSchedulerRunning" variable.
The "FreeRTOS Event Groups" main task will only wait a single tick for the created
tasks to set their response bits. This short delay may not be sufficent if the tick
frequency is high.
This commit updates the test so that
- the main task waits indefinitely for all the response bits to be set.
- created tasks are cleand up by the main task
FreeRTOS synchronization primitives (e.g., queues, eventgroups) use various event lists (i.e., task lists) to track what
tasks are blocked on a current primitive. Usually these event lists are accessed via one of the event lists functions
(such as vTask[PlaceOn|RemoveFrom]UnorderedEventList()), which in turn ensure that the global task list spinlock
(xTaskQueueMutex) is taken when accessing these lists.
However, some functions in event_groups.c manually traverse their event lists. Thus if a tick interrupt occurs on
another core during traversal and that tick interrupt unblocks a task on the event list being traversed, the event list
will be corrupted.
This commit modifies the following event_groups.c functions so that they take the global task list lock before
traversing their event list.
- xEventGroupSetBits()
- vEventGroupDelete()
The CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH allows some FreeRTOS functions to be placed
into flash, thus saving some IRAM. However, this feature was previously not supported for
SMP FreeRTOS.
This commit adds CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH support for SMP FreeRTOS. There
are now separate linker fragment files for IDF FreeRTOS and SMP FreeRTOS, named "linker.lf"
and "linker_smp.lf" respectively.
The TLSP deletion callback feature is not compatible with the CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP
option. However, the "freertos_options" unit test configuration will enable that option.
This commit disables all CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP related features when compiling with
SMP FreeRTOS.
prvYieldCore() leads to an array-out-of-bounds error when compiled with
-Os optimization and configNUM_CORES = 1. This commit avoids this
compile warning by compiling out the part of code which is unnecessary
when configNUM_CORES is 1.
The Xtensa FreeRTOS port does not save the threadptr register when
doing a voluntary yield. This can result in a crash when multiple
tasks used the threadptr register and call "taskYIELD()".
This commit adds the threadptr register to the solicited stack frame.
This commit makes changes to cpu_ll.h, cpu_hal.h, and interrupt_controller_hal.h:
- Moved to esp_hw_support in order to be deprecated in the future
- HAL/LL API now route their calls to esp_cpu.h functions instead
Also updated soc_hal.h as follows:
- Removed __SOC_HAL_..._OTHER_CORES() macros as they dependend on cpu_hal.h
- Made soc_hal.h and soc_ll.h interfaces always inline, and removed soc_hal.c.
This commit also updates the XCHAL_ERRATUM_572 workaround by
- Removing it's HAL function and invoking the workaround it directly the bootloader
- Added missing workaround for the ESP32-S3
Previously the RV port was routing IDF style critical section API to call FreeRTOS style critical section API.
For example, a call to "portENTER_CRITICAL(mux)" would eventually call `vTaskEnterCritical()" via the following call flow:
- portENTER_CRITICAL(mux)
- vPortEnterCritical()
- portSET_INTERRUPT_MASK_FROM_ISR()
- vTaskEnterCritical()
This commit fixes the IDF style critical section by making sure that they are completely orthogonal to FreeRTOS critical sections
This commit fixes the following build errors in SMP FreeRTOS when building with GCC 11:
- "-Wattributes" warning due to conflicting attributes on xPortInterruptedFromISRContext()
- "-Wtype-limits" warning due to taskVALID_CORE_ID() not casting xCoreID
The behavior of vTaskSuspendAll() has changed in SMP FreeRTOS. This commit
disables scheduler suspension related unit tests for SMP FreeRTOS.
The tests will be updated in IDF-5201
SMP FreeRTOS adds support for dynamic reentrancy in the following commit:
34b8e24d7c
This commit does the following:
- Pulls in the upstream changes
- Move __getreent() to "freertos_tasks_c_additions.h"
- Add the required configNEWLIB_REENTRANT_IS_DYNAMIC to SMP FreeRTOS port
The "Test Queue sets thread safety" tests relied on IDF FreeRTOS specific
scheduling behavior, thus resulting in the test getting stuck when running
with SMP FreeRTOS.
This commit updates and refactors the tests to work on both IDF and SMP FreeRTOS.
This commit fixes how SMP FreeRTOS feeds the INT WDT. Previously, the
port used vApplicationTickHook(). Now, all cores will feed the INT WDT
in xPortSysTickHandler().
This commit moidifies the TWDT as follows:
- Adds a feature to allows subscribing arbitrary users to the TWDT
- Changes esp_task_wdt_init() API to accept configuration structure
- Changes esp_task_wdt_init() and esp_task_wdt_deinit() to subscribe/unsubscribe
idle tasks of various cores.
- Adds support for SMP FreeRTOS idle tasks
- Updates startup code TWDT initialization
- Updates API documentation
This commit refactors FreeRTOS Kconfig options as follows:
- Grouped them into Kernel and Port submenus
- Renamed Kernel option promppts to match upstream names
- Simplified some option descriptions
- Added "Todo" markers related to SMP support