From 0d869cad61cf0469f44e406c9fc4edad3a3b3b75 Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Wed, 13 May 2026 14:05:28 +0200 Subject: [PATCH] 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 --- .../ulp_riscv/main/test_ulp_riscv_i2c.c | 19 ++++++++++++++++--- .../ulp_riscv/main/ulp/test_main_i2c.c | 10 +++++----- .../ulp_riscv/main/ulp/ulp_test_shared.h | 3 +-- .../test_apps/ulp_riscv/sdkconfig.defaults | 4 ++++ 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/components/ulp/test_apps/ulp_riscv/main/test_ulp_riscv_i2c.c b/components/ulp/test_apps/ulp_riscv/main/test_ulp_riscv_i2c.c index 2be2e701c2f..41de501bd95 100644 --- a/components/ulp/test_apps/ulp_riscv/main/test_ulp_riscv_i2c.c +++ b/components/ulp/test_apps/ulp_riscv/main/test_ulp_riscv_i2c.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -28,8 +28,8 @@ static void load_and_start_ulp_riscv_firmware(const uint8_t* ulp_bin, size_t ulp TEST_ASSERT(ulp_riscv_run() == ESP_OK); } -#define I2C_SLAVE_SCL_IO 7 /*! #include "ulp_test_shared.h" -// #include "ulp_riscv.h" #include "ulp_riscv_utils.h" #include "ulp_riscv_i2c_ulp_core.h" +#include "esp_err.h" volatile riscv_test_command_reply_t read_test_reply = RISCV_COMMAND_INVALID; volatile riscv_test_command_reply_t write_test_cmd = RISCV_COMMAND_INVALID; @@ -22,10 +22,10 @@ int main(void) ulp_riscv_i2c_master_set_slave_addr(I2C_SLAVE_ADDRESS); /* Read from the I2C slave device */ - ulp_riscv_i2c_master_read_from_device(data_rd, RW_TEST_LENGTH); + esp_err_t ret = ulp_riscv_i2c_master_read_from_device(data_rd, RW_TEST_LENGTH); - /* Signal the main CPU once read is done */ - read_test_reply = RISCV_COMMAND_OK; + /* Signal the main CPU with actual result */ + read_test_reply = (ret == ESP_OK) ? RISCV_COMMAND_OK : RISCV_COMMAND_NOK; /* Wait for write command from main CPU */ while (write_test_cmd != RISCV_COMMAND_OK) { diff --git a/components/ulp/test_apps/ulp_riscv/main/ulp/ulp_test_shared.h b/components/ulp/test_apps/ulp_riscv/main/ulp/ulp_test_shared.h index de72a171fd8..054edb9f647 100644 --- a/components/ulp/test_apps/ulp_riscv/main/ulp/ulp_test_shared.h +++ b/components/ulp/test_apps/ulp_riscv/main/ulp/ulp_test_shared.h @@ -11,8 +11,7 @@ /* I2C test params */ #define I2C_SLAVE_ADDRESS 0x28 #define DATA_LENGTH 200 -// TODO: Updated the test to perform multi-byte read/write (IDFGH-11056) -#define RW_TEST_LENGTH 1 /*!