Commit Graph

389 Commits

Author SHA1 Message Date
Sudeep Mohanty
42fcb0350f 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.

Split the combined multi-device pytest into separate LP I2C and LP SPI
cases so each runs independently, tagging the C test cases accordingly.
2026-07-29 15:30:35 +02:00
Sudeep Mohanty
56fa0f2d5b 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 15:30:01 +02:00
Alexey Gerenkov
166e2a075e Merge branch 'fix/lp_core_noreset_under_debug_option_v5.4' into 'release/v5.4'
fix(lp_core): fix build for CONFIG_ULP_NORESET_UNDER_DEBUG=n (v5.4)

See merge request espressif/esp-idf!49870
2026-07-20 17:11:03 +08:00
Sudeep Mohanty
7ae6b26b66 fix(ulp): make LP peripheral default config macros C++ compatible 2026-07-01 08:14:56 +02:00
Samuel Obuch
00f8b8740f fix(lp_core): fix build for CONFIG_ULP_NORESET_UNDER_DEBUG=n 2026-06-22 11:17:51 +02:00
hebinglin
52e48def21 change(ulp): add lp periph intr enable apis 2026-06-02 11:39:23 +08:00
Marius Vikhammer
b733e190f0 Merge branch 'bugfix/ulp_riscv_rtc_i2c_test_fix_v5.4' into 'release/v5.4'
fix(ulp_riscv_i2c): Fix spurious pass in RTC I2C multi-device test (v5.4)

See merge request espressif/esp-idf!48527
2026-06-01 16:05:24 +08:00
Sudeep Mohanty
babd3e3ac8 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 15:24:43 +02:00
Sudeep Mohanty
dd2dd96a0e fix(lp_core): repair LP UART read_bytes RX handling
Fix read_bytes handling in lp_core_uart.c. Fix HP-side read_bounds guard
checks in test_lp_core_uart.c: the ULP export header types shared symbols as
uint32_t while the LP image maps a larger struct; avoid struct subscript on
that symbol so GCC 14 -Warray-bounds= passes in CI (build_non_test_related_apps).

Made-with: Cursor
2026-04-29 14:19:28 +02:00
Sudeep Mohanty
2544368c14 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-29 11:53:37 +02:00
Sudeep Mohanty
bf6a44f5d1 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.

Made-with: Cursor
2026-04-28 15:30:47 +02:00
Sudeep Mohanty
b8d99436a5 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 15:30:17 +02:00
Sudeep Mohanty
b211749924 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.

Made-with: Cursor
2026-04-28 15:29:48 +02:00
Sudeep Mohanty
2d3acb0805 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 11:51:55 +02:00
Sudeep Mohanty
ffd41dc3e1 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 11:51:55 +02:00
Evgeny Torbin
f7395255da test: format all test scripts 2026-03-11 07:34:34 +01:00
hebinglin
1d2ffd5941 fix(hal): fix the issue of dual-core contention for RTC_CNTL regs 2026-03-02 12:22:15 +08:00
Sudeep Mohanty
4f981ea920 fix(lp_adc): Update ADC threshold values for LP core LP ADC test 2026-02-09 12:37:58 +01:00
Sudeep Mohanty
aa4fba8818 change(lp_adc): Cleanup LP ADC driver and example 2026-02-09 12:37:57 +01:00
Sudeep Mohanty
cf302a2f3b 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:37:57 +01:00
Marius Vikhammer
fcafa0de5d 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:41 +08:00
Marius Vikhammer
5173e81565 ci(ulp): reset board between ulp-fsm tests 2025-10-24 11:33:22 +08:00
Konstantin Kondrashov
bcdb428aa1 fix(ulp_riscv): Fix a delay function to handle small delays correctly
Fixed ulp_riscv_delay_cycles function

Closes https://github.com/espressif/esp-idf/issues/16891
2025-09-16 10:43:35 +03:00
Meet Patel
1b5138e37e refactor(ulp_riscv): Modify ulp i2c read/write functions to return error code
Updated the i2c read/write APIs ulp_riscv_i2c_master_read_from_device
and ulp_riscv_i2c_master_write_to_device in ulp_riscv component to
return error codes back to the application

Closes https://github.com/espressif/esp-idf/issues/15904
2025-09-15 10:35:20 +05:30
Meet Patel
032e141150 refactor(ulp_riscv): Modify ESP_EARLY_LOG to ESP_LOG and move it outside critical section
Moved the error logs outside critical section for i2c communication errors
like READ fail, WRITE fail etc. in the ulp_riscv_i2c component

Also changed the error log API from ESP_EARLY_LOG to ESP_LOG, so we can support
tag based filtering and enabling/disabling of logs

Closes https://github.com/espressif/esp-idf/issues/17425
2025-09-15 10:35:20 +05:30
Marius Vikhammer
ea68500941 Merge branch 'bugfix/lp_core_array_bounds_p4_v5.4' into 'release/v5.4'
fix(lp_core): fixed array-bound warning when compiling on P4 with -Os (v5.4)

See merge request espressif/esp-idf!41614
2025-09-01 10:52:46 +08:00
Marius Vikhammer
7c90e1c6b4 fix(lp_core): fixed array-bound warning when compiling on P4 with -Os
Closes https://github.com/espressif/esp-idf/issues/17054
2025-08-29 13:17:53 +08:00
Marius Vikhammer
74b003cfa1 ci(ulp): fixed default config not running in CI 2025-08-29 09:56:45 +08:00
Samuel Obuch
6ce0ed4a2e fix(lp_core): dont reset lp cpu with debug attached 2025-08-04 09:52:20 +02:00
Sudeep Mohanty
6b75576db2 change(lp-core): Update LP I2C and LP UART drivers to use raw interrupt status
This commit updates the LP I2C and LP UART drivers to use the raw
interrupt status without enabling the interrupts.
2025-05-19 10:33:21 +02:00
wuzhenghui
33aca83c63 change(ci): remove esp32c5 from readme since esp32c5 skipped CI build 2025-04-25 17:13:27 +08:00
Konstantin Kondrashov
93750520fe fix(ulp): Fix accumulation of wakeup cause bits in ULP
Closes https://github.com/espressif/esp-idf/issues/15794
2025-04-18 15:52:28 +03:00
gaoxu
b227da9b2b ci(adc): enable P4 ADC test and correct ADC performance thresh 2025-04-01 15:05:36 +08:00
Marius Vikhammer
4354c3080a Merge branch 'fix/lp_uart_flush_wait_for_idle_v5.4' into 'release/v5.4'
fix(lp_uart): Update the `lp_core_uart_tx_flush()` API to wait for UART Tx idle state (v5.4)

See merge request espressif/esp-idf!37473
2025-04-01 14:55:18 +08:00
Song Ruo Jing
e774dbfd0f fix(uart): LP UART does not have the pre-divider for its clock source
Closes https://github.com/espressif/esp-idf/issues/15427
2025-03-10 15:29:09 +08:00
Sudeep Mohanty
528b1b3c37 fix(lp_uart): Update the lp_core_uart_tx_flush() API to wait for Tx idle
This commit updates the lp_core_uart_tx_flush() API to wait for the Tx line
to become idle, therefore confirming that all bytes are sent out.

Closes https://github.com/espressif/esp-idf/issues/15433
2025-03-04 08:52:22 +01:00
wuzhenghui
8e6ec50bcc fix(esp_hw_support): fix esp32s2/esp32s3 RTC IOMUX clock management 2025-02-21 09:50:42 +08:00
Sudeep Mohanty
1e5308211d fix(lp_uart): Fixed flaky LP UART unit tests
This commit fixes some flaky LP UART multi device tests. It also adds
code to put the HP core to light sleep for few tests.
2025-02-17 10:29:04 +01:00
Marek Fiala
b37383f75b feat(tools): Enforce utf-8 encoding with open() function 2025-01-10 13:52:58 +08:00
Omar Chebib
ab4fa65d0d fix(ulp): fix ULP RISC-V interrupt handler corrupting the stack
* Closes https://github.com/espressif/esp-idf/issues/14930
2024-11-27 11:43:15 +08:00
morris
fe3bb073f9 Merge branch 'refactor/i2c_ll_trm_sync_v5.4' into 'release/v5.4'
refactor(i2c): rename some LL functions according to TRM descriptions (v5.4)

See merge request espressif/esp-idf!35107
2024-11-25 10:30:02 +08:00
Armando
37d8e97a9d doc(lp_vad): lp vad programming guide 2024-11-22 10:46:43 +08:00
morris
85e86626ff refactor(i2c): rename some LL functions according to TRM descriptions 2024-11-22 10:14:22 +08:00
Marius Vikhammer
2a2f0fd6f1 Merge branch 'bugfix/p4_ld_newlib_api' into 'master'
fix(lp_core): updated lp rom newlib API addresses

See merge request espressif/esp-idf!34412
2024-10-28 10:24:57 +08:00
Marius Vikhammer
8406735635 fix(lp_core): updated lp rom newlib API addresses 2024-10-24 10:45:55 +08:00
Marius Vikhammer
1f1954378e Merge branch 'feature/lp_core_gpio_wakeup' into 'master'
feat(lp_core): added support for LP-IO as LP-core wakeup source

Closes IDF-10200

See merge request espressif/esp-idf!31828
2024-10-18 09:32:49 +08:00
Armando
56af6b5fc4 test(sleep): vad wakeup hp core test 2024-10-16 17:27:27 +08:00
Armando
60c005d1dc test(vad): vad wakeup test 2024-10-16 17:27:27 +08:00
Armando
1792aba1dc feat(vad): lp vad driver and wakeup feature 2024-10-16 17:27:27 +08:00
Marius Vikhammer
b4c501374f feat(lp_core): added support for LP-IO as LP-core wakeup source 2024-10-16 09:34:20 +08:00