Commit Graph

441 Commits

Author SHA1 Message Date
Jiang Jiang Jian
5fc1e1be13 Merge branch 'backport/lp_spi_fix_inline_v5.5' into 'release/v5.5'
fix(ulp/lp_spi): fix stale data in driver (v5.5)

See merge request espressif/esp-idf!51311
2026-08-06 12:02:56 +08:00
Jiang Jiang Jian
8c7d44897e Merge branch 'fix/lp_uart_data_bits_v5.5' into 'release/v5.5'
fix(ulp/lp_core): fix LP UART data_bits validation and add full word-length test coverage (v5.5)

See merge request espressif/esp-idf!48032
2026-08-05 13:56:42 +08:00
Marius Vikhammer
ddfd2934ef 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-07-29 14:47:48 +02:00
Marius Vikhammer
37a4390c64 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-07-29 14:47:48 +02:00
Marius Vikhammer
25b9025d93 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-07-29 14:47:48 +02:00
Sudeep Mohanty
d93b5289ab test(ulp/lp_spi): improve test stability and add cleanup
Reset the LP SPI peripheral and GPIOs before and after every SPI case so
each test starts from a known-clean baseline, and gate the master on an
explicit slave-armed handshake so the master cannot clock the bus while
the slave is still in its arm prologue. Verify received data against the
expected pattern with bounded waits instead of merely logging it.

Add a dedicated LP SPI multi-device pytest for esp32p4 that runs the
retagged lp_core_spi cases, and tag the LP I2C case accordingly.
2026-07-29 14:46:32 +02:00
Sudeep Mohanty
0f4f16033b fix(ulp/lp_spi): fix driver bugs and add bus deinit API
The LP SPI driver read and wrote the W0..W15 data buffer registers a
whole 32-bit word at a time, which overran the caller's buffer for
transfers whose length was not a multiple of four bytes and corrupted
the received data. Read and write the data buffer byte-granularly so
sub-word transfers no longer alias adjacent bytes.

The master transfer also programmed the shared bit-length register from
tx_length alone, truncating receive-longer-than-transmit transactions,
and always enabled MOSI even on read-only transfers, clocking out stale
buffer contents. Size each hardware transaction by max(tx_length,
rx_length) and gate MOSI/MISO on the corresponding buffer.

The slave path reused the master's single-shot flow, so it re-triggered
reg_update after preload (clocking out the previous transaction's data)
and offered no way for the caller to publish readiness before the master
started the clock. Split the slave transfer into an arm step that
preloads the buffer and starts the user phase, and a wait step that
blocks on TRANS_DONE and drains only the bytes the master actually
clocked in, tracked in software since reg_usr is not a reliable busy
indicator in slave mode.

Set the LP IO direction for the SPI pads, add
lp_core_lp_spi_bus_deinit() to release the LP GPIO pins, and reset the
LP SPI peripheral at bus initialization so a stale configuration from a
previous run cannot leak into the next.
2026-07-29 14:45:16 +02:00
Sudeep Mohanty
57ece57241 fix(lp_core): repair LP UART read_bytes RX handling
Made-with: Cursor
2026-07-27 15:35:30 +02:00
Sudeep Mohanty
f5f061601a test(lp_core): add LP UART read_bytes multi-device tests
Made-with: Cursor
2026-07-27 15:35:30 +02:00
Sudeep Mohanty
63e1ee965f 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-07-27 15:35:30 +02:00
Sudeep Mohanty
08195c3e36 test(lp_core): use soc_filtered_targets for all LP core pytest parametrization
Several LP core pytest files were either hardcoded to specific chip lists
or using a less-precise SOC capability filter:

- test_lp_core_multi_device: was locked to ['esp32c6'] pending a workaround
  for LP I2C on esp32p4; all three active LP core chips now have
  SOC_LP_I2C_SUPPORTED=1, so switch to soc_filtered_targets.

- test_lp_uart_wakeup_modes: was using SOC_LP_CORE_SUPPORTED which is
  semantically wrong for a UART test; change to SOC_ULP_LP_UART_SUPPORTED.

- LP core example pytests (build_system, interrupt, gpio_intr_pulse_counter,
  lp_timer_interrupt): replace hardcoded ['esp32c5', 'esp32c6', 'esp32p4']
  with soc_filtered_targets('SOC_LP_CORE_SUPPORTED == 1') so that new
  chips automatically get coverage when their SOC cap is enabled.
2026-07-27 15:35:30 +02:00
Sudeep Mohanty
c0f555d799 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-07-27 15:35:30 +02:00
Sudeep Mohanty
ee9d199d7f 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-07-27 15:35:30 +02:00
Sudeep Mohanty
fd466db9f6 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-07-27 15:35:30 +02:00
Marius Vikhammer
6813d2d2fe Merge branch 'backport-50410-to-release/v5.5' into 'release/v5.5'
fix(pthread,ulp): harden TLS key lookup and ULP bss_size validation (v5.5)

See merge request espressif/esp-idf!50954
2026-07-21 15:17:33 +08:00
Marius Vikhammer
4fce6e8ddb Merge branch 'fix/lp_periph_init_fail_with_cpp_v5.5' into 'release/v5.5'
fix(ulp): make LP peripheral default config macros C++ compatible (v5.5)

See merge request espressif/esp-idf!50212
2026-07-20 13:54:23 +08:00
Meet Patel
5439f280d9 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-20 11:15:10 +05:30
Sudeep Mohanty
a9ea3ff796 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:36 +02:00
Samuel Obuch
23d4dcbebc fix(lp_core): fix build for CONFIG_ULP_NORESET_UNDER_DEBUG=n 2026-06-22 11:17:43 +02:00
Jiang Jiang Jian
d627f319af Merge branch 'bugfix/ulp_lp_core_wakeup_race_v5.5' into 'release/v5.5'
fix(ulp): fix LP core wakeup race with LP timer (v5.5)

See merge request espressif/esp-idf!49563
2026-06-17 12:02:24 +08:00
Jiang Jiang Jian
510488345c Merge branch 'fix/esp_idf_lp_uart_wakeup_muti_times_v5.5' into 'release/v5.5'
fix(ulp): fix lp uart keep wakeup triggered v5.5

See merge request espressif/esp-idf!49401
2026-06-17 11:59:15 +08:00
Abanoub Salah
4cf6148d38 fix(ulp_riscv): Prioritize error bits over data flags in I2C interrupt wait 2026-06-16 12:19:12 +03:00
hebinglin
ab7f6a6d95 fix(ulp): fix lp uart keep wakeup triggered 2026-06-15 15:18:31 +08:00
Marius Vikhammer
6124c9c153 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:47 +08:00
Jiang Jiang Jian
c987c21dbc Merge branch 'bugfix/esp_idf_ulp_wakeupcauses_record_v5.5' into 'release/v5.5'
fix(ulp): record wakeup causes before lp core request sleep v5.5

See merge request espressif/esp-idf!49121
2026-06-03 10:51:04 +08:00
hebinglin
c0f21a426d fix(esp_hw_support): fix LP core exception interrupt not being cleared 2026-06-02 17:01:24 +08:00
hebinglin
604faf8fe2 change(ulp): add HP Core wakeup causes save test cases 2026-06-02 16:58:41 +08:00
hebinglin
45ea59b0c9 change(ulp): add lp periph intr enable apis 2026-06-02 11:44:10 +08:00
hebinglin
4a42a8847b fix(ulp): record wakeup causes before lp core request sleep 2026-06-01 21:11:48 +08:00
Marius Vikhammer
1f8477249a Merge branch 'bugfix/ulp_riscv_rtc_i2c_test_fix_v5.5' into 'release/v5.5'
fix(ulp_riscv_i2c): Fix spurious pass in RTC I2C multi-device test (v5.5)

See merge request espressif/esp-idf!48526
2026-06-01 16:05:08 +08:00
Song Ruo Jing
5b7db25db1 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-22 15:35:21 +08:00
Sudeep Mohanty
ed852d95c8 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-15 14:55:49 +02:00
Konstantin Kondrashov
325ebb8021 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-04-30 15:17:34 +03:00
Sudeep Mohanty
05244449ba 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-04-29 16:13:43 +02:00
wanckl
5d37003c47 ci(p4): p4 eco5 enable parts of special tests 2026-04-24 15:09:56 +08:00
Jiang Jiang Jian
8ff9c4de4b Merge branch 'bugfix/fence_instruction_spinlock_v5.5' into 'release/v5.5'
fix(spinlock): Added fence instruction in spinlock acquire and release (v5.5)

See merge request espressif/esp-idf!46805
2026-03-31 10:49:27 +08:00
Marius Vikhammer
fe62bfcc2d 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-27 11:50:35 +08:00
Meet Patel
f562a2bdef 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:37 +05:30
hebinglin
a2840f0287 fix(hal): fix the issue of dual-core contention for RTC_CNTL regs 2026-03-06 20:07:26 +08:00
Alexey Gerenkov
0c7eac2565 Merge branch 'feature/picolibc_v5.5' into 'release/v5.5'
feat(build): add Picolibc support (v5.5)

See merge request espressif/esp-idf!44108
2026-02-26 18:12:58 +08:00
Sudeep Mohanty
660200f05e fix(lp_adc): Update ADC threshold values for LP core LP ADC test 2026-02-09 12:37:17 +01:00
Sudeep Mohanty
66c76d0c34 change(lp_adc): Cleanup LP ADC driver and example 2026-02-09 12:36:18 +01:00
Sudeep Mohanty
0ebd2fd79e 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:17 +01:00
Alexey Lapshin
0b3929d0d9 feat(esp_libc): add full support for picolibc 2026-01-30 23:39:53 +07:00
Marius Vikhammer
91e8dc6b53 fix(lp-core): fixed rtc mem conflict on p4 eco5 between app and ULP 2025-11-26 11:40:01 +05:30
armando
304ba1655b fix check test scripts build issue 2025-11-20 11:33:36 +08:00
armando
cdff2570c7 ci(p4): disable p4 rev3 invalid tests temporarily 2025-11-20 11:33:36 +08:00
Marius Vikhammer
17dd84e012 test(ulp): added larger delay in ULP FSM I_WR_REG instruction test
Test is flakey, could possibly be due to the ULP occasionally needing
a bit more time to start up.
2025-11-17 16:23:34 +08:00
Marius Vikhammer
9be2f4f7b0 ci(ulp): reset board between ulp-fsm tests 2025-10-24 11:25:06 +08:00
Jiang Jiang Jian
3a6614bf8e Merge branch 'fix/ulp_riscv_delay_cycles_v5.5' into 'release/v5.5'
fix(ulp_riscv): Fix ulp_riscv_delay_cycles() to handle small delays correctly (v5.5)

See merge request espressif/esp-idf!41941
2025-09-28 18:52:09 +08:00