cpu/stm32: add STM32U3 peripheral driver support#22428
Open
itsadarshnair wants to merge 6 commits into
Open
Conversation
added 6 commits
June 29, 2026 00:18
Add the STM32U3 (Cortex-M33) family to the STM32 CPU support: CPU_FAM detection and line/RAM/ROM info, CMSIS header selection, Kconfig family and model definitions, and the cpu_stm32u3 feature. Clock bring-up uses the MSI oscillator to reach high SYSCLK (no PLL needed); FLASH wait states are connected to the ACR register. Core register fixups (APB3, AHB1ENR1/2, FLASH key, CLOCK_LSI) are added so the family compiles.
Wire up GPIO (incl. EXTI/SYSCFG for external interrupts) and the UART/LPUART driver for STM32U3, including LPUART clock routing.
Add the Nucleo-U385RG-Q board with the minimum to boot: CPU/clock selection, LED/button, timer, and the UART/LPUART serial console. Additional peripherals are added in a follow-up.
OpenOCD does not yet support the STM32U3, so note the STM32CubeProgrammer CLI workflow as the interim way to flash the board.
Add STM32U3 support to the shared STM32 peripheral drivers: - ADC: rename adc_f3_h7.c -> adc_f3_h7_u3.c and add the U3 path - SPI: continuous-mode fix for last-frame truncation - I2C: APB1 routing and register fixups - USB: DRD FS support in usbdev_fs - HWRNG, VBAT, RTC: whitelist/route the U3 family - flashpage: page size / write block / FLASH key for U3
Declare and configure the remaining peripherals on the board: ADC, I2C, PWM, RTC, SPI, and USB device (pins, instances, and FEATURES_PROVIDED).
|
Hey @itsadarshnair, thank you for your first contribution! We really appreciate it! If you haven't already, please take a look at our contributing guidelines before the review process starts. Also, due to how the GitHub review system works, please avoid force-pushing or squashing your commits unless asked to by a maintainer (or unless your commit is still in "draft commit" stage). Lastly, make sure to comply with our AI Policy when using AI. Your pull request will be reviewed as soon as possible. |
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.
Contribution description
Follow-up to the STM32U3 / NUCLEO-U385RG-Q bring-up (#), stacked on
that PR. It adds the remaining MCU peripherals on top of the bring-up base.
Peripherals added (drivers in
cpu/stm32, board wiring inboards/nucleo-u385rg-q):(continuous mode + CSUSP). Verified on hardware via loopback test.
is selected so program/erase does not raise PGSERR.
adc_f3_h7.crenamed toadc_f3_h7_u3.cand extended with the U3 path;ADC1 on Arduino A0–A5 plus internal VREFINT.
usbdev_fs(D+/D− on PA12/PA11).Warning
ADC, I2C, and USB are work-in-progress: they are configured and compile, but
still have known bugs and are not yet verified on hardware. They are included here
so the board configuration is complete and to allow collaborative debugging, but
should be treated as experimental until fixed and tested.
Testing procedure
Note
Depends on # — review/merge that first. Flashing uses
STM32CubeProgrammer (OpenOCD does not yet support the STM32U3); see the bring-up
PR / board
doc.mdfor the exact command.Compiled for the NUCLEO-U385RG-Q:
cd tests/periph/spi && make BOARD=nucleo-u385rg-q
cd tests/periph/pwm && make BOARD=nucleo-u385rg-q
cd tests/periph/rtc && make BOARD=nucleo-u385rg-q
cd tests/periph/flashpage && make BOARD=nucleo-u385rg-q
cd tests/periph/adc && make BOARD=nucleo-u385rg-q
cd tests/periph/i2c && make BOARD=nucleo-u385rg-q
cd examples/advanced/usbus_minimal && make BOARD=nucleo-u385rg-q
Per-peripheral status:
How to confirm it's not in master: these peripherals are not provided by the board
on
master(the board andstm32u3family don't exist there); after this Pmake BOARD=nucleo-u385rg-qbuilds the apps above. The "working" peripherals behaveas their tests expect; ADC/I2C/USB still need fixes (see below).
Issues/PRs references
Depends on #22427 (initial bring-up). Together these two PRs supersede
the original #22175.Do not merge until #22427 is merged
Declaration of AI-Tools / LLMs usage:
AI-Tools / LLMs that were used are: