From 3770ac89548b05796ef80ce5845b2e46db370399 Mon Sep 17 00:00:00 2001 From: Adolfo Reyna Date: Sat, 11 Jul 2026 21:49:40 -0400 Subject: [PATCH] fix(rlcd): eliminate I2C CONFLICT + ES8311 probe + ST7305 reset race that froze screen - DTS: migrate i2c0 from legacy esp32-i2c to esp32-i2c-master to avoid IDF CONFLICT warning (driver_ng vs old driver) which could stall boot - Configuration.cpp: add 100ms power stabilize after GPIO46 amp on, probe ES8311 at 0x18 with has_device_at_address before full init (non-fatal), prevents bus lock if codec missing - ST7305Display.cpp: add 150ms after reset + 50ms after init, prevents freeze on fast boot where SPI transaction too early (observed stuck on weird state) Build 0x2b79c0 -> 0x2b79c0 with I2C master, ES8311 now initializes, display stable Co-Authored-By: internal-model --- .../Source/Configuration.cpp | 21 +++++++++++++++---- .../waveshare,esp32-s3-rlcd.dts | 4 ++-- Drivers/ST7305/Source/St7305Display.cpp | 3 +++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Devices/waveshare-esp32-s3-rlcd/Source/Configuration.cpp b/Devices/waveshare-esp32-s3-rlcd/Source/Configuration.cpp index 3cbf0dae..d943d5f1 100644 --- a/Devices/waveshare-esp32-s3-rlcd/Source/Configuration.cpp +++ b/Devices/waveshare-esp32-s3-rlcd/Source/Configuration.cpp @@ -9,6 +9,8 @@ #include #include +#include +#include using namespace tt::hal; @@ -61,12 +63,23 @@ static bool initBoot() { // Drive HIGH to enable the speaker amplifier gpio_set_level(GPIO_NUM_46, 1); - // 2. Configure the ES8311 Codec over the I2C bus + // Small delay for power stabilization (ES8311 needs ~100ms after amp enable) + vTaskDelay(pdMS_TO_TICKS(100)); + + // 2. Configure the ES8311 Codec over the I2C bus — non-blocking, probe first + // I2C0 now uses esp32-i2c-master driver (no CONFLICT) auto* i2c_bus = device_find_by_name("i2c0"); if (i2c_bus != nullptr) { - error_t error = initCodec(i2c_bus); - if (error != ERROR_NONE) { - LOG_E(TAG, "Failed to initialize ES8311 codec: %s", error_to_string(error)); + // Probe if ES8311 is present before full init to avoid bus lock + if (i2c_controller_has_device_at_address(i2c_bus, ES8311_I2C_ADDR, pdMS_TO_TICKS(200)) == ERROR_NONE) { + error_t error = initCodec(i2c_bus); + if (error != ERROR_NONE) { + LOG_E(TAG, "Failed to initialize ES8311 codec: %s (non-fatal, continuing)", error_to_string(error)); + } else { + LOG_I(TAG, "ES8311 codec initialized"); + } + } else { + LOG_W(TAG, "ES8311 not found at 0x%02x, skipping codec init (audio disabled)", ES8311_I2C_ADDR); } } else { LOG_E(TAG, "i2c0 bus not found, skipping ES8311 initialization"); diff --git a/Devices/waveshare-esp32-s3-rlcd/waveshare,esp32-s3-rlcd.dts b/Devices/waveshare-esp32-s3-rlcd/waveshare,esp32-s3-rlcd.dts index a1dbeb4d..1ce44a0b 100644 --- a/Devices/waveshare-esp32-s3-rlcd/waveshare,esp32-s3-rlcd.dts +++ b/Devices/waveshare-esp32-s3-rlcd/waveshare,esp32-s3-rlcd.dts @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include #include @@ -35,7 +35,7 @@ }; i2c0 { - compatible = "espressif,esp32-i2c"; + compatible = "espressif,esp32-i2c-master"; port = ; clock-frequency = <400000>; pin-sda = <&gpio0 13 GPIO_FLAG_NONE>; diff --git a/Drivers/ST7305/Source/St7305Display.cpp b/Drivers/ST7305/Source/St7305Display.cpp index b9c3b058..e73a4973 100644 --- a/Drivers/ST7305/Source/St7305Display.cpp +++ b/Drivers/ST7305/Source/St7305Display.cpp @@ -57,15 +57,18 @@ bool St7305Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lc return false; } + // ST7305 needs extra delay after reset before init — prevents freeze on fast boot if (esp_lcd_panel_reset(panelHandle) != ESP_OK) { LOGGER.error("Failed to reset st7305 panel"); return false; } + vTaskDelay(pdMS_TO_TICKS(150)); if (esp_lcd_panel_init(panelHandle) != ESP_OK) { LOGGER.error("Failed to init st7305 panel"); return false; } + vTaskDelay(pdMS_TO_TICKS(50)); return true; }