feat(stm32): MCU foundation — CMSIS, device headers, startup, linker#413
feat(stm32): MCU foundation — CMSIS, device headers, startup, linker#413nhuvaoanh123 wants to merge 5 commits into
Conversation
b993d73 to
21c4538
Compare
…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.
21c4538 to
2818dbf
Compare
There was a problem hiding this comment.
Pull request overview
Introduces the initial STM32 Cortex‑M4 platform foundation for OpenBSW (NUCLEO‑G474RE and NUCLEO‑F413ZH), including CMSIS/ST device headers, startup code, linker scripts, and CMake integration/presets for cross-compiling.
Changes:
- Adds STM32 platform selection + per-chip CMake configuration modules (STM32F413ZH / STM32G474RE).
- Adds
bspMcuwith CMSIS/ST headers, startup assembly, linker scripts, and a software reset wrapper. - Adds STM32 CMake presets and root build integration for the new STM32 platforms.
Reviewed changes
Copilot reviewed 31 out of 34 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| platforms/stm32/CMakeLists.txt | Adds STM32 platform entrypoint and chip selection via STM32_CHIP. |
| platforms/stm32/cmake/stm32g474re.cmake | Defines STM32G474RE chip parameters and paths to startup/linker artifacts. |
| platforms/stm32/cmake/stm32f413zh.cmake | Defines STM32F413ZH chip parameters and paths to startup/linker artifacts. |
| platforms/stm32/bsp/CMakeLists.txt | Adds STM32 BSP subtree (currently only bspMcu). |
| platforms/stm32/bsp/bspMcu/startup/startup_stm32g474xx.s | Startup/reset handler + vector table for STM32G474xx. |
| platforms/stm32/bsp/bspMcu/startup/startup_stm32f413xx.s | Startup/reset handler + vector table for STM32F413xx. |
| platforms/stm32/bsp/bspMcu/src/reset/softwareSystemReset.cpp | Adds software-triggered system reset wrapper with weak pre-reset hook. |
| platforms/stm32/bsp/bspMcu/module.spec | Declares module metadata. |
| platforms/stm32/bsp/bspMcu/linker/STM32G474RExx_FLASH.ld | Linker script for STM32G474RE flash/RAM layout. |
| platforms/stm32/bsp/bspMcu/linker/STM32F413ZHxx_FLASH.ld | Linker script for STM32F413ZH flash/RAM layout. |
| platforms/stm32/bsp/bspMcu/include/reset/softwareSystemReset.h | Public header for software reset API. |
| platforms/stm32/bsp/bspMcu/include/mcu/typedefs.h | Adds NVIC convenience macro mappings. |
| platforms/stm32/bsp/bspMcu/include/mcu/mcu.h | Single include point for chip headers + platform interrupt macros. |
| platforms/stm32/bsp/bspMcu/include/3rdparty/st/stm32g4/system_stm32g4xx.h | Imports ST system header for G4 family. |
| platforms/stm32/bsp/bspMcu/include/3rdparty/st/stm32g4/stm32g4xx.h | Imports ST device-family header for G4. |
| platforms/stm32/bsp/bspMcu/include/3rdparty/st/stm32f4/system_stm32f4xx.h | Imports ST system header for F4 family. |
| platforms/stm32/bsp/bspMcu/include/3rdparty/st/stm32f4/stm32f4xx.h | Imports ST device-family header for F4. |
| platforms/stm32/bsp/bspMcu/include/3rdparty/cmsis/m-profile/cmsis_gcc_m.h | Imports CMSIS compiler support header (GCC, M-profile). |
| platforms/stm32/bsp/bspMcu/include/3rdparty/cmsis/m-profile/cmsis_clang_m.h | Imports CMSIS compiler support header (Clang, M-profile). |
| platforms/stm32/bsp/bspMcu/include/3rdparty/cmsis/m-profile/armv7m_mpu.h | Imports CMSIS MPU API for Armv7‑M. |
| platforms/stm32/bsp/bspMcu/include/3rdparty/cmsis/LICENSE | Adds Apache-2.0 license text for CMSIS import. |
| platforms/stm32/bsp/bspMcu/include/3rdparty/cmsis/cmsis_version.h | Imports CMSIS version header. |
| platforms/stm32/bsp/bspMcu/include/3rdparty/cmsis/cmsis_gcc.h | Imports CMSIS GCC compiler abstraction header. |
| platforms/stm32/bsp/bspMcu/include/3rdparty/cmsis/cmsis_compiler.h | Imports CMSIS compiler selection header. |
| platforms/stm32/bsp/bspMcu/include/3rdparty/cmsis/cmsis_clang.h | Imports CMSIS Clang compiler abstraction header. |
| platforms/stm32/bsp/bspMcu/doc/index.rst | Adds module documentation for the STM32 MCU foundation layer. |
| platforms/stm32/bsp/bspMcu/CMakeLists.txt | Defines bspMcu library and includes/compile defs for STM32. |
| executables/referenceApp/platforms/nucleo_g474re/Options.cmake | Adds referenceApp options for NUCLEO‑G474RE. |
| executables/referenceApp/platforms/nucleo_g474re/CMakeLists.txt | Adds placeholder board CMakeLists. |
| CMakePresets.json | Adds STM32 build/test presets (boards × RTOS). |
| CMakeLists.txt | Adds STM32 platform detection for selecting platforms/stm32 and Rust target. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- 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>
76aa238 to
8dfaa91
Compare
| | ThreadX Cortex M4 Port | 6.4.3 | MIT | ``platforms/s32k1xx/3rdparty/threadx/LICENSE.md`` | | ||
| | ThreadX Linux Port | 6.4.3 | MIT | ``platforms/posix/3rdparty/threadx/LICENSE.md`` | | ||
| | CMSIS | 6.1.0 | Apache v2 | ``platforms/s32k1xx/bsp/bspMcu/include/3rdparty/cmsis/LICENSE`` | | ||
| | CMSIS | 6.1.0 | Apache v2 | ``platforms/stm32/bsp/bspMcu/include/3rdparty/cmsis/LICENSE`` | |
There was a problem hiding this comment.
Is this another copy of the same Cortex-M CMSIS as in s32k1xx? Shouldn't it be factored out, then? E.g. to libs/3rdparty ?
| } | ||
| }, | ||
| { | ||
| "name": "nucleo-f413zh-freertos-gcc", |
There was a problem hiding this comment.
cmake --preset nucleo-f412zh-freertos-gcc -DCMAKE_CXX_STANDARD=17
cmake --build --preset nucleo-f413zh-freertos-gcc --verbose
gives me:
CMake Error at CMakeLists.txt:41 (include):
include could not find requested file:
executables/referenceApp/platforms/nucleo_f413zh/Options.cmake
I understand that you intend to add this other board in another PR. Consider merging them to make it testable. Or better refactor between the PRs.
| } | ||
| }, | ||
| { | ||
| "name": "nucleo-g474re-freertos-gcc", |
There was a problem hiding this comment.
cmake --preset nucleo-g474re-freertos-gcc -DCMAKE_CXX_STANDARD=17
cmake --build --preset nucleo-g474re-freertos-gcc --verbose
gives me:
In file included from /home/rr/openbsw/libs/3rdparty/freeRtos/include/FreeRTOS.h:64,
from /home/rr/openbsw/libs/3rdparty/freeRtos/src/croutine.c:29:
/home/rr/openbsw/libs/bsw/asyncFreeRtos/freeRtosConfiguration/FreeRTOSConfig.h:82:10: fatal error: os/FreeRtosPlatformConfig.h: No such file or directory
82 | #include "os/FreeRtosPlatformConfig.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Add restructured PR split plan addressing reviewer feedback: - CMSIS shared library as separate prep PR - Presets ship only with their scaffolding - Tests CMake-registered in the PR that introduces them - HIL boot-smoke gates for PRs 6-8 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Thank you for the review.
Full restructured plan: We'll rebase the series to match and update the PRs. |
- PR 0 now includes full impact analysis: 6 files touched, what changes, what doesn't, dead code path identified - Fix test coverage table: current vs target state - Fix cross-doc consistency for transceiver and safety test registration Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Are you still planning to provide the PR 0, and update the others, as documented there? OTOH, you can also convert the PRs to "draft" for now, and in the beginning of collaboration in this project, first work on one of the smaller tasks under "issues". |
|
Yes, sticking with the plan. Starting with PR 0 (CMSIS move to |
|
Hi @rolandreichweinbmw — PR 0 is now open as #445 (cmake-format CI cleared via Marking #414–422 as draft for now while #445 is in review, per your suggestion. |
Purpose of this PR
Description
First PR in a 10-part series adding STM32 Cortex-M4 platform support to OpenBSW.
This PR establishes the MCU foundation layer for two STM32 Nucleo boards:
What's included
startup_stm32f413xx.s,startup_stm32g474xx.s)stm32f413zh.cmake,stm32g474re.cmake)CMakeLists.txtintegration for STM32 platform detectionMilestone
cmake --preset nucleo-g474re-freertos-gccconfigures successfully with ARM GCC cross-compiler.Series overview
Related Issues
Continues the STM32 platform port discussed in #408 (closed, now split into reviewable PRs).
Breaking Changes
Test Plan
CC=arm-none-eabi-gcc CXX=arm-none-eabi-g++ cmake --preset nucleo-g474re-freertos-gcclibs/bsw/changes)Regression Tests
Have tests been added/updated? [ ] Yes [x] No — unit tests come in PRs 3–4