Commit Graph

86 Commits

Author SHA1 Message Date
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
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
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
Jakob Hasse
5b3a645813 feat(esp_system): Partially buildable on Linux now 2022-11-16 09:03:09 +01:00
Darian Leung
8b98e4e3b8 freertos(IDF): Restore vanilla call behavior on xTaskIncrementTick() and vTaskSwitchContext()
Due to SMP, critical sections have been added to xTaskIncrementTick() and
vTaskSwitchContext() (to take the xKernelLock). However, this is technically
not necessary when building for single-core as FreeRTOS expect these funcitons
to be called with interrupts already disabled.

This commit makes the critical secitons in those functions depend on
"configNUM_CORES > 1", and ensures that interrupts are disabled when calling
those functions. This effectively restores the vanilla behavior for these
functions when building for single-core.
2022-11-16 15:50:21 +08:00
Darian Leung
087e4318a6 freertos(IDF): Use common macros for SMP specific critical sections
In IDF FreeRTOS, when building for SMP, there are numerous functions
which require different critical sections when compared to single-core. This
commit encapsulates those difference into a common set of macros whose
behavior depends on "configNUM_CORES > 1". As such...

- Vanilla behavior has been restored for some functions when building for
  single core (i.e., used to call taskENTER_CRITICAL, now disables interrupts
  mactching vanilla behavior).
- Reduces number of "#ifdef (configNUM_CORES > 1)" in functions
- Any SMP only critical sections are now wrapped by
  "#ifdef (configNUM_CORES > 1)" and properly documented via comments.
2022-11-16 15:50:21 +08:00
Sudeep Mohanty
ac99c0ad6b Merge branch 'feature/freertos_remove_untested_fn_feature' into 'master'
freertos: Removed CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION kconfig option

Closes IDF-5298

See merge request espressif/esp-idf!21000
2022-11-16 10:28:42 +08:00
Omar Chebib
bcb8516744 FreeRTOS: Make the default stack alignment 16 for Xtensa 2022-11-11 19:31:20 +08:00
Alexey Gerenkov
dbc3409d6c Merge branch 'bugfix/fix_asm_xtensa_vectors' into 'master'
freertos: fix gnu asm extensions.

See merge request espressif/esp-idf!19167
2022-11-09 16:28:50 +08:00
Sudeep Mohanty
0744f4d5a5 freertos: Removed CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION kconfig option
This commit removes the unused FreeRTOS kconfig option
CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION.
2022-11-09 08:14:16 +01:00
Sudeep Mohanty
9bb8f0e38d freertos-smp: Fixed stack overflow on esp32s3 with FreeRTOS SMP
The following changes have been made in this commit:
1. configMINIMAL_STACK_SIZE is now defined as CONFIG_FREERTOS_IDLE_TASK_STACKSIZE.
2. Removed configIDLE_TASK_STACK_SIZE config as it was redundant.
3. Updates the order of allocating the TCB and stack memory to avoid the
   stack memory overriding the TCB memory when the stack grows downwards.
4. CONFIG_FREERTOS_IDLE_TASK_STACKSIZE is now incorporated into the
   FreeRTOSConfig_smp.h to configure the IDLE0 stack size.
2022-11-07 09:59:02 +01:00
Jakob Hasse
37e8f1f348 feat(freertos): added event group and stream buffer to linux target 2022-10-31 16:34:23 +01:00
Andrei Safronov
847462a578 freertos: fix gnu asm extensions.
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.
2022-10-27 00:27:50 +03:00
Sudeep Mohanty
70070989f0 freertos: Enable configUSE_PORT_OPTIMISED_TASK_SELECTION for RISC-V targets
This commit enables the config option
configUSE_PORT_OPTIMISED_TASK_SELECTION on RISC-V targets for legacy
FreeRTOS (IDF-FreeRTOS).
2022-10-17 16:47:21 +02:00
Darian Leung
9f7f964363 freertos: Fix FPU ISR core pinning bug
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.
2022-10-12 22:45:56 +08:00
Darian Leung
fe0d4f2834 freertos: Refactor riscv port stack initialization code
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
2022-10-09 14:51:45 +08:00
Darian Leung
282f10d1bc freertos: Refactor xtensa port stack initialization 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
2022-10-09 14:48:30 +08:00
Jakob Hasse
bfbbd9d790 feat(freertos): Added FreeRTOS POSIX/Linux Simulator
* 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
2022-09-27 16:23:54 +02:00
Darian Leung
aa5d74410b freertos: Synchronize tasks.c functions (minor changes) to v10.4.3
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()
2022-09-19 21:30:52 +08:00
Darian Leung
abf0bc13e6 riscv: Fix esprv_intc_int_set_threshold() naming
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.
2022-09-16 16:45:43 +08:00
Darian Leung
0c97fbd5ba riscv: Remove redundant riscv_interrupts.h 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
2022-09-16 16:45:43 +08:00
Omar Chebib
53c7dd4efc WDT: implement interrupt wdt and task wdt for ESP32-C2
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.
2022-09-15 14:37:59 +08:00
Ivan Grokhotkov
0332b8db07 Revert "Merge branch 'feature/freertos_10.4.3_sync_various_functions' into 'master'"
This reverts merge request !19761
2022-09-12 19:53:09 +08:00
Darian Leung
bb5e189d2b freertos: Synchronize tasks.c functions (minor changes) to v10.4.3
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()
2022-09-07 23:34:52 +08:00
wuzhenghui
c5d8e94898 freertos, ulp: Fix header inclusion to be compatible with new esp32c6 target 2022-09-06 09:13:20 +00:00
morris
d94432fea8 systimer: refactor hal to accomodate more xtal choices 2022-07-25 16:08:52 +08:00
Guillaume Souchere
6005cc9163 hal: Deprecate interrupt_controller_hal.h, cpu_hal.h and cpu_ll.h interfaces
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.
2022-07-22 00:06:06 +08:00
Darian Leung
781d06af73 esp_hw_support: Remove compare_set.h API
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.
2022-07-22 00:06:06 +08:00
Darian Leung
7a4e1fee99 freertos: Fix xTaskIncrementTick()
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()
2022-07-20 11:31:50 +08:00
Omar Chebib
e5c83211a7 Merge branch 'bugfix/interrupt_stack_bss' into 'master'
System: move interrupt stack to .bss instead of .data section

Closes IDFGH-7635

See merge request espressif/esp-idf!18697
2022-07-12 13:44:07 +08:00
Omar Chebib
bac62cfac8 System: move interrupt stack to .bss instead of .data section
The interrupt stack for Xtensa targets is now declared in C, automatically moving it to .bss section instead of .data section.

* Closes https://github.com/espressif/esp-idf/issues/9188
2022-07-11 17:49:21 +08:00
Alexey Lapshin
7e5a7921fe freertos: fix inlining for xtensa port 2022-07-07 09:04:51 +00:00
Mahavir Jain
311822da25 freertos: Fix issue with bootup failure in ESP_MAIN_TASK_AFFINITY_CPU1 config
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
2022-07-01 05:40:46 +00:00
Darian Leung
434287fc8b freertos: Xtensa FreeRTOS saves threadptr in solicited stack frame
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.
2022-06-15 20:20:41 +08:00
Armando (Dou Yiwen)
0b80546f8e Merge branch 'feature/new_esp_psram_component' into 'master'
esp_psram: new esp psram component

Closes IDF-4318, IDF-4382, IDF-4841, and IDFGH-7192

See merge request espressif/esp-idf!18050
2022-06-15 19:16:56 +08:00
Darian
e213e66ba3 Merge branch 'refactor/esp_hw_support_cpu' into 'master'
esp_hw_support: Add new esp_cpu.h abstraction

Closes IDF-4769

See merge request espressif/esp-idf!17091
2022-06-14 21:11:30 +08:00
Armando
cdad8a02fe esp_psram: remove g_spiram_ok 2022-06-14 15:44:27 +08:00
Armando
38e5043ae8 esp_psram: new psram component 2022-06-14 15:44:27 +08:00
Darian Leung
a8a3756b38 hal: Route CPU and Interrupt Controller HAL/LL to esp_cpu calls
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
2022-06-14 14:40:03 +08:00
Mahavir Jain
4e4d0a5011 Merge branch 'bugfix/psram_startup_crash' into 'master'
psram: Fix startup crash when `CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=0`

Closes IDFGH-6938

See merge request espressif/esp-idf!17543
2022-06-14 14:36:47 +08:00
Laukik Hase
914b0de764
freertos: Indicate completed initialization for APP CPU with idle task hook
Co-authored-by: Mahavir Jain <mahavir@espressif.com>
2022-06-13 17:17:42 +05:30
Sudeep Mohanty
12e2312aaa freertos: FreeRTOS SMP RISC-V port cleanup and enable esp32c3 in KConfig
This commit does general cleanup of the risc-v port files and restricts
FreeRTOS SMP config option to only esp32 and esp32c3.
2022-06-13 13:39:16 +02:00
KonstantinKondrashov
ac4c7d99fe dport: Move DPORT workaround to G0 2022-05-31 13:44:18 +08:00
Darian Leung
7dc6fd9ff6 esp_system: Make interrupt WDT private API
This commit makes the interrupt WDT API private. To use the API,
IDF components should now '#include "esp_private/esp_int_wdt.h"'
2022-05-18 20:12:25 +08:00
Darian Leung
5953bca376 esp_system: Add arbitrary user feature to TWDT
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
2022-05-13 18:01:28 +08:00