Skip to content

feat(stm32): bxCAN/FDCAN device drivers and CAN transceiver#415

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

feat(stm32): bxCAN/FDCAN device drivers and CAN transceiver#415
nhuvaoanh123 wants to merge 4 commits into
eclipse-openbsw:mainfrom
nhuvaoanh123:stm32-pr-3

Conversation

@nhuvaoanh123
Copy link
Copy Markdown

Purpose of this PR

  • Bugfix
  • New Feature
  • Documentation Update
  • Other

Description

Third PR in the STM32 platform series. Adds CAN peripheral device drivers and the bxCAN transceiver adapter.

Modules added

Module Purpose
bspCan Low-level CAN device drivers — BxCanDevice (F4) and FdCanDevice (G4)
bxCanTransceiver OpenBSW ICanTransceiver adapter for bxCAN peripheral
unitTest STM32-specific unit test cmake infrastructure

Architecture

  • bspCan/CMakeLists.txt uses CAN_TYPE to select the correct driver at compile time
  • BxCanDevice: 3 TX mailboxes, 28 filter banks, hardware FIFO with overrun detection
  • FdCanDevice: 3 TX FIFO slots, 28 standard + 8 extended filters, FD frame support
  • Unit tests use mock register headers (test/include/mcu/mcu.h) for host-based verification

Milestone

cmake --preset tests-stm32-debug configures successfully. Unit tests (BxCanDeviceTest, BxCanTransceiverTest) run in CI Docker environment.

Depends on #414 (PR 2: BSP drivers). PR 3 of 10.

Related Issues

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

Breaking Changes

  • Yes
  • No

Test Plan

  1. Configure unit tests: cmake --preset tests-stm32-debug
  2. Build and run: cmake --build --preset tests-stm32-debug && ctest --preset tests-stm32-debug
  3. Tests: BxCanDeviceTest, BxCanTransceiverTest, BxCanTransceiverIntegrationTest

Regression Tests

Have tests been added/updated? [x] Yes — BxCanDeviceTest, FdCanDeviceTest, BxCanTransceiverTest [ ] No

nhuvaoanh123 added a commit to nhuvaoanh123/openbsw that referenced this pull request Mar 30, 2026
Add the FdCanTransceiver module — OpenBSW ICanTransceiver adapter for
STM32G4 FDCAN peripheral. Mirrors the bxCAN transceiver from PR 3 but
supports FD frames (up to 64-byte payload) and extended filter banks.

- FdCanTransceiver: ICanTransceiver implementation for FDCAN
- Unit tests with mock FdCanDevice headers for host verification
- Updated bsp/CMakeLists.txt for CAN_TYPE-based transceiver selection

Milestone: `cmake --preset tests-stm32-debug` configures with both transceivers.
Depends on eclipse-openbsw#415 (PR 3: bxCAN/FDCAN drivers). PR 4 of 10.
nhuvaoanh123 pushed a commit to nhuvaoanh123/openbsw that referenced this pull request Mar 30, 2026
Add the FdCanTransceiver module — OpenBSW ICanTransceiver adapter for
STM32G4 FDCAN peripheral. Mirrors the bxCAN transceiver from PR 3 but
supports FD frames (up to 64-byte payload) and extended filter banks.

- FdCanTransceiver: ICanTransceiver implementation for FDCAN
- Unit tests with mock FdCanDevice headers for host verification
- Updated bsp/CMakeLists.txt for CAN_TYPE-based transceiver selection

Milestone: `cmake --preset tests-stm32-debug` configures with both transceivers.
Depends on eclipse-openbsw#415 (PR 3: bxCAN/FDCAN drivers). PR 4 of 10.
…ker scripts

Add the STM32 platform skeleton for OpenBSW, supporting both STM32F4 (bxCAN)
and STM32G4 (FDCAN) families via chip selection cmake variables.

Contents:
- ARM CMSIS-Core headers (Cortex-M4) with Apache-2.0 license
- ST device headers for STM32F413ZH and STM32G474RE
- GNU AS startup files and linker scripts for both chips
- Chip-selection cmake modules (stm32f413zh.cmake, stm32g474re.cmake)
- CMakePresets for NUCLEO-G474RE and NUCLEO-F413ZH (FreeRTOS + ThreadX)
- Platform integration in root CMakeLists.txt

Milestone: `cmake --preset nucleo-g474re-freertos-gcc` configures successfully.
This is PR 1 of 10 — subsequent PRs add BSP drivers, RTOS config, and UDS services.
nhuvaoanh123 added a commit to nhuvaoanh123/openbsw that referenced this pull request Mar 30, 2026
Add the FdCanTransceiver module — OpenBSW ICanTransceiver adapter for
STM32G4 FDCAN peripheral. Mirrors the bxCAN transceiver from PR 3 but
supports FD frames (up to 64-byte payload) and extended filter banks.

- FdCanTransceiver: ICanTransceiver implementation for FDCAN
- Unit tests with mock FdCanDevice headers for host verification
- Updated bsp/CMakeLists.txt for CAN_TYPE-based transceiver selection

Milestone: `cmake --preset tests-stm32-debug` configures with both transceivers.
Depends on eclipse-openbsw#415 (PR 3: bxCAN/FDCAN drivers). PR 4 of 10.
nhuvaoanh123 added a commit to nhuvaoanh123/openbsw that referenced this pull request Mar 31, 2026
Add the FdCanTransceiver module — OpenBSW ICanTransceiver adapter for
STM32G4 FDCAN peripheral. Mirrors the bxCAN transceiver from PR 3 but
supports FD frames (up to 64-byte payload) and extended filter banks.

- FdCanTransceiver: ICanTransceiver implementation for FDCAN
- Unit tests with mock FdCanDevice headers for host verification
- Updated bsp/CMakeLists.txt for CAN_TYPE-based transceiver selection

Milestone: `cmake --preset tests-stm32-debug` configures with both transceivers.
Depends on eclipse-openbsw#415 (PR 3: bxCAN/FDCAN drivers). PR 4 of 10.
nhuvaoanh123 and others added 3 commits March 31, 2026 14:26
- Change .fpu softvfp → fpv4-sp-d16 in both startup files to match
  the toolchain's -mfloat-abi=hard -mfpu=fpv4-sp-d16 flags. The
  mismatch produced conflicting ELF float ABI attributes.

- Add FPU CP10/CP11 enable block to F413 startup (was only in G474).
  Both are Cortex-M4F; ThreadX needs early FPU access since it does
  not enable the FPU in its port (unlike FreeRTOS port.c).

- Add OPENBSW_PLATFORM=stm32 branch to root CMakeLists.txt so the
  tests-stm32-debug preset no longer hits FATAL_ERROR at configure.
  Add platforms/stm32/unitTest/ stub (mirrors s32k1xx pattern).

- Add ST BSD-3-Clause LICENSE file under 3rdparty/st/ for vendor
  header compliance — the headers reference a LICENSE file that was
  missing.

- Remove dead bspMcu/linker/ scripts and STM32_LINKER_SCRIPT cmake
  variables. The real linker scripts live in each board's
  referenceApp/platforms/*/main/linkerscript/application.ld, wired
  via PROP_LINKER_SCRIPT on the startUp INTERFACE library.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add the complete low-level BSP layer for STM32F4/G4 platforms:

- bspClock: Clock configuration for F4 (100 MHz HSE) and G4 (170 MHz PLL)
- bspUart: USART2 driver with DMA-ready ring buffer, VCP console output
- bspIo: GPIO driver with pin configuration (AF, push-pull, speed)
- bspTimer: SysTick-based system timer for RTOS tick and delays
- bspInterruptsImpl: NVIC interrupt enable/disable (FreeRTOS + ThreadX variants)
- bspAdc: ADC driver for analog inputs
- bspEepromDriver: Flash-based EEPROM emulation
- etlImpl: ETL clock and print backends for STM32
- bspConfiguration: NUCLEO-G474RE board pin mappings (UART, LED, etc.)

Milestone: cmake configures with all BSP modules. Boots to UART console with PR 6 (RTOS).
Depends on PR 1 (MCU foundation). PR 2 of 10.
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 the FdCanTransceiver module — OpenBSW ICanTransceiver adapter for
STM32G4 FDCAN peripheral. Mirrors the bxCAN transceiver from PR 3 but
supports FD frames (up to 64-byte payload) and extended filter banks.

- FdCanTransceiver: ICanTransceiver implementation for FDCAN
- Unit tests with mock FdCanDevice headers for host verification
- Updated bsp/CMakeLists.txt for CAN_TYPE-based transceiver selection

Milestone: `cmake --preset tests-stm32-debug` configures with both transceivers.
Depends on eclipse-openbsw#415 (PR 3: bxCAN/FDCAN drivers). PR 4 of 10.
@nhuvaoanh123 nhuvaoanh123 marked this pull request as draft May 1, 2026 19:16
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