Commit Graph

321 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
f28a2765d8 fix(esp_system): xtensa: refactor linker scripts and reduce binary size for C++ apps 2026-01-30 23:27:32 +07:00
Michael Wilson
39409058d3 fix(freertos): Correct misleading error messages for vPortEnter/ExitCritical
The error messages for vPortEnterCritical and vPortExitCritical are
misleading when they're called on a multi-core target, as they seem to
imply that the call is NOT supported on a single-core target. In fact,
they are, these functions are, however, not supported on multi-core
targets, so the error message has been updated to reflect this.

Merges https://github.com/espressif/esp-idf/pull/18109
2026-01-13 10:33:45 +01:00
morris
291554cd09 refactor(global): remove completed todos in the codebase 2025-12-15 22:40:15 +08:00
Laukik Hase
7c24682643 feat(esp_tee): Add support for the RISC-V H/W stack guard mechanism 2025-11-24 18:49:06 +05:30
Erhan Kurubas
79cda70029 change(app_trace): move sysview to component registry 2025-11-10 15:55:41 +08:00
Erhan Kurubas
1dac8685db feat(tracing): add new component for tracing 2025-10-30 12:15:35 +01:00
Sudeep Mohanty
cf12478049 refactor(freertos): Deprecate xPortGetTickRateHz()
This commit deprecates xPortGetTickRateHz() from the FreeRTOS port API
as the FreeRTOS tickrate is constant for an application and can be
inferred using the CONFIG_FREERTOS_HZ config option.
2025-09-22 09:23:07 +02:00
Sudeep Mohanty
9a4341bb87 refactor(freertos): Moved FreeRTOS Run Time Stats gathering to port.c
This commit creates a new port layer API xPortGetRunTimeCounterValue()
in port.c files. This helps to remove inclusion of header files such as
esp_timer.h and xtensa/hal.h from portmacro.h
2025-09-22 09:23:01 +02:00
Sudeep Mohanty
75619d8ef5 Merge branch 'task/remove_vportcleanuptcb_support' into 'master'
remove(freertos): Remove legacy vPortCleanUpTCB user hook

Closes IDF-8097

See merge request espressif/esp-idf!41867
2025-09-19 10:03:07 +02:00
Sudeep Mohanty
c76cc9a24d remove(freertos): Remove legacy vPortCleanUpTCB user hook
This commit removes support for the vPortCleanUpTCB() user hook as well
as drops support for associated Kconfig option,
CONFIG_FREERTOS_STATIC_TASK_CLEAN_UP.
2025-09-11 16:05:11 +02:00
Marius Vikhammer
926817e872 docs(freertos): fixed stack watermark documentation bytes vs words issue
Upstream freertos reports stack sizes in words, while IDF-kernel uses bytes.
2025-09-10 08:50:16 +08:00
Alexey Lapshin
b25cb2906c fix(freertos): fix xesppie registers save/restore 2025-08-25 11:58:21 +07:00
Sudeep Mohanty
11b80a7f11 Merge branch 'feat/freertos_in_flash_by_default' into 'master'
feat(freertos): Place FreeRTOS in flash by default

Closes IDF-12695

See merge request espressif/esp-idf!40579
2025-08-15 02:18:57 +02:00
Sudeep Mohanty
26c19928a9 feat(freertos): Place FreeRTOS in flash by default
The following updates have been made in this commit:
- The commit places FreeRTOS code in flash memory by default.
- CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH has been removed.
- CONFIG_FREERTOS_IN_IRAM is unhidden and can be used to restore the
  previous memory placement.
- A test has been added for users to conduct performance impact testing
  based on memory placement configurations.
2025-08-07 19:56:30 +08:00
Omar Chebib
03f4744497 feat(riscv): add support for the DSP coprocessor 2025-08-07 14:40:30 +08:00
Nebojsa Cvetkovic
d0ceef20f4 refactor(xtensa): Rename specreg.h register macros
This commit renames all registers in xtensa/specreg.h to by adding the
prefix XT_REG_. This is done to avoid naming collisions with similar
variable names. A new register file, viz., xt_specreg.h is created. The
previous names are still available to use but have been deprecated.

Closes https://github.com/espressif/esp-idf/issues/12723
Merges https://github.com/espressif/esp-idf/pull/16040
2025-06-17 15:37:33 +02:00
John Boiles
6287650225 fix(freertos): Use ESP_EARLY_LOGE in vPortTLSPointersDelCb for RISCV
Using ESP_LOG* in this function causes a crash
2025-06-06 10:11:32 +08:00
Marius Vikhammer
e527554144 feat(core): bringup dual-core for H4 2025-05-26 17:11:12 +02:00
Sudeep Mohanty
3af5603938 fix(freertos): Fixed tickless idle tick count accounting
This commit fixes an issue where the FreeRTOS kernel does not account
for the pended ticks occuring during automatic light-sleep mode and
hence causing a jump in the tick count at a later stage in the
application lifetime.

Closes: https://github.com/espressif/esp-idf/issues/15642
2025-04-15 09:38:26 +02:00
Omar Chebib
0bc169e735 fix(freertos): optimize HWLP context switch by disabling it when unused 2025-03-13 11:11:24 +08:00
Omar Chebib
c26879d29e fix(freertos): workaround a hardware bug related to HWLP coprocessor
This commit manually sets the HWLP context to dirty when a Task that needs it is scheduled it.
2025-03-13 11:11:24 +08:00
Sudeep Mohanty
ee18a4d9ab fix(freertos): Backported a change to suppress Coverity warnings
This commit backports the commit# f94bc89108ffca538cf91d5856149960a5d4be81
from the upstream FreeRTOS kernel repository to supress a Coverity
warning. The change was done to avoid using string modification
functions which cause a security violation.
2025-02-07 08:52:51 +01:00
Sudeep Mohanty
65dba9f930 fix(freertos): Limit idle task name length for copy operation
This commit:
- Updates the FreeRTOS kernel prvCreateIdleTasks() function to
limit the length of the IDLE task name before copying it to avoid memory
out-of-bounds warnings.
- Fixes a bug where in the IDLE task name string could be a non
  null-terminated string in SMP configuration.
2025-01-03 18:06:47 +08:00
Sudeep Mohanty
1fe57a5d8e fix(freertos): Fixed SMP race condition in xStreamBufferSend()
This commit fixes a race condition in dual-core SMP mode where in the
xStreamBufferSend() makes the xTaskWaitingToSend NULL but it may
have already been evaluated to not be NULL by xStreamBufferReceive()
running on another core and eventually leading to a crash in tasks.c.
2024-10-16 19:39:42 +08:00
Sudeep Mohanty
03d76006b8 fix(freertos): Fixed SMP race condition in stream_buffers.c
This commit fixes a race condition in dual-core SMP mode where in the
xStreamBufferReceive() makes the xTaskWaitingToReceive NULL but it may
have already been evaluated to not be NULL by xStreamBufferSend()
running on another core and eventually leading to a crash in tasks.c.
2024-10-11 14:31:06 +02:00
Sudeep Mohanty
a97a7b0962 Merge branch 'fix/priority_inv_when_remove_from_unordered_event_list' into 'master'
fix(freertos): Fixed priority inversion when setting event group bits

Closes IDF-8160

See merge request espressif/esp-idf!33953
2024-10-11 17:49:08 +08:00
Sudeep Mohanty
0e5adc1b9c feat(freertos): Add FreeRTOS port layer mocks for CMock tests
This commit adds mocks for the FreeRTOS linux port layer for tests which
mock the FreeRTOS component and use port layer APIs.
2024-10-08 12:08:24 +02:00
Sudeep Mohanty
bd4de3c8a3 fix(freertos): Fixed priority inversion when setting event group bits
This commit fixes a priority inversion when a lower priority task set
event group bits to unblock a higher priority task but the lower
priority task continued to run.
2024-10-08 09:36:45 +02:00
Marius Vikhammer
4bf8d49159 fix(system): fixed potential double exception when booting on xtensa
Due to old windows from the startup flow being present after
switching to running freertos tasks  windowoverflow exceptions
could potentially try to save windows to the startup stack.

During this overflow they also values previously saved on the
startup stack to find earlier frames' stacks.
Since the start up stack was already recycled these values were
invalid and would cause a crash.

Closes https://github.com/espressif/esp-idf/issues/14406Y
2024-09-27 09:34:00 +08:00
Alexey Gerenkov
9ca231e76e change(build): Use integrated assembler with Clang for RISCV chips 2024-09-18 21:40:39 +03:00