# stmicroelectronics/stm32cubeg4 architecture

> Architecture diagram of the GitHub repository stmicroelectronics/stm32cubeg4, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/stmicroelectronics/stm32cubeg4
- Repository: https://github.com/stmicroelectronics/stm32cubeg4

## Overview

STM32CubeG4 is an embedded firmware package for STM32G4 boards, not a single application. The principal workflow is for an engineer to choose a board-specific project, run its firmware on the target, and observe the demonstrated peripheral or application behavior. The README documents CMSIS, HAL/LL, BSP, middleware, and board projects as package capabilities; the supplied tree and excerpts show selected examples, DSP/controller code, and storage integrations. Several documented subsystems are represented at their available directory paths because their implementation was not sampled.

Main entry points: [`Projects/NUCLEO-G431KB/Templates/Src/main.c`](https://github.com/stmicroelectronics/stm32cubeg4/blob/master/Projects/NUCLEO-G431KB/Templates/Src/main.c) (Board templates), [`Projects/NUCLEO-G431RB/Examples_LL/ADC`](https://github.com/stmicroelectronics/stm32cubeg4/tree/master/Projects/NUCLEO-G431RB/Examples_LL/ADC) (ADC examples), [`Projects/NUCLEO-G431RB/Examples_LL/I2C`](https://github.com/stmicroelectronics/stm32cubeg4/tree/master/Projects/NUCLEO-G431RB/Examples_LL/I2C) (I2C examples), [`Projects/B-G474E-DPOW1/Applications/Digital_Power`](https://github.com/stmicroelectronics/stm32cubeg4/tree/master/Projects/B-G474E-DPOW1/Applications/Digital_Power) (Digital power)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_platform["Platform layers"]
  node_cmsiscore["CMSIS core"]
  node_haldrivers["HAL and LL"]
  node_bsp["Board support"]
end

subgraph group_examples["Board projects"]
  node_templates["Board templates<br/>[main.c]"]
  node_adcexamples["ADC examples"]
  node_i2cexamples["I2C examples"]
  node_freertos["FreeRTOS examples"]
end

subgraph group_applications["Applications"]
  node_digitalpower["Digital power"]
  node_powerdemo["Power demonstrations"]
  node_usbmsc["USB mass storage<br/>[usbd_storage_if.c]"]
  node_evalstorage["Demo storage<br/>[k_storage.c]"]
end

subgraph group_libraries["Libraries and middleware"]
  node_dsp["CMSIS-DSP<br/>[arm_math.h]"]
  node_dspcontrollers["DSP controllers"]
  node_dspvalidation["DSP test suite"]
  node_middleware["Middleware libraries"]
end

node_engineer(("Firmware engineer"))
node_g4boards{{"STM32G4 boards"}}

node_engineer -.->|"selects project"| node_templates
node_engineer -.->|"selects example"| node_adcexamples
node_engineer -.->|"selects example"| node_i2cexamples
node_engineer -.->|"selects application"| node_digitalpower
node_templates -->|"runs on"| node_g4boards
node_adcexamples -->|"runs on"| node_g4boards
node_i2cexamples -->|"runs on"| node_g4boards
node_digitalpower -->|"runs on"| node_g4boards
node_powerdemo -->|"runs on"| node_g4boards
node_usbmsc -->|"runs on"| node_g4boards
node_dspcontrollers -->|"implements functions"| node_dsp
node_dspvalidation -.->|"exercises"| node_dsp
node_evalstorage -.->|"uses storage stack"| node_middleware

click node_cmsiscore "https://github.com/stmicroelectronics/stm32cubeg4/tree/master/Drivers/CMSIS/Core"
click node_haldrivers "https://github.com/stmicroelectronics/stm32cubeg4/tree/master/Drivers"
click node_bsp "https://github.com/stmicroelectronics/stm32cubeg4/tree/master/Drivers/BSP/Adafruit_Shield"
click node_templates "https://github.com/stmicroelectronics/stm32cubeg4/blob/master/Projects/NUCLEO-G431KB/Templates/Src/main.c"
click node_adcexamples "https://github.com/stmicroelectronics/stm32cubeg4/tree/master/Projects/NUCLEO-G431RB/Examples_LL/ADC"
click node_i2cexamples "https://github.com/stmicroelectronics/stm32cubeg4/tree/master/Projects/NUCLEO-G431RB/Examples_LL/I2C"
click node_freertos "https://github.com/stmicroelectronics/stm32cubeg4/tree/master/Projects/NUCLEO-G431KB/Applications/FreeRTOS"
click node_digitalpower "https://github.com/stmicroelectronics/stm32cubeg4/tree/master/Projects/B-G474E-DPOW1/Applications/Digital_Power"
click node_powerdemo "https://github.com/stmicroelectronics/stm32cubeg4/tree/master/Projects/B-G474E-DPOW1/Demonstrations"
click node_usbmsc "https://github.com/stmicroelectronics/stm32cubeg4/blob/master/Projects/STM32G474E-EVAL/Applications/USB_Device/MSC_Standalone/USB_Device/App/usbd_storage_if.c"
click node_evalstorage "https://github.com/stmicroelectronics/stm32cubeg4/blob/master/Projects/STM32G474E-EVAL/Demonstrations/Core/Src/k_storage.c"
click node_dsp "https://github.com/stmicroelectronics/stm32cubeg4/blob/master/Drivers/CMSIS/DSP/Include/arm_math.h"
click node_dspcontrollers "https://github.com/stmicroelectronics/stm32cubeg4/blob/master/Drivers/CMSIS/DSP/Source/ControllerFunctions/ControllerFunctions.c"
click node_dspvalidation "https://github.com/stmicroelectronics/stm32cubeg4/blob/master/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/src/controller_tests/controller_test_common_data.c"
click node_middleware "https://github.com/stmicroelectronics/stm32cubeg4/tree/master/Drivers"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cmsiscore,node_haldrivers,node_bsp toneBlue
class node_templates,node_adcexamples,node_i2cexamples,node_freertos toneAmber
class node_digitalpower,node_powerdemo,node_usbmsc,node_evalstorage toneMint
class node_dsp,node_dspcontrollers,node_dspvalidation,node_middleware toneRose
class node_engineer,node_g4boards toneIndigo
```

## Components

### Platform layers

- [CMSIS core](https://github.com/stmicroelectronics/stm32cubeg4/tree/master/Drivers/CMSIS/Core): `Drivers/CMSIS/Core`
- [HAL and LL](https://github.com/stmicroelectronics/stm32cubeg4/tree/master/Drivers): `Drivers`
- [Board support](https://github.com/stmicroelectronics/stm32cubeg4/tree/master/Drivers/BSP/Adafruit_Shield): `Drivers/BSP/Adafruit_Shield`

### Board projects

- [Board templates](https://github.com/stmicroelectronics/stm32cubeg4/blob/master/Projects/NUCLEO-G431KB/Templates/Src/main.c): `Projects/NUCLEO-G431KB/Templates/Src/main.c`
- [ADC examples](https://github.com/stmicroelectronics/stm32cubeg4/tree/master/Projects/NUCLEO-G431RB/Examples_LL/ADC): `Projects/NUCLEO-G431RB/Examples_LL/ADC`
- [I2C examples](https://github.com/stmicroelectronics/stm32cubeg4/tree/master/Projects/NUCLEO-G431RB/Examples_LL/I2C): `Projects/NUCLEO-G431RB/Examples_LL/I2C`
- [FreeRTOS examples](https://github.com/stmicroelectronics/stm32cubeg4/tree/master/Projects/NUCLEO-G431KB/Applications/FreeRTOS): `Projects/NUCLEO-G431KB/Applications/FreeRTOS`

### Applications

- [Digital power](https://github.com/stmicroelectronics/stm32cubeg4/tree/master/Projects/B-G474E-DPOW1/Applications/Digital_Power): `Projects/B-G474E-DPOW1/Applications/Digital_Power`
- [Power demonstrations](https://github.com/stmicroelectronics/stm32cubeg4/tree/master/Projects/B-G474E-DPOW1/Demonstrations): `Projects/B-G474E-DPOW1/Demonstrations`
- [USB mass storage](https://github.com/stmicroelectronics/stm32cubeg4/blob/master/Projects/STM32G474E-EVAL/Applications/USB_Device/MSC_Standalone/USB_Device/App/usbd_storage_if.c): `Projects/STM32G474E-EVAL/Applications/USB_Device/MSC_Standalone/USB_Device/App/usbd_storage_if.c`
- [Demo storage](https://github.com/stmicroelectronics/stm32cubeg4/blob/master/Projects/STM32G474E-EVAL/Demonstrations/Core/Src/k_storage.c): `Projects/STM32G474E-EVAL/Demonstrations/Core/Src/k_storage.c`

### Libraries and middleware

- [CMSIS-DSP](https://github.com/stmicroelectronics/stm32cubeg4/blob/master/Drivers/CMSIS/DSP/Include/arm_math.h): `Drivers/CMSIS/DSP/Include/arm_math.h`
- [DSP controllers](https://github.com/stmicroelectronics/stm32cubeg4/blob/master/Drivers/CMSIS/DSP/Source/ControllerFunctions/ControllerFunctions.c): `Drivers/CMSIS/DSP/Source/ControllerFunctions/ControllerFunctions.c`
- [DSP test suite](https://github.com/stmicroelectronics/stm32cubeg4/blob/master/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/src/controller_tests/controller_test_common_data.c): `Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/src/controller_tests/controller_test_common_data.c`
- [Middleware libraries](https://github.com/stmicroelectronics/stm32cubeg4/tree/master/Drivers): `Drivers`

### Other components

- **Firmware engineer**
- **STM32G4 boards**

## Connections

- Firmware engineer → Board templates: selects project
- Firmware engineer → ADC examples: selects example
- Firmware engineer → I2C examples: selects example
- Firmware engineer → Digital power: selects application
- Board templates → STM32G4 boards: runs on (evidence: `README.md`)
- ADC examples → STM32G4 boards: runs on (evidence: `README.md`)
- I2C examples → STM32G4 boards: runs on (evidence: `README.md`)
- Digital power → STM32G4 boards: runs on (evidence: `README.md`)
- Power demonstrations → STM32G4 boards: runs on (evidence: `README.md`)
- USB mass storage → STM32G4 boards: runs on (evidence: `README.md`)
- DSP controllers → CMSIS-DSP: implements functions (evidence: `Drivers/CMSIS/DSP/Source/ControllerFunctions/ControllerFunctions.c`)
- DSP test suite → CMSIS-DSP: exercises
- Demo storage → Middleware libraries: uses storage stack
