Skip to content

Add STM32 BSP peripheral drivers#414

Draft
nhuvaoanh123 wants to merge 3 commits into
eclipse-openbsw:mainfrom
nhuvaoanh123:stm32-pr-2
Draft

Add STM32 BSP peripheral drivers#414
nhuvaoanh123 wants to merge 3 commits into
eclipse-openbsw:mainfrom
nhuvaoanh123:stm32-pr-2

Conversation

@nhuvaoanh123

Copy link
Copy Markdown
Contributor

Purpose of this PR

  • Bugfix
  • New Feature
  • Documentation Update
  • Other

Description

Second PR in the STM32 platform series. Adds the complete low-level BSP layer enabling UART console output, GPIO control, clock initialization, and peripheral support.

Modules added

Module Purpose
bspClock Clock tree init — HSE→PLL for F4 (100 MHz) and G4 (170 MHz)
bspUart USART2 driver with ring buffer, used for VCP console
bspIo GPIO driver — pin mode, AF selection, push-pull/open-drain
bspTimer SysTick system timer for RTOS tick source
bspInterruptsImpl NVIC interrupt management (FreeRTOS + ThreadX variants)
bspAdc ADC peripheral driver
bspEepromDriver Flash-based EEPROM emulation
etlImpl ETL clock/print backends for STM32
bspConfiguration NUCLEO-G474RE board pin mappings

Milestone

CMake configures with all BSP modules included. First UART console output achieved when combined with PR 6 (FreeRTOS board config).

Depends on #413 (PR 1: MCU foundation). PR 2 of 10.

Related Issues

Part of the STM32 platform port series — see #413 for overview.

Breaking Changes

  • Yes
  • No

Test Plan

  1. Configure: CC=arm-none-eabi-gcc CXX=arm-none-eabi-g++ cmake --preset nucleo-g474re-freertos-gcc
  2. Verify all BSP modules are found and configured
  3. Unit tests for UART, Clock, GPIO, ADC, EEPROM come in later PRs

Regression Tests

Have tests been added/updated? [x] Yes — test source files included, runnable with PR 3+ [ ] No

nhuvaoanh123 added a commit to nhuvaoanh123/openbsw that referenced this pull request Mar 30, 2026
Add CAN peripheral drivers for both STM32 CAN controller variants:

- BxCanDevice: Basic Extended CAN controller (STM32F4 family)
- FdCanDevice: Flexible Data-rate CAN controller (STM32G4 family)
- BxCanTransceiver: OpenBSW CAN transceiver adapter for bxCAN
- Unit test infrastructure (unitTest CMakeLists, mock device headers)

The bspCan module uses compile-time chip selection (CAN_TYPE=BXCAN|FDCAN)
to build only the relevant driver. Tests use mock register headers for
host-based verification.

Milestone: `cmake --preset tests-stm32-debug` configures. Tests run in CI Docker.
Depends on eclipse-openbsw#414 (PR 2: BSP drivers). PR 3 of 10.
nhuvaoanh123 pushed a commit to nhuvaoanh123/openbsw that referenced this pull request Mar 30, 2026
Add CAN peripheral drivers for both STM32 CAN controller variants:

- BxCanDevice: Basic Extended CAN controller (STM32F4 family)
- FdCanDevice: Flexible Data-rate CAN controller (STM32G4 family)
- BxCanTransceiver: OpenBSW CAN transceiver adapter for bxCAN
- Unit test infrastructure (unitTest CMakeLists, mock device headers)

The bspCan module uses compile-time chip selection (CAN_TYPE=BXCAN|FDCAN)
to build only the relevant driver. Tests use mock register headers for
host-based verification.

Milestone: `cmake --preset tests-stm32-debug` configures. Tests run in CI Docker.
Depends on eclipse-openbsw#414 (PR 2: BSP drivers). PR 3 of 10.
nhuvaoanh123 added a commit to nhuvaoanh123/openbsw that referenced this pull request Mar 30, 2026
Add CAN peripheral drivers for both STM32 CAN controller variants:

- BxCanDevice: Basic Extended CAN controller (STM32F4 family)
- FdCanDevice: Flexible Data-rate CAN controller (STM32G4 family)
- BxCanTransceiver: OpenBSW CAN transceiver adapter for bxCAN
- Unit test infrastructure (unitTest CMakeLists, mock device headers)

The bspCan module uses compile-time chip selection (CAN_TYPE=BXCAN|FDCAN)
to build only the relevant driver. Tests use mock register headers for
host-based verification.

Milestone: `cmake --preset tests-stm32-debug` configures. Tests run in CI Docker.
Depends on eclipse-openbsw#414 (PR 2: BSP drivers). PR 3 of 10.
nhuvaoanh123 added a commit to nhuvaoanh123/openbsw that referenced this pull request Mar 31, 2026
Add CAN peripheral drivers for both STM32 CAN controller variants:

- BxCanDevice: Basic Extended CAN controller (STM32F4 family)
- FdCanDevice: Flexible Data-rate CAN controller (STM32G4 family)
- BxCanTransceiver: OpenBSW CAN transceiver adapter for bxCAN
- Unit test infrastructure (unitTest CMakeLists, mock device headers)

The bspCan module uses compile-time chip selection (CAN_TYPE=BXCAN|FDCAN)
to build only the relevant driver. Tests use mock register headers for
host-based verification.

Milestone: `cmake --preset tests-stm32-debug` configures. Tests run in CI Docker.
Depends on eclipse-openbsw#414 (PR 2: BSP drivers). PR 3 of 10.
nhuvaoanh123 added a commit to nhuvaoanh123/openbsw that referenced this pull request Mar 31, 2026
Add CAN peripheral drivers for both STM32 CAN controller variants:

- BxCanDevice: Basic Extended CAN controller (STM32F4 family)
- FdCanDevice: Flexible Data-rate CAN controller (STM32G4 family)
- BxCanTransceiver: OpenBSW CAN transceiver adapter for bxCAN
- Unit test infrastructure (unitTest CMakeLists, mock device headers)

The bspCan module uses compile-time chip selection (CAN_TYPE=BXCAN|FDCAN)
to build only the relevant driver. Tests use mock register headers for
host-based verification.

Milestone: `cmake --preset tests-stm32-debug` configures. Tests run in CI Docker.
Depends on eclipse-openbsw#414 (PR 2: BSP drivers). PR 3 of 10.
@nhuvaoanh123 nhuvaoanh123 marked this pull request as draft May 1, 2026 19:16
@nhuvaoanh123 nhuvaoanh123 mentioned this pull request May 1, 2026
6 tasks
@nhuvaoanh123 nhuvaoanh123 changed the title feat(stm32): UART, GPIO, clock, timer, and peripheral BSP drivers Add STM32 BSP peripheral drivers Jun 2, 2026
@nhuvaoanh123 nhuvaoanh123 deleted the stm32-pr-2 branch June 2, 2026 07:48
@nhuvaoanh123 nhuvaoanh123 reopened this Jun 2, 2026
@nhuvaoanh123 nhuvaoanh123 force-pushed the stm32-pr-2 branch 2 times, most recently from 0413810 to 5fd8c07 Compare June 2, 2026 07:59
Import the STM32F4 and STM32G4 CMSIS device headers from
STMicroelectronics' dedicated RIM-tracked repositories. Keep only the
F413 and G474 headers needed by the STM32 MCU foundation and record
the unused upstream headers as RIM ignores.
Add the STM32 platform entry point, chip CMake files, bspMcu startup
code, a software reset wrapper, and the STM32 unit-test presets. The
platform reuses the shared CMSIS core from libs/3rdparty/cmsis
instead of carrying a local copy.
Add STM32 BSP modules for clock, UART, GPIO, timer, ADC, and EEPROM,
plus interrupt handling primitives and the ETL platform glue.
@rolandreichweinbmw

Copy link
Copy Markdown
Contributor

Now that #413 is merged, you can continue with this one, resolving the current merge conflicts.

Thanks for your contribution and sorry for the delay!

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