Skip to content

Add TinyUSB option to USB support#2906

Open
code-fiasco wants to merge 3 commits intostm32duino:mainfrom
code-fiasco:f4-tinyusb-support
Open

Add TinyUSB option to USB support#2906
code-fiasco wants to merge 3 commits intostm32duino:mainfrom
code-fiasco:f4-tinyusb-support

Conversation

@code-fiasco
Copy link

Summary

Add a TinyUSB USB menu option for Generic STM32F4 boards to improve compatibility with the Adafruit TinyUSB Arduino library.

This PR fixes/implements the following bugs/features

Feature

  • Adds a TinyUSB USB menu option for GenF4 boards in boards.txt
  • Enables ARDUINO_ARCH_TINYUSB via build.usb_flags when selected

Non-breaking

  • Existing USB options and behavior are unchanged unless TinyUSB is explicitly selected

Motivation

I have completed the STM32 port files for the Adafruit TinyUSB Arduino library and a pull request has been submitted upstream to include them after testing.

Without a dedicated USB menu option in the STM32 core, using TinyUSB currently requires sketch-level workarounds or manual defines. Adding a TinyUSB option in boards.txt allows the core to expose the required build flag cleanly and consistently.

This change enables TinyUSB to work across all STM32F4 boards using the Generic core configuration, simplifying usage and improving compatibility.

While this approach could be extended to other STM32 families in the future, testing for this change has currently been limited to an STM32F411 BlackPill board.

Validation

  • CI build passes
  • Tested on STM32F411 BlackPill
  • Verified TinyUSB CDC works without requiring sketch-level #define workarounds

Code formatting

  • No source formatting changes required (boards.txt only)
  • CI AStyle unaffected

Closing issues

  • N/A

Allows user to make use of TinyUSB if using Generic F4 boards.
@fpistm
Copy link
Member

fpistm commented Jan 27, 2026

Hi @code-fiasco
thanks for this PR.
Could you explain how to test, please?

I've planned to add tinyUSB support in the coming month. And also deployed the PluggableUSB from ARduinoCore-API.

@code-fiasco
Copy link
Author

Hi,

Yeah no problem!

You'll want to install the version of the TinyUSB library from this link:
https://github.com/code-fiasco/Adafruit_TinyUSB_Arduino/tree/stm32f4-support

Then using the updated boards.txt you should be able to select 'Adafruit TinyUSB' in the USB Support menu in arduino IDE. With that selected all the TinyUSB examples should work with no further modification.

I've only tested it with an F411 board as that's all I have, but it should work with all F4 boards so do let me know if you test it on anything else. Hoping the port files will be added to the main TinyUSB branch soon.

@code-fiasco
Copy link
Author

Sorry I just realised I haven't given you the actual lines for the boards.txt! All that needs adding to work with that branch of TinyUSB is:

GenF4.menu.usb.TinyUSBMIDI=Adafruit TinyUSB
GenF4.menu.usb.TinyUSBMIDI.build.usb_flags={build.extra_flags} -DARDUINO_ARCH_TINYUSB

@fpistm
Copy link
Member

fpistm commented Jan 27, 2026

No worry. It is in the PR.

@fpistm fpistm marked this pull request as draft February 10, 2026 08:11
@code-fiasco
Copy link
Author

Added support for F1 and G4 as well as F4. Also increased functionality in general. Correct version of TinyUSB at:
https://github.com/code-fiasco/Adafruit_TinyUSB_Arduino/tree/stm32-support-v2

This release adds more lines to boards.txt to extend support for Adafruit TinyUSB library and also adds DFU push functionality using 1200bps touch.

For testing with this branch of the TinyUSB library:
https://github.com/code-fiasco/Adafruit_TinyUSB_Arduino/tree/stm32-support-v2
@code-fiasco
Copy link
Author

Hi, Just letting you know I added more lines to boards.txt to include nucleo-64 boards (F1xx, F4xx, WB55 & some G4xx variants) and implement DFU push with 1200bps touch. I noticed there's no clock config included for the generic WB55 boards, I was thinking of updating this pr to include the one I added but not sure if I should be adding extra things like that or just submit a separate pr?

@code-fiasco code-fiasco marked this pull request as ready for review February 26, 2026 03:08
@fpistm
Copy link
Member

fpistm commented Feb 26, 2026

Thanks for the update.
It is better to add clock config in a separate PR. This one is only for USB TinyUSB thanks Adafruit library.

@code-fiasco
Copy link
Author

code-fiasco commented Feb 26, 2026 via email

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.

2 participants