Commit Graph

478 Commits

Author SHA1 Message Date
Marius Vikhammer
5c35b8848e fix(ulp): hardcode LP core RC_FAST frequency per target
The SoC RC_FAST approximation is a nominal figure that can be off by ~10%
from the clock the LP core actually runs at, which made
ulp_lp_core_delay_us() over-delay by up to 9% and the LP core delay test
flake on ESP32-C5 and ESP32-C6.

Use a measured per-target value instead, and fail the build for targets
that have no measured value so that new chips cannot silently inherit a
wrong one.
2026-09-10 09:24:09 +08:00
Sudeep Mohanty
61a3bce867 refactor(ulp): simplify LP core peripheral IO setup on matrix targets
On SOC_LP_GPIO_MATRIX_SUPPORTED targets, route LP SPI, I2C, and remapped
LP UART pins through lp_gpio_connect_* (rtcio_hal_matrix_* on release
branches applies IOMUX and matrix routing).

Remove redundant rtc_gpio_set_direction and rtc_gpio_iomux_func_sel
before matrix connect for LP SPI and remapped LP UART pins.

Non-matrix LP I2C: use rtc_gpio_iomux_output instead of
rtc_gpio_iomux_func_sel. Non-matrix LP UART: use rtc_gpio_iomux_output
and rtc_gpio_iomux_input for func sel and direction.
2026-07-27 14:01:55 +02:00
Jiang Jiang Jian
3a09c553ce Merge branch 'backport-50410-to-release/v6.0' into 'release/v6.0'
fix(pthread,ulp): harden TLS key lookup and ULP bss_size validation (v6.0)

See merge request espressif/esp-idf!50955
2026-07-24 20:43:06 +08:00
Meet Patel
eadae0b093 fix(ulp): validate bss_size before zeroing ULP BSS region
Crafted ULP binaries could specify a bss_size larger than the reserved
memory, causing memset to zero past the ULP region boundary.
2026-07-24 15:41:16 +08:00
Renz Bagaporo
bd83aa20f0 fix(ulp): clear LP GPIO edge wakeup latch 2026-07-21 10:50:42 +09:00
Jiang Jiang Jian
fdb33a4ce7 Merge branch 'fix/lp_periph_init_fail_with_cpp_v6.0' into 'release/v6.0'
fix(ulp): make LP peripheral default config macros C++ compatible (v6.0)

See merge request espressif/esp-idf!50211
2026-07-09 12:34:03 +08:00
Jiang Jiang Jian
4193c391f2 Merge branch 'fix/lp_core_noreset_under_debug_option_v6.0' into 'release/v6.0'
fix(lp_core): fix build for CONFIG_ULP_NORESET_UNDER_DEBUG=n (v6.0)

See merge request espressif/esp-idf!49868
2026-07-09 12:31:38 +08:00
Sudeep Mohanty
df31c13c96 fix(ulp): make LP peripheral default config macros C++ compatible
Use dual-path macros: C keeps fragment-style designated initializers;
C++ uses GNU statement expressions (ESP_LOG_CONFIG_INIT pattern).
Add compile-only C++ regression tests for LP UART/I2C and ULP RISC-V I2C.

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

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 15:40:08 +02:00
hebinglin
bb49e40841 change(ulp): add HP Core wakeup causes save test cases 2026-06-29 16:27:04 +08:00
hebinglin
a764b5f222 fix(ulp): record wakeup causes before lp core request sleep 2026-06-29 16:25:56 +08:00
Jiang Jiang Jian
f881254b0f Merge branch 'fix/esp_idf_lp_uart_wakeup_muti_times_v6.0' into 'release/v6.0'
fix(ulp): fix lp uart keep wakeup triggered v6.0

See merge request espressif/esp-idf!49399
2026-06-29 15:38:47 +08:00
Jiang Jiang Jian
340b3aaa65 Merge branch 'change/esp_idf_ulp_add_int_api_6.0' into 'release/v6.0'
change(ulp): add lp periph intr enable apis v6.0

See merge request espressif/esp-idf!49143
2026-06-29 15:36:10 +08:00
Marius Vikhammer
837628688e Merge branch 'contrib/github_pr_18664_v6.0' into 'release/v6.0'
ulp_riscv: prioritize error bits over data flags in I2C interrupt wait (GitHub PR) (v6.0)

See merge request espressif/esp-idf!49717
2026-06-29 14:42:18 +08:00
Marius Vikhammer
b170866059 Merge branch 'bugfix/ulp_lp_core_wakeup_race_v6.0' into 'release/v6.0'
fix(ulp): fix LP core wakeup race with LP timer (v6.0)

See merge request espressif/esp-idf!49562
2026-06-29 10:31:56 +08:00
Samuel Obuch
900d956236 fix(lp_core): fix build for CONFIG_ULP_NORESET_UNDER_DEBUG=n 2026-06-22 11:16:16 +02:00
Marius Vikhammer
e9d89e85cb test(ulp): check LP core apps avoid soft-float helpers
Inspect generated LP core ELF files so accidental floating-point helper linkage is caught in CI.
2026-06-22 14:06:55 +08:00
Marius Vikhammer
a6c7484b53 fix(ulp): use RC_FAST approximation for LP core fallback
Use the shared SoC RC_FAST approximation when the target has no RTC_FAST source option.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-22 14:02:12 +08:00
Marius Vikhammer
6e12910f8e fix(ulp): use SoC RC_FAST frequency for LP core delay
Use the target RC_FAST approximation for LP core delay conversion.
This prevents ESP32-S31 from under-delaying when running from RC_FAST.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-22 14:02:12 +08:00
Abanoub Salah
5c2be9ecc4 fix(ulp_riscv): Prioritize error bits over data flags in I2C interrupt wait 2026-06-16 12:18:24 +03:00
Marius Vikhammer
4dd862314d fix(ulp): fixes potential race-condition for lp-timer wakeup with lp-core
Reconfigure wakeup time before enabling the wakeup source to avoid
a wakeup from potentially stale values.

Closes https://github.com/espressif/esp-idf/issues/17009
2026-06-11 09:02:28 +08:00
hebinglin
f088b73ea8 fix(ulp): fix lp uart keep wakeup triggered 2026-06-08 19:49:42 +08:00
hebinglin
b5f815b016 change(ulp): add lp periph intr enable apis 2026-06-02 10:58:28 +08:00
Jiang Jiang Jian
a7b604fd33 Merge branch 'fix/lp_uart_data_bits_v6.0' into 'release/v6.0'
fix(ulp/lp_core): fix LP UART data_bits validation and add full word-length test coverage (v6.0)

See merge request espressif/esp-idf!48031
2026-05-15 14:03:13 +08:00
Sudeep Mohanty
a2ea0da4e8 fix(ulp_riscv_i2c): Fix spurious pass in RTC I2C multi-device test
The test was passing without real I2C communication due to a GPIO
mismatch (slave on GPIO 6/7 vs RTC I2C master on GPIO 2/3), single-byte
zero-coincidence, unchecked ULP return values, and an insufficient
RTC I2C timeout.

Fix slave GPIOs, increase test length, check I2C return values, add
proper assertions, and set an adequate RTC I2C timeout.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-14 09:41:30 +02:00
Song Ruo Jing
eef2153dd0 refactor(rtcio): split rtcio/gpio switch with rtc iomux func sel func
This allows rtc_gpio_deinit to always switch the pad back to GPIO,
regardless of lp io clock enabled or not, so that gpio_config can
always switch the IO back to GPIO use after wakeup from deep sleep.
2026-05-08 18:08:00 +08:00
Sudeep Mohanty
ae6cc662b3 fix(lp_core): repair LP UART read_bytes RX handling
Made-with: Cursor
2026-04-29 07:59:05 +02:00
Sudeep Mohanty
e473d690bd test(lp_core): add LP UART read_bytes multi-device tests
Made-with: Cursor
2026-04-28 16:14:00 +02:00
Sudeep Mohanty
6ed6548866 fix(lp_core): fix multi-device LP UART test failures on esp32p4
The multi-device LP UART tests were failing on esp32p4 due to several
issues in the test harness:

- LP ROM boot banner: On chips with LP ROM (esp32p4), the LP core emits
  a ROM banner on LP UART during startup, corrupting the first bytes of
  test data. Set skip_lp_rom_boot=true in the ULP config for write, read
  and mismatch tests to suppress this.

- Stale FIFO data: The HP UART RX FIFO could accumulate garbage during
  pin mux setup. Add uart_flush_input() after HP UART driver installation
  and before each read phase. Call lp_core_uart_clear_buf() before LP-side
  read tests to flush the LP UART RX FIFO as well.

- Missing synchronization: The HP reader could start listening before
  the LP transmitter was ready (or vice versa), causing data loss at
  higher baud rates. Add signal exchange (unity_send_signal /
  unity_wait_for_signal) to coordinate LP-to-HP data transfers.

- Short read timeout: The uart_read_bytes() timeout of 10 ms was too
  aggressive for slower baud rates. Increase to 100 ms.

Made-with: Cursor
2026-04-28 16:14:00 +02:00
Sudeep Mohanty
11dc12d2dd test(lp_core): use soc_filtered_targets for all LP core pytest parametrization
Made-with: Cursor
2026-04-28 16:14:00 +02:00
Sudeep Mohanty
299480a5c0 test(lp_core): extend LP UART multi-device test coverage
Refactor the LP UART multi-device tests to use a single parameterised
helper pair (test_lp_uart_write_cfg / test_lp_uart_read_cfg) instead of
one-off functions per config, and extend coverage to:

- write and read tests for 5-, 6-, 7-bit and even-parity configurations
- negative tests: word-length mismatch (FRAM_ERR recovery on LP side,
  garbled receive on HP side)
- LP GPIO Matrix routing tests (SOC_LP_GPIO_MATRIX_SUPPORTED chips only):
  swaps the default TX/RX GPIO numbers so both pins go through the LP GPIO
  Matrix, covering the lp_gpio_connect_in/out_signal() branch of
  lp_uart_config_io() that was previously untested at the data-transfer
  level; the same physical cross-wiring as all other LP UART tests is reused

Add rtc_gpio_deinit() cleanup at the end of single-board LP UART tests
so configured pins are returned to HP/digital mode and do not interfere
with subsequent tests that may reuse the same GPIOs.
2026-04-28 16:14:00 +02:00
Sudeep Mohanty
379f50a196 fix(lp_core): skip LP UART RTS/CTS pin setup when flow control is disabled
lp_core_uart_set_pin() unconditionally configured the RTS and CTS GPIO
pins even when flow control was disabled. Only configure the RTS pin
when UART_HW_FLOWCTRL_RTS is set, and the CTS pin when
UART_HW_FLOWCTRL_CTS is set.
2026-04-28 16:14:00 +02:00
Sudeep Mohanty
3b92ee04f0 fix(lp_core): fix LP UART IOMUX pin not bypassing LP GPIO Matrix for RX
On chips with SOC_LP_GPIO_MATRIX_SUPPORTED (esp32p4, esp32s31), when the
default IOMUX pin is used for LP UART, calling rtc_gpio_iomux_func_sel()
alone only selects the IOMUX function on the pad side but does not set
sig_in_sel=0 on the peripheral side. This leaves the LP UART RX input
still reading from the LP GPIO Matrix (where no signal is connected),
causing RX to receive nothing.

Apply the same fix that was already in the HP UART driver: use
rtc_gpio_iomux_input() / rtc_gpio_iomux_output() which additionally
configure the peripheral to bypass the LP GPIO Matrix for IOMUX pins.
2026-04-28 16:14:00 +02:00
Sudeep Mohanty
57167c2c74 fix(lp_core): fix LP UART init parameter validation
Align data_bits, flow_ctrl, and rx_flow_ctrl_thresh checks with uart_param_config().

Made-with: Cursor
2026-04-28 16:13:59 +02:00
Jiang Jiang Jian
4d9c8f3064 Merge branch 'feature/improve_ulp_delay_api_v6.0' into 'release/v6.0'
feat(ulp): Improved ULP delay accuracy and removed floating point operations (v6.0)

See merge request espressif/esp-idf!46423
2026-03-21 14:32:29 +08:00
Marius Vikhammer
0794ac84c3 Merge branch 'bugfix/fence_instruction_spinlock_v6.0' into 'release/v6.0'
fix(spinlock): Added fence instruction in spinlock acquire and release (v6.0)

See merge request espressif/esp-idf!46804
2026-03-21 14:31:43 +08:00
Konstantin Kondrashov
144c74a1fe revert(ulp): drop riscv timeout helper from backports 2026-03-20 16:44:14 +08:00
Konstantin Kondrashov
bc2081ca1e revert(ulp): drop lp timeout helper from backports 2026-03-20 16:44:14 +08:00
Konstantin Kondrashov
6fe2cf575f feat(ulp): Improved ULP delay API accuracy and removed floating point operations
Closes https://github.com/espressif/esp-idf/issues/17494
Closes https://github.com/espressif/esp-idf/issues/16891
2026-03-20 16:44:14 +08:00
Frantisek Hrbata
e14d50b79b fix(ulp): add sdkconfig directory to ULP target include directories
The ULP sources include sdkconfig.h for compile-time configuration
values. The sdkconfig directory was previously available to the ULP
target indirectly through the COMPONENT_INCLUDES variable, which is
populated from the parent component's INTERFACE_INCLUDE_DIRECTORIES.
In cmake v1, idf_component_register() adds the config_dir as PUBLIC
include directory to every component (component.cmake:498), so it
ends up in INTERFACE_INCLUDE_DIRECTORIES and gets passed to the ULP
subproject via COMPONENT_INCLUDES.

In cmakev2, the config_dir is added as a build-level property and
applied to components as PRIVATE (component.cmake:1053), so it no
longer appears in INTERFACE_INCLUDE_DIRECTORIES. As a result, the
sdkconfig directory is missing from the ULP target's include paths.

Add the sdkconfig directory explicitly to the ULP target's include
directories. Note that SDKCONFIG_HEADER is already passed to the ULP
subproject and its directory is already extracted into sdkconfig_dir
for linker script preprocessing (IDFULPProject.cmake:40).

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2026-03-20 08:16:52 +01:00
Meet Patel
1d7d6eaf30 fix(spinlock): Added fence instruction in spinlock acquire and release
The existing spinlock mechanism possibly has an overlap of memory
operations during multi core execution, as visible in CI testing. When
running the example inter_cpu_critical_section, shared count increment
stops at 299999 instead of reaching 300000, but this only happens
randomly 1 out of 10 times. It is suspected that a memory operation
happens simultaneously from both core, even though spinlock protection
is in place.

To handle this problem, a memory barrier (fence instruction) is added
at critical places during spinlock acquire and release, to ensure that
all memory operations upto that point are completed and synchronised
before proceeding further.
2026-03-20 11:46:28 +05:30
Jiang Jiang Jian
dfa5e5d53a Merge branch 'bugfix/esp_idf_s3_deepsleep_dead_v6.0' into 'release/v6.0'
fix(hal): fix the issue of dual-core contention for RTC_CNTL regs(v6.0)

See merge request espressif/esp-idf!46180
2026-03-20 10:15:14 +08:00
Marius Vikhammer
1640707473 Merge branch 'fix/lp_core_wake_stub_pmu_sw_int_v6.0' into 'release/v6.0'
fix(esp_hw_support): clear LP core SW interrupt in wake stub before sleep (v6.0)

See merge request espressif/esp-idf!46550
2026-03-20 09:20:50 +08:00
Marius Vikhammer
67913c7df8 fix(esp_hw_support): clear LP core SW interrupt in wake stub before sleep
When ulp_lp_core_wakeup_main_processor() is called, it sets the
PMU_SW_INT_RAW bit on the HP side. The normal sleep path clears this
bit before re-entering sleep, but esp_wake_stub_sleep() did not, leaving
the wakeup cause sticky. This caused the PMU to immediately re-trigger a
wakeup as soon as sleep was requested from the wake stub, producing a
rapid re-wakeup loop that eventually triggered LP_WDT_SYS resets.

Add a test case that verifies the wake stub can return to sleep correctly
across multiple LP core wakeup cycles without the re-wakeup bug.

Closing https://github.com/espressif/esp-idf/issues/18308

Made-with: Cursor
2026-03-12 16:46:21 +08:00
hebinglin
e2e1aa4502 fix(hal): fix the issue of dual-core contention for RTC_CNTL regs 2026-03-02 14:29:08 +08:00
Sudeep Mohanty
4177d83566 fix(lp_adc): Update ADC threshold values for LP core LP ADC test 2026-02-09 12:36:05 +01:00
Sudeep Mohanty
b9c375d09b change(lp_adc): Cleanup LP ADC driver and example 2026-02-09 12:36:04 +01:00
Sudeep Mohanty
a6c11f9e84 feat(lp_adc): Set LP ADC calibration params
This commit sets the calibration parameters for a a given LP ADC unit
and channel to improve the raw LP ADC reading when read from the LP
core. The calibration params are set from the HP core.
2026-02-09 12:36:04 +01:00
Song Ruo Jing
89da3742b8 refactor(clk): split clock HAL into separate component 2026-01-31 22:32:37 +08:00
wuzhenghui
2d8c6ed6b4 change(esp_hal_rtc_timer): unify lp_timer/rtc_timer naming to RTC_TIMER 2026-01-31 22:31:34 +08:00
wuzhenghui
12b9fb6549 feat(esp_hal_rtc_timer): introduce new RTC timer component and refactor existing timer functions 2026-01-31 22:29:20 +08:00