Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.riminfo -whitespace
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@ if (BUILD_EXECUTABLE STREQUAL "unitTest")
add_subdirectory(platforms/posix/bsp/bspEepromDriver/test)
add_subdirectory(platforms/posix/bsp/socketCanTransceiver/test)

elseif (OPENBSW_PLATFORM STREQUAL "stm32")

add_subdirectory(platforms/stm32/unitTest EXCLUDE_FROM_ALL)

add_subdirectory(platforms/stm32/bsp/bspCan/test)
add_subdirectory(platforms/stm32/bsp/bxCanTransceiver/test)
add_subdirectory(platforms/stm32/bsp/fdCanTransceiver/test)
add_subdirectory(platforms/stm32/safety/safeBspMcuWatchdog/test)

elseif (OPENBSW_PLATFORM STREQUAL "s32k1xx")

add_subdirectory(platforms/s32k1xx/unitTest EXCLUDE_FROM_ALL)
Expand Down
80 changes: 80 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,52 @@
"OPENBSW_PLATFORM": "s32k1xx"
}
},
{
"name": "tests-stm32-debug",
"displayName": "Configure for testing STM32 modules (debug)",
"description": "Configure for testing STM32 modules (debug)",
"inherits": "_config-base",
"binaryDir": "${sourceDir}/build/tests/stm32/Debug",
"cacheVariables": {
"CMAKE_DEFAULT_BUILD_TYPE": "Debug",
"CMAKE_CONFIGURATION_TYPES": "Debug",
"BUILD_EXECUTABLE": "unitTest",
"OPENBSW_PLATFORM": "stm32"
}
},
{
"name": "tests-stm32-release",
"displayName": "Configure for testing STM32 modules (release)",
"description": "Configure for testing STM32 modules (release)",
"inherits": "_config-base",
"binaryDir": "${sourceDir}/build/tests/stm32/Release",
"cacheVariables": {
"CMAKE_DEFAULT_BUILD_TYPE": "Release",
"CMAKE_CONFIGURATION_TYPES": "Release",
"BUILD_EXECUTABLE": "unitTest",
"OPENBSW_PLATFORM": "stm32"
}
},
{
"name": "nucleo-g474re-freertos-gcc",
"generator": "Ninja Multi-Config",
"displayName": "NUCLEO-G474RE FreeRTOS configuration (GCC)",
"description": "Configure for NUCLEO-G474RE platform using ARM GCC toolchain",
"inherits": "_config-base",
"toolchainFile": "${sourceDir}/cmake/toolchains/ArmNoneEabi-gcc.cmake",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"BUILD_EXECUTABLE": "referenceApp",
"BUILD_TARGET_PLATFORM": "NUCLEO_G474RE",
"BUILD_TARGET_RTOS": "FREERTOS",
"STM32_CHIP": "STM32G474RE",
"CMAKE_ASM_FLAGS_RELWITHDEBINFO": "-g3",
"CMAKE_CONFIGURATION_TYPES": "RelWithDebInfo;Debug;Release",
"CMAKE_C_FLAGS_RELWITHDEBINFO": "-g3 -O2 -DNDEBUG",
"CMAKE_CXX_FLAGS_RELWITHDEBINFO": "-g3 -O2 -DNDEBUG",
"CMAKE_DEFAULT_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "posix-freertos",
"displayName": "POSIX-FREERTOS compliant configuration",
Expand Down Expand Up @@ -228,6 +274,26 @@
"configurePreset": "tests-s32k1xx-release",
"configuration": "Release"
},
{
"name": "tests-stm32-debug",
"displayName": "Build tests of STM32 modules (debug)",
"description": "Build tests of STM32 modules (debug)",
"configurePreset": "tests-stm32-debug",
"configuration": "Debug"
},
{
"name": "tests-stm32-release",
"displayName": "Build tests of STM32 modules (release)",
"description": "Build tests of STM32 modules (release)",
"configurePreset": "tests-stm32-release",
"configuration": "Release"
},
{
"name": "nucleo-g474re-freertos-gcc",
"displayName": "NUCLEO-G474RE FreeRTOS build (GCC)",
"description": "Build reference application for NUCLEO-G474RE platform with GCC",
"configurePreset": "nucleo-g474re-freertos-gcc"
},
{
"name": "posix-freertos",
"displayName": "build POSIX-FREERTOS",
Expand Down Expand Up @@ -305,6 +371,20 @@
"description": "Run tests of S32K1XX modules (release)",
"configuration": "Release",
"configurePreset": "tests-s32k1xx-release"
},
{
"name": "tests-stm32-debug",
"displayName": "Run tests of STM32 modules (debug)",
"description": "Run tests of STM32 modules (debug)",
"configuration": "Debug",
"configurePreset": "tests-stm32-debug"
},
{
"name": "tests-stm32-release",
"displayName": "Run tests of STM32 modules (release)",
"description": "Run tests of STM32 modules (release)",
"configuration": "Release",
"configurePreset": "tests-stm32-release"
}
]
}
3 changes: 3 additions & 0 deletions NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@ We recommend to read their licenses, as their terms may differ from the terms de
| FreeRTOS Real Time Kernel | 10.6.2 | MIT | ``platforms/posix/3rdparty/freeRtosPosix/LICENSE.md`` |
| FreeRTOS Real Time Kernel | 10.6.2 | MIT | ``platforms/s32k1xx/3rdparty/freertos_cm4_sysTick/LICENSE.md`` |
| FreeRTOS Real Time Kernel | 10.6.2 | MIT | ``libs/3rdparty/freeRtos/LICENSE.md`` |
| FreeRTOS Real Time Kernel | 10.6.2 | MIT | ``platforms/stm32/3rdparty/freertos_cm4_sysTick/LICENSE.md`` |
| ThreadX Kernel | 6.4.3 | MIT | ``libs/3rdparty/threadx/LICENSE.md`` |
| 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 | ``libs/3rdparty/cmsis/LICENSE`` |
| NXP S32K148 Headers | 1.1a | BSD-3 | ``platforms/s32k1xx/bsp/bspMcu/include/3rdparty/nxp/*.h`` |
| ST STM32F4 Device Headers | 2.6.11 | Apache v2 | ``platforms/stm32/bsp/bspMcu/include/3rdparty/st/LICENSE`` |
| ST STM32G4 Device Headers | 1.2.6 | Apache v2 | ``platforms/stm32/bsp/bspMcu/include/3rdparty/st/LICENSE`` |
| CodeCoverage | | BSD-3 | ``cmake/modules/CodeCoverage.cmake`` |

## MISRA
Expand Down
1 change: 1 addition & 0 deletions doc/dev/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ Eclipse OpenBSW is a trademark of the Eclipse Foundation.
modules/common
modules/posix
modules/s32k1xx
modules/stm32
modules/executables
modules/mocks

Expand Down
9 changes: 9 additions & 0 deletions doc/dev/modules/executables.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ S32K148EVB

../../../executables/referenceApp/platforms/s32k148evb/**/doc/index

STM32 Nucleo
++++++++++++

.. toctree::
:maxdepth: 1
:glob:

../../../executables/referenceApp/platforms/nucleo_*/**/doc/index

Safety
++++++

Expand Down
22 changes: 22 additions & 0 deletions doc/dev/modules/stm32.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
..
*******************************************************************************
Copyright (c) 2026 An Dao
This program and the accompanying materials are made available under the
terms of the Apache License Version 2.0 which is available at
https://www.apache.org/licenses/LICENSE-2.0

SPDX-License-Identifier: Apache-2.0
*******************************************************************************

STM32
=====

BSP
---

.. toctree::
:maxdepth: 1
:glob:

../../../platforms/stm32/**/doc/index
11 changes: 11 additions & 0 deletions executables/referenceApp/platforms/nucleo_g474re/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# NUCLEO-G474RE platform for referenceApp

add_subdirectory(bspConfiguration)
add_subdirectory(safety)
add_subdirectory(main)

if (BUILD_TARGET_RTOS STREQUAL "FREERTOS")
add_subdirectory(freeRtosCoreConfiguration)
add_library(freeRtosPort ALIAS freeRtosCm4SysTickPort)
add_library(freeRtosPortImpl ALIAS freeRtosCm4SysTick)
endif ()
46 changes: 46 additions & 0 deletions executables/referenceApp/platforms/nucleo_g474re/Options.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# *******************************************************************************
# Copyright (c) 2026 An Dao
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

set(OPENBSW_PLATFORM
"stm32"
CACHE STRING "" FORCE)
set(STM32_CHIP
"STM32G474RE"
CACHE STRING "" FORCE)
set(BUILD_TARGET_RTOS
"FREERTOS"
CACHE STRING "")
set(PLATFORM_SUPPORT_CAN
ON
CACHE BOOL "" FORCE)
set(PLATFORM_SUPPORT_IO
OFF
CACHE BOOL "" FORCE)
set(PLATFORM_SUPPORT_ETHERNET
OFF
CACHE BOOL "" FORCE)
set(PLATFORM_SUPPORT_TRANSPORT
ON
CACHE BOOL "" FORCE)
set(PLATFORM_SUPPORT_UDS
ON
CACHE BOOL "" FORCE)
set(PLATFORM_SUPPORT_WATCHDOG
OFF
CACHE BOOL "" FORCE)
set(PLATFORM_SUPPORT_MPU
OFF
CACHE BOOL "" FORCE)
set(PLATFORM_SUPPORT_STORAGE
OFF
CACHE BOOL "" FORCE)
set(PLATFORM_SUPPORT_ROM_CHECK
OFF
CACHE BOOL "" FORCE)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
add_library(bspConfiguration src/bsp/stdIo/stdIo.cpp
src/bsp/uart/UartConfig.cpp)

target_include_directories(bspConfiguration PUBLIC include)

target_link_libraries(
bspConfiguration
PUBLIC bspUart
PRIVATE bspMcu platform)
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
..
*******************************************************************************
Copyright (c) 2026 An Dao

This program and the accompanying materials are made available under the
terms of the Apache License Version 2.0 which is available at
https://www.apache.org/licenses/LICENSE-2.0

SPDX-License-Identifier: Apache-2.0
*******************************************************************************

.. _bspconfig_nucleo_g474re:

bspConfiguration - NUCLEO-G474RE
================================

Overview
--------

The ``bspConfiguration`` module contains hardware-specific configuration for the
NUCLEO-G474RE evaluation board. Driver logic is separated from its configuration
so that users can customise a project for different boards or pin assignments
without modifying driver source code.

The STM32G474RE platform exposes a minimal set of BSP peripherals required for
the CAN reference application:

- **bspUart** - USART2 configuration (ST-LINK Virtual COM Port on PA2/PA3).
- **bspStdIo** - Standard I/O bridge that routes ``putByteToStdout`` /
``getByteFromStdin`` through the configured UART instance.

.. note::

Unlike the S32K148EVB reference application, this platform does not include
ADC, PWM, or digital I/O configuration modules because the CAN reference
application does not require analogue inputs or GPIO-driven outputs.
These modules can be added following the same configuration pattern if
a future application requires them.

Hardware Summary
++++++++++++++++

.. csv-table::
:widths: 30, 70
:width: 100%

"MCU", "STM32G474RE (Arm Cortex-M4F, 170 MHz, single-precision FPU)"
"UART peripheral", "USART2 - routed to ST-LINK/V3 Virtual COM Port"
"UART TX pin", "PA2 (AF7)"
"UART RX pin", "PA3 (AF7)"
"UART baud rate", "115 200 baud (BRR = 1476 at 170 MHz APB1)"
"CAN peripheral", "FDCAN1 (configured in CanSystem, not bspConfiguration)"

.. toctree::
:hidden:

user/index
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
..
*******************************************************************************
Copyright (c) 2026 An Dao

This program and the accompanying materials are made available under the
terms of the Apache License Version 2.0 which is available at
https://www.apache.org/licenses/LICENSE-2.0

SPDX-License-Identifier: Apache-2.0
*******************************************************************************

.. _bspConfig_StdIo_G474RE:

bspStdIo
========

Overview
--------

The standard I/O bridge implements the ``putByteToStdout`` and
``getByteFromStdin`` C-linkage functions required by the OpenBSW logging
framework, routing character-level I/O through the UART ``TERMINAL`` instance
configured in :ref:`bspConfig_Uart_G474RE`.

``putByteToStdout(uint8_t byte)`` transmits one byte over USART2 TX (PA2),
blocking by polling until the UART TX register is free.

``getByteFromStdin()`` attempts to read one byte from USART2 RX (PA3) and is
non-blocking: if ``Uart::read()`` reports that no byte was received, it returns
``-1`` (POSIX ``getchar()`` convention); otherwise it returns the byte value
(0-255).

Both functions resolve the UART instance once into a ``static`` local
reference, avoiding a global constructor ordering dependency.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
..
*******************************************************************************
Copyright (c) 2026 An Dao

This program and the accompanying materials are made available under the
terms of the Apache License Version 2.0 which is available at
https://www.apache.org/licenses/LICENSE-2.0

SPDX-License-Identifier: Apache-2.0
*******************************************************************************

.. _bspConfig_Uart_G474RE:

bspUart Configuration
=====================

Overview
--------

The UART configuration defines the hardware parameters for the on-board
ST-LINK Virtual COM Port of the NUCLEO-G474RE. A single UART instance
(``TERMINAL``) is configured for debug logging and interactive console use.

``UartConfig.h`` declares the ``Uart::Id`` enumeration of available UART
instances, and ``UartConfig.cpp`` maps each ``Uart::Id`` to its hardware
parameters and provides the singleton accessor
``bsp::Uart::getInstance(Uart::Id)``.

Configuration
-------------

.. csv-table::
:header: "Parameter", "Value"
:widths: 30, 70
:width: 100%

"Peripheral", "USART2 (APB1)"
"TX pin", "PA2, alternate function AF7"
"RX pin", "PA3, alternate function AF7"
"Baud rate", "115 200 baud"
"BRR", "170 000 000 / 115 200 = 1475.69 -> 1476"

The resulting actual baud rate is 170 MHz / 1476 = 115 176 baud (0.021 % error),
well within the UART tolerance.

.. note::

The UART driver uses polling mode (no DMA, no interrupts). For high-
throughput or latency-sensitive applications, consider extending the
``bspUart`` BSP module with an interrupt-driven or DMA-backed backend.
Loading
Loading