Commit Graph

597 Commits

Author SHA1 Message Date
KonstantinKondrashov
e8bf8ce14d freertos: Adds new APIs to set/get and restore base priority
Closes https://github.com/espressif/esp-idf/issues/7580
2022-10-14 19:04:44 +08:00
Darian Leung
bfb4a0c9df freertos: Fix flakey event group unit test
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 cleaned up by the main task
2022-07-25 03:01:16 +00:00
Darian Leung
ad39eaaeb0 freertos: Fix event group task list race condition
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()
2022-07-25 03:01:16 +00:00
Jiang Jiang Jian
802c93b5f1 Merge branch 'bugfix/xtensa_sol_frame_saves_extra_registers_v4.3' into 'release/v4.3'
freertos: Xtensa solicited stack frame should save threadptr register (v4.3)

See merge request espressif/esp-idf!18854
2022-07-10 15:45:16 +08:00
Mahavir Jain
35f8df3995
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-08 08:37:28 +05:30
Darian Leung
5f50e835e6 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-07-04 18:27:26 +08:00
Laukik Hase
7c85d2c498
freertos: Indicate completed initialization for APP CPU with idle task hook
Co-authored-by: Mahavir Jain <mahavir@espressif.com>
2022-06-14 14:25:59 +05:30
Alexey Gerenkov
d06fac5c8b apptrace: Adds ESP32-C3 support 2022-05-13 16:23:46 +03:00
Alexey Gerenkov
fa6655cbcf apptrace: Refactors apptrace for better support various tracing HW 2022-05-13 08:45:31 +00:00
Alexey Gerenkov
dfd3a9c3bc riscv: Use semihosting to set breakpoint and watchpoint when running under debugger 2022-04-22 13:17:54 +03:00
Alexey Gerenkov
e688645ff9 riscv: Fixes GDB backtrace end function to point to prvTaskExitError 2022-04-22 12:38:16 +03:00
Marius Vikhammer
b30ff28034 freertos: always inline xPortSetInterruptMaskFromISR and vPortClearInterruptMaskFromISR
These were called from IRAM context where the caller expect them to be inlined
and accessible when cache is disabled. This was not the case when compiled with -O0.

Closes https://github.com/espressif/esp-idf/issues/8301
2022-03-03 10:09:33 +08:00
intern
a8736a9b66 docs:fix broken links 2022-02-15 14:28:59 +08:00
Zim Kalinowski
6dce875bf9 Merge branch 'bugfix/freertos_pd_ticks_to_ms_precision_v4.3' into 'release/v4.3'
Freertos: Fix loss of precision in pdTICKS_TO_MS (v4.3)

See merge request espressif/esp-idf!16675
2022-01-07 14:32:13 +00:00
lisekt84
3764b03734 freertos: Fix loss of precision in pdTICKS_TO_MS
Closes https://github.com/espressif/esp-idf/pull/7856
Closes https://github.com/espressif/esp-idf/issues/7853

[darian@espressif.com: Updated commit message]
Signed-off-by: Darian Leung <darian@espressif.com>
2022-01-06 15:54:01 +08:00
Zim Kalinowski
aef7850157 Merge branch 'bugfix/freertos_round_robin_scheduling_retain_skip_v4.3' into 'release/v4.3'
freertos: Implement best effort round robin scheduling (v4.3)

See merge request espressif/esp-idf!16542
2021-12-31 02:58:53 +00:00
Omar Chebib
7467c68a17 Merge branch 'bugfix/xStreamBufferReset_crashing_v4.3' into 'release/v4.3'
FreeRTOS: Fix xStreamBufferReset function always crashing (backport v4.3)

See merge request espressif/esp-idf!16171
2021-12-27 14:25:01 +00:00
Darian Leung
e9cbf56d36 freertos: Fix SMP round robin scheduling
The previous SMP freertos round robin would skip over tasks when
time slicing. This commit implements a Best Effort Round Robin
where selected tasks are put to the back of the list, thus
makes the time slicing more fair.

- Documentation has been updated accordingly.
- Tidy up vTaskSwitchContext() to match v10.4.3 more
- Increased esp_ipc task stack size to avoid overflow

Closes https://github.com/espressif/esp-idf/issues/7256
2021-12-27 11:52:11 +08:00
Darian Leung
c33b260e7a freertos: Fix prvTaskIsTaskSuspended check
This commit fixes prvTaskIsTaskSuspended(). Both pending ready lists
should be checked to confirm that is truly suspended.

Closes https://github.com/espressif/esp-idf/issues/7564
2021-12-24 21:08:56 +08:00
Omar Chebib
5e805d58a8 FreeRTOS: Fix xStreamBufferReset function always crashing
This function resets the spinlock given as a parameter after taking it
(when entering the critical section). This then results in a panic once
it tries to exit the same critical section.

* Closes https://github.com/espressif/esp-idf/issues/7725
2021-12-23 06:15:50 +00:00
Ivan Grokhotkov
e26a2250a5 freertos: linker.lf rules fixes
1. Add conditions based on Kconfig options for functions which are
   compiled based on those options.
2. Static allocation is always enabled, move corresponding functions
   into the common list.
2021-12-21 01:26:44 +00:00
Mahavir Jain
a8260c9c77 freertos: fix thread safety for checking scheduler state
This issue was earlier fixed in commit 79e74e5d5f
but during migration to newer FreeRTOS release, it got introduced again.

This commit fixes thread safety issues with configASSERT() calls
regarding the value of uxSchedulerSuspended. A false negative
occurs if a context switch to the opposite core occurs in between
the getting the core ID and the assesment.

Relevant https://github.com/espressif/esp-idf/issues/4230
Closes https://github.com/espressif/esp-idf/issues/7726
Closes IDFGH-6041
2021-11-25 19:32:19 +05:30
Zim Kalinowski
8bb5d87f0c Merge branch 'bugfix/freertos_ut_suspend_v4.3' into 'release/v4.3'
freertos: Increases delta for UT - Test suspend-resume CPU. The number of... (v4.3)

See merge request espressif/esp-idf!14630
2021-09-13 04:14:14 +00:00
Zim Kalinowski
121910b939 Merge branch 'ci/change_perf_key_v4.3' into 'release/v4.3'
ci: update performance test key to db compatible format (v4.3)

See merge request espressif/esp-idf!14654
2021-09-10 04:23:09 +00:00
Mahavir Jain
94667365d3 Merge branch 'esp32c3/override_assert_v4.3' into 'release/v4.3'
newlib: Override __assert and __assert_func (v4.3)

See merge request espressif/esp-idf!14685
2021-09-09 13:24:01 +00:00
Gautier Seidel
7808bccfb9 fix(FreeRTOS): Initialize uxTaskNumber at task initialization
Signed-off-by: Laukik Hase <laukik.hase@espressif.com>

Closes https://github.com/espressif/esp-idf/pull/4025
2021-09-08 16:42:30 +08:00
Sachin Parekh
cc9d354ba8 Update tests for assert and abort
- Place panic_abort in IRAM
- Added abort, assert test case in case of cache disabled
- Expect assert instead of abort in a freertos_mutex test
2021-09-08 16:32:09 +08:00
Fu Hanxi
2231d6b158 ci: update performance test key to db compatible format 2021-08-04 12:22:25 +08:00
KonstantinKondrashov
0cd1bc6753 freertos: Increases delta for UT - Test suspend-resume CPU. The number of tick_hook should be the same for both CPUs 2021-08-03 12:50:15 +05:00
Krzysztof Budzynski
5ab8799f09 Merge branch 'docs/provide_link_to_pcb_layout_for_ethernet_board_v4.3' into 'release/v4.3'
docs: provide the link to pcb layout for ethernet board v1.2 and fix a typo in freetos/task (v4.3)

See merge request espressif/esp-idf!13966
2021-07-23 10:57:37 +00:00
Angus Gratton
9f6e09d0d3 Merge branch 'bugfix/flash_rodata_any_alignement_v4.3' into 'release/v4.3'
build: Fix cache issue and add dedicated section for (Custom) App version info (backport v4.3)

See merge request espressif/esp-idf!13448
2021-06-22 00:23:49 +00:00
Angus Gratton
b5256118ff Merge branch 'bugfix/riscv_stack_alignment_v4.3' into 'release/v4.3'
core: fix cases where riscv SP were not 16 byte aligned (v4.3)

See merge request espressif/esp-idf!13653
2021-06-17 02:09:34 +00:00
Wang Fang
1903d8587a docs: provide the link to pcb layout for ethernet board v1.2 and fix a typo in freetos/task 2021-06-15 15:26:10 +08:00
Marius Vikhammer
57442c38bd core: fix cases where riscv SP were not 16 byte aligned
RISC-V stack pointer should always be 16 byte aligned, but for some cases where
we were doing manual SP manipulation this was not always the case.
2021-06-02 16:02:10 +08:00
Angus Gratton
0cca9e860d freertos docs: Specify that uxTaskGetStackHighWaterMark() returns bytes not words
As reported https://esp32.com/viewtopic.php?f=13&t=20043&p=73732
2021-05-28 05:13:40 +00:00
Ivan Grokhotkov
b7707c54ce freertos: fix TLS run-time address calculation
Since dd849ffc, _rodata_start label has been moved to a different
linker output section from where the TLS templates (.tdata, .tbss)
are located. Since link-time addresses of thread-local variables are
calculated relative to the section start address, this resulted in
incorrect calculation of THREADPTR/$tp registers.

Fix by introducing new linker label, _flash_rodata_start, which points
to the .flash.rodata output section where TLS variables are located,
and use it when calculating THREADPTR/$tp.

Also remove the hardcoded rodata section alignment for Xtensa targets.
Alignment of rodata can be affected by the user application, which is
the issue dd849ffc was fixing. To accommodate any possible alignment,
save it in a linker label (_flash_rodata_align) and then use when
calculating THREADPTR. Note that this is not required on RISC-V, since
this target doesn't use TPOFF.
2021-05-06 11:42:14 +08:00
Angus Gratton
d30ec8c94e freertos: Add addition overflow check for stream buffer
Patch from upstream commit d05b9c123f2bf9090bce386a244fc934ae44db5b
2021-05-04 18:30:49 +10:00
Angus Gratton
658a0acdbe freertos: Check for arithmetic overflows on queue creation
Addition overflow check is from FreeRTOS kernel commit 47338393f1f79558f6144213409f09f81d7c4837
2021-05-04 18:30:49 +10:00
Angus Gratton
275743ab1c doc: Add notes that vTaskStartScheduler() is called during startup
Closes https://github.com/espressif/esp-idf/issues/1457
2021-04-23 22:48:47 +10:00
Angus Gratton
2290d0385e freertos: Fix race condition returning incorrect TCB on unpinned tasks
Noted as a problem with thread local storage returning a different task's
pointers, but some other were APIs also accessing current task unsafely.

Regression in FreeRTOS 10 update a3c90bf59a
2021-04-20 03:51:43 +00:00
Angus Gratton
a7994b1a42 freertos: Add some comments about deleting tasks when using SMP
Some cases are not immediately obvious, so document them in comments.
2021-04-14 19:45:08 +10:00
Angus Gratton
c725aa3ec1 freertos: Fix race condition using vTaskDelete() cross-core causing resource leak
Causes test added in parent commit to pass.

This race happens if the deleted task is running on the other CPU,
and is already spinning in a critical section waiting for xTaskQueueMutex
because it's about to be blocked for a resource.

The "deleted" task would end up blocked, possibly indefinitely, and
never actually deleted or its resources cleaned up by the idle tasks.

Details:

vTaskDelete() adds the target task to the xTasksWaitingTermination list,
expecting it to be yielded off CPU and then cleaned up later. However as soon as
vTaskDelete() releases xTaskQueueMutex, the target task runs and moves itself to the
xDelayedTaskList1. Because interrupts are already disabled on that CPU,
the "yield" to the other CPU sent by the vTaskDelete() comes afterward so
doesn't help.
2021-04-14 19:45:08 +10:00
Angus Gratton
3687ae989b freertos: Add unit test for deleting task which may be blocking 2021-04-14 19:45:08 +10:00
Angus Gratton
7703fcbd8d Merge branch 'bugfix/silent_asserts_v4.3' into 'release/v4.3'
freertos/lw ip: Support silent assertions (v4.3)

See merge request espressif/esp-idf!13011
2021-04-13 04:30:09 +00:00
Angus Gratton
322cba0bf0 freertos: Add a small additional stack when optimization set to None
Fix for occasional crash on startup when DPORT task overwrites its stack during
context switch, otherwise.
2021-04-06 02:43:24 +00:00
Angus Gratton
f5c6595cb4 freertos: Increase minimum task stack size when stack smashing checker is enabled
Fixes issue with DPORT init task, this task uses minimum stack size and may not be
enough if stack smashing detection is set to Overall mode.

Also reworks the way we calculate minimum stack to allow for adding multiple
contributing factors.

Closes https://github.com/espressif/esp-idf/issues/6403
2021-04-06 02:43:24 +00:00
Angus Gratton
e9e2b68587 freertos: Use the standard assert() function for configASSERT
Unless the option for "assert and keep running" is enabled.

This means that silent asserts now work for FreeRTOS, and disabling asserts
now also disables them in FreeRTOS without needing a separate config change.

Related to https://github.com/espressif/esp-idf/issues/6306
2021-04-02 11:07:23 +11:00
Omar Chebib
774f010196 freertos: Fix delay between interrupt request and trigger on RISC-V
NOP instructions have been added in order to prevent the code
from executing code it shouldn't execute. This is due to a delay
between the moment an interrupt is requested and the moment it
is fired. It only happens on RISC-V SoC.
2021-03-10 12:14:21 +08:00
Angus Gratton
8e187e7157 Merge branch 'bugfix/c3_unit_test_cleanup_v4.3' into 'release/v4.3'
System: C3 shared stack watchpoint & unit test cleanups (v4.3)

See merge request espressif/esp-idf!12418
2021-02-24 22:51:11 +00:00
Marius Vikhammer
3d9523724d freertos: add API for getting tick rate on C3 2021-02-23 12:14:11 +08:00