How to Implement Flash Memory Diagnostic (FLASH_SM_0) without Using X-CUBE-STL on STM32G4
Hello,
I am working with an STM32G431 MCU and referring to the STM32G4 Series Safety Manual (UM2454). In section 3.6.4 (Embedded Flash Memory) — Table 21: FLASH_SM_0, it describes a periodic software test for Flash memory using signature-based methods (e.g., CRC).
According to the document, this diagnostic can be implemented via X-CUBE-STL, but I would like to implement it manually, without using the STL library.
My goal is to verify Flash memory integrity periodically or at startup by computing a CRC over a defined Flash region and comparing it with a stored “golden” reference signature in Flash.
I would like to understand the following:
-
What is the correct approach to implement FLASH_SM_0 manually according to the safety manual’s requirements?
-
How should I select the Flash regions for testing (code, data, unused memory)?
-
What is the recommended way to store and update the reference (golden) CRC signature in Flash?
-
Are there any STM32 hardware CRC peripheral examples or best practices for this type of diagnostic?
-
Should this test be executed at startup only, or periodically during runtime as well?
Any guidance, example code, or references from similar safety implementations would be very helpful.
Thankyou.
