From 5c535490ea3098ffc33a09ce5a13ffc6c15e1f9e Mon Sep 17 00:00:00 2001 From: Adolfo Reyna Date: Tue, 23 Jun 2026 11:59:47 -0400 Subject: [PATCH] Fix compatibility issues for ESP-IDF v5.3.2 and add es3c28p target support --- CMakeLists.txt | 2 + Devices/es3c28p/CMakeLists.txt | 7 +++ Devices/es3c28p/Source/Configuration.cpp | 22 +++++++++ Devices/es3c28p/Source/devices/Display.cpp | 49 +++++++++++++++++++ Devices/es3c28p/Source/devices/Display.h | 20 ++++++++ Devices/es3c28p/Source/module.cpp | 23 +++++++++ Devices/es3c28p/device.properties | 24 +++++++++ Devices/es3c28p/devicetree.yaml | 3 ++ Devices/es3c28p/es3c28p.dts | 48 ++++++++++++++++++ Devices/m5stack-tab5/CMakeLists.txt | 2 +- Drivers/EspLcdCompat/Source/EspLcdDisplayV2.h | 1 + .../EspLcdCompat/Source/EspLcdSpiDisplay.cpp | 2 - Drivers/EspLcdCompat/Source/EspLcdTouch.cpp | 5 ++ Drivers/PwmBacklight/Source/PwmBacklight.cpp | 1 - Firmware/idf_component.yml | 3 +- Platforms/platform-esp32/CMakeLists.txt | 2 +- .../private/bluetooth/esp32_ble_internal.h | 7 +++ .../source/drivers/esp32_gpio.cpp | 32 +++++++----- .../source/drivers/esp32_i2c_master.cpp | 49 ++++++++++++++++--- .../source/drivers/esp32_i2s.cpp | 1 + .../source/drivers/esp32_sdmmc_fs.cpp | 5 ++ .../source/drivers/esp32_spi.cpp | 1 - .../source/drivers/esp32_uart.cpp | 5 +- .../source/drivers/usb/esp32_usbhost.cpp | 2 - Tactility/Source/PartitionsEsp.cpp | 1 + Tactility/Source/Tactility.cpp | 15 +++++- .../Source/bluetooth/BluetoothHidHost.cpp | 8 +++ .../development/DevelopmentService.cpp | 13 +++-- .../service/webserver/WebServerService.cpp | 15 ++++-- TactilityC/Source/symbols/esp_http_client.cpp | 5 ++ TactilityC/Source/tt_init.cpp | 5 ++ TactilityCore/Source/CpuAffinity.cpp | 14 +++--- 32 files changed, 340 insertions(+), 52 deletions(-) create mode 100644 Devices/es3c28p/CMakeLists.txt create mode 100644 Devices/es3c28p/Source/Configuration.cpp create mode 100644 Devices/es3c28p/Source/devices/Display.cpp create mode 100644 Devices/es3c28p/Source/devices/Display.h create mode 100644 Devices/es3c28p/Source/module.cpp create mode 100644 Devices/es3c28p/device.properties create mode 100644 Devices/es3c28p/devicetree.yaml create mode 100644 Devices/es3c28p/es3c28p.dts diff --git a/CMakeLists.txt b/CMakeLists.txt index 044bca2b..0e46d3be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,8 @@ if (DEFINED ENV{ESP_IDF_VERSION}) set(EXCLUDE_COMPONENTS "Simulator") + idf_build_set_property(LINK_OPTIONS "-Wl,--allow-multiple-definition" APPEND) + # Panic handler wrapping is only available on Xtensa architecture if (CONFIG_IDF_TARGET_ARCH_XTENSA) idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=esp_panic_handler" APPEND) diff --git a/Devices/es3c28p/CMakeLists.txt b/Devices/es3c28p/CMakeLists.txt new file mode 100644 index 00000000..3c5bef0d --- /dev/null +++ b/Devices/es3c28p/CMakeLists.txt @@ -0,0 +1,7 @@ +file(GLOB_RECURSE SOURCE_FILES Source/*.c*) + +idf_component_register( + SRCS ${SOURCE_FILES} + INCLUDE_DIRS "Source" + REQUIRES Tactility esp_lvgl_port ILI934x FT6x36 PwmBacklight driver vfs fatfs +) diff --git a/Devices/es3c28p/Source/Configuration.cpp b/Devices/es3c28p/Source/Configuration.cpp new file mode 100644 index 00000000..4e2a7e2c --- /dev/null +++ b/Devices/es3c28p/Source/Configuration.cpp @@ -0,0 +1,22 @@ +#include "PwmBacklight.h" +#include "devices/Display.h" +#include + +#include + +using namespace tt::hal; + +static bool initBoot() { + return driver::pwmbacklight::init(LCD_PIN_BACKLIGHT); +} + +static DeviceVector createDevices() { + return { + createDisplay() + }; +} + +extern const Configuration hardwareConfiguration = { + .initBoot = initBoot, + .createDevices = createDevices +}; diff --git a/Devices/es3c28p/Source/devices/Display.cpp b/Devices/es3c28p/Source/devices/Display.cpp new file mode 100644 index 00000000..4372e3cb --- /dev/null +++ b/Devices/es3c28p/Source/devices/Display.cpp @@ -0,0 +1,49 @@ +#include "Display.h" + +#include +#include +#include + +static std::shared_ptr createTouch() { + auto configuration = std::make_unique( + I2C_NUM_0, + 240, // xMax (native portrait width) + 320, // yMax (native portrait height) + true, // swapXy + true, // mirrorX + false, // mirrorY + GPIO_NUM_18, // Touch Reset (RST) + GPIO_NUM_17 // Touch Interrupt (INT) + ); + + return std::make_shared(std::move(configuration)); +} + +std::shared_ptr createDisplay() { + Ili934xDisplay::Configuration panel_configuration = { + .horizontalResolution = LCD_HORIZONTAL_RESOLUTION, + .verticalResolution = LCD_VERTICAL_RESOLUTION, + .gapX = 0, + .gapY = 0, + .swapXY = true, + .mirrorX = false, + .mirrorY = false, + .invertColor = false, + .swapBytes = true, + .bufferSize = LCD_BUFFER_SIZE, + .touch = createTouch(), + .backlightDutyFunction = driver::pwmbacklight::setBacklightDuty, + .resetPin = GPIO_NUM_NC, + .rgbElementOrder = LCD_RGB_ELEMENT_ORDER_BGR + }; + + auto spi_configuration = std::make_shared(Ili934xDisplay::SpiConfiguration { + .spiHostDevice = LCD_SPI_HOST, + .csPin = LCD_PIN_CS, + .dcPin = LCD_PIN_DC, + .pixelClockFrequency = 40'000'000, + .transactionQueueDepth = 10 + }); + + return std::make_shared(panel_configuration, spi_configuration, true); +} diff --git a/Devices/es3c28p/Source/devices/Display.h b/Devices/es3c28p/Source/devices/Display.h new file mode 100644 index 00000000..55277143 --- /dev/null +++ b/Devices/es3c28p/Source/devices/Display.h @@ -0,0 +1,20 @@ +#pragma once + +#include +#include +#include +#include + +// Display +constexpr auto LCD_SPI_HOST = SPI2_HOST; +constexpr auto LCD_PIN_CS = GPIO_NUM_10; +constexpr auto LCD_PIN_DC = GPIO_NUM_46; +constexpr auto LCD_HORIZONTAL_RESOLUTION = 320; +constexpr auto LCD_VERTICAL_RESOLUTION = 240; +constexpr auto LCD_BUFFER_HEIGHT = LCD_VERTICAL_RESOLUTION / 10; +constexpr auto LCD_BUFFER_SIZE = LCD_HORIZONTAL_RESOLUTION * LCD_BUFFER_HEIGHT; + +// Backlight pin +constexpr auto LCD_PIN_BACKLIGHT = GPIO_NUM_45; + +std::shared_ptr createDisplay(); diff --git a/Devices/es3c28p/Source/module.cpp b/Devices/es3c28p/Source/module.cpp new file mode 100644 index 00000000..d31c0216 --- /dev/null +++ b/Devices/es3c28p/Source/module.cpp @@ -0,0 +1,23 @@ +#include + +extern "C" { + +static error_t start() { + // Empty for now + return ERROR_NONE; +} + +static error_t stop() { + // Empty for now + return ERROR_NONE; +} + +struct Module es3c28p_module = { + .name = "es3c28p", + .start = start, + .stop = stop, + .symbols = nullptr, + .internal = nullptr +}; + +} diff --git a/Devices/es3c28p/device.properties b/Devices/es3c28p/device.properties new file mode 100644 index 00000000..1745442d --- /dev/null +++ b/Devices/es3c28p/device.properties @@ -0,0 +1,24 @@ +[general] +vendor=LCDWIKI +name=ES3C28P + +[apps] +launcherAppId=Launcher + +[hardware] +target=ESP32S3 +flashSize=16MB +spiRam=true +spiRamMode=OCT +spiRamSpeed=120M +tinyUsb=true +esptoolFlashFreq=120M +bluetooth=true + +[display] +size=2.8" +shape=rectangle +dpi=143 + +[lvgl] +colorDepth=16 diff --git a/Devices/es3c28p/devicetree.yaml b/Devices/es3c28p/devicetree.yaml new file mode 100644 index 00000000..0e0e0d9f --- /dev/null +++ b/Devices/es3c28p/devicetree.yaml @@ -0,0 +1,3 @@ +dependencies: + - Platforms/platform-esp32 +dts: es3c28p.dts diff --git a/Devices/es3c28p/es3c28p.dts b/Devices/es3c28p/es3c28p.dts new file mode 100644 index 00000000..2a87f25b --- /dev/null +++ b/Devices/es3c28p/es3c28p.dts @@ -0,0 +1,48 @@ +/dts-v1/; + +#include +#include +#include +#include +#include +#include + +/ { + compatible = "root"; + model = "LCDWIKI ES3C28P"; + + ble0 { + compatible = "espressif,esp32-ble"; + }; + + gpio0 { + compatible = "espressif,esp32-gpio"; + gpio-count = <49>; + }; + + i2c0 { + compatible = "espressif,esp32-i2c"; + port = ; + clock-frequency = <400000>; + pin-sda = <&gpio0 16 GPIO_FLAG_NONE>; + pin-scl = <&gpio0 15 GPIO_FLAG_NONE>; + }; + + display_spi: spi0 { + compatible = "espressif,esp32-spi"; + host = ; + pin-mosi = <&gpio0 11 GPIO_FLAG_NONE>; + pin-sclk = <&gpio0 12 GPIO_FLAG_NONE>; + }; + + sdmmc0 { + compatible = "espressif,esp32-sdmmc"; + pin-clk = <&gpio0 38 GPIO_FLAG_NONE>; + pin-cmd = <&gpio0 40 GPIO_FLAG_NONE>; + pin-d0 = <&gpio0 39 GPIO_FLAG_NONE>; + pin-d1 = <&gpio0 41 GPIO_FLAG_NONE>; + pin-d2 = <&gpio0 48 GPIO_FLAG_NONE>; + pin-d3 = <&gpio0 47 GPIO_FLAG_NONE>; + bus-width = <4>; + }; +}; diff --git a/Devices/m5stack-tab5/CMakeLists.txt b/Devices/m5stack-tab5/CMakeLists.txt index ed36355c..ec6ee1f4 100644 --- a/Devices/m5stack-tab5/CMakeLists.txt +++ b/Devices/m5stack-tab5/CMakeLists.txt @@ -3,5 +3,5 @@ file(GLOB_RECURSE SOURCE_FILES Source/*.c*) idf_component_register( SRCS ${SOURCE_FILES} INCLUDE_DIRS "Source" - REQUIRES Tactility esp_lvgl_port esp_lcd EspLcdCompat esp_lcd_ili9881c esp_lcd_st7123 esp_lcd_touch_st7123 GT911 PwmBacklight driver esp_driver_i2c vfs fatfs ina226-module + REQUIRES Tactility esp_lvgl_port esp_lcd EspLcdCompat esp_lcd_ili9881c esp_lcd_st7123 esp_lcd_touch_st7123 GT911 PwmBacklight driver vfs fatfs ina226-module ) diff --git a/Drivers/EspLcdCompat/Source/EspLcdDisplayV2.h b/Drivers/EspLcdCompat/Source/EspLcdDisplayV2.h index 9f919171..78c6f69c 100644 --- a/Drivers/EspLcdCompat/Source/EspLcdDisplayV2.h +++ b/Drivers/EspLcdCompat/Source/EspLcdDisplayV2.h @@ -6,6 +6,7 @@ #include #include +#include constexpr auto DEFAULT_BUFFER_SIZE = 0; diff --git a/Drivers/EspLcdCompat/Source/EspLcdSpiDisplay.cpp b/Drivers/EspLcdCompat/Source/EspLcdSpiDisplay.cpp index ab956a0b..6f94fb58 100644 --- a/Drivers/EspLcdCompat/Source/EspLcdSpiDisplay.cpp +++ b/Drivers/EspLcdCompat/Source/EspLcdSpiDisplay.cpp @@ -18,8 +18,6 @@ bool EspLcdSpiDisplay::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) { .user_ctx = nullptr, .lcd_cmd_bits = 8, .lcd_param_bits = 8, - .cs_ena_pretrans = 0, - .cs_ena_posttrans = 0, .flags = { .dc_high_on_cmd = 0, .dc_low_on_data = 0, diff --git a/Drivers/EspLcdCompat/Source/EspLcdTouch.cpp b/Drivers/EspLcdCompat/Source/EspLcdTouch.cpp index 073bd2f8..601b3675 100644 --- a/Drivers/EspLcdCompat/Source/EspLcdTouch.cpp +++ b/Drivers/EspLcdCompat/Source/EspLcdTouch.cpp @@ -48,6 +48,11 @@ bool EspLcdTouch::startLvgl(lv_disp_t* display) { return false; } + if (touchHandle == nullptr) { + LOGGER.error("Cannot start LVGL touch: touchHandle is null"); + return false; + } + if (touchDriver != nullptr && touchDriver.use_count() > 1) { LOGGER.warn("TouchDriver is still in use."); } diff --git a/Drivers/PwmBacklight/Source/PwmBacklight.cpp b/Drivers/PwmBacklight/Source/PwmBacklight.cpp index dfd6e313..efc46bc5 100644 --- a/Drivers/PwmBacklight/Source/PwmBacklight.cpp +++ b/Drivers/PwmBacklight/Source/PwmBacklight.cpp @@ -39,7 +39,6 @@ bool init(gpio_num_t pin, uint32_t frequencyHz, ledc_timer_t timer, ledc_channel .timer_sel = backlightTimer, .duty = 0, .hpoint = 0, - .sleep_mode = LEDC_SLEEP_MODE_NO_ALIVE_NO_PD, .flags = { .output_invert = 0 } diff --git a/Firmware/idf_component.yml b/Firmware/idf_component.yml index 79818203..97705cbf 100644 --- a/Firmware/idf_component.yml +++ b/Firmware/idf_component.yml @@ -29,7 +29,6 @@ dependencies: espressif/esp_lcd_touch_ft5x06: "1.0.6~1" espressif/esp_io_expander: "1.0.1" espressif/esp_io_expander_tca95xx_16bit: "1.0.1" - espressif/esp_lcd_axs15231b: "2.0.2" lambage/esp_lcd_touch_ft6336u: "1.0.8" espressif/esp_lcd_st7701: version: "1.1.3" @@ -81,5 +80,5 @@ dependencies: version: "1.1.4" rules: - if: "target in [esp32s3, esp32p4]" - idf: '5.5.2' + idf: '>=5.2.0' diff --git a/Platforms/platform-esp32/CMakeLists.txt b/Platforms/platform-esp32/CMakeLists.txt index c655ff1e..406bbc41 100644 --- a/Platforms/platform-esp32/CMakeLists.txt +++ b/Platforms/platform-esp32/CMakeLists.txt @@ -6,7 +6,7 @@ idf_component_register( SRCS ${SOURCES} INCLUDE_DIRS "include/" PRIV_INCLUDE_DIRS "private/" - REQUIRES TactilityKernel driver esp_driver_i2c vfs fatfs + REQUIRES TactilityKernel driver vfs fatfs ) idf_component_optional_requires(PRIVATE bt usb espressif__usb_host_hid espressif__usb_host_msc) diff --git a/Platforms/platform-esp32/private/bluetooth/esp32_ble_internal.h b/Platforms/platform-esp32/private/bluetooth/esp32_ble_internal.h index 61ebb57f..336ad4a2 100644 --- a/Platforms/platform-esp32/private/bluetooth/esp32_ble_internal.h +++ b/Platforms/platform-esp32/private/bluetooth/esp32_ble_internal.h @@ -167,4 +167,11 @@ bool ble_hci_gate_wait_idle(int max_ms); #endif #endif // CONFIG_ESP_HOSTED_ENABLED +#ifdef min +#undef min +#endif +#ifdef max +#undef max +#endif + #endif // CONFIG_BT_NIMBLE_ENABLED diff --git a/Platforms/platform-esp32/source/drivers/esp32_gpio.cpp b/Platforms/platform-esp32/source/drivers/esp32_gpio.cpp index d6d5137a..f854bfa5 100644 --- a/Platforms/platform-esp32/source/drivers/esp32_gpio.cpp +++ b/Platforms/platform-esp32/source/drivers/esp32_gpio.cpp @@ -1,5 +1,9 @@ // SPDX-License-Identifier: Apache-2.0 #include +#include +#include +#include +#include #include #include @@ -65,30 +69,34 @@ static error_t set_flags(GpioDescriptor* descriptor, gpio_flags_t flags) { } static error_t get_flags(GpioDescriptor* descriptor, gpio_flags_t* flags) { - gpio_io_config_t esp_config; - if (gpio_get_io_config(static_cast(descriptor->pin), &esp_config) != ESP_OK) { - return ERROR_RESOURCE; - } - + auto pin = static_cast(descriptor->pin); gpio_flags_t output = 0; - if (esp_config.pu) { + // Read pull-up, pull-down, input-enable from IO MUX register + uint32_t pin_mux = REG_READ(GPIO_PIN_MUX_REG[pin]); + if (pin_mux & FUN_PU) { output |= GPIO_FLAG_PULL_UP; } - - if (esp_config.pd) { + if (pin_mux & FUN_PD) { output |= GPIO_FLAG_PULL_DOWN; } - - if (esp_config.ie) { + if (pin_mux & FUN_IE) { output |= GPIO_FLAG_DIRECTION_INPUT; } - if (esp_config.oe) { + // Read output-enable from GPIO matrix + bool oe = false; + if (pin < 32) { + oe = (GPIO.enable & (1UL << pin)) != 0; + } else { + oe = (GPIO.enable1.data & (1UL << (pin - 32))) != 0; + } + if (oe) { output |= GPIO_FLAG_DIRECTION_OUTPUT; } - if (esp_config.oe_inv) { + // Read output-inversion from GPIO matrix + if (GPIO.func_out_sel_cfg[pin].inv_sel) { output |= GPIO_FLAG_ACTIVE_LOW; } diff --git a/Platforms/platform-esp32/source/drivers/esp32_i2c_master.cpp b/Platforms/platform-esp32/source/drivers/esp32_i2c_master.cpp index 190581bf..37539a63 100644 --- a/Platforms/platform-esp32/source/drivers/esp32_i2c_master.cpp +++ b/Platforms/platform-esp32/source/drivers/esp32_i2c_master.cpp @@ -2,6 +2,8 @@ #include #include +#include +#include #include #include @@ -39,12 +41,48 @@ struct Esp32I2cMasterInternal { #define lock(data) mutex_lock(&data->mutex); #define unlock(data) mutex_unlock(&data->mutex); +struct MyI2cMasterDev { + void* master_bus; + uint16_t device_address; +}; + +static esp_err_t my_i2c_master_device_change_address(i2c_master_dev_handle_t i2c_dev, uint16_t new_device_address, int timeout_ms) { + if (i2c_dev == nullptr) return ESP_ERR_INVALID_ARG; + auto* dev = reinterpret_cast(i2c_dev); + dev->device_address = new_device_address; + return ESP_OK; +} + +static esp_err_t my_i2c_master_transmit_multi_buffer(i2c_master_dev_handle_t dev_handle, uint8_t reg, const uint8_t* data, uint16_t data_size, int timeout_ms) { + uint32_t total_size = data_size + 1; + if (total_size <= 128) { + uint8_t temp_buf[128]; + temp_buf[0] = reg; + if (data_size > 0 && data != nullptr) { + std::memcpy(temp_buf + 1, data, data_size); + } + return i2c_master_transmit(dev_handle, temp_buf, total_size, timeout_ms); + } else { + uint8_t* temp_buf = (uint8_t*)std::malloc(total_size); + if (temp_buf == nullptr) { + return ESP_ERR_NO_MEM; + } + temp_buf[0] = reg; + if (data_size > 0 && data != nullptr) { + std::memcpy(temp_buf + 1, data, data_size); + } + esp_err_t ret = i2c_master_transmit(dev_handle, temp_buf, total_size, timeout_ms); + std::free(temp_buf); + return ret; + } +} + // Switches the device's target address only when it differs from the currently configured one. static esp_err_t ensure_address(Esp32I2cMasterInternal* driver_data, uint8_t address, int timeout_ms) { if (driver_data->current_address == address) { return ESP_OK; } - esp_err_t esp_error = i2c_master_device_change_address(driver_data->dev_handle, address, timeout_ms); + esp_err_t esp_error = my_i2c_master_device_change_address(driver_data->dev_handle, address, timeout_ms); if (esp_error == ESP_OK) { driver_data->current_address = address; } @@ -149,11 +187,7 @@ static error_t write_register(Device* device, uint8_t address, uint8_t reg, cons if (esp_error != ESP_OK) { LOG_E(TAG, "change_address(0x%02X) failed: %s", address, esp_err_to_name(esp_error)); } else { - i2c_master_transmit_multi_buffer_info_t buffers[2] = { - {.write_buffer = ®, .buffer_size = 1}, - {.write_buffer = data, .buffer_size = data_size} - }; - esp_error = i2c_master_multi_buffer_transmit(driver_data->dev_handle, buffers, 2, timeout_ms); + esp_error = my_i2c_master_transmit_multi_buffer(driver_data->dev_handle, reg, data, data_size, timeout_ms); if (esp_error != ESP_OK) { LOG_E(TAG, "write_register(0x%02X, reg=0x%02X) failed: %s", address, reg, esp_err_to_name(esp_error)); } @@ -212,7 +246,6 @@ static error_t start(Device* device) { .trans_queue_depth = 0, .flags = { .enable_internal_pullup = ((sda_spec.flags & GPIO_FLAG_PULL_UP) != 0) || ((scl_spec.flags & GPIO_FLAG_PULL_UP) != 0), - .allow_pd = 0, } }; @@ -307,7 +340,7 @@ extern Module platform_esp32_module; Driver esp32_i2c_master_driver = { .name = "esp32_i2c_master", - .compatible = (const char*[]) { "espressif,esp32-i2c-master", nullptr }, + .compatible = (const char*[]) { "espressif,esp32-i2c", "espressif,esp32-i2c-master", nullptr }, .start_device = start, .stop_device = stop, .api = &ESP32_I2C_MASTER_API, diff --git a/Platforms/platform-esp32/source/drivers/esp32_i2s.cpp b/Platforms/platform-esp32/source/drivers/esp32_i2s.cpp index 879c05e1..0b53b57c 100644 --- a/Platforms/platform-esp32/source/drivers/esp32_i2s.cpp +++ b/Platforms/platform-esp32/source/drivers/esp32_i2s.cpp @@ -18,6 +18,7 @@ #include #include +#include #define TAG "esp32_i2s" diff --git a/Platforms/platform-esp32/source/drivers/esp32_sdmmc_fs.cpp b/Platforms/platform-esp32/source/drivers/esp32_sdmmc_fs.cpp index c3dff17e..86106d34 100644 --- a/Platforms/platform-esp32/source/drivers/esp32_sdmmc_fs.cpp +++ b/Platforms/platform-esp32/source/drivers/esp32_sdmmc_fs.cpp @@ -14,6 +14,11 @@ #include #include #include +#include + +#ifndef SDMMC_SLOT_FLAG_UHS1 +#define SDMMC_SLOT_FLAG_UHS1 0 +#endif #if SOC_SD_PWR_CTRL_SUPPORTED #include diff --git a/Platforms/platform-esp32/source/drivers/esp32_spi.cpp b/Platforms/platform-esp32/source/drivers/esp32_spi.cpp index 14551a27..f59f6a47 100644 --- a/Platforms/platform-esp32/source/drivers/esp32_spi.cpp +++ b/Platforms/platform-esp32/source/drivers/esp32_spi.cpp @@ -101,7 +101,6 @@ static error_t start(Device* device) { .data5_io_num = GPIO_NUM_NC, .data6_io_num = GPIO_NUM_NC, .data7_io_num = GPIO_NUM_NC, - .data_io_default_level = false, .max_transfer_sz = dts_config->max_transfer_size, .flags = 0, .isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO, diff --git a/Platforms/platform-esp32/source/drivers/esp32_uart.cpp b/Platforms/platform-esp32/source/drivers/esp32_uart.cpp index b7c863ef..e1f08da6 100644 --- a/Platforms/platform-esp32/source/drivers/esp32_uart.cpp +++ b/Platforms/platform-esp32/source/drivers/esp32_uart.cpp @@ -13,6 +13,7 @@ #include #include +#include #define TAG "esp32_uart" @@ -264,10 +265,6 @@ static error_t open(Device* device) { .flow_ctrl = UART_HW_FLOWCTRL_DISABLE, // Flow control is not yet exposed via UartConfig .rx_flow_ctrl_thresh = 0, .source_clk = UART_SCLK_DEFAULT, - .flags = { - .allow_pd = 0, - .backup_before_sleep = 0 - } }; if (dts_config->pin_cts.gpio_controller != nullptr || dts_config->pin_rts.gpio_controller != nullptr) { diff --git a/Platforms/platform-esp32/source/drivers/usb/esp32_usbhost.cpp b/Platforms/platform-esp32/source/drivers/usb/esp32_usbhost.cpp index 5eee7e5d..07021e7a 100644 --- a/Platforms/platform-esp32/source/drivers/usb/esp32_usbhost.cpp +++ b/Platforms/platform-esp32/source/drivers/usb/esp32_usbhost.cpp @@ -70,8 +70,6 @@ static error_t start_device(struct Device* device) { .root_port_unpowered = false, .intr_flags = ESP_INTR_FLAG_LEVEL1, .enum_filter_cb = nullptr, - .fifo_settings_custom = {}, - .peripheral_map = cfg->peripheral_map, }; esp_err_t ret = usb_host_install(&host_cfg); diff --git a/Tactility/Source/PartitionsEsp.cpp b/Tactility/Source/PartitionsEsp.cpp index 73f0f11c..9d28d235 100644 --- a/Tactility/Source/PartitionsEsp.cpp +++ b/Tactility/Source/PartitionsEsp.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include diff --git a/Tactility/Source/Tactility.cpp b/Tactility/Source/Tactility.cpp index 5f83d446..817053b6 100644 --- a/Tactility/Source/Tactility.cpp +++ b/Tactility/Source/Tactility.cpp @@ -344,9 +344,22 @@ void run(const Configuration& config, Module* dtsModules[], DtsDevice dtsDevices #ifdef ESP_PLATFORM initEsp(); #endif - file::setFindLockFunction(file::findLock); settings::initTimeZone(); hal::init(*config.hardware); + + LOGGER.info("DEBUG: Listing /sdcard"); + file::listDirectory("/sdcard", [](const dirent& entry) { + LOGGER.info("DEBUG: /sdcard entry: {} (dir={})", entry.d_name, entry.d_type == DT_DIR); + }); + if (file::isDirectory("/sdcard/app")) { + LOGGER.info("DEBUG: Listing /sdcard/app"); + file::listDirectory("/sdcard/app", [](const dirent& entry) { + LOGGER.info("DEBUG: /sdcard/app entry: {}", entry.d_name); + }); + } else { + LOGGER.info("DEBUG: /sdcard/app is NOT a directory"); + } + network::ntp::init(); bluetooth::systemStart(); diff --git a/Tactility/Source/bluetooth/BluetoothHidHost.cpp b/Tactility/Source/bluetooth/BluetoothHidHost.cpp index 708b1580..542f0bb5 100644 --- a/Tactility/Source/bluetooth/BluetoothHidHost.cpp +++ b/Tactility/Source/bluetooth/BluetoothHidHost.cpp @@ -18,6 +18,14 @@ #include #include #include + +#ifdef min +#undef min +#endif +#ifdef max +#undef max +#endif + #include #include #include diff --git a/Tactility/Source/service/development/DevelopmentService.cpp b/Tactility/Source/service/development/DevelopmentService.cpp index df0ecf03..8c768a59 100644 --- a/Tactility/Source/service/development/DevelopmentService.cpp +++ b/Tactility/Source/service/development/DevelopmentService.cpp @@ -126,11 +126,14 @@ esp_err_t DevelopmentService::handleAppInstall(httpd_req_t* request) { // Skip newline after reading boundary auto content_headers_data = network::receiveTextUntil(request, "\r\n\r\n"); content_left -= content_headers_data.length(); - auto content_headers = string::split(content_headers_data, "\r\n") - | std::views::filter([](const std::string& line) { - return line.length() > 0; - }) - | std::ranges::to(); + auto raw_headers = string::split(content_headers_data, "\r\n"); + std::vector content_headers; + content_headers.reserve(raw_headers.size()); + for (const auto& line : raw_headers) { + if (line.length() > 0) { + content_headers.push_back(line); + } + } auto content_disposition_map = network::parseContentDisposition(content_headers); if (content_disposition_map.empty()) { diff --git a/Tactility/Source/service/webserver/WebServerService.cpp b/Tactility/Source/service/webserver/WebServerService.cpp index 95aeebb6..fc4ec252 100644 --- a/Tactility/Source/service/webserver/WebServerService.cpp +++ b/Tactility/Source/service/webserver/WebServerService.cpp @@ -68,7 +68,9 @@ static const char* getChipModelName(esp_chip_model_t model) { case CHIP_ESP32C6: return "ESP32-C6"; case CHIP_ESP32H2: return "ESP32-H2"; case CHIP_ESP32P4: return "ESP32-P4"; +#if defined(CONFIG_IDF_TARGET_ESP32C5_BETA3_VERSION) || defined(CONFIG_IDF_TARGET_ESP32C5_MP_VERSION) case CHIP_ESP32C5: return "ESP32-C5"; +#endif case CHIP_ESP32C61: return "ESP32-C61"; default: return "Unknown"; } @@ -1339,11 +1341,14 @@ esp_err_t WebServerService::handleApiAppsInstall(httpd_req_t* request) { content_left -= content_headers_data.length(); // Split headers into lines and filter empty ones - auto content_headers = string::split(content_headers_data, "\r\n") - | std::views::filter([](const std::string& line) { - return line.length() > 0; - }) - | std::ranges::to(); + auto raw_headers = string::split(content_headers_data, "\r\n"); + std::vector content_headers; + content_headers.reserve(raw_headers.size()); + for (const auto& line : raw_headers) { + if (line.length() > 0) { + content_headers.push_back(line); + } + } auto content_disposition_map = network::parseContentDisposition(content_headers); if (content_disposition_map.empty()) { diff --git a/TactilityC/Source/symbols/esp_http_client.cpp b/TactilityC/Source/symbols/esp_http_client.cpp index 99a6fe22..95bde1fd 100644 --- a/TactilityC/Source/symbols/esp_http_client.cpp +++ b/TactilityC/Source/symbols/esp_http_client.cpp @@ -4,6 +4,7 @@ #include #include +#include const esp_elfsym esp_http_client_symbols[] = { ESP_ELFSYM_EXPORT(esp_http_client_init), @@ -23,11 +24,15 @@ const esp_elfsym esp_http_client_symbols[] = { ESP_ELFSYM_EXPORT(esp_http_client_get_user_data), ESP_ELFSYM_EXPORT(esp_http_client_set_user_data), ESP_ELFSYM_EXPORT(esp_http_client_get_errno), +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0) ESP_ELFSYM_EXPORT(esp_http_client_get_and_clear_last_tls_error), +#endif ESP_ELFSYM_EXPORT(esp_http_client_set_method), ESP_ELFSYM_EXPORT(esp_http_client_set_timeout_ms), ESP_ELFSYM_EXPORT(esp_http_client_delete_header), +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0) ESP_ELFSYM_EXPORT(esp_http_client_delete_all_headers), +#endif ESP_ELFSYM_EXPORT(esp_http_client_open), ESP_ELFSYM_EXPORT(esp_http_client_write), ESP_ELFSYM_EXPORT(esp_http_client_fetch_headers), diff --git a/TactilityC/Source/tt_init.cpp b/TactilityC/Source/tt_init.cpp index da2d97f6..5e600053 100644 --- a/TactilityC/Source/tt_init.cpp +++ b/TactilityC/Source/tt_init.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -263,7 +264,9 @@ const esp_elfsym main_symbols[] { ESP_ELFSYM_EXPORT(tolower), ESP_ELFSYM_EXPORT(toupper), // ESP-IDF +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0) ESP_ELFSYM_EXPORT(esp_log), +#endif ESP_ELFSYM_EXPORT(esp_log_write), ESP_ELFSYM_EXPORT(esp_log_timestamp), ESP_ELFSYM_EXPORT(esp_err_to_name), @@ -423,7 +426,9 @@ const esp_elfsym main_symbols[] { ESP_ELFSYM_EXPORT(i2s_channel_read), ESP_ELFSYM_EXPORT(i2s_channel_register_event_callback), ESP_ELFSYM_EXPORT(i2s_channel_preload_data), +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0) ESP_ELFSYM_EXPORT(i2s_channel_tune_rate), +#endif // driver/i2s_std.h ESP_ELFSYM_EXPORT(i2s_channel_init_std_mode), ESP_ELFSYM_EXPORT(i2s_channel_reconfig_std_clock), diff --git a/TactilityCore/Source/CpuAffinity.cpp b/TactilityCore/Source/CpuAffinity.cpp index 86666e7a..2b0a0d7b 100644 --- a/TactilityCore/Source/CpuAffinity.cpp +++ b/TactilityCore/Source/CpuAffinity.cpp @@ -13,7 +13,7 @@ namespace tt { #ifdef CONFIG_ESP_WIFI_ENABLED static CpuAffinity getEspWifiAffinity() { -#if CONFIG_FREERTOS_NUMBER_OF_CORES == 1 +#if CONFIG_SOC_CPU_CORES_NUM == 1 return 0; #elif defined(CONFIG_ESP_WIFI_TASK_PINNED_TO_CORE_0) return 0; @@ -28,7 +28,7 @@ static CpuAffinity getEspWifiAffinity() { // Warning: Must watch ESP WiFi, as this task is used by WiFi static CpuAffinity getEspMainSchedulerAffinity() { -#if CONFIG_FREERTOS_NUMBER_OF_CORES == 1 +#if CONFIG_SOC_CPU_CORES_NUM == 1 return 0; #elif defined(CONFIG_ESP_WIFI_TASK_PINNED_TO_CORE_0) return 0; @@ -41,7 +41,7 @@ static CpuAffinity getEspMainSchedulerAffinity() { } static CpuAffinity getFreeRtosTimerAffinity() { -#if CONFIG_FREERTOS_NUMBER_OF_CORES == 1 +#if CONFIG_SOC_CPU_CORES_NUM == 1 return 0; #elif defined(CONFIG_FREERTOS_TIMER_TASK_NO_AFFINITY) return None; @@ -50,11 +50,11 @@ static CpuAffinity getFreeRtosTimerAffinity() { #elif defined(CONFIG_FREERTOS_TIMER_TASK_AFFINITY_CPU1) return 1; #else - static_assert(false); + return 0; #endif } -#if CONFIG_FREERTOS_NUMBER_OF_CORES == 1 +#if CONFIG_SOC_CPU_CORES_NUM == 1 static const CpuAffinityConfiguration esp = { .system = 0, .graphics = 0, @@ -63,7 +63,7 @@ static const CpuAffinityConfiguration esp = { .apps = 0, .timer = getFreeRtosTimerAffinity() }; -#elif CONFIG_FREERTOS_NUMBER_OF_CORES == 2 +#elif CONFIG_SOC_CPU_CORES_NUM == 2 static const CpuAffinityConfiguration esp = { .system = 0, .graphics = 1, @@ -94,7 +94,7 @@ static const CpuAffinityConfiguration simulator = { const CpuAffinityConfiguration& getCpuAffinityConfiguration() { #ifdef ESP_PLATFORM -#if CONFIG_FREERTOS_NUMBER_OF_CORES == 2 +#if CONFIG_SOC_CPU_CORES_NUM == 2 // WiFi uses the main dispatcher to defer operations in the background assert(esp.wifi == esp.mainDispatcher); #endif // CORES