Skip to content

RP2040: Adafruit_TinyUSB_Arduino compiled without USE_TINYUSB, so FastLED Pico sketches fail #1719

Closed

Description

@stevenmunn312-tech

Summary

On RP2040 (Arduino-Pico 4.5.3), fbuild 2.5.44 selects and compiles the core's bundled Adafruit_TinyUSB_Arduino library even though TinyUSB is not the selected USB stack. The build then stops at the library's own guard:

Adafruit_TinyUSB_Arduino/src/arduino/Adafruit_TinyUSB_API.h:50:2: error: #error TinyUSB is not selected, please select it in "Tools->Menu->USB Stack"

This shows up now that #1670 is fixed: boot2 assembles on 2.5.44, and the build gets one step further. Thanks for that fix.

Reproduce

Windows 11, fbuild 2.5.44, FastLED 3.10.8 in lib/FastLED (a clone of the 3.10.8 tag).

platformio.ini:

[env:pico]
platform = raspberrypi
board = pico
framework = arduino

src/main.cpp:

#include <FastLED.h>
CRGB leds[8];
void setup() { FastLED.addLeds<WS2812B, 2, GRB>(leds, 8); }
void loop() { FastLED.show(); }

fbuild build -e pico fails with the error above.

Controls, same environment:

  • A sketch with only #include <Arduino.h> builds (334,608 bytes of flash).
  • A sketch using only IRremote 4.7.1 from lib/ builds.

Likely cause

FastLED's Arduino SD backend includes <SD.h> and <SPI.h>, so the resolver selects the core's SD, SPI and LittleFS libraries. Arduino-Pico adds this block to the top of the sources of its standard libraries, for example libraries/SD/src/SD.cpp:

#ifdef USE_TINYUSB
// For Serial when selecting TinyUSB. ...
#include <Adafruit_TinyUSB.h>
#endif

SPI/src/SPI.cpp and LittleFS/src/LittleFS.cpp contain the same include. USE_TINYUSB is not defined for this environment. It appears that the reconciliation pass in fbuild-library-select, which re-walks each dependent library's full source set, follows that include without honoring the #ifdef. That would select Adafruit_TinyUSB_Arduino and compile all of its sources. #1606 fixed the same class of problem for Bluetooth-only libraries.

If that is right, any Pico sketch that pulls in SPI, SD or LittleFS should hit it, with or without FastLED. I have not built that smaller case.

Expected

Adafruit_TinyUSB_Arduino is selected only when USE_TINYUSB is defined (the TinyUSB USB-stack menu option), as in the Arduino IDE.

Found while rechecking the fbuild legs of Design Studio for FastLED after #1689.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions