From 0031761b46bbff55b56521ae3c4a787cfba8e9a7 Mon Sep 17 00:00:00 2001 From: "Zhibin (Ryan) Wen" Date: Fri, 29 May 2026 21:00:22 +0800 Subject: [PATCH 1/4] fix: support IDF v6 GPIO register changes Signed-off-by: Zhibin (Ryan) Wen --- src/m5_unit_component/adapter_gpio_v2.cpp | 10 ++++++---- src/m5_unit_component/pin.cpp | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/m5_unit_component/adapter_gpio_v2.cpp b/src/m5_unit_component/adapter_gpio_v2.cpp index 0a0ed56..282adf7 100644 --- a/src/m5_unit_component/adapter_gpio_v2.cpp +++ b/src/m5_unit_component/adapter_gpio_v2.cpp @@ -27,11 +27,13 @@ rmt_tx_channel_config_t to_rmt_tx_config(const adapter_config_t &cfg, const uint out.clk_src = RMT_CLK_SRC_DEFAULT; out.mem_block_symbols = std::max(SOC_RMT_MEM_WORDS_PER_CHANNEL, cfg.tx.mem_blocks * SOC_RMT_MEM_WORDS_PER_CHANNEL); - out.resolution_hz = calculate_rmt_resolution_hz(apb_freq_hz, cfg.tx.tick_ns); - out.trans_queue_depth = 4; - out.flags.with_dma = cfg.tx.with_dma; + out.resolution_hz = calculate_rmt_resolution_hz(apb_freq_hz, cfg.tx.tick_ns); + out.trans_queue_depth = 4; + out.flags.with_dma = cfg.tx.with_dma; +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(6, 0, 0) out.flags.io_loop_back = cfg.tx.loop_enabled; - out.flags.invert_out = cfg.tx.invert_signal; +#endif + out.flags.invert_out = cfg.tx.invert_signal; return out; } diff --git a/src/m5_unit_component/pin.cpp b/src/m5_unit_component/pin.cpp index 3089e96..0ddabb9 100644 --- a/src/m5_unit_component/pin.cpp +++ b/src/m5_unit_component/pin.cpp @@ -14,6 +14,7 @@ #include #include #include +#include namespace m5 { namespace unit { From 0f923f7335f00dd436700b9a66840e19835bfca4 Mon Sep 17 00:00:00 2001 From: "Zhibin (Ryan) Wen" Date: Fri, 29 May 2026 21:00:48 +0800 Subject: [PATCH 2/4] fix: make IDF component dependencies version-aware Signed-off-by: Zhibin (Ryan) Wen --- CMakeLists.txt | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3219703..c7f1a64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,16 +8,26 @@ # (i2c_master_bus_handle_t) is the one used in non-Arduino builds. # - googletest helpers (src/googletest/*) are EXCLUDED — they pull in # for test scaffolding only and are not needed at runtime. +include($ENV{IDF_PATH}/tools/cmake/version.cmake) + file(GLOB_RECURSE SRCS "src/*.cpp") list(FILTER SRCS EXCLUDE REGEX "/googletest/") -# REQUIRES = public deps (exposed through src/ public headers); PRIV_REQUIRES = used only in .cpp. -# Use the `driver` meta-component (exists in all IDF 5.x and publicly aggregates esp_driver_*), -# NOT the split esp_driver_* components which only exist from IDF 5.3 and would break >=5.0. + +set(public_requires driver M5HAL) +set(private_requires esp_adc esp_timer M5Utility) + +# Keep IDF 5.x on the driver meta-component. IDF v6 no longer exposes all split +# driver include paths transitively, so add only the v6-specific component deps. +if("${IDF_VERSION_MAJOR}" VERSION_GREATER_EQUAL "6") + list(APPEND public_requires esp_driver_gpio esp_driver_i2c esp_driver_rmt esp_driver_spi esp_driver_uart esp_hw_support) + list(APPEND private_requires esp_driver_ledc esp_ringbuf) +endif() + idf_component_register( SRCS ${SRCS} INCLUDE_DIRS "src" - REQUIRES driver M5HAL - PRIV_REQUIRES esp_adc esp_timer M5Utility + REQUIRES ${public_requires} + PRIV_REQUIRES ${private_requires} ) # Optionally link M5Unified only when it is already part of the build (e.g. a M5Unified-based From edcb5826bac9f98c1ee57fd793d7b8b6d3fae0e4 Mon Sep 17 00:00:00 2001 From: "Zhibin (Ryan) Wen" Date: Fri, 29 May 2026 20:58:36 +0800 Subject: [PATCH 3/4] fix: build native IDF component as C++17 Signed-off-by: Zhibin (Ryan) Wen --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c7f1a64..05b4484 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,8 @@ idf_component_register( PRIV_REQUIRES ${private_requires} ) +idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++17" APPEND) + # Optionally link M5Unified only when it is already part of the build (e.g. a M5Unified-based # app or example). This puts M5GFX's on adapter_i2c.cpp's include path, # so the real m5::I2C_Class adapter is compiled instead of the stub. Pure ESP-IDF builds without From c1db95f08d69bce9c428ec6aa878449b2686783f Mon Sep 17 00:00:00 2001 From: "Zhibin (Ryan) Wen" Date: Fri, 29 May 2026 20:59:11 +0800 Subject: [PATCH 4/4] fix: include FreeRTOS header in SPI adapter Signed-off-by: Zhibin (Ryan) Wen --- src/m5_unit_component/adapter_spi.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/m5_unit_component/adapter_spi.cpp b/src/m5_unit_component/adapter_spi.cpp index c37dcf8..00d80e8 100644 --- a/src/m5_unit_component/adapter_spi.cpp +++ b/src/m5_unit_component/adapter_spi.cpp @@ -11,6 +11,7 @@ #include "adapter_spi.hpp" #if defined(ESP_PLATFORM) #include +#include #endif #include #include