an4435-guidelines-for-obtaining-ulcsaiec-607301603351-class-b-certification-in-any-stm32-application-stmicroelectronics
an4435-guidelines-for-obtaining-ulcsaiec-607301603351-class-b-certification-in-any-stm32-application-stmicroelectronics
Application note
Guidelines for obtaining UL/CSA/IEC 60730-1/60335-1
Class B certification in any STM32 application
Introduction
The role of safety is more and more important in electronic applications. The safety
requirements for components are steadily increasing, and the manufacturers of electronic
devices include new solutions in their designs. Software techniques for improving safety are
continuously being developed. The standards related to safety requirements for hardware
and software are under continuous development as well.
The current safety recommendations and requirements are specified in worldwide
recognized standards issued by IEC (International Electrotechnical Commission), UL
(Underwriters Laboratories) and CSA (Canadian Standards Association) authorities.
Compliance, verification, and certification are the focus of institutions like TUV and VDE
(mostly operating in Europe), UL and CSA (targeting mainly US and Canadian markets).
The main purpose of this document and of the associated software X-CUBE-CLASSB is to
facilitate and accelerate user software development and certification processes for
applications based on STM32 microcontrollers, subject to these requirements and
certifications.
Contents
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
List of tables
List of figures
a. Arm is a registered trademark of Arm Limited (or its subsidiaries) in the US and/or elsewhere.
For more information about error handling techniques, refer to Handling of soft errors in
STM32 applications (AN4750).
For more information on EMC, refer to the following application notes:
• Software techniques for improving microcontroller EMC performance (AN1015)
• EMC design guide (AN1709)
For more detailed information about cyclic redundancy check calculation (CRC), refer to
Using the CRC peripheral in STM32 family (AN4187).
The following safety manuals are available on www.st.com:
• UM1741 (for the F0 series)
• UM1814 (for the F1 series)
• UM1845 (for the F2 series)
• UM1846 (for the F3 series)
• UM1840 (for the F4 series)
• UM2318 (for the F7 series)
• UM2455 (for the G0 series)
• UM2454 (for the G4 series)
• UM2331 (for the H7 series)
• UM2037 (for the L0 series)
• UM1813 (for the L1 series)
• UM2305 (for the L4 and L4+ series)
• UM2752 (for the L5 series)
The development of safety manuals for other series is an ongoing process. Contact your
local FAE or the nearest ST office to check for the availability of new documents.
The STL packages and included HAL firmware are summarized in Table 1.
The included projects for specific STM32 products and dedicated evaluation boards have
been prepared and tested with the environments and toolchains detailed in Table 3.
The detailed structure of these projects and the list of files included in the common and
specific parts of the STL stack are summarized in Table 4 and Table 5, respectively.
Additional supporting files used in the examples are listed in Table 6.
stm32xxxx_STLcpustartIAR.s
stm32xxxx_STLcpurunIAR.s
stm32xxxx_STLRamMcMxIAR.s
stm32xxxx_STLcpustartKEIL.s
Start-up and run time CPU and RAM tests written
Source stm32xxxx_STLcpurunKEIL.s
in Assembler for IAR, Keil and GCC
stm32xxxx_STLRamMcMxKEIL.s
stm32xxxx_STLcpustartGCC.s
stm32xxxx_STLcpurunGCC.s
stm32xxxx_STLRamMcMxGCC.s
Header stm32xxx_STLparam.h STL product specific configuration file
Users can find some small differences, mainly due to hardware and to incompatibilities of
compilers and debugging tools.
The main differences are due mainly to compatibility aspects between different STM32
products.
These differences, summarized in Table 7, are described in this section.
Frequency 48 MHz 24-72 MHz 70 MHz 64 MHz 150 MHz 72 MHz 168 MHz 216(1) MHz 400 MHz 480/240 MHz 32 MHz 32 MHz 80 MHz 110 Mhz 64 MHz
Performance 38 DMIPS 61 DMIPS 90 DMIPS 59 DMIPS 190 DMIPS 61 DMIPS 210 DMIPS 462 DMIPS 856 DMIPS 1327 DMIPS 26 DMIPS 33 DMIPS 100 DMIPS 165 DMIPS DMIPS
Flash memory 16-128 KB 16-1024 KB 16-512 KB 16-512 KB 128-1024 KB 32-256 KB 128-2048 KB 512-2048 KB 128-2048 KB 2048 KB 32-192 KB 32-512 KB 128-1024 KB 256-512 KB 256-1024 KB
ECC on External
No No Yes Yes Yes(1) No External only Yes, embedded CRC unit Yes No Yes Yes Yes
Flash memory only(1)
CRC
Yes No No Yes Yes Yes No Yes Yes Yes No Yes Yes Yes
configurable
RAM 4-16 KB 4-96 KB 16-80 KB 8-128 KB 32-128 KB 16-48 KB 64-256 KB 256-512 KB 1024 KB 8-20 KB 4-80 KB 4-320 KB 256 KB 256 KB
(2)
RAM parity
AN4435 Rev 10
Yes/Yes No/Yes No/No Yes/No Yes(3)/No No/No No/No No/No No(4)/No No/No No/No Yes(3)/No Yes(3)/No Yes(3)/No
/scrambling
Auxiliary RAM No No Yes No CCM RAM(1) CCM RAM(1) Yes Yes TCM, backup No No Yes Backup Backup
IWDG
Yes No No Yes Yes Yes No Yes Yes Yes No Yes Yes Yes
window option
MSI, HSI48(1)
HSI14, HSI48 HSI48 MSI, HSI48 MSI MSI, HSI48(1) MSI, HSI48
Clock system(5) (LSI~40 kHz) (LSI~32 kHz) (LSI~32 kHz) (LSI~40 kHz) (LSI~32 kHz) (LSI~32 kHz) CSI, HSI48, (LSI~32 kHz) (LS1/2I~32
(LSI~40 kHz) (LSI~32 kHz) (LSI~38 kHz) (LSI~38 kHz) (LSI~32 kHz) (LSI~32 kHz)
kHz)
Clock cross
reference TIM14/Ch1 TIM5/Ch4(1) TIM5/Ch4(7) TIM16/Ch1 TIM16/Ch1 TIM14/Ch1 TIM5/Ch4 TIM5/Ch4 TIM16/Ch1 TIM16/Ch1 TIM21/Ch1 TIM10/Ch1 TIM16/Ch1 TIM16/Ch1 TIM16/Ch1
measurement(6)
GPIO, RTC, LSE, GPIO, RTC, LSE CSI LSE CSI GPIO, MSI, GPIO, RTC, LSE RTC
Clock reference GPIO, RTC, MCO HSE/32 GPIO, RTC, GPIO, RTC, GPIO, RTC,
HSE/32, - HSE/32, HSE/32, HSE_1MHz HSE_1MHz LSI, LSE LSI, LSE, MSI, LSE, RTC MSI HSE/32
next options LSI, LSE RTC LSE LSI, LSE LSI, LSE LSI, LSE
MCO MCO MCO MCO1, MCO2 MCO1, MCO2 HSE_RTC HSE/32, MCO MCO
Voltage scaling
Yes(1) No Yes(1) Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
management
2. When product features SRAM parity bit, address is included, except the STM32F0 series, where parity is computed only over data.
3. Parity bit does not cover the whole RAM, but only a portion of it. Check the product datasheet for detailed info.
5. All the family members feature HSI16, HSE, PLL, LSI and LSE clock sources. Additional sources are listed in the table.
AN4435
6. Timers dedicated to clock cross reference measurements are 16-bit wide, except STM32F2, STM32F4, STM32F7 and TIM5 of STM32G4, where 32-bit ones are used.
;------------------------------------------------------------------------
; r0 is used as a pointer to RAM,
; r1 keeps end address of the area
;------------------------------------------------------------------------
;At every step of the loop, the 32-byte block (r2-r9) is copied to RAM
; starting from address kept at r0, r0 is then increased by 32
; the loop body is performed while r0<r1
LDR R0, =RAM_block_begin
ADD R1, R0, #RAM_block_size
RAM_init_loop
STMIA R0!, {R2-R9}
CMP R0, R1
BLT RAM_init_loop
; RAM is initialized now, program can continue by startup self-test
LDR R0, =STL_StartUp
BLX R0
Note: The real content of the registers copied by the STMIA instruction is not relevant because the
purpose of this loop is to initialize the parity system. The RAM content is initialized at a later
stage by the compiler standard startup procedure. RAM_block_begin, RAM_block_size, and
end memory address setting must be aligned with the number of data copied by the STMIA
instruction to prevent any undefined memory access, especially at the end of the loop.
Note: For new products featuring optional hardware initialization of the SRAM, there is no need to
perform initialization of the memory by the upper software loop if the user activates this
option.
When the initial software March test is performed over a RAM area dedicated to the stack, it
destroys all the stack content including the return address of the test routine itself stored
there when a high level compiler is used. The store and restore procedure of the return
address depends on the compiler implementation and can differ for different optimization
levels. Besides an optimization effort, this is the main reason why the routines supporting
SRAM testing are written in assembly, to be independent from the higher compiler
implementation. On the other side this solution brings a light tool dependency, and different
assembly source files have to be kept to pass their compilation correctly.
When applying a new version of the compiler to older versions of the STL, the assembly
testing routine applied at startup can become incompatible and require small adaptations.
For more information, see Section 3.10.
block size used during the test. By default, the block size is set to 16 words (64 bytes) by the
parameter FLASH_BLOCK_WORDS defined in the stm32xx_STLparam.h file. Unused
memory areas included in the check have to be identified with predefined values. An all-1
pattern is used by default.
The range under the nonvolatile memory test is defined by the user. During run time, if the
test of the overall memory range is not acceptable because too long, the user can split it into
segments that correspond to local areas where the program is executed. This requires to
dynamically modify the area under test, so that the testing is performed exclusively over
those areas.
The STL integration examples perform tests of single contiguous areas described by a
single check sum descriptor. When the user considers additional separated segments, the
test procedure must be adapted, as done in the X-CUBE-STL library targeting SIL.
The result of the CRC calculation must be compared with the corresponding reference
pattern provided either automatically by the compiler (IAR case), or added by the end user
from a computation handled externally (MDK-Arm and GCC cases).
When the tool does not support CRC pattern placement, specific script files
(crc_gen_keil.bat or crc_gen_gcc.bat) are provided in the implementation example projects
to run post-built procedures calculating the check sum automatically. They are based on
installation of Srecord GNU tool, freely available from http://srecord.sourceforge.net. The
default HEX file provided by the linker output is modified and the CRC reference pattern is
inserted in a new HEX file. Ensure that the modified HEX file (output_name_CRC.hex) is
used for the application download (for example, by implementation of crc_load.ini file or by
proper modification of launch configuration properties when the debug or download session
starts).
CPU load and test duration decrease significantly with hardware computation via CRC unit,
compared with software computation. The CPU load can be further decreased when the
CRC unit is fed automatically by DMA, but the speed of the test itself does not change
significantly, because DMA needs at least a few cycles to read and transfer data. The test
can even slow down when DMA services other transfers or interrupts in parallel. Moreover,
some additional DMA configuration is required at initialization of the test. For detailed
information about use of DMA for CRC calculation, see AN4187.
Some of the oldest STM32 devices do not feature the CRC hardware block, they use
exclusively software routines for the 16-bit wide CRC calculation. Optional 32-bit wide
calculation has been added to support dual cores. Commonly, these software procedures
are based on predefined look-up table constants to speed up the calculation, but they
consume a significant part of the code memory.
Once this security is enabled, the memory areas can be accessed and tested only under the
secure state. Alternatively, the user can separate and split their testing strictly into two parts
related to the secure and non-secure state execution (for example, a case when the non-
secure code size and its CRC check sum is not known in advance).
In this case, consider and prevent possible cross collisions between the secure and non-
secure state execution (for example, when the secure or non-secure state interrupt
accesses data from RAM area under modification or test of the complementary state at the
same time, or if hardware CRC unit calculation is shared between the states for different
purposes).
The non-secure state can still use and call APIs related to the secure state, provided these
APIs to be shared are properly published and mapped via a secure gateway.
Arm® Cortex® core Include proper CPU testing start-up and runtime procedures, proper handling of core hard faults and exceptions
Handling SYSTCLK_AT_RUN_HSE / SYSTCLK_AT_RUN_HSI / HSE_VALUE / HSE_CLOCK_APPLIED / LSI_Freq parameters in
Frequency (MHz)
stm32xx_STLparam.h
Handling ROM_START / ROM_END in
stm32xx_STLparam.h
Setup LR_IROM1 load region in Handling ROM_START / ROM_END in
project sct file. stm32xx_STLparam.h
Flash memory Handling Checksum option in Project linker Define Flash memory region in project ld
Define Check_Sum pattern placement
density (KB) option menu ROM_region in project icf. file file. Implement proper post-built script files
either in startup_stm32yyyyxxKEIL.s or in for the automatic CRC check sum
project.sct file. calculation
Implement proper post-built script files for
the automatic CRC check sum calculation.
ECC on Flash Implement handling ECC event by interrupt or by pulling
AN4435 Rev 10
Setup RUN_TIME_RAM_BUF_region, Setup RAM_BUF, RAM_PNT, CLASSB, Define CLASSBRAM and RAM regions in
RUN_TIME_RAM_PNT_region, CLASB_INV RW_IRAM1 in project sct file project ld file.
RAM density (KB) CLASS_B_RAM_region, Handling RAM_START, RAM_END, Handling RAM_START, RAM_END,
CLASS_B_RAM_REV_region, RAM_region CLASS_B_START, CLASS_B_END CLASS_B_START, CLASS_B_END
in project icf. file parameters in stm32xx_STLparam.h parameters in stm32xx_STLparam.h.
RAM parity Handling RAM parity event by interrupt or by pulling
Define ARTISAN=1 in Properties for
Define ARTISAN=1 in Project Assembler / Define ARTISAN=1 in Option for Target /
(1) Assembly / Tool Settings / MCU GCC
RAM scrambling Preprocessor option menu when scrambling Asm / Conditional assembly control symbols
Assembler / General / Assembler Flags
is applied menu when scrambling is applied
when scrambling is applied.
Define USE_MARCHX_TEST=1 in Option Define USE_MARCHX_TEST=1 in
March-X flow during Define USE_MARCHX_TEST=1 in Project
for Target / Asm / Conditional assembly Properties for Assembly / Tool Settings /
transparent Assembler / Preprocessor option menu
control symbols menu when the flow is MCU GCC Assembler / General /
RAM test when the flow is applied
applied Assembler Flags when the flow is applied.
ECC on E2PROM Implement handling ECC event by interrupt or by pulling
AN4435
IWDG option Handling IWDG_FEATURES_BY_WINDOW_OPTION parameter in stm32xx_STLparam.h
Table 8. How to manage compatibility aspects and configure STL package (continued)
AN4435
Feature IAR-EWARM MDK-Arm GCC
Clock cross
reference Setup proper timer system for cross reference measurement and handling its events
measurement
Define SUPERSET_DUAL_CORE, DUAL_CORE_MASTER, DUAL_CORE_SLAVE to include associated control of dual core
synchronization.
Dual core specific
Define SW_CRC_32 flag to select 32-bit software CRC calculation.
setting
Adapt optionally MAX_NUMBER_OF_MISSED_SLAVE_CORE_CYCLES and HSEM IDs HSEM_ID_CLASSB_SLAVE_SELFTEST,
HSEM_ID_CLASSB_SLAVE_CYCLE and HSEM_ID_CLASSB_MASTER_SELFTEST.
Handling STL_VERBOSE_POR, STL_VERBOSE, STL_EVAL_MODE, STL_EVAL_MODE_SLAVE, STL_EVAL_LCD,
(2) NO_RESET_AT_FAIL_MODE, DEBUG_CRC_CALCULATION, STL_USER_AUX_MODE, USE_WINDOW_WDOG,
Debugging option
USE_INDEPENDENT_WDOG, HSE_CLOCK_APPLIED, IGNORE_COMPLEMENTARY_CORE_STATUS parameters in
stm32xx_STLparam.h
1. Tool specific procedures (source code written in assembler).
AN4435 Rev 10
2. Evaluation board specific and STL optional handling when debugging the firmware (not part of the safety code, but used as an application integrating example). For
additional details follow associated comments in the stm32xx_STLparam.h file and in Section 5.4.3.
HAL_IWDG_Init
HAL_WWDG_Init
HAL_IWDG_Start
HAL_WWDG_Start
stm32xx_STLstartup.c
IWDG and WWDG HAL_IWDG_Refresh
stm32xx_STLmain.c
HAL_WWDG_Refresh
__HAL_RCC_CLEAR_FLAG
__HAL_RCC_GET_FLAG
__WWDG_CLK_ENABLE()
HAL_Init stm32xx_STLstartup.c
HAL layer HAL_IncTick stm32xx_STLmain.c
HAL_GetTick stm32xx_it.c
Note: Be careful when using a HAL version newer than that used for the STL certification, check
changes summarized in release notes. For more information, refer to Section 3.10.
Another issue related to the compiler optimization can be an unexpected replacement of the
control flow (based on step by step filling of the specific dedicated flow control registers
between the test caller and caller procedures) by a single last time setup of these registers
with final expected values (precomputed by the compiler during compilation) just before the
program starts to check their content. This is why it is strongly suggested setting the lowest
possible optimization for the stm32xx_STLstartup.c file compilation configuration.
Note: FailSafePOR service content is under user responsibility. STL performs a direct jump to this
service by default when the CPU startup test detects a fault. Be careful when testing stack
pointers, especially when the jump is performed with destructed and invalid PSP or MSP
register content. The service must be written not to rely on it. Original value of the tested
pointer is kept in register R0.
One of the crucial definitions of the commonly used error status enumerator is changed in
the HAL library so that the assembler-written STL code, which relies on the original
definition, must be either adapted or declared independently from the common operator
recognized at C-level. To make the firmware independent on HAL definition of this
enumerator user can define a specific enumerator dedicated to the test and modify the
declaration of the related test function accordingly. For example, to correctly evaluate result
of RAM startup test, the stm32xx_STLRam.h file must be modified in following way:
typedef enum
{
SRAMTEST_SUCCESS = 1,
SRAMTEST_ERROR = !SRAMTEST_SUCCESS
} SRAMErrorStatus;
and
SRAMErrorStatus STL_FullRamMarchC(uint32_t *beg, uint32_t *end, uint32_t
pat, uint32_t *bckup);
while comparison of result when startup test is called in the stm32xx_STLstartup.c file must
be modified in following way:
...
if (STL_FullRamMarchC(RAM_START, RAM_END, BCKGRND, RAM_BCKUP) !=
SRAMTEST_SUCCESS)
{
...
The upper workaround is applied only for RAM startup test since revision 2.3.0 of the STL,
while a unique STL specific enumerator STLErrorStatus is defined for all the associated
testing APIs from revision 2.4.0.
There is an additional back-up pointer added as a next input parameter since revision 2.3.0
when calling the startup SRAM test procedure, not used in previous versions of the library.
This is an optional solution to solve the problem seen during the CPU startup test, and to
save preserved registers. The RAM_BCKUP pointer held at R3 during the call must point at
the beginning of some volatile memory area with 16 bytes capacity to save registers R4-R7
used and modified by the self test. The situation here is a bit more complicated, as the test
can destroy the stack content if the stack area is under test. Save the preserved registers to
another SRAM or into a part of memory excluded from the test. The test must start and
finish by storing and restoring the registers from the address provided by R3:
STL_FullRamMarchC:
STMIA R3!,{R4-R7} ; Save content of preserved registers R4-R7
...
LDMDB R3!,{R4-R7} ; Restore R4-R7 content
BX LR ; return to the caller
The R3 content cannot be modified by the procedure. Its original implementation must be
replaced using R7. If there is no area available for such a backup, adopt another optional
solution and save the R4-R7 registers one by one in some RW peripheral registers not used
at startup.
There can be problems with modified HEX file load at debugger entry with latest versions of
the MDK-Arm because it no longer performs load of the user defined initialization file as the
last action of the debugger entry, hence the flash memory remains programmed by its
default content at the end. Only the modified HEX file keeps a valid CRC image of the code,
hence the execution of the default memory integrity check fails. As a workaround, copy the
correct CRC pattern from the HEX file to the CHEKSUM segment definition defined at the
end of the startup_stm32xxxx.s modified assembly file (KEIL compiler case), or directly at
segment placing the check sum result at linker script file (GCC compiler), and recompile the
project with the correct CRC pattern copy after modifications of the source files. Another
debugging option is to define a DEBUG_CRC_CALCULATION conditional flag during
compilation, when the CRC result calculated during the start up test is applied for the run
time test, whatever the CHECKSUM segment content.
With the latest versions of the IAR compiler, the user can face problem with segment
placement in the RAM. This is due to the overlay of the common read/write section and
class B related sections in the region defined by the provided icf linker file. Separate the
content of these sections by changing the definition of the common section start to put it out
of the class B sections range:
...
define symbol __ICFEDIT_region_CLASSB_end__ = 0x2000007F;
define symbol __ICFEDIT_region_user_RAM_start__ = 0x20000080;
define region RAM_region = mem:[from __ICFEDIT_region_user_RAM_start__
to __ICFEDIT_region_RAM_end__];
place in RAM_region { readwrite, rw section .noinit };
to select procedures sufficient to ensure the required reliability with respect to performance
and memory capacity available in the application (to accommodate look up table data).
At startup, a single loop testing cycle over the memory area is called, by direct call of
STL_crc16() or STL_crc32() procedures. The tested area must then be aligned with,
respectively, 2- or 4-byte multiples.
At run time, sequence of partial tests is called under the same principle as when hardware
CRC unit is applied to separate the memory test into small blocks (block size is set by
FLASH_BLOCK parameter to 32 bytes by default). This sequence is handled by repeated
calling of STL_CrcSWRun() procedure, which returns ClassBTestStatus enumerator values
to identify the test phase and result. Each new test sequence must be initialized by
STL_FlashCrcSWInit() procedure pre-call. The tested area must be aligned with the block
size setting. The number of the tested blocks is verified by control flow (see definition of the
FULL_FLASH_CHECKED). Both values of partial checksum result and pointer to the flash
memory are carried as a complementary Class B variable type pair ,and checked for
consistency at each step of the sequence.
The applied software methods use different CRC algorithms, which requires wider setting
modifications of the tool providing pattern matching with the calculation result (for example,
IAR IDE). The CRC-32 algorithm requires byte reversed input and reversed output of the bit
flow, different from the CRC-16 one. To receive IEEE compliant result, the output must be
additionally reversed by XOR with “all 1” pattern (this is not a case of comparison with
pattern provided by IAR).
User must take care about linker file setting, too, to ensure adequate placement of the
check sum out of the tested area in the required format when switching between 32- and
16-bit software CRC calculation, due to casting of the calculation result.
When the compiler does not support the checksum (like Arm-KEIL or GCC), the situation is
much more complex: the user must handle the correct setting of a post-built calculation
provided by an external tool additionally, and insert the correct pattern into the project
(modify CHECKSUM segment defined at the end of the code area). To assure that, specific
batch procedures are prepared based on SREC freeware tool, which performs modification
of the HEX file provided by IDE.
For debugging purposes, it is crucial to keep load of the original code image and symbols,
not available for the modified HEX file. Older versions of the applied IDEs allow to load the
modified HEX file as a last step of the debug mode entry. Unfortunately, it is no more
possible with the latest versions of the IDEs when the original HEX is loaded exclusively at
the end. This overwrites the modification of the original file, making the debug of the CRC
calculation result quite complicated and time consuming (the only way is to modify the CRC
value by editing the sources after whatever change to match original and modify HEX files).
For an initial debugging user can avoid this external process and implement
DEBUG_CRC_CALCULATION feature.
The two cores communicate via specific embedded hardware semaphore system unit
(HSEM) to cross check each other activity and testing status. Both cores monitor HSEM
events by interrupts and process occupancy checks of dedicated channels permanently to
see the STL correct ongoing status. Master core monitors the periodicity of the slave STL
test cycles completed under timeout evaluation additionally on a separate channel.
The STL occupancy of HSEM channels and their distribution between master (Cortex® M7)
and slave (Cortex® M4) cores for the STL 3.0.0 integration example on the STM32H747
product is shown in Figure 1.
HSEM_ID_CLASSB_
SLAVE_SELFTEST (9) Each release of this HSEM cycle ID by slave raises master
interrupt and resets the slave activity timeout handled by master
HSEM_ID_CLASSB_ Master uses its run time test cycle complete period
SLAVE_CYCLE (10) to increase the slave HSEM cycle ID activity timeout
HSEM_ID_CLASSB_
MASTER_SELFTEST (11)
MS54334V1
The slave uses channel IDs 9 and 10, while the master uses only channel ID 11. Channel
IDs 9 and 11 perform global STL ongoing status of the cores, channel ID 10 informs master
whenever slave completes the STL testing cycle successfully. Both cores initially verify if the
complementary core overtakes its channel(s) during startup and make itself sensitive for
interrupt whenever each of them is released. When one of the cores faces an interrupt from
the complementary core channel indicating correct STL activity status release, it puts itself
to fail safe state by default. When master faces an interrupt from the slave channel
indicating completed STL test cycle, it sets a timeout (clears counter counting completion of
master testing cycles, which determines the period of the counter increments). The user can
set maximum number of master complete cycles as a limit to detect single complete event
from slave by constant MAX_NUMBER_OF_MISSED_SLAVE_CORE_CYCLES. When
master achieves this limit by the counter, it evaluates problem at slave side and puts itself in
safe state by default.
The code associated with dual core handling is included with conditional compilation flags
into the 2.4.0 version source files, hence the 3.0.0 code coincides with the 2.4.0 code if the
dual core support is not included. The user can monitor all this added or modified code
through conditional code blocks under SUPERSET_DUAL_CORE user define control in the
library source files. The code is then divided based on DUAL_CORE_SLAVE and
DUAL_CORE_MASTER user defines. To cover single core products, the dedicated source
files STLstartup and STLmain are not kept in the STL but new source files
STLstartup_DualCore and STLmain_DualCore have replaced them. The user can switch
back to the original source content, by keeping conditional the flag
SUPERSET_DUAL_CORE not defined.
Standard STL diagnostic verbose mode performed on dedicated UART interface is
supposed to be implemented by the main core only at the time of debugging. BSP LED
signals can be optionally provided from both cores to indicate system status. The master
core uses a standard set of LEDs indicating completion of RAM and flash memory testing
cycles and safe error status. The slave core controls a single additional LED toggling when
flash memory testing cycle completes at run time only.
For debugging purpose, user can make independent the testing processes running on both
cores by uncommenting define IGNORE_COMPLEMENTARY_CORE_STATUS. In this
case, the associated cross monitoring stays active and it is evaluated but not taken into
account and each core continues the normal STL execution even if problems are reported
by the other core.
For programmable electronic component applying a safety protection function, the 60335-1
standard requires incorporation of software measures to control fault /error conditions
specified in tables R.1 and R.2, based on Table H.11.12.7 of the 60730-1 standard:
• Table R.1 summarizes general conditions comparable with requirements given for
Class B level in Table H.11.12.7.
• Table R.2 summarizes specific conditions comparable with requirements for Class C
level of the 60730-1 standard, for particular constructions to address specific hazards.
Similarly, if software is used for functional purposes only, the R.1 and R.2 requirements are
not applicable.
The scope of this application note and associated STL package is Class B specification in
the sense of 60730-1 standard and of the respective conditions, summarized in Table R.1 of
the 60335-1 standard.
If safety depends on Class B level software, the code must prevent hazards if another fault
occurs in the appliance. The self test software is taken into account after a failure. An
accidental software fault occurring during a safety critical routine does not necessarily result
into a hazard, thanks to another applied redundant software procedure or hardware
protection function. This is not a case of much more severe Class C level, where fault at a
safety critical software results in a hazard due to lack of next protection mechanisms.
Appliances complying with Class C specification in the sense of the 60730-1 standard and
of the respective conditions summarized in Table R.2 of the 60335-1 standard are outside
the scope of this document as they need more robust testing and usually lead to some
specific hardware redundancy solutions like dual microcontroller operation. In this case,
user must use product dedicated safety manuals and apply the methods described there.
Class B compliance aspects for microcontrollers are related both to hardware and software.
The compliant parts can be divided into two groups, that is, micro specific and application
specific items, as exemplified in Table 10.
While application specific parts rely on customer application structure and must be defined
and developed by user (communication, IO control, interrupts, analog inputs, and outputs)
micro specific parts are related purely to the micro structure and can be generic (core self
diagnostic, volatile and non-volatile memories integrity checking, clock system tests). This
group of micro specific tests is the focus of the ST solution, based on powerful hardware
features of STM32 microcontrollers, like double independent watchdogs, CRC units or
system clock monitoring.
Table 10. MCU parts that must be tested under Class B compliance
Group Component to be tested according to the standard
CPU registers
CPU program counter
System clock
Microcontroller specific
Invariable and variable memories
Internal addressing (and External if any)
Internal data path
Table 10. MCU parts that must be tested under Class B compliance (continued)
Group Component to be tested according to the standard
Interrupt handling
External communication
Timing
Application specific
I/O periphery
Analog A/D and D/A
Analog multiplexer
The applied tests are primarily dedicated to detect permanent faults (to cover faults under
so called d.c. fault model). Detection of transient faults by any software testing is always
limited, because of the relatively long repetition period of testing (in comparison with any
hardware methods with permanent checking capability), and can be covered partially with
indirect routes.
Note: In case of minor changes to the modules, keep track of all of them, placing clear explanation
commentaries in the source files and informing the certification authorities of the differences
vs. the certified routines.
Internal reference voltage and temperature sensor (VBAT for some devices)
• Ratio between these signals can be verified within the allowed ranges
• Additional testing can be performed where the VDD voltage is known.
ADC clock
• Measurement of the ADC conversion time (by timers) can be used to test the
independent ADC clock functionality.
Comparator functionality
• Comparison between known voltage and DAC output or internal reference voltage can
be used for testing comparator output on another comparator input.
• Analog signal disconnection can be tested by pull-down or pull-up activation on tested
pin and comparing this signal with DAC voltage as reference on another comparator
input.
Operational amplifier
• Functionality can be tested forcing (or measuring) a known analog signal to the
operational amplifier (OPAMP) input pin, and internally measuring the output voltage
with the ADC. The input signal to OPAMP can also be measured by ADC (on another
channel).
Reconfiguration is only possible at the next reset sequence in this case. In addition, the bit
banding feature can be used for atomic manipulation of the SRAM and peripheral registers.
4.2.3 Interrupts
Occurrence in time and periodicity of events must be checked. Different methods can be
used; one of them uses set of incremental counters where every interrupt event increments
a specific counter. The values in the counters are then cross-checked periodically with other
independent time bases. The number of events occurred within the last period depends
upon the application requirements.
The configuration lock feature can be used to secure the timer register settings with three
levels controlled by the TIMx_BDTR register. Unused interrupt vectors must be diverted into
common error handler. Polling is preferable for non safety relevant tasks if possible to
simplify application interrupt scheme.
4.2.4 Communication
Data exchange during communication sessions must be checked while including a
redundant information into the data packets. Parity, sync signals, CRC check sums, block
repetition or protocol numbering can be used for this purpose. Robust application software
protocol stacks like TCP/IP give higher level of protection, if necessary. Periodicity and
occurrence in time of the communication events together with protocol error signals must be
checked permanently.
The user can find more information and methods in product dedicated safety manuals.
Architecture planning
The STL packet structure is the result of a long experience with repeatedly certified
firmware, where modules were integrated into ST standard peripheral libraries dedicated to
different products in the past. The main goal of the new firmware is to remove any hardware
dependence on different products and integration of safety dependent parts into a single
common stack of self tests based on new unique hardware abstraction interface (HAL)
developed for the whole STM32 family.
Such common architecture is considerably safer from a systematic point of view, involves
easier maintenance and integration of the solution when migrating either between existing
or into new products. The same structures are applied by many customers in many different
configurations, so their feedback is absolutely significant and helps to efficiently address
weaknesses, if any.
Coding
Coding is based on principles defined by internal ST policy, respecting widely recognized
international standards of coding, proven verification tools and compilers.
Emphasis is put on performing very simple and transparent thread structure of code, calling
step by step the defined set of testing functions while using simplified and clear inputs and
outputs.
The process flow is secured by a specific control mechanism and synchronized with system
tick interrupts providing specific particular background transparent testing. Hardware
watchdogs service is provided exclusively once the full set of partial checking procedures is
successfully completed.
Testing modules
Modules have been tested for functionality on different products, with different development
tools. Details can be found in the following sections and in the specific test documentation
dedicated to certification authorities (test report).
Maintenance
For the firmware maintenance ST uses feedback from customers (including preliminary beta
testers) processed according to standard internal processes. New upgrades are published
at regular intervals or when some significant bugs are identified. All the versions are
published with proper documentation describing the solution and its integration aspects.
Differences between upgrades, applied modifications, and known limitations are described
in associated release notes included in the package.
Specific tools are used to support proper software revision numbering, source files and the
associated documentation archiving.
All the firmware and documentation are available to ST customers directly from
www.st.com, or on request made to local supporting centers.
This section highlights the basic common principles used in ST software solution. The
workspace organization is described together with its configuration and debugging
capabilities. The differences between the supported development environments
(IAR-EWARM, Keil MDK-Arm and GCC Eclipse™ based SW4STM32 and STM32CubeIDE)
are addressed.
Area under
RAM backup buffer
run time
Pointer to Class B area
check
Gap (overlap) at the beginning
Area tested during of Class B area
the first step
Overlap
Area tested during
the second step Class B variables
(redundant complementary values)
Area under
...
run time
check
Class B variables
Area tested during
(normal values)
the last but one step
Overlap
Area tested during
the last step Gap (overlap) at the end
of Class B area
Class A variables
Unused RAM
Area under
Specific pattern to detect stack
run time
overflow
check
Stack
* Next pattern must be stored here if the stack does not start at the end of the RAM
MS35281V4
Align the size of the tested area to multiply single transparent steps while respecting the
overlay used for the first and last step of the test, including address scrambling.
That is why dummy gaps must be allocated at the beginning and at the end of the area
dedicated to Class B variables. Their size must correspond to the applied overlay of the
tested single block.
Backup buffer and pointer to Class B area must be allocated out of the area dedicated to
Class B variables, at a specific location tested separately each time the overall Class B area
test cycle is completed.
A specific pattern is written at the low boundary of stack space and checked for corruption at
regular intervals to detect the stack overflow. To check its underflow, a second pattern can
be written at high boundary if the stack is not placed at top of RAM. If the stack is placed at
top of RAM an underflow event raises a hardware exception event.
When more than a single stack area is used by the application, it is advisable to separate
the adjacent areas by boundary patterns to check that all the pointers operate exclusively
within their dedicated areas.
Stack and non safety RAM area are not checked by the Transparent RAM test at run time.
Counter = Counter + 5
Counter = Counter_ - 5
Component test 2
Component test n
MS39907V1
Note: The unique number for calling point of Component test 1 at main level is defined as 5 and
for the procedure itself it is defined as 7 in this example. The initial value of the counters are
0x0000 0000 and 0xFFFF FFFF for simplicity. The table in upper right corner of Figure 3
shows how the counters are changed in four steps and their consistent complementary state
after the last step of checking policy (return from procedure) is done.
5.2.3 Defining new safety variables and memory areas under check
Duplicate allocation of the safety critical variable image in CLASS_B_RAM and
CLASS_B_RAM_REV is needed to ensure redundancy of the safety critical data (Class B)
stored in variable memories. All other variables defined without any particular attributes are
considered as Class A variables and are not checked during the transparent RAM test.
Sizes of Class A and Class B variable regions can be modified in the linker configuration file.
New Class B variables must be declared in stm32xx_STLclassBvar.h header file, with
following syntaxes:
IAR™
__no_init EXTERN uint32_t MyClassBvar @ "CLASS_B_RAM";
__no_init EXTERN uint32_t MyClassBvarInv @ "CLASS_B_RAM_REV";
Keil®
EXTERN uint32_t MyClassBvar __attribute__((section("CLASS_B_RAM"),
zero_init));
EXTERN uint32_t MyClassBvar Inv __attribute__((section("CLASS_B_RAM_REV"),
zero_init));
GCC
extern uint32_t MyClassBvar __attribute__((section (".class_b_ram")));
extern uint32_t MyClassBvarInv __attribute__((section
(".class_b_ram_rev")));
Keep consistency between definition of the variables in the stm32xx_STLclassBvar.h
header file, linker configuration file and the self test library configuration file
For the integration examples the information provided by BSP LEDs, LCD display and via
verbose messages can vary according to the products. The STL status and its testing cycles
passed are performed by blinking dedicated LEDs, counters appearing on LCD screen or
flow of text and characters output at verbose terminal window.
Partial test
duration
Partial test
period
Complete Class B test period
ai18002
A dedicated signal toggles when specific tests (RAM, flash memory, clock) are active and
every time the testing procedure is completed (both at start-up and during run time). These
signals can be used to measure among others; length of the tests; frequency of partial tests
and time needed to finish an overall single testing cycle during both start-up and run time.
When the dedicated area under test has been completely inspected, a set of partial tests
starts again from the beginning.
Typical waveforms related to monitoring of dedicated I/Os signals at start-up or during run
time are shown in the oscilloscope screenshots shown, respectively, in Figure 5 and in
Figure 6.
RAM
LED2
Flash
memory
LED3
LED4
Watch dogs
NRST
MS40515V1
LED2
Flash memory test
cycle completed
MS40516V2
Table 12 summarizes the I/O signals, while Table 13 lists the typical values measured
during the test of the firmware packages.
STM32NUCLEO
STM32G081B
STM32L476G
20-21-45-46G
STM32L152B
STM32H747I-
STM32WB5P
STM32H743I
STM32756G
STM32052B
STM32373C
Signal
STM3241G
STM3210C
L552ZE-Q
NUCLEO
NUCLEO
NUCLEO
-G474RE
L053R8
-EVAL2
STM32
DISCO
-EVAL
-EVAL
-EVAL
-EVAL
-EVAL
-EVAL
-EVAL
EVAL
EVAL
Orange
PD9 PD13 PG8 PC1 PG8 PC8 PA5 PD7 PA8 PC7 PF10 PB0 PD5 PA5
LED2 PI12 (NC)
(CN8-6) (CN9-4) (CN3-22) (CN14-48) (CN3-22) (CN6-51) (CN5-D13) (CN10-15) (CN11-3) (CN12-19) (CN7-1) (CN10-22) (CN9-9) (CN10-11)
(yellow)
Red
PD10 PD3 PI9 PC2 PI9 PC9 PA6 PG14 PA9 PA9 PA4 PB1 PD8 PA6
LED3 PI13 (NC)
(CN8-4) (CN8-25) (CN1-12) (CN14-47) (CN1-12) (CN6-46) (CN5-D12) (CN10-6) (CN11-1) (CN12-21) (CN6-19) (CN10-24) (CN9-1) (CN10-13)
(green)
Blue
PD11 PD4 PC7 PC3 PC7 PC10 PA7 PG15 PA10 PB7 PA11 PA4 PD9
LED4 PI14 (NC) Not used
(CN11-21) (MFX-IO11) (CN10-17A)
AN4435 Rev 10
(purple) (CN8-2) (CN8-26) (CN3-20) (CN14-46) (CN3-20) (CN6-55) (CN5-D11) (CN10-5) (CN11-5) (CN9-2)
AN4435
Table 13. Comparison of results(1)
AN4435
STM32 series
Feature
F0 F1 F2 F3 F4 F7 L0 L1 L4 L5 H7 WB G0 G4
XTAL (MHz) 8 25 25 8 25 25 8 8 8 16 25 32 8 24
PLL frequency (MHz) 48 72 120 64 / 72 168 216 32 32 80 110 400 64 64 170
IAR 7.2 5.9 1.5 6.4 1.2 3.1 8.4 6.8 2.5 5.4 1.6 3.4 5.6 1.5
Flash memory test,
Keil 1.8 1.2 0.4 1.6 0.3 0.5 2.0 2.4 0.63 2.05 0.6 2.2 1.0 0.4
start-up (ms)
GCC 0.6 0.58 0.2 0.7 0.15 0.5 0.86 1.0 0.34 - 0.6 0.7 1.0 0.4
IAR 41 37 32 37 32 40 32 35 38 64 64 64 40 64
Tested flash memory (KB) Keil 10 11 9 12 9 10 12 12 11 134 18 33 10 11
GCC 10 10.6 9 11 9 9.5 10 10 10 - 22 12 20 11
Full RAM test, start-up (ms) 4.5 12.8 12.0 8.1 8.6 18.5 3.8 12.2 12.1 28.2 6.6 36 8 5.9
AN4435 Rev 10
Figure 7. Hyper terminal output window in verbose mode - Single core products
Figure 8. Hyper terminal output window in verbose mode - Dual core products
Figure 9. Integration of start-up and periodic run time self tests into application
RESET
Start up self-test
(STL _StartUp ())
Application startup
Main loop
Timebase ISR
Task 1
(SysTick_Handler())
Task 2
ISR 1
Task 3
ISR 2
MS18592V2
In principle, the following steps must be provided by the user when STL modules are
integrated into an application:
• Execution of initial start-up tests before user program starts
• Periodic execution of run time self tests set within dedicated time period related to
safety time
• Setup independent and window watchdogs and prevent their expiration when
application is running (ideal case is to tune their refresh with the STL testing period)
• Setup correct testing zones for both start-up and run time tests of RAM and Flash
• Respect error results of the tests and handle proper safety procedures
• Handle Safe state procedure and its content
• Handle HardFault exception procedure and its content
• Prevent possible conflicts with application software (especially interrupts, DMA, CRC -
see Table 14)
• Run tests of application specific microcontroller parts related to application safety tasks
• Exclude all debug features not related to any safety relevant task and use them for
debugging or testing purposes only.
Table 14. Possible conflicts of the STL processes with user software
Test Possible conflict Source
CPU Content of CPU registers under test is changed or applied by user software User interrupt
RAM content under test is changed or applied by user software User interrupt
RAM Data change done by user within range of just performed block of or
transparent test can be ignored or corrupted DMA activity
When any debug support is enabled during start-up tests user must ensure passing proper
C compiler initialization as some peripheral HAL drivers rely on content copied into RAM (for
example, fields of configuration constants supporting hardware of evaluation boards). This
could be a problem after complete RAM test is done, as this test destroys all the RAM
content. To prevent any problem with those HAL drivers user must ensure recovery of the
RAM content if they are used at this program phase between RAM test and entry to main
level.
While application is running, process periodic tests are performed at certain intervals
defined by value of Class B variable TimeBaseFlag. Frequency of these repetitions
provides a basic safety interval. Its setting is defined by the user and depends on application
limitations and needs. When user calculates overall runtime test cycle completion the tested
areas at RAM and Flash have to be considered together with size of single blocks under
these partial tests additionally.
To initialize periodic testing, user must call the STL_InitRunTimeChecks() routine at
beginning of main and then ensure periodical calls of STL_DoRunTimeChecks() at main
level - inside of main loop in best case. Periodicity is derived from SysTick interrupts defined
and initialized in the HAL layer. SysTick_Handler() interrupt service counts 1ms ticks and
performs short partial transparent RAM March C or March X checks at defined intervals (set
to 10 ms by default) when TimeBaseFlag rises, too, to synchronize the rest run checks
called from main level. FailSafePOR() routine is discussed in Section 5.1.1: Fail safe mode.
Pay special care to the possibility of corrupting the checking processes by accidental
interrupts (including NMI, if it is used for purposes different from the result of an internal
fault), and consider all the possible consequences of such events. He must also ensure that
no interrupts can corrupt execution of the STL tests or significantly change their timing.
When other time critical libraries (for example, real time operating system, motor control,
touch sensing control) are implemented, the user must ensure adequate system
performance for the repeated execution of all the self tests integrated into the target
application, and consider the impact of all possible interferences between the applied
libraries.
If there is no room to handle all the processes in parallel, the user can consider to postpone
run time testing procedures when application performs some critical operation, or give up
the run time testing and rely either on the results of the startup test or on hardware safety
features (like ECC or parity). Such a solution is acceptable when the application duration
period is short, or when the application restarts frequently. Anyway, such a specific
implementation of the STL library must always be matter of consultation with the certification
authority, and well documented by the applicant.
RESET
Fail
CPU core self-test
HW Reset
Watchdogs self-test
Switch PLL ON
Fail
Flash integrity check
Fail
RAM functional check
Fail
Clock frequency check
Fail
Control Flow check
MS18593V1
The start-up test structure is shown in Figure 11, and includes the following self tests:
• CPU start-up self test
• Watchdog start-up self test
• Flash memory complete check sum self test
• Full RAM March-C self test
• Clock start-up self test
• Control flow check
Fail
Test Flags
Fail
Test R0
Fail
Test link register R14
Fail
Test R1to R12
Fail
Verify ramp pattern R 0 to R 12
Fail
Test Process Stack Pointer
Fail
Test Stack Pointer R13
MS18594V1
Yes
Standard
reset?
No
Clear All Flags
No IWDG
reset ? HW Reset
Test IWDG
SW Reset
Yes Yes
Software Reset
HW Reset
WWDG No
Test WWDG
reset ?
Yes
Test OK
MS18595V1
The standard reset condition (power-on, low power, software or external pin flag signaling
the previous reset cause) is assumed at the beginning of the watchdog test. All the flags are
cleared while the IWDG is set to the shortest period and reset from IWDG is expected
initially. After the next reset, IWDG flag must be set and recognized as the sole reset cause.
The test can then continue with WWDG test. When both flags are set in reset status register
the test is considered as completed and all the flags in reset status register are cleared
again.
Ensure proper settings of IWDG and WWDG. Their periods and parameters of refresh
window must be set in accordance with time base interval because a normal refresh is
performed at the successful end of the periodical run time test at main loop.
The system tick interrupt service routine indicates a defined time base interval via a
dedicated time base flag. The run-time test is started at the main level periodically at this
interval. As the watchdog control is the last step of successfully finished run-time tests (and
it must be the only place where the watchdog is refreshed in the main loop) the time base
interval must be set in correlation with the watchdog timeout and vice versa.
The watchdog refresh period must be shorter than the watchdog timeout to prevent a reset
of the CPU, as indicated in Figure 17.
32-bit CRC = No
_check sum
Test OK
MS35297V1
Table 15. Physical order of RAM addresses organized into blocks of 16 words
Physical order of addresses →
0 1 3 2 4 5 7 6 8 9 11 10 12 13 15 14
Rows →
16 17 19 18 20 21 23 22 24 25 27 26 28 29 31 30
32 33 35 34 36 37 39 38 40 ...
Some new products have implemented hardware word protection with single bit redundancy
(hardware parity check) applied on CCM RAM or on part of SRAM at least. This aspect is
discussed in Section 3.
The algorithm of the entire test loop is shown in Figure 14. If an error is detected, the test is
interrupted and a fail result is returned.
MS39924V1
Note: The RAM test is word oriented but the more precise bit March testing algorithm can be used.
However this method is considerably more time and code consuming.
a. The product specific function STL_InitClock_Xcross_Measurement() handling the clock cross-check initial
configuration can't be a part of files keeping generic STL code, but it is implemented in the file
stm32yyxx_it.c, collecting all the associated interrupt services applied to the device.
application (for example, because of the varying accuracy of the reference clock signal over
the temperature range). The CPU clock is switched back to default HSI source after the test
is finished. If HSE clock is not used, comment parameter HSE_CLOCK_APPLIED in the
stm32xx_STLparam.h file (all the clock tests are performed on HSI).
Fail
Start of LSI clock
Fail
Start of HSE clock
Yes
Switch clock from HSE to HSI
MS35298V1
MS18900V1
Figure 17. Periodic run time self test and time base interrupt service structure
From main
True
TB_Flag?
TB_Flag= False
False
Partial CPU core test Fail
Note: Test of analog part, communication peripherals and application interrupts occurrence are
not included and their implementation depends upon device capability and user application
needs.
Push R4 – R7
Fail
Test R1 – R12
Fail
Verify ramp pattern R1 – R12
Pop R4 – R7
MS35280V1
Yes Fail
Any pattern corruption?
No
MS39925V2
1. The high end pattern must be checked for the stack underflow case when the stack area is not placed at
the physical end of the RAM space.
HSE in range No
+/- 25%?
Yes
MS35282V2
Figure 21. Partial Flash CRC run time self test structure
FLASH_pointer Yes
at ROM_END?
No No
CRC =
Compute continuous CRC _checksum?
over the current block
Yes
Set FLASH_Pointer
Init CRC computation
to next block
AI18016V2
No
Save content of RAM
block into the Buffer
RAM_pointer = Start
RAM_pointer += block_size of Class B RAM
AI18017V2
A single step of the test is performed in three phases, as shown in Figure 23 and in
Figure 24: the first one shows a continuous address model, while the second refers to a
model with physical scrambling (the different and not continuous testing order is highlighted
by gray boxes).
In the first phase, the current content of all the cells involved in the block testing (cells D1 to
D4) and the overlapped words (cells D0 and D5) is stored into the storage buffer. In the next
phase destructive March tests are performed over all the words of the tested RAM block. In
the final phase, the original content is restored from the storage buffer back to the tested
location.
The storage buffer itself is tested by a March test as the last step of the overall sequence.
The buffer area is tested together with the two next additional neighbor words to cover
coupling faults on the buffer itself. Size of storage buffer must be adapted to the size of
tested block. After the storage buffer is successfully tested, the whole test is reinitialized and
restarts from the beginning. If any fault is detected, the Fail Safe routine is called. The test
checks integrity of all associated variables before a block is checked.
The size of the block used for partial testing is fixed to four words by default (the next two
are involved into the test as overlap). This model corresponds to the repetition of the
scrambling pattern. When user changes the size of this block, the algorithm must respect
the period of the scrambling (if present). When SRAM is designed without any scrambling
the size of the block is free, but the user has anyway to modify routines written in assembly
(they are written for a fixed default block size).
Figure 23. Partial RAM run time self test - Fault coupling principle (no scrambling)
Ascending Test Descending Test
Step n Step n+1 Step n+1
Storage D0' D1' D2' D0' D1' D2' D0' D1' D2'
buffer D3' D4' D5' D3' D4' D5' D3' D4' D5'
D5
Overlap D0 D4 D3 D2 D1
Tested
D1 D2 D3 D4 D0 D0
area Overlap D5 D1 D2 D3 D4
D5 …..
MS39927V1
Figure 24. Partial RAM run time self tests - Fault coupling principle (with scrambling)
Ascending Test Descending Test
Step n Step n+1 Step n+1
Storage D0' D1' D2' D0' D1' D2' D0' D1' D2'
buffer D3' D4' D5' D3' D4' D5' D3' D4' D5'
D5
Overlap D0 D4 D3 D1 D2
Tested
D1 D2 D4 D3 D0 D0
area Overlap D5 D1 D2 D4 D3
D5 …..
MS39926V1
The order of the operations is given in Table 16. The March X algorithm can be used instead
of March C when symbol USE_MARCHX_TEST is applied for assembly compilation. The
test is faster because steps 2 and 3 are skipped and not executed.
AN4435
Table 17. Start-up
Pre-calls Control
Test module API procedure Input Defines Output HAL calls Comment
required flow
Written in assembler,
CPU STL_StartUpCPUTest() - void - STLErrorStatus(1) 3 - Failsafe is called directly (no
error return provided).
__HAL_RCC_GET_FLAG()
__HAL_RCC_CLEAR_FLAG()
__WWDG_CLK_ENABLE()
Based on RCC CSR register
HAL_WWDG_Init()
Watchdog STL_WDGSelfTest() - void - - - content, waiting for the
HAL_WWDG_Start()
device hardware reset.
HAL_IWDG_Init()
HAL_IWDG_Start()
NVIC_SystemReset()
Flash ROM_START
memory uint32_t CRC32 HAL driver is
AN4435 Rev 10
HAL_RCC_OscConfig()
HAL_RCC_ClockConfig()
HAL_RCC_EnableCSS()
HAL_NVIC_SetPriority()
LSI_Freq
STL_InitClock_ HAL_NVIC_EnableIRQ
HSE_VALUE,
Clock STL_ClockStartUpTest() Xcross_ void ClockStatus(2) 29 HAL_NVIC_SystemReset -
HSI_VALUE
Measurement() HAL_TIM_IC_Init()
APIs overview
SYSTCLK_AT_STARTUP
HAL_TIMEx_RemapConfig()
HAL_TIM_IC_ConfigChannel()
HAL_TIM_IC_Start_IT()
__HAL_RESET_HANDLE_STATE()
67/73
1. ErrorStatus = {ERROR=0, SUCCESS=1}: definition was taken from older HAL one, but replaced by separated definition of STLErrorStatus due to incompatibility with the latest HAL versions where the
original define has been changed.
68/73
APIs overview
2. ClockStatus = {LSI_START_FAIL, HSE_START_FAIL, HSI_HSE_SWITCH_FAIL, TEST_ONGOING, EXT_SOURCE_FAIL, XCROSS_CONFIG_FAIL, HSE_HSI_SWITCH_FAIL, PLL_OFF_FAIL,
CLASS_B_VAR_FAIL, CTRL_FLOW_ERROR, FREQ_OK}.
Written in assembler,
CPU STL_RunTimeCPUTest() - void - STLErrorStatus(1) 3 - Failsafe is called directly
(no error return provided).
init array
Stack STL_CheckStack() void - STLErrorStatus(1) 59 - -
aStackOverFlowPtrn[]
CLASS_B_START
RT_RAM_BLOCKSIZE CLASS_B_START and
CLASS_B_END define
RAM STL_TranspMarch() STL_TranspMarchInit() void RT_RAM_BLOCK_OVERLAP ClassBTestStatus(2) - -
tested area range (called
CLASS_B_END from ISR).
BCKGRND, INV_BCKGRND
HAL_RCC_OscConfig()
HAL_RCC_ClockConfig()
HAL_RCC_EnableCSS()
HAL_NVIC_SetPriority()
LSI_Freq
HAL_NVIC_EnableIRQ
STL_InitClock_Xcross_ HSE_VALUE, HSI_VALUE
Clock STL_ MainClockTest() void ClockStatus(3) 61 HAL_NVIC_SystemReset -
Measurement() SYSTCLK_AT_RUN_HSE
HAL_TIM_IC_Init()
SYSTCLK_AT_RUN_HSI
HAL_TIMEx_RemapConfig()
HAL_TIM_IC_ConfigChannel()
HAL_TIM_IC_Start_IT()
__HAL_RESET_HANDLE_STATE()
1. ErrorStatus = {ERROR=0, SUCCESS=1}: definition was taken from older HAL one, but replaced by separated definition of STLErrorStatus due to incompatibility with the latest HAL versions where the
original define has been changed.
2. ClassBTestStatus = {TEST_RUNNING, CLASS_B_DATA_FAIL, CTRL_FLW_ERROR, TEST_FAILURE, TEST_OK}.
AN4435
3. ClockStatus = {LSI_START_FAIL, HSE_START_FAIL, HSI_HSE_SWITCH_FAIL, TEST_ONGOING, EXT_SOURCE_FAIL, XCROSS_CONFIG_FAIL, HSE_HSI_SWITCH_FAIL, PLL_OFF_FAIL,
CLASS_B_VAR_FAIL, CTRL_FLOW_ERROR, FREQ_OK}.
AN4435 Revision history
Revision history
STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, enhancements, modifications, and
improvements to ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on
ST products before placing orders. ST products are sold pursuant to ST’s terms and conditions of sale in place at the time of order
acknowledgment.
Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or
the design of purchasers’ products.
Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product.
ST and the ST logo are trademarks of ST. For additional information about ST trademarks, refer to www.st.com/trademarks. All other
product or service names are the property of their respective owners.
Information in this document supersedes and replaces information previously supplied in any prior versions of this document.