Skip to content

esp32: default serial IO to io_esp_idf.hpp — make io_arduino.hpp opt-in, drop the <Arduino.h> probe #3720

Closed as not planned

Description

@zackees

Part of #3715.

Problem

src/platforms/esp/32/io_esp.cpp.hpp decides between the IDF serial backend and the Arduino one by probing for the Arduino core:

  • Lines 16–26: FL_HAS_INCLUDE(<Arduino.h>) + ARDUINO_USB_MODE / ARDUINO_USB_CDC_ON_BOOT determine FL_ESP_USE_IDF_SERIAL.
  • Line 35: when FL_ESP_USE_IDF_SERIAL == 0, includes platforms/arduino/io_arduino.hpp — pulling the Arduino Serial object into the print path.

A full IDF-native backend already exists and is battle-tested: io_esp_idf.hpp with detail/io_esp_jtag_or_uart.hpp (runtime USB-Serial-JTAG vs UART selection; see #2665/#2668 history). The Arduino backend survives mainly for the case where the sketch and FastLED must share the Serial object's buffering/CDC state.

Fix

  1. Flip the default: FL_ESP_USE_IDF_SERIAL defaults to 1 on all ESP32 builds. The USB-JTAG-vs-UART decision already lives in detail/io_esp_jtag_or_uart.hpp and does not need <Arduino.h> probing.
  2. io_arduino.hpp routing becomes opt-in (FASTLED_ESP32_ARDUINO_SERIAL=1) for users who need fl::print interleaved with their own Serial writes through Arduino's buffers.
  3. Remove the FL_HAS_INCLUDE(<Arduino.h>) probe from this file.

Risks / compat notes

  • Behavior risk, not compile risk: on Arduino builds with ARDUINO_USB_CDC_ON_BOOT=1, Arduino's CDC console and the IDF driver can contend for the USB-Serial-JTAG peripheral. The detail/io_esp_jtag_or_uart.hpp non-blocking/no-host contract (fl::print: minimal-surface contract — non-blocking on missing CDC host, USJ LL fallback on ESP32 USJ chips #2668) must hold in that configuration — test S3 (USB-OTG CDC) and C3/C6 (USB-Serial-JTAG) explicitly, plus classic ESP32 (UART0-only).
  • IDF version spread: UART driver source_clk handling for 3.x/4.x/5.x already exists in uart_peripheral_esp.cpp.hpp:34-40; the console path should reuse it.

Acceptance criteria

  • fl::print/fl::println output verified on: classic ESP32 (UART0), C6 (USB-Serial-JTAG), S3 (CDC) — under both Arduino and -DFL_NO_ARDUINO compiles.
  • No <Arduino.h> probe remains in io_esp.cpp.hpp.
  • AutoResearch RPC (which depends on serial IO) still works on the bench boards.

Activity

  1. added
    type: feature
    platform: esp32
    area: core
    on Jul 22, 2026
  2. zackees commented on Jul 22, 2026

    @zackees
    MemberAuthor

    Closing without a code change after re-reading io_esp.cpp.hpp closely.

    The original meta-issue audit (based on a broad Explore-agent sweep, not a line-by-line read) characterized this file as probing <Arduino.h> presence and defaulting to Arduino Serial whenever it's found. On closer reading that's not quite right:

    #ifndef FL_ESP_USE_IDF_SERIAL
        #if !FL_HAS_INCLUDE(<Arduino.h>)
            #define FL_ESP_USE_IDF_SERIAL 1  // Arduino not available - use ESP-IDF
        #elif (... USB-CDC-capable chip in device mode without CDC-on-boot ...)
            #define FL_ESP_USE_IDF_SERIAL 1  // Arduino Serial is UART0; use USB-Serial-JTAG
        #else
            #define FL_ESP_USE_IDF_SERIAL 0  // Arduino available - use Arduino Serial by default
        #endif
    #endif

    Flipping this default unconditionally (my original sub-issue draft) would risk regressing the #2665/#2668 hardware bring-up work without the multi-chip hardware validation (classic ESP32 UART0-only, C3/C6 USB-Serial-JTAG, S3 USB-OTG-CDC) that would be needed to prove it safe — for a case that, on inspection, isn't actually broken.

    No code change needed. Closing as already-satisfied; #3715 no longer lists this as required work.

  3. moved this from Triage to Done in FastLED Trackeron Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreplatform: esp32type: feature

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions