AN4992 · Application noteIntroduction to secure firmware install (SFI) for STM32 MCUs
Download .pdfOpen in the full document

SFI security features

SFI security features

The SFI security features are the following:

  • Only genuine STMicroelectronics STM32 microcontrollers can install the protected firmware.
  • The number of STM32 devices on which the firmware has been installed can be counted.
  • Authenticity, integrity and confidentiality of the OEM internal firmware and option bytes are checked and user flash memory is programmed with decrypted firmware, OBK (in case of STM32H5 and STM32H7RS), and option bytes. If applicable, for the confidentiality of the OEM external firmware, the STM32 receives encrypted OEM external firmware, decrypts this firmware, and re-encrypts with a device unique or global key before programming in external flash memory.

Secure bootloader overview

On the STM32H75xxx, the secure bootloader is stored in the internal boot ROM (system memory) and supports following interfaces: USART, SPI, USB-DFU and JTAG.

The STM32H75xxx secure bootloader permits to run the SFI process several times after complete erase of the internal user flash memory, if erase allowed by installed application.

For more details on STM32 bootloader protocols, refer to [AN3155] (USART protocol), [AN4286] (SPI protocol) and [AN3156] (USB DFU protocol). The documents are available on www.st.com (unless an NDA applies).

Figure 8. STM32H75xxx secure bootloader


User flash memory mapping

On STM32H75xxx, since the secure bootloader is stored in the system memory, the product is delivered in RDP level0 and all the user flash memory is available for OEM.

The OEM firmware can be built to start at the beginning of the user flash memory (starting address 0x0800 0000).

Secure boot path

After successful SFI process and if a secure area is set, the STM32H75xxx always boot in the secure area closest to the configured boot address.

More information is available in [RM0399] for STM32H755xx/STM32H757xx.

More information is available in [RM0433] for STM32H750xx/STM32H753xx.

STM32H7RS

Note:

Hereafter, “STM32” refers to STM32H7RS (applicable to whole STM32H7RS).

The STM32 SFI process can only perform secure programming in user flash memory firmware when all necessary data are loaded in SRAM (no interaction between host and STM32 device during SFI process) and product state is set to provisioning at the beginning of the SFI procedure.

Secure bootloader overview

On STM32, the secure bootloader is split in two parts.

The first part is stored in boot ROM (system memory). It is responsible for loading the second part of the bootloader in SRAM through the supported interfaces. The supported interfaces are USART, SPI, I2C, I3C, FDCAN, USB and JTAG.

The second part runs in SRAM and is responsible for executing the SFI process, applying the SFI protocol and parsing all the data previously loaded in SRAM.

The STM32 secure bootloader permits to run the SFI process several times after complete erase of user flash memory, if the erase is allowed by the previously installed application.

For more details on the STM32 bootloader protocols, refer to [AN3155] (USART protocol), [AN4286] (SPI protocol), [AN4221] (I2C), [AN5927] (I3C), [AN3154] (FDCAN) and [AN3156] (USB). The documents are available on www.st.com (unless an NDA applies).

Figure 9. STM32H7RS secure bootloader


User flash memory mapping

On STM32, the secure bootloader is stored in system memory and SRAM, the product is delivered in Open product state and all the user flash memory is available for OEM.

More information is available in [RM0477].

STM32L5, STM32U3, STM32U5, STM32WBA5, STM32WBA6, and STM32H5

Note:

Hereafter, “STM32” refers to STM32L5, STM32U3, STM32U5, STM32WBA5 , STM32WBA6, and STM32H5 series (applicable to whole Section 3.3).

The STM32 SFI process can only perform secure programming in user flash memory firmware using Arm® TrustZone®, i.e with TZEN bit from FLASH_OPTR register set to 1.

Secure bootloader overview

On STM32, the secure bootloader is split in two parts.

The first part is stored in boot ROM (system memory). It is responsible for loading the second part of the bootloader in SRAM through the supported interfaces. The supported interfaces are USART, SPI, I2C, FDCAN, USB and JTAG.

The second part runs in SRAM and is responsible for executing the SFI process and applying the SFI protocol thanks to the commands received through the above mentioned supported interfaces.

The STM32 secure bootloader permits to run the SFI process several times after complete erase of user flash memory, if the erase is allowed by the previously installed application.

For more details on the STM32 bootloader protocols, refer to [AN3155] (USART protocol), [AN4286] (SPI protocol), [AN4221] (I2C), [AN3154] (FDCAN) and [AN3156] (USB). The documents are available on www.st.com (unless an NDA applies).

Figure 10. STM32 secure bootloader


No STM32TRUSTEE

The OEM internal firmware can be built to start at the beginning of the user flash memory (starting address 0x0800 0000). After a SFI, the SRAM is fully available for OEM.

External flash memory mapping

As explained before, the STM32L562xx, STM32U585xx, STM32U5Axxx, STM32U5Gxxx, STM32H5Fxxx, STM32H573xx, and STM32H533xx can decrypt external firmware and data on-the-fly. This can be done if they reside on external flash memory connected to the STM32 through the OCTOSPI interface. Consequently, the external firmware must be built with addresses within the range 0x90000000 to 0x9FFFFFFF (OCTOSPI1) or within the range 0x70000000 to 0x7FFFFFFF (only for STM32U585xx with OCTOSPI2).

The STM32L562xx, STM32U585xx, STM32U5Axxx, STM32U5Gxxx, STM32H5Fxxx, STM32H573xx, and STM32H533xx OCTOSPI peripheral can drive external flash memory up to 256 Mbytes. The available external flash memory dependends on the external flash memory device connected by the user to the STM32L562xx, STM32U585xx, STM32U5Axxx, STM32U5Gxxx, STM32H5Fxxx, STM32H573xx, or STM32H533xx.

Secure boot path

In order to get STM32 booting on secure user flash memory (at SECBOOTADD0 from FLASH_SECBOOTADD0R Option Byte register) after successful SFI, it is recommended to set to 0 nSWBOOT0 and set nBOOT0 to 1 from FLASH_OPTR register.

More information is available in: