Repository navigation
fix(esp32): build cleanly on ESP-IDF 6 - #2509
Conversation
Three ESP-IDF 6 incompatibilities in the bundled glob-built sources: - src/platforms/esp/32/drivers/gpio_isr_rx/mcpwm_timer.cpp.hpp: soc/mcpwm_periph.h moved to hal/mcpwm_periph.h in IDF 6. Pick the right path with ESP_IDF_VERSION_6_OR_HIGHER. - src/platforms/esp/32/audio/devices/idf5_i2s_context.hpp and src/platforms/esp/32/audio/devices/idf5_pdm_context.hpp: IDF 6 removed the i2s_port_t enum; i2s_chan_config_t::id is now int. Pass config.mI2sNum (already int) directly on IDF 6, keep the explicit static_cast on IDF 5. Include esp_version.h so the new guard always resolves regardless of include order. No behaviour change on IDF 5 or earlier.
ota_impl.cpp.hpp uses mbedtls_sha256_* and mbedtls_md_* APIs across ~10 call sites (digest-auth nonce, password hashing, derived keys, firmware MD5). mbedtls 3.6 / ESP-IDF 6 moved these direct hash APIs to mbedtls/private/ and recommends PSA (psa_hash_*) as the public interface, so the file fails to compile under IDF 6. Gate FL_ESP_OTA_SUPPORTED off on IDF 6+ for now. A proper port to PSA is a separate, larger change.
ESP-IDF 6 trimmed several driver config flag fields. FastLED was unconditionally assigning them, breaking the IDF 6 build. Each removed flag was already being set to 0 (or, for RX loopback, was runtime-controlled but inert by default), so gate the assignments on !ESP_IDF_VERSION_6_OR_HIGHER and emit a warning if a caller asks for behaviour the new driver no longer supports. - mcpwm_capture_channel_config_t::flags: pull_up, pull_down, io_loop_back removed (kept pos_edge / neg_edge / invert_cap_signal). Use gpio_set_pull_mode() / signal routing instead if needed. - rmt_tx_channel_config_t::flags: io_od_mode, io_loop_back removed. Both were 0 here -- defaults still match. - rmt_rx_channel_config_t::flags: io_loop_back removed. Warn instead of silently dropping when caller requested it.
IDF 6 removed io_loop_back not because loopback is unsupported, but because it became implicit: configuring the same GPIO as both TX output and RX input routes the signal internally automatically. Drop the misleading 'not supported' warning and keep the existing 'loopback enabled' notification regardless of IDF version.
ESP-IDF 6 stops implicitly converting int → gpio_num_t. Several LCD bus / panel-IO configs in the I2S LCD_CAM and LCD_SPI drivers assigned raw ints directly, which now fails to compile on the S3 (and any other variant that pulls these drivers in). - i2s_lcd_cam_peripheral_esp.cpp.hpp: cast dc_gpio_num, wr_gpio_num, data_gpio_nums entries; use GPIO_NUM_NC for the unused CS pin. - lcd_spi_peripheral_esp.cpp.hpp: same set of casts (dc_gpio_num defaulting, wr_gpio_num clock, data_gpio_nums), GPIO_NUM_NC for CS. No behaviour change -- GPIO_NUM_NC is the canonical (gpio_num_t)-1 "no pin" sentinel and has been available since IDF 4.x.
The fix commits themselves explain the IDF 6 changes; in-code comments duplicating that context add noise.
📝 WalkthroughWalkthroughThis PR updates multiple ESP32 audio and driver modules to support ESP-IDF v6+ API changes. Changes include conditional I2S channel configuration macros, version-gated peripheral header includes, explicit GPIO type casting for type safety, conditional GPIO flag assignments for newer IDF versions, and restricting OTA support to IDF versions 4–5. ChangesESP-IDF v6 Compatibility Updates
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hi @swoboda1337 — I'm I went through what you shipped here and it's a really clean piece of cross-version compatibility work:
And testing on both IDF 6.0.1 and 5.5.4 via ESPHome with arduino-esp32 as a managed component is exactly the kind of dual-version validation that gives us confidence nothing regressed for existing users. The commit hygiene is excellent too — one logical change per commit, each message explains the why, and the final Contributions like this — surgical, well-tested, well-documented, and forward-thinking with the OTA follow-up note — are exactly what keeps FastLED healthy across the wide ESP-IDF version matrix. Your work was greatly appreciated! 💛 — clud (on behalf of @zackees) |
|
Thanks! |
|
No, thank you! ~Z |
Master doesnt currently compile against ESP-IDF 6.0. Hit these
testing FastLED with ESPHome on IDF 6, all in the bundled glob-built
ESP32 sources. Each fix is gated on
ESP_IDF_VERSION_6_OR_HIGHER;IDF 5 and earlier are unchanged.
Changes
mcpwm_periph.hrelocation — IDF 6 moved this header fromsoc/to
hal/. (drivers/gpio_isr_rx/mcpwm_timer.cpp.hpp)i2s_port_tremoval — IDF 6 dropped the enum;i2s_chan_config_t::idis now
int. Passconfig.mI2sNum(already int) directly on IDF 6.(
audio/devices/idf5_i2s_context.hpp,audio/devices/idf5_pdm_context.hpp)ota_impl.cpp.hppusesmbedtls_sha256_*/
mbedtls_md_*across ~10 call sites. mbedtls 3.6 / IDF 6 movedthese to
mbedtls/private/and recommends PSA as the public API.Gate
FL_ESP_OTA_SUPPORTEDoff on IDF 6 for now; a proper port topsa_hash_*is a separate change.mcpwm_capture_channel_config_t::flags(no morepull_up/pull_down/io_loop_back) and the RMT TX/RX flag structs (no moreio_od_mode/io_loop_back). All were being set to 0 / inert. Loopback is nowimplicit on IDF 6 — same-GPIO TX+RX routes internally without the flag.
gpio_num_tstrict typing — IDF 6 stops implicitint→gpio_num_t. Addstatic_cast<gpio_num_t>(...)for the LCD_CAM /LCD_SPI bus configs; use
GPIO_NUM_NCfor "no pin" instead of-1.(
drivers/i2s/i2s_lcd_cam_peripheral_esp.cpp.hpp,drivers/lcd_spi/lcd_spi_peripheral_esp.cpp.hpp)Testing
Compiled via ESPHome on IDF 6.0.1 and 5.5.4 with arduino-esp32 as
managed component for esp32dev and esp32s3.
Follow-up
PSA-crypto port for
ota_impl.cpp.hppto re-enable OTA on IDF 6.Summary by CodeRabbit