Commit Graph

1398 Commits

Author SHA1 Message Date
Sudeep Mohanty
9ab3da0da8 feat(freertos): speed up SMP critical section enter and exit
The critical section port already disables interrupts and reads the core id for
the whole section, but spinlock_acquire()/spinlock_release() then disabled
interrupts again to the same level and re-read the core id register.

Add spinlock_acquire_impl()/spinlock_release_impl(), which take a caller-supplied
owner id and skip interrupt management, and reuse them from
spinlock_acquire()/spinlock_release() to avoid duplicated code. The Xtensa and
RISC-V ports now read the core id once and call the impl variants, removing one
core id read and one interrupt mask/restore per critical section enter and exit.

Closes https://github.com/espressif/esp-idf/issues/18908
2026-08-06 12:43:28 +02:00
Jiang Jiang Jian
8e7e031230 Merge branch 'feat/support_active_tickless_idle' into 'master'
feat(esp_pm): support freertos tickless IDLE with auto lightsleep disabled

Closes PM-799

See merge request espressif/esp-idf!49817
2026-07-28 17:04:50 +08:00
wuzhenghui
0aa75e183b feat(esp_pm): add tickless idle support in WAITI mode to reduce power consumption 2026-07-22 12:55:53 +08:00
Meet Patel
6062cfd0a1 test(freertos): harden WithCaps OOM sizing and leak checks
Derive OOM sizes from heap totals to avoid size_t overflow, and rely on
Unity setUp/tearDown for create/delete leak detection.
2026-07-16 10:39:25 +05:30
Meet Patel
9131bdab3a test(freertos): strengthen IDF additions WithCaps coverage
Exercise functional use, OOM failure paths, heap restoration, and SPIRAM
placement for WithCaps helpers beyond create-only smoke checks.
2026-07-16 10:12:58 +05:30
Meet Patel
10c888c859 test(esp_system): relocate FreeRTOS tick hook test
Tick hook registration lives in esp_system, so its scheduler-suspension
coverage belongs in the esp_system unity test app rather than the
freertos IDF additions suite.
2026-07-07 10:11:18 +05:30
Meet Patel
2fd3ccbb19 Merge branch 'test/idf-additions-coverage' into 'master'
test(freertos): expand IDF additions test coverage

See merge request espressif/esp-idf!50303
2026-07-07 09:44:56 +05:30
morris
651d6a283f refactor(esp_common): centralize ALIGN_UP/ALIGN_DOWN into esp_macros.h
Remove ~50 duplicate local definitions of ALIGN_UP/ALIGN_DOWN/ALIGN_UP_BY/
ALIGN_DOWN_BY across the codebase and replace them with canonical
ESP_ALIGN_UP/ESP_ALIGN_DOWN from esp_macros.h.
2026-07-06 13:36:06 +08:00
Meet Patel
d0e018cf6b test(freertos): expand IDF additions test coverage
Improve coverage of idf_additions.h task utility APIs and correct
WithCaps delete usage in existing tests to avoid heap leaks.
2026-07-06 10:45:53 +05:30
Marius Vikhammer
61c798000f Merge branch 'feature/enable_more_linux_examples' into 'master'
feat(linux): enable more examples for linux target

See merge request espressif/esp-idf!50172
2026-07-06 11:40:51 +08:00
Guillaume Souchere
513c013403 fix(freertos): discard stale wake events on linux port context switch
On the Linux port, tasks are pthreads that cannot be forcibly paused;
the scheduler "unschedules" a task only by selecting a different next
task, and the outgoing task keeps running until it next blocks itself
in event_wait (e.g. via vPortYield). If the scheduler later switches
back into such a task (event_signal) before it ever parked in
event_wait, that wake is never consumed and event_triggered stays
latched. The task's next voluntary block then returns immediately
instead of blocking (e.g. vTaskDelay(100ms) returning in 0ms), which
desynchronizes kernel and port scheduling state.

Clear the outgoing task's pending event when switching to a different
task, under s_port_mutex and atomically with the scheduling decision.
Any latched-but-unconsumed wake is stale at that point; a legitimate
wake can only be delivered later, once the scheduler selects the task
again as next_thread.

Add event_clear() to the wait_for_event helper to support this.

Verified: minimal repros (busy-wait with another ready task, and
pthread-blocked task) now measure 92-101 ms for vTaskDelay(100ms)
instead of 0 ms; linux_freertos kernel test app 18/18 pass; the
previously failing esp_linenoise host test suite passes 34/34.
2026-07-02 08:30:14 +02:00
Marius Vikhammer
9f126baed8 feat(linux): enable more examples for linux target 2026-07-01 15:10:22 +08:00
wuzhenghui
3a18ec3b7f feat(freertos): make FREERTOS_PORT_THREAD_SAFE_CLAIM optinal 2026-06-22 10:15:32 +08:00
wuzhenghui
90f6eeb327 feat(freertos): introduce thread-safe context management functions 2026-06-18 09:41:39 +08:00
Alexey Lapshin
104f8ff55b fix(freertos): ZCMP workaround: restore RISC-V interrupt threshold after enabling 2026-06-15 11:42:50 +07:00
wuzhenghui
9d824a9c33 feat(esp_system): support esp32s31 esp_perip_clk_init 2026-06-10 21:20:03 +08:00
Guillaume Souchere
a010738ec2 Merge branch 'feat/new-freertos-linux-simulator' into 'master'
feat(freertos): Refactor linux simulator

Closes IDF-8339

See merge request espressif/esp-idf!43564
2026-06-05 12:18:44 +02:00
Guillaume Souchere
9835daba70 feat(freertos/vfs): add Linux cooperative syscall dispatch with VFS FD registration
Rework the syscall interposition architecture so FreeRTOS works
standalone (without VFS) and VFS optionally overrides with strong
symbols.  All kernel FDs are registered with VFS via
esp_vfs_register_fd_with_local_fd, so the application only sees
VFS-allocated FD numbers, preventing numerical collisions between
kernel FDs and VFS-internal FD slots.

FreeRTOS side:
- Create linux_port_coop_internal.h with LINUX_COOP_IO_LOOP,
  LINUX_COOP_RESOLVE, linux_coop_yield and FD state table functions
- Export cooperative I/O primitives (freertos_linux_coop_read/write/
  open/close/fcntl/select/pread/pwrite/readv/writev/recv/send/
  recvfrom/sendto/recvmsg/sendmsg/connect/accept/pselect/poll/
  socket/socketpair/pipe/pipe2/dup/dup2/syscalls_init)
- Define weak POSIX symbols calling through to the cooperative
  primitives; keep nanosleep/sleep/usleep as strong (not FD-related)
- Refactor freertos_linux_coop_syscalls.h into a pure public API header

VFS side:
- Register the Linux host FS with esp_vfs_register_fs_with_id() as a
  proper VFS driver; register stdin/stdout/stderr at init (priority 99)
- Rewrite vfs_linux.c with strong POSIX symbols dispatching through
  esp_vfs_*
- Add strong overrides for FD-creating syscalls (open, pipe, pipe2,
  socket, socketpair, dup, dup2, accept) that register returned FDs
  with VFS
- Add strong overrides for FD-translating syscalls (readv, writev,
  recv, send, recvfrom, sendto, recvmsg, sendmsg, connect, pselect,
  poll) that translate VFS FD to kernel FD
- Delete vfs_coop_syscalls.c (absorbed into FreeRTOS weak + VFS strong)
- Update CMakeLists.txt: remove vfs_coop_syscalls.c, add linker hook
2026-06-04 11:36:34 +02:00
Guillaume Souchere
78420f2614 feat(freertos): soft-preempting linux simulator 2026-06-04 11:36:21 +02:00
Marius Vikhammer
d21dc8ca2e feat(freertos): added option for automatically placing task stacks in PSRAM
When CONFIG_FREERTOS_PLACE_TASK_STACKS_IN_EXT_RAM is enabled freertos will
now automatically allocate task stacks to PSRAM.
2026-06-04 16:06:52 +08:00
Sudeep Mohanty
7b294c4ab9 fix(esp_hw_support): move linux spinlock.h to esp_hw_support/include/linux
Moved the linux spinlock.h stub into esp_hw_support/include/linux.
esp_hw_support's INCLUDE_DIRS already places include/linux before
include, so the correct include files are picked up for the linux
target.

- Drop the FreeRTOS-Kernel-SMP linux spinlock.h duplicate.
- rv_decode_test: use PRIV_REQUIRES esp_hw_support instead of
  hardcoding component include paths.
2026-05-25 15:24:25 +02:00
Sudeep Mohanty
d09693fdc8 Merge branch 'fix/freertos_delete_with_caps_smp_race' into 'master'
fix(freertos): close vTaskDeleteWithCaps cross-core delete race on SMP preview kernel

Closes IDFCI-11425

See merge request espressif/esp-idf!48501
2026-05-15 14:41:45 +02:00
Sudeep Mohanty
ac4258c95a fix(freertos): close vTaskDeleteWithCaps cross-core delete race on SMP preview kernel
Replace the eTaskGetState() polling guard in prvTaskDeleteWithCaps()
with a per-core xTaskGetCurrentTaskHandleForCore() check, so the
predicate matches vTaskDelete()'s immediate-vs-deferred decision. This
closes the taskTASK_SCHEDULED_TO_YIELD race against the IDLE-deferred
TCB cleanup on the SMP preview kernel; behaviour is unchanged on the
default IDF kernel and on single-core targets.
2026-05-14 09:23:18 +02:00
Marius Vikhammer
8f6ea2a1ba test(ci): re-enable ESP32-H4 in core system test apps
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-13 09:00:12 +08:00
Chen Jichang
3c3b9a6a4e ci(esp32h4): disable tests which cannot pass 2026-05-11 16:48:58 +08:00
Jonas Jonsson
94b526c9fe fix(freertos): Avoid core switch deadlock on start
With CONFIG_ESP_MAIN_TASK_AFFINITY_NO_AFFINITY=y the main task could
switch core between registering the idle hook and the while loop.

This would cause a deadlock were the current task was waiting for the
idle hook to run on the same core it's busy waiting.

Merge https://github.com/espressif/esp-idf/pull/16149
2026-05-07 11:47:34 +03:00
Konstantin Kondrashov
92bb2641b4 Merge branch 'fix/zol_reset_lcounter' into 'master'
fix(xtensa): Reset zero overhead loop counter in ISRs

Closes IDF-15322

See merge request espressif/esp-idf!45865
2026-04-29 12:44:00 +03:00
Sudeep Mohanty
1c278df88e test(freertos): harden mutex owner assert reset test 2026-04-10 08:34:35 +02:00
Sudeep Mohanty
6ddbfbdb18 fix(freertos): hide mutex-owner check config 2026-04-09 09:06:14 +02:00
Marius Vikhammer
54c6851bf1 test: align esp32s31 freertos perf limits
ESP32-S31 scheduling and spinlock benchmarks match the relaxed P4 thresholds
better than the generic limits, so use those limits to keep the
FreeRTOS perf cases stable.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-08 14:46:25 +08:00
Guillaume Souchere
8706cd6135 feat(esp_system): add linux test for system init function regisration 2026-04-01 11:46:06 +02:00
Omar Chebib
08f33cf590 Merge branch 'feature/esp32s31_pie_coproc_old_commit' into 'master'
feat: add support for PIE coprocessor on the ESP32-S31

Closes IDF-14867 and IDF-14661

See merge request espressif/esp-idf!45851
2026-04-01 15:46:01 +08:00
Marius Vikhammer
5c572e5a60 docs: refresh broken documentation links 2026-04-01 10:17:33 +08:00
Omar Chebib
38abf98216 feat: add support for PIE coprocessor on the ESP32-S31 2026-03-31 13:27:16 +08:00
Sudeep Mohanty
f3fe60c36d fix(freertos): Use bare ticks for cleanup delays in freertos tests 2026-03-20 14:47:44 +01:00
Sudeep Mohanty
4ae2f6a6a1 fix(freertos): Fix flaky PSRAM tests for freertos
This commit adds additional delays to the stress test where we create
and self-delete tasks on PSRAM. iSuch tasks rely on the kernel creating
a special cleanup task to delete them. Hence, the delays in the main
task allow the cleanup task to bescheduled and the deletion to go
through.
2026-03-20 09:29:56 +01:00
Konstantin Kondrashov
59901fd3bb Merge branch 'fix/freertos_riscv_px_end_of_stack_alignment' into 'master'
fix(freertos): fix riscv pxEndOfStack offset alignment

Closes IDFGH-17266

See merge request espressif/esp-idf!45969
2026-03-11 09:54:13 +02:00
Marius Vikhammer
5b4c0c91fa Merge branch 'fix/freertos-message-buffer-privileged-function' into 'master'
fix(freertos): remove spurious PRIVILEGED_FUNCTION from macro body

Closes IDFGH-16879

See merge request espressif/esp-idf!46265
2026-03-11 12:41:38 +08:00
Marius Vikhammer
eb6f35f6a0 fix(freertos): remove spurious PRIVILEGED_FUNCTION from macro body
The macro expanded with a trailing PRIVILEGED_FUNCTION; token, making it
unusable in expression contexts (e.g. inside assert() or as a function
argument), causing a compile error: "expected ')' before ';' token".

Closes https://github.com/espressif/esp-idf/issues/17948

Made-with: Cursor
2026-03-04 15:23:04 +08:00
Konstantin Kondrashov
a00bb2d1cb fix(xtensa): Reset zero overhead loop counter in ISRs 2026-03-04 09:09:09 +02:00
Wu Zheng Hui
b4def1d7db Merge branch 'feat/support_rv_fp_retention' into 'master'
feat(esp_hw_support): support rv fp retention

See merge request espressif/esp-idf!45565
2026-03-03 17:36:04 +08:00
Konstantin Kondrashov
fa9b7843bc fix(freertos): fix riscv pxEndOfStack offset alignment
Closes https://github.com/espressif/esp-idf/issues/18256
2026-02-20 12:42:26 +02:00
Konstantin Kondrashov
b40aae66e3 fix(esp32): Fix access to MALLOC_CAP_IRAM_8BIT byte array in loop
The Xtensa load/store handler did not properly handle 8/16-bit
memory access to IRAM regions configured with MALLOC_CAP_IRAM_8BIT
(and CONFIG_ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY=y) from a loop
(LBEG/LEND/LCOUNT) context. This caused the loop to exit after
the first access, instead of continuing to iterate as intended.

Closes https://github.com/espressif/esp-idf/issues/14127
2026-02-13 16:12:58 +02:00
Konstantin Kondrashov
ac8fd0f491 fix(esp32): Fix IRAM_AS_8BIT_ACCESSIBLE_MEMORY accessible from ISR1 2026-02-13 11:30:44 +02:00
Frantisek Hrbata
66c0a4d658 Merge branch 'fix/cmakev2_linux_target' into 'master'
fix(cmakev2): linux target fixes

Closes IDFGH-17121

See merge request espressif/esp-idf!45315
2026-02-09 14:09:36 +01:00
Chen Chen
eeb24057c4 refactor(hal): graduate systimer hal driver into esp_hal_systimer 2026-02-06 18:08:57 +08:00
wuzhenghui
b7edaebed9 feat(esp_hw_support): support esp32p4 & esp32h4 RV FPU context retention in pd_cpu sleep 2026-02-05 15:39:40 +08:00
Alexey Lapshin
526891e08f Merge branch 'feature/refactor_linker_scripts' into 'master'
feat(esp_system): refactor linker scripts to reduce duplicated code

See merge request espressif/esp-idf!45220
2026-02-02 13:09:30 +04:00
Alexey Lapshin
f28a2765d8 fix(esp_system): xtensa: refactor linker scripts and reduce binary size for C++ apps 2026-01-30 23:27:32 +07:00
armando
695510b21c fix(freertos): place criticalsection in internal ram on smp 2026-01-28 01:27:37 +00:00