Skip to main content

RAL Overview

Supported STM32 families: F4 · G4 · H5 · H7 · L4 · U5

This repository provides a structured foundation for embedded development based on STM32 microcontrollers.
It consolidates several hardware abstraction layers and device-specific configurations into modular components.


📁 Repository Structure​

├── CMSIS # Core CMSIS components provided by ARM
│   ├── CMSIS
│   │   ├── Core
│ │ | └── Include # ARM Cortex-M core headers
│   │   ├── Core_A
│   │   ├── CoreValidation
│   │   ├── DAP
│   │   ├── DoxyGen
│   │   ├── Driver
│   │   ├── DSP
│   │   ├── NN
│   │   ├── Pack
│   │   ├── RTOS
│   │   ├── RTOS2
│   │   └── Utilities
│   └── Device
│      └── ARM
|
├── CMSIS_ST # CMSIS Device files from STMicroelectronics
│   ├── Include # STM32 device header files (e.g., STM32U5xx.h)
│   └── Source # System initialization files (system_stm32u5xx.c, etc.)
|
├── RAL_ST # Register Abstraction Layer (formerly HAL drivers)
| ├── Port # Interface layer for user access to HAL without MCU-family dependency
| └── Stm32_Drv # Low-Layer drivers provided by ST
| ├── Inc # STM32 device header files (e.g., stm32u5xx_ll_tim.h)
| └── Src # System initialization files (stm32u5xx_ll_tim.c, etc.)
│
└── LICENSE

Modules Overview​

CMSIS (by ARM)​

Contains the official ARM Cortex Microcontroller Software Interface Standard.
Provides:

  • Core peripheral access layer (Cortex-M, -A)
  • DSP and NN libraries
  • RTOS and driver interfaces
  • Device definitions for ARM reference architectures

Branch structure:

  • CMSIS – base branch synchronized with official ARM CMSIS repository
  • CMSIS_<major>.<minor>.x – release branches mirroring official releases

CMSIS_ST (by STMicroelectronics)​

Contains ST-specific extensions of CMSIS, distributed as part of STM32Cube firmware packages. Includes peripheral definitions, startup code, and system configuration for STM32 microcontrollers.

Provides:

  • Device headers, register definitions, and startup files for STM32 families
  • ST-specific system and interrupt handling extensions

Branch structure:

  • STM32U5, STM32H7, etc. – family branches
  • STM32U5_1.5.x – release branch derived from the family branch

RAL_ST (Register Abstraction Layer)​

Implements a hardware abstraction interface built on top of ST’s HAL drivers.
The Port subdirectory introduces a unified interface (Stm32_tim.h, Stm32_i2c.h, Stm32_spi.h ...) that allows seamless switching between STM32 MCU families without changing user-level code.

Structure:

  • Stm32_Drv/ – Original HAL and LL drivers provided by STMicroelectronics
  • Port/ – Intermediate interface layer (Stm32_im.h, etc.)
    • Provides unified function naming independent of MCU family
    • Enables fast switching between STM32 families without changing user code

Example:

#include "Stm32_tim.h" // Automatically selects correct HAL headers based on MCU definition

Branch structure:

  • STM32U5, STM32H7, etc. – family branches
  • STM32U5_1.5.x, STM32H7_1.14.x, ... – release branches derived from family branches
  • All family branches are derived from the master branch.

Usage​

This repository is fully integrated with CMake and provides two library targets that can be linked to your project depending on your abstraction needs.

Ral_Lib represents the official Register Abstraction Layer interface.
It exposes only the public headers located in the Port/ directory, ensuring a stable and hardware-independent API for user applications.

Key properties:

  • Public include path: RAL_ST/Port/
  • Minimal dependency surface
  • Maintains full portability between STM32 families
  • Intended for inclusion in user modules or middleware

CMake example:

# Add RAL interface to your project
target_link_libraries(MyApp PRIVATE Ral_Lib)

Usage example:

#include "Stm32_tim.h" // Unified abstraction header

⚠️ The Ral_Lib target is the only officially supported interface for external projects.


HAL_LL_Lib — Extended low-level access​

HAL_LL_Lib provides access to the entire set of header files available within the RAL_ST module,
including all HAL and LL driver headers from STMicroelectronics.

Key properties:

  • Public include path: RAL_ST/Stm32_Drv/Inc/
  • Contains all original ST HAL and LL headers
  • Intended for internal integration and testing only

CMake example:

# Add full HAL layer (not recommended for modular projects)
target_link_libraries(MyApp PRIVATE HAL_LL_Lib)

⚠️ Use HAL_LL_Lib only when low-level ST HAL or LL APIs are explicitly required.
Direct usage may reduce modularity and portability of your code.


Build Integration​

Both libraries are automatically configured and exported by the CMake build system. To include them, ensure your CMakeLists.txt contains the following:

add_subdirectory(RAL)

After this step, both Ral_Lib and HAL_LL_Lib become available as CMake targets.


Repository Philosophy​

This repository serves as a central abstraction hub, ensuring consistent naming, structure, and portability across STM32 families.
Each submodule evolves in sync with vendor updates while preserving a clean interface boundary for user applications.


📚 License​

All CMSIS and HAL source code follows their respective vendor licenses (ARM and STMicroelectronics).
Custom extensions (e.g., Port/ layer) are distributed under the repository’s LICENSE file.

Family support​

F4G4H5H7L4U5
CMSIS ST✅✅✅✅✅✅
RAL ST✅✅✅✅✅✅