Commit Graph

994 Commits

Author SHA1 Message Date
morris
f8d68efcbf Merge branch 'bugfix/atomic_gptimer_fsm' into 'master'
gptimer: fix race condition between start and stop

See merge request espressif/esp-idf!22620
2023-03-11 09:40:17 +08: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
morris
2d52334e5d gptimer: fix race condition between start and stop
Added state transition in gptimer_start/stop functions.
So that it's not possible to make a stopped timer continue to run
because of race condition.
2023-03-10 23:27:29 +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
Zim Kalinowski
44df8624ed Merge branch 'bugfix/freertos-fix-ignored-warnings' into 'master'
freertos: fix and re-enable no-format warnings

Closes IDF-6798

See merge request espressif/esp-idf!22638
2023-03-10 13:58:45 +08:00
Darian
77ca79a5e9 Merge branch 'refactor/freertos_check_scheduler_suspend_asserts' into 'master'
FreeRTOS(IDF): Refactor configASSERTs for scheduler suspension

Closes IDF-5889

See merge request espressif/esp-idf!22576
2023-03-09 20:19:57 +08:00
Zim Kalinowski
70ba19b806 freertos: fix and re-enable no-format warnings 2023-03-09 12:43:11 +01:00
Darian Leung
353b25410a freertos: Refactor configASSERTs for scheduler suspension
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.
2023-03-07 18:12:15 +08:00
Darian Leung
e21ab0332b freertos(IDF): Refactor port heap functions
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.
2023-03-06 16:00:29 +08:00
Darian Leung
c97523ae0a freertos: Fix stream buffer send-receive test
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.
2023-02-23 12:52:28 +08:00
Alexey Lapshin
25cb9b3f0e Merge branch 'fix/freertos-clang-riscv-port' into 'master'
freertos: riscv: implement vPortTaskWrapper with asm only

Closes IDF-6347

See merge request espressif/esp-idf!22199
2023-02-22 05:52:15 +08:00
Alexey Lapshin
d1214aef8c freertos: riscv: fix vPortTaskWrapper for clang 2023-02-20 13:09:42 +08:00
Cao Sen Miao
fd3e0b0b18 esp32h2(ci): enable target test 2023-02-15 10:20:43 +08:00
Marius Vikhammer
25abc7f6d8 ci: update idf-core related tests for C6 2023-02-13 13:01:57 +08:00
Darian Leung
903ac5dff9 freertos(IDF): Update IDF FreeRTOS linker fragment file
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.
2023-02-01 15:15:51 +08:00
Darian Leung
321254a776 freertos(SMP): Update SMP FreeRTOS linker fragment file
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.
2023-02-01 15:15:51 +08:00
Darian Leung
0574e63e6f freertos: Add linker fragments for common functions
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.
2023-02-01 15:09:46 +08:00
Jakob Hasse
9991862a10 fix(linux): fix build errors and warnings, remove ignore file 2023-01-18 09:24:28 +08:00
Cao Sen Miao
94120b82c2 esp32h2: add build test 2023-01-17 10:29:04 +08:00
morris
f7c3d791a2 Merge branch 'feature/systimer_support_esp32h2' into 'master'
systimer: assign counter and alarm in esp_hw_support

Closes IDF-6484, IDF-5323, and IDF-6230

See merge request espressif/esp-idf!21984
2023-01-12 11:01:17 +08:00
morris
6c1d98d556 systimer: assign counter and alarm in esp_hw_support 2023-01-10 17:05:49 +08:00
Jakob Hasse
83afda922b style(freertos/linux): improved docs and coding style 2022-12-29 12:05:15 +08:00
Darian Leung
92bbf85350 freertos: Fix clang-tidy warning on pxPortInitialiseStack() 2022-12-23 15:29:17 +08:00
Darian Leung
82f28a3e09 freertos: Update FPU unit tests to run for multiple iterations
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.
2022-12-23 15:29:17 +08:00
Darian Leung
45badf864f freertos(IDF): Allow cross-core freeing of task memory when deleting tasks
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
2022-12-23 15:29:17 +08:00
Darian Leung
c318c89453 freertos(IDF): Remove dependency on portUSING_MPU_WRAPPERS
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.
2022-12-23 15:29:17 +08:00
Darian Leung
9300bef9b8 freertos(SMP): Refactor FPU handling on the Xtensa port of Amaazon 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
2022-12-23 15:29:17 +08:00
Darian Leung
fd48daf278 freertos(SMP): Fix SMP FreeRTOS Xtensa port FPU/Coproccessor bugs
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.
2022-12-23 15:29:17 +08:00
Darian Leung
cdbd8ebeaa pytest: Expect "Calling app_main()" to indicate start of application
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.
2022-12-09 19:40:40 +08:00
Darian Leung
486cc33fb3 freertos: Refactor port common functions
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).
2022-12-08 01:57:30 +08:00
Darian Leung
09690906e7 freertos: Refactor OS startup functions
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.
2022-12-08 01:57:30 +08:00
Marius Vikhammer
ea249dc3a6 freertos: add missing header include for esp_chip_info.h to port.c
Closes https://github.com/espressif/esp-idf/issues/10310
2022-12-06 11:31:15 +08:00
Song Ruo Jing
56302544f6 Merge branch 'ci/enable_esp32c6_target_test_stage' into 'master'
CI: Enable esp32c6 target test stage

Closes IDF-5830 and IDF-5831

See merge request espressif/esp-idf!21010
2022-11-29 19:54:05 +08:00
Darian
1e953e31fc Merge branch 'feature/freertos_restore_single_core_task_selection_algorithm' into 'master'
FreeRTOS(IDF): Restore vanilla task selection algorithm if building for single core with optimized selection is disabled

See merge request espressif/esp-idf!21001
2022-11-29 14:04:44 +08:00
Sudeep Mohanty
3082fc7911 Merge branch 'feature/freertos_vtasklist_include_coreid' into 'master'
freertos-smp: Made CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID available only for IDF-FreeRTOS

Closes IDF-5295

See merge request espressif/esp-idf!21291
2022-11-29 11:52:57 +08:00
Darian
297670300d Merge branch 'contrib/github_pr_10199' into 'master'
Removed the 'configASSERT( xInheritanceOccurred == pdFALSE )' assertion from xQueueSemaphoreTake (GitHub PR)

Closes IDFGH-8766

See merge request espressif/esp-idf!21272
2022-11-28 19:37:41 +08:00
Sudeep Mohanty
d451a7539d freertos-smp: Made CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID available only for IDF-FreeRTOS
Since core affinity is supported in task stats by default in Amazon
FreeRTOS SMP, the Kconfig option
CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID is now made only available for
IDF-FreeRTOS.
2022-11-28 12:09:56 +05:30
Darian Leung
dff138f883 freertos(IDF): Restore vanilla task selection algorithm for single core
This commit restores the vanilla behavior for taskSELECT_HIGHEST_PRIORITY_TASK
when configNUM_CORES == 1 && configUSE_PORT_OPTIMISED_TASK_SELECTION == 0. This
results in the SMP selection algorithm (taskSelectHighestPriorityTaskSMP) to
only be run when configNUM_CORES > 1.
2022-11-28 13:55:03 +08:00
Darian Leung
2537dd8eca freertos(IDF): Add preprocessor check for configNUM_CORES configuration
This commit adds preprocessing time checks to ensure that

- configNUM_CORES is defined to 1 or 2
- Incompatible configurations are not set depending on configNUM_CORES
2022-11-28 13:55:03 +08:00
Song Ruo Jing
1575b9e43a ci: Disable all currently failed target tests for esp32c6 2022-11-28 12:09:08 +08:00
Alexey Gerenkov
47c2c13de5 build: Adds support for universal Clang toolchain 2022-11-23 13:25:16 +03:00
Darian
74ed2aa2ee Merge branch 'feature/freertos_10.4.3_sync_critical_sections_vs_suspension' into 'master'
FreeRTOS(IDF): Resolve critical section (multi-core) vs scheduler suspension (single-core)

Closes IDF-3755

See merge request espressif/esp-idf!21002
2022-11-21 18:38:43 +08:00
Omar Chebib
6fe563163c RISC-V: fix PC not saved when using backtrace 2022-11-18 15:07:38 +08:00
Omar Chebib
d580f6b076 RISC-V: Create a wrapper around FreeRTOS Tasks to detect the ones returning 2022-11-18 15:07:32 +08:00
timoxd7
355abfdff6
Queue Send fix
Fixes rare deadlock on heavy loaded multicore-systems.
2022-11-17 20:20:29 +01:00
Darian
eb837bbb6f Merge branch 'bugfix/freertos_smp_riscv_statement_expr_macro' into 'master'
FreeRTOS(SMP): Fix SMP FreeRTOS RISC-V statement expression macro

See merge request espressif/esp-idf!21110
2022-11-17 15:35:26 +08:00
Jakob Hasse
c381fee319 Merge branch 'feature/esp_system_linux' into 'master'
esp_system partially buildable on Linux

Closes IDF-5983

See merge request espressif/esp-idf!21055
2022-11-16 22:38:48 +08:00
Darian Leung
623f20d2b5 freertos(SMP): Fix SMP FreeRTOS RISC-V statement expression macro
Macros that need to reteurn a value should use GCC statement expression macro
syntax. This commit fixes the portTRY_ENTER_CRITICAL() in the RISC-V port of
SMP FreeRTOS to be a statement expression macro.
2022-11-16 17:51:10 +08:00
Jakob Hasse
cce1f9dee4 Merge branch 'feature/freertos_task_notification_configurable' into 'master'
freertos: make num of task notifications configurable

Closes IDFGH-7819

See merge request espressif/esp-idf!20880
2022-11-16 17:11:03 +08:00
Jakob Hasse
5b3a645813 feat(esp_system): Partially buildable on Linux now 2022-11-16 09:03:09 +01:00