Provides drivers, examples, loader files and testing routines for external loaders for STM32 series of microcontrollers.
Provides drivers, examples, loader files and testing routines for external loaders for STM32 series of microcontrollers.
This repository contains STM32 memory loader source code for both external and internal memories used on STM32 hardware boards. The master branch provides the memory loader projects and source files integrated with STM32CubeProgrammer.
stm32-memory-loaders/
├── external_memory_loaders/ # Memory loaders for external Flash/SRAM chips
│ ├── STM32F4x_boards/
│ ├── STM32F7x_boards/
│ ├── STM32G4x_boards/
│ ├── STM32H5x_boards/
│ ├── STM32H7x_boards/
│ ├── STM32L4x_boards/
│ ├── STM32L5x_boards/
│ └── STM32U5x_boards/
└── internal_memory_loaders/ # Memory loaders for on-chip Flash memories
├── stm32_mem_loader/ # Unified loader infrastructure (CMSIS Pack)
└── stm32_device_loaders/ # Device-specific loader implementations
└── stm32c5xx/[!IMPORTANT] The
external_memory_loaders/directory uses submodules. Please follow the instructions below to clone and get updates.
git clone --recursive https://github.com/STMicroelectronics/stm32-memory-loaders.gitgit pull
git submodule update --init --recursive[!NOTE]
- The
--recursiveflag applies to the external memory loaders only. Internal memory loaders are self-contained and do not require submodule initialization.- If the GitHub Download ZIP option is used instead of
git clone, the submodules must be collected and added manually.
External memories are available on many STM32 hardware boards such as evaluation and discovery kits. They can be Flash or SRAM and provide higher storage capabilities. STM32 boards support many types of external memories from vendors such as Micron and Winbond, connected through interfaces like FMC, QSPI, and SPI.
Internal memories are embedded directly inside STM32 MCUs (on-chip Flash). The loaders in this repository target the internal Flash controller of each supported STM32 series and expose a standard API consumed by STM32CubeProgrammer.
External memory loaders are located in external_memory_loaders/ and are organized by STM32 series and board.
Each external memory loader project is built with EWARM or MDK-ARM IDE and comes with the corresponding source, header, and linker files:
| STM32 Series | Board | Memory |
|---|---|---|
| STM32F4x | STM32F469I-DK | IS42S32400F, MT25QL128A |
| STM32F4x | STM32469I-EVAL | MT25QL512A |
| STM32F4x | STM32412G-DISCO | N25Q128A |
| STM32F4x | STM32F413H-DISCO | N25Q128A |
| STM32F7x | STM32F723E-DISCO | MX25L512G |
| STM32F7x | STM32F7508-DISCO | N25Q128A |
| STM32F7x | STM32F769I-EVAL | PC28F128M29 |
| STM32G4x | STM32G474E-EVAL | MT25QL512ABB |
| STM32H5x | STM32H573I-DK | MX25LM51245G |
| STM32H7x | STM32H743I-EVAL | M29W128GL, MT25TL01G |
| STM32H7x | STM32H747I-DISCO | MT25TL01G |
| STM32H7x | STM32H747I-EVAL | MT25TL01G |
| STM32H7x | STM32H735G-DK | MX25LM51245G |
| STM32H7x | STM32H7B3I-DISCO | MX25LM51245G |
| STM32H7x | STM32H7B3I-EVAL | MX25LM51245G |
| STM32L4x | STM32L476G-EVAL | M29W128GL |
| STM32L4x | STM32L4P5G-DK | MX25LM51245G |
| STM32L4x | STM32L4R9I-DISCO | MX25LM51245G |
| STM32L4x | STM32L4R9I-EVAL | MX25LM51245G |
| STM32L4x | STM32L496G-DISCO | MX25R6435F |
| STM32L4x | STM32L476G-DISCO | N25Q128A |
| STM32L5x | STM32L562E-DK | MX25LM51245G |
| STM32U5x | STM32U575I-EVAL | MX25LM51245G |
| STM32U5x | STM32U585I-IOT02A | MX25LM51245G |
The required steps to build a customized external loader for STM32CubeProgrammer are available at this link (Section 3.9).
Internal memory loaders are located in internal_memory_loaders/ and are split into two parts: a shared infrastructure (stm32_mem_loader) and device-specific loader implementations (stm32_device_loaders).
…All internal loaders implement the following interface declared in common/device_loader.h:
| Function | Description |
|---|---|
mem_loader_init() |
Initialize the Flash controller |
mem_loader_deinit() |
De-initialize the Flash controller |
mem_loader_sector_erase(start, end) |
Erase sectors in the given address range |
mem_loader_program(addr, size, buf) |
Program a buffer into Flash |
mem_loader_mass_erase() |
Erase the entire Flash |
Return values use mem_loader_status: MEM_LOADER_STATUS_SUCCESS (0) or MEM_LOADER_STATUS_FAIL (1).
The stm32_mem_loader CMSIS Pack provides ready-to-use glue layers for three toolchains:
| Toolchain | Component | Linker resource |
|---|---|---|
| IAR EWARM | STMicroelectronics::Utility:Loader:IAR |
common/linker/iar/mem_loader.icf |
| Keil MDK (ARMCC) | STMicroelectronics::Utility:Loader:Keil |
Not provided in the current pack layout |
| GCC (ST toolchain) | STMicroelectronics::Utility:Loader:ST |
Not provided in the current pack layout |
| Series | Target define | Flash size | Start address |
|---|---|---|---|
| STM32C5xx | STM32C5_0x44E_0x08000000_512K |
512 KB | 0x08000000 |
| STM32C5xx | STM32C5_0x44F_0x08000000_256K |
256 KB | 0x08000000 |
The internal loaders use the Open-CMSIS-Toolbox cbuild command.
Install Open-CMSIS-Toolbox and make sure cbuild is available from your terminal PATH.
Install the required CMSIS Pack:
cpackget add ARM::[email protected] The STMicroelectronics::stm32_mem_loader pack is referenced locally by the solution file:
internal_memory_loaders/stm32_mem_loader.
Navigate to the loader directory and run cbuild:
cd internal_memory_loaders/stm32_device_loaders/stm32c5xx
cbuild stm32c5_mem_loader.csolution.yml --context stm32c5_mem_loader.IAR+STM32C5_0x44E_0x08000000_512KThe built .elf / .out files are placed under build/+/.
The build tool may report the following warning :
Warning: Cannot detect the section type of 'FlashDevice'This warning is expected for the current loader integration. The FlashDevice
symbol is required by the loader interface used by STM32CubeProgrammer and
must remain available for CubeProgrammer loader compatibility. The warning does
not indicate a failed build when the build summary reports success and the
.elf / .out output is generated.
The STM32C5xx IAR build has been validated with the following tool versions:
| Tool | Version |
|---|---|
| IAR ANSI C/C++ Compiler for Arm | V9.60.3.422/W64 |
Open-CMSIS-Toolbox cmsis-project |
2.11.0 |
Open-CMSIS-Toolbox cmsis-build |
2.11.0 |
Open-CMSIS-Toolbox cmsis-cbuild2cmake |
0.9.8 |
| CMake | 4.0.1 |
| Ninja | 1.12.1 |
CMSIS Pack ARM::CMSIS |
5.9.0 |
Please refer to the CONTRIBUTING.md guide.
No open issues yet, or sync has not completed.