2026-02-18 12:45 AM
Does anyone know what settings are needed to check the internal flash memory using the STL library?
I wrote a small test firmware (for a 61508 safety application without TZ) using the STL library, which is supposed to perform a self-test flash memory check.
However, this test always fails.
I ran the checksum check using STM32CubeProgrammer v2.20.0.
I had to manually enter the settings for FlashStart, FlashEnd, and FlashSectionSize (0x08000000 0x0800E000 0x00010000) because the macros from the readme file didn't work.
The STM32CubeProgrammer then reports: CRCs area injected successfully.
After loading the modified ELF file, the STM32CubeProgrammer displays:
Number of segments: 2
segment[0]: address= 0x8000000, Size = 0xC314
segment[1]: address= 0x800E000, Size = 0x2000
But what settings should be specified to perform the flash test?
Unfortunately, this information is not available in the manual or the STL documentation.
I've already tried the following unsuccessfully:
1st attempt: #define FLASH_SECTION_SIZE 0xE000U
2nd attempt: #define FLASH_SECTION_SIZE 0xC400U
3rd attempt: #define FLASH_SECTION_SIZE 0x10000U
each with: #define TEST_FLASH_SECTION_NB 1
The StlErrorHandler() is always called because the flash check fails. (FlashTmStatus: STL_FAILED)
Does anyone know what settings need to be changed:
a) when calling the STM32CubeProgrammer and
b) for testing the flash
so that it works?
2026-02-18 1:10 AM
Many questions - but which cpu you asking about ? no info given, so what you expect ?
2026-02-18 1:16 AM - edited 2026-02-18 1:18 AM
Sorry.
We use the STM32H503CBT.
2026-02-18 2:40 AM - edited 2026-02-18 2:43 AM
Hm, has "normal" flash;
Flash can only be erased and written, then read for verify , whether its correct; thats always this way.
on download/flash the image is verified (if you sect it in CubeProgrammer);
so what you wanna "check" ?
+
Some series have error detection+correction in flash , if need 100% safety always, example H7 series ->
2026-02-18 3:06 AM
Hello.
Flash testing is required for safety software that must meet a SIL (Safety Integrity Level) according to DIN EN 61508.
This includes the need for cyclical self-tests of the CPU, RAM, and Flash memory, as well as all inputs and outputs.
These tests must be performed 100 times more frequently than standard safety tests.
The TÜV-certified X-CUBE-STL-H5 software is required and has the following features:
These tests specifically ensure that the contents of the Flash memory are still valid ( the test FLASH_SM_0 for example).
For this to work, the firmware image must first be calculated and modified using the CRC tool of the STMCubeProgrammer.
2026-02-18 4:58 AM - edited 2026-02-18 5:04 AM
Aha, ok. I never needed this...so i dont know.
Did you ask sidekick ?
->
The STM32 Self-Test Library (STL) is designed to help you implement safety mechanisms in your application, such as periodic self-tests for RAM, Flash, and CPU. The following sections provide a comprehensive guide to integrating, configuring, and using the STL safety library in your STM32 project.
Project Setup
Add STL Library Files
IDE-Specific Configuration
Configure Flash Memory Range
Optional Preprocessor Switches
Develop STL Flow Control
To use the STL safety library:
For additional support or to discuss your specific application with ST experts, you’re welcome to join conversations in STM32 forums.
2026-02-18 5:49 AM
I don't know ST's STL library, because my company does not use any STM32 devices in safety-critical applications.
Which more or less means we use a "hand-coded" approach here, at least for certain devices.
First, we run the test only over code, not (constant) data that end up in the Flash. For that end, we had to split the application in sub-segments, were usually "end-of-code" section separates actual code from constant data.
The latter usually depends on the application size, and might either require frequent adaption, or a relatively static Flash layout.
With the start address and the end address of the code section known, the checksum is calculated by an external tool in the post-build process.
It is patched into the SREC file into a known specific location, a "program header structure", which contains the start and end addresses as well, and which is of course outside the code range.
At runtime, the application cyclically calculates the checksum itself, and compares it with the one stored in the header.
In case of issues, check that both the external tool and the application code treat unused/unprogrammed Flash areas the same way.
This method applies to most of our older hardware, often using relatively arcane architectures and toolchains. And there are some legal reasons that keep me from sharing all details.
For new development my company now only considers commercial ECUs, which means the ECUs for SIL-2 applications come with this feature built-in by the vendor.
2026-02-18 6:05 AM
Hi AScha.3
I've read the entire documentation.
However, I'm having trouble implementing it in the STM32CubeIDE.
According to the documentation, I should execute the following post-build command for CRC calculation:
STM32_Programmer_CLI.exe -sl D:\Projects\SW\STL_Test\Debug\STL_Test.elf FlashStart@ FlashEnd@ FlashSectionSize
But the output in STM32CubeIDE-Console at building only shows:
-------------------------------------------------------------------
STM32CubeProgrammer v2.20.0
-------------------------------------------------------------------
Error: The safety lib command is missing parameters
make[1]: *** [makefile:102: post-build] Error 1
make: *** [makefile:63: all] Error 2
"make -j24 all" terminated with exit code 2. Build might be incomplete.
The problem likely lies with: FlashStart@ FlashEnd@ FlashSectionSize
If I manually enter values there, the CRC calculation works, but not correctly (because nowhere is it precisely described what needs to be used or where the macros for start, end, and length come from)!
And that's my problem.
Nowhere in the documentation is there any mention of the parameters for Start, End, and Length for the CRC program.
Nowhere in the documentation is there any mention of Start, End, and Length for the firmware with flash testing.
I'm at my wit's end.
2026-02-18 6:13 AM
ask sidekick:
To set up the CRC calculation for your STM32 program, you need to define three key parameters: Start, End, and Length. Here’s how to determine each:
Summary Table:
Parameter How to Determine| Start | Address where user program begins (32-bit aligned) |
| End | Address where user program ends |
| Length | End - Start (size of program area to check) |
To get the parameters for Start, End, and Length for the CRC program in STM32:
For additional support or to discuss your specific application with ST experts, you’re welcome to join conversations in STM32 forums.
2026-02-19 6:11 AM
Hello @Heinz_Baumer,
In the command:
STM32_Programmer_CLI.exe -sl D:\Projects\SW\STL_Test\Debug\STL_Test.elf FlashStart@ FlashEnd@ FlashSectionSize
FlashStart@ is the start address of the flash (not the user program)
FlashEnd@ is the end address of the flash (not the user program)
FlashSectionSize is constant and is always 0x400 (1kB).
The FlashSectionSize means that a 32-bit CRC figure is calculated for every 1kB section of flash. But the STM32_Programmer_CLI utlity uses the elf file to calculate the CRC only for flash sections containing actual code. It doesn't calculate CRC on empty flash.
Some examples of where the CRCs are located at the end of the flash is illustrated in Figure 4. Flash memory test: CRC use cases versus program areas and Figure 3. Flash memory test: CRC principle of UM3267. This document is for classB but the same flash test is used for 61508.
Note that the TÜV-certified X-CUBE-STL-H5 package is delivered under NDA and provided by the ST's local Technical Marketing Engineer. Support on 61508 safety is not done on STCommunity but through ST Online Support Center (Support Home - STMicroelectronics).
Best regards