Skip to content

Add TinyUSB serial library support - #162

Open
twhiston wants to merge 1 commit into
CNMAT:masterfrom
twhiston:TinyUSB-support
Open

Add TinyUSB serial library support#162
twhiston wants to merge 1 commit into
CNMAT:masterfrom
twhiston:TinyUSB-support

Conversation

@twhiston

Copy link
Copy Markdown

Adds a check to enable TinyUSB support for SlipEncodedSerial.h

adrianfreed added a commit that referenced this pull request Aug 4, 2026
Several cores offer a "USB Stack: TinyUSB" menu option, and with it selected
Serial is an Adafruit_USBD_CDC rather than the core's own class. The include
ladder still pulled in the core's USB header, which redeclares Serial:

  adafruit:samd:adafruit_feather_m0:usbstack=tinyusb
    USBAPI.h:189: error: conflicting declaration 'Serial_ Serial'
  rp2040:rp2040:rpipico:usbstack=tinyusb
    SerialUSB.h:87: error: conflicting declaration 'SerialUSB Serial'

Both measured on HEAD before this commit and passing after. Controls that
must not move, all PASS both ways: gemma_m0, rpipico with the default
stack, teensy40, leonardo, esp32.

twhiston's PR #162 identified this and put a USE_TINYUSB branch first in
the ladder, which is the right shape. It is not merged as sent, for two
reasons found by building it:

 - It includes <Adafruit_USBD_CDC.h>. That is the header declaring the
   class, but it lives in .../Adafruit_TinyUSB_Arduino/src/arduino, which
   the cores add with a raw -I. arduino-cli's library resolver never sees
   it, so the TinyUSB library is never linked and every target board dies
   at "undefined reference to Adafruit_USBD_CDC::begin". Including
   <Adafruit_TinyUSB.h> instead is what makes the resolver pull the
   library in -- the same trap 46789e6 hit on nRF52.
 - Adafruit's nRF52 core defines -DUSE_TINYUSB unconditionally, so as sent
   the new branch shadowed the ARDUINO_NRF52_ADAFRUIT arm that 46789e6
   added to make that board link, turning feather52840 from PASS to a link
   failure.

Using the resolver-visible header fixes the targeted boards and leaves
nRF52 working, so the nRF52 arm is now redundant but harmless.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant