Open
Conversation
Added support for F1 and G4 boards Serial aliased to SerialTinyUSB USB initialisation. task polloing, CDC flushing and DFU bootloader entry added added txt file with lines for boards.txt
## Description Major update to STM32 support introducing STM32WB55 support and a complete overhaul of software DFU entry across supported STM32 families. ## Added - STM32WB55 support (tested on WeAct STM32WB55CGU6) - Support via P-NUCLEO-WB55 and NUCLEO WB55 USB Dongle board definitions - Nucleo-64 board definition support (F1/F4/G4 variants should work) - `dfu_boot_stm32wb.c` for reliable WB55 DFU entry - Additional hardware validation: WeAct STM32G474 and STM32F405 ## Changed - DFU implementation rewritten for reliability: - F1/F4/G4 use direct ROM bootloader jump - WB55 uses magic value in `BKP0R` + `NVIC_SystemReset()` with early Reset_Handler interception - `boards.txt` now requires extra lines to enable 1200bps touch - Updated `boards_txt_additions.txt` with new format and Nucleo_64 entry - Added suggested change to readme to reflect status of this port ## Known Limitations - Generic WB55 board definitions lack proper USB clock configuration and are not supported. Use P-NUCLEO-WB55 or NUCLEO WB55 USB Dongle board definitions. - STM32F1 DFU entry requires further validation on boards with factory bootloader. This release significantly improves stability and expands supported hardware.
There was a problem hiding this comment.
Pull request overview
Extends the STM32 Arduino port to support additional STM32 families (F1/F4/G4/WB) with automatic USB init/task servicing, and introduces a WB-specific DFU entry path via early reset interception.
Changes:
- Auto-detect STM32 family in TinyUSB config and adjust class/buffer defaults.
- Add automatic TinyUSB initialization (
initVariant) and background servicing (HAL_IncTickflag +yield()/serialEventRun()). - Implement WB55 software DFU entry via backup-register “magic” + custom
Reset_Handler, plus documentation updates for STM32duinoboards.txtintegration.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/arduino/ports/stm32/tusb_config_stm32.h | Adds STM32 family autodetection and updates TinyUSB configuration for the STM32 port. |
| src/arduino/ports/stm32/Adafruit_TinyUSB_stm32.cpp | Implements multi-family STM32 USB HW init, automatic init/task pumping, and DFU entry logic. |
| src/arduino/ports/stm32/dfu_boot_stm32wb.c | Adds WB reset-time DFU interception and bootloader jump. |
| src/arduino/ports/stm32/boards_txt_additions.txt | Documents STM32duino boards.txt menu additions needed to enable TinyUSB. |
| README.md | Updates documentation for STM32 and other cores without built-in support. |
Comments suppressed due to low confidence (1)
src/arduino/ports/stm32/boards_txt_additions.txt:22
- The WB55 note says the Nucleo-64 definitions are “covered by the Nucleo_64 entry above”, but the
Nucleo_64.menu.usb.TinyUSB...lines are below this comment in the file. Please fix the wording (“below”) so the instructions are unambiguous.
# Generic WB55 variants lack USB clock configuration and will not enumerate.
# Use the P-NUCLEO-WB55 or NUCLEO WB55 USB Dongle board definition instead
# (covered by the Nucleo_64 entry above). Custom WB55 boards with a 32MHz
# HSE crystal should also work with these definitions.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixed incorrect path to boards_txt_additions.txt Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Set CFG_TUSB_RHPORT0_MODE to include the speed bits Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Addresses PR review comments: - Fix WB55 Nucleo-64 wording in boards_txt_additions.txt - Add build.enable_usb override to prevent duplicate STM32 core USB stack - Correct README path to boards_txt_additions.txt - Fix CFG_TUSB_RHPORT0_MODE to include speed bits - Update TINYUSB_NEED_POLLING_TASK comment to reflect actual scheduling mechanism - Rework HAL_IncTick() override to avoid hard-coded +1 tick increment - Replace naked Reset_Handler C implementation with safe assembly wrapper + C handler No functional changes beyond the requested fixes and clarifications.
485057e to
10363b4
Compare
…fruit_TinyUSB_Arduino into stm32-support-v2
10363b4 to
64b66ff
Compare
Replace `build.usb_flags` with `build.enable_usb` to match existing boards.txt conventions
Contributor
Author
|
Assuming esp32_v2 fail is unrelated like last time? I've submitted pr to STM32 to get boards.txt additions. Next goal is to add F0xx support and then I'm probably done for a while until someone requests something specific, can't keep buying microcontrollers! lol |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request: Full STM32 Support and Reliable DFU Entry
TL;DR
Serialautomatically aliased toSerialTinyUSBBKP0R+NVIC_SystemReset()with earlyReset_Handlerinterceptiondfu_boot_stm32wb.cNotes:
Full Detailed Description
Summary
This PR extends the Adafruit TinyUSB Arduino library to support a broader range of STM32 MCUs and adds reliable software DFU for all supported boards. It consolidates functionality previously implemented in separate updates (v0.2.0 and v0.3.0).
Added
initVariant()HAL_IncTick()override andserialEventRun()hookSerialtoSerialTinyUSBBKP0R), triggersNVIC_SystemReset(), intercepted bydfu_boot_stm32wb.catReset_HandlerChanged
boards.txtentries updated: four lines per board (includinguse_1200bps_touchandwait_for_upload_port)boards_txt_additions.txtupdated to reflect new format and include Nucleo-64 entryTesting
Known Limitations
Notes
Suggested Testing / Validation Checklist
Suggested Testing / Validation Checklist
Serialalias toSerialTinyUSBbehave as expectedboards.txtauto-upload (use_1200bps_touch+wait_for_upload_port) functions correctly