Introduction to Secure Firmware Install (SFI) for STM32 MCUs

This application note supports the secure firmware install (SFI) feature available on the STM32 MCUs listed in Table 1. Outsourcing of product manufacturing enables original equipment manufacturers (OEMs) to reduce their direct costs and concentrate on high added-value activities, such as research and development, sales and marketing. However, contract manufacturing puts the OEM's proprietary assets at risk, and since the contract manufacturer (CM) manipulates the OEM's intellectual property (IP), it might be disclosed to other customers, or appropriated.

To meet the new market security requests and protect customers against any leakage of their IPs, STMicroelectronics introduces a new security concept, secure firmware install (SFI), permitting programming of OEM firmware into STM32 MCU internal flash memory in a secure way (with confidentiality, authentication and integrity checks).

Moreover, ST provides the STM32TRUSTEE that eases the OEM to secure its platform. STM32TRUSTEE involves adding STM32TRUSTEE-SM in SFI. STM32TRUSTEE is only available on STM32H5 series. In this document, each time there is a reference to STM32TRUSTEE, it applies only on STM32H5.

STM32 series devices support protection mechanisms that permit the protection of critical operations (such as cryptography algorithms) and critical data (such as secret keys) against unexpected access.

This application note gives an overview of the STM32 SFI solution with its associated tools ecosystem, and explains how to use it to protect OEM firmware during the CM product manufacturing stage.

Table 1. Applicable products

TypePart numbersOrder codeReferred as
STM32H5xxxxEntire STM32H5 series.STM32H5
STM32H730xxSupported on specific order codes, see [ES0491].STM32H7
STM32H733xx
STM32H735xx
MicrocontrollersSTM32H75xxxAll order codes supported (refer to datasheet ordering information section).
STM32H7B0xxSupported on specific order codes, see [ES0478].
STM32H7B3xx
STM32H7R3/7S3Entire STM32H7R/S lines.STM32H7RS
STM32H7R7/7S7
STM32L5xxxxEntire STM32L5 series.STM32L5
STM32U5xxxxEntire STM32U5 series.STM32U5
STM32WBA52/55STM32WBA52xG/55xG(1).STM32WBA5
STM32WL5xxxEntire STM32WL5x line.STM32WL5

1. These are the only supported order codes, only samples Revision B, only with 128 kB of RAM.

Related documents

Refer to the following documents available from www.st.com (unless an NDA applies):

Note: Programming tool manufacturers who want to support SFI/SMI/SSP solutions from STMicroelectronics and integrate them into their production line equipment should contact ST sales office for additional information under NDA.

Note: Arm is a registered trademark of Arm Limited (or its subsidiaries) in the US and/or elsewhere.

Glossary

TermDefinition
AESAdvanced encryption standard
AES GCMAES Galois counter mode
CMContract manufacturer
FTFlash memory programming tool
HDPHide data protection
HDPLHDP level
HSMHardware security module
MACMessage authentication code
MCUMicrocontroller unit
OBOption bytes
OBKOption bytes key
OCTOSPIOcto-SPI interface
OEMOriginal equipment manufacturer
OTFDECOn-the-fly decryption engine
RDPReadout protection
Secure bootRoot of trust, check STM32 security protection
Secure bootloaderStandard ST bootloader with additional security features
SFISecure firmware install
SFIxSFI on external flash memory
STM32 TPCSTM32 Trusted Package Creator (see [UM2238])
STM32TRUSTEE-SMSTM32TRUSTEE secure manager
user flash memoryFlash memory embedded within STM32 microcontrollers (internal flash memory)
WRPWrite protection

STM32 secure firmware install (SFI)

SFI principles overview

SFI is a secure mechanism implemented in STM32 microcontrollers that allows secure and counted installation of OEM firmware and STM32TRUSTEE-SM in untrusted production environment (such as OEM contract manufacturer). SFI is implemented in a secure bootloader.

The SFI process prevents the OEM firmware and STM32TRUSTEE-SM code from:

This mechanism consists in having the following content encrypted with an AES secret key, thanks to STM32 Trusted Package Creator tool(1), during OEM firmware development:

OEM must use STM32 Trusted Package Creator tool to program HSM with its own AES secret key(2), its own nonce, and a maximum installation counter.

In order to properly protect the firmware confidentiality, the AES secret key must be different every time the OEM encrypts a new firmware or a new release of the same firmware.

OEM contract manufacturer have to use STM32CubeProgrammer to initiate SFI process and send encrypted SFI image (3) to STM32 device.

A hardware security module (HSM) is in charge of:

The applicable STM32 microcontrollers are provisioned by STMicroelectronics with device dedicated public/private keys (unique key pair per device). The device keys can be accessed only through the embedded secure bootloader that retrieve AES secret key(7) by decrypting license using device private key.

Thanks to STM32 security features and cryptographic algorithm, the STM32 supports the programming in internal flash memory of:

More information is available in [WikiSFI].

SFI and internal flash memory

This section describes the execution of the SFI process for internal flash memory.

Figure 1. SFI process overview

Diagram illustrating the SFI process from OEM firmware development to STM32 SFI device, involving STM32 Trusted Package Creator, HSM, and STM32 Cube Programmer.

The secure bootloader is a standard ST bootloader with additional security features. If the STM32 microcontroller is reset during retrieving AES secret key (7), all sensitive data are erased before restarting initial SFI procedure. During SFI process, the secure bootloader never allows any other code to access user flash memory or SRAM.

SFI and external flash memory

This section applies to STM32 products with OTFDEC:

Note: When speaking of external flash memory, it matters to clearly identify the firmware and data that reside in external flash memory from the firmware and data that reside in user flash memory. Firmware and data in user flash memory are named hereafter internal firmware and data. The firmware and data that reside in external flash memory are referenced as external firmware and external data throughout the next sections.

The internal firmware must enable the read/fetch of data/code within external flash memory, using OTFDEC and OCTOSPI peripherals.

SFI cannot handle internal flash memory in a first sequence and external in a separate independent one: when SFI handles external firmware and data, it must first handle internal firmware and data that in turn enable decryption at runtime of external firmware and data.

External firmware and data on-the-fly decryption is handled by the OTFDEC peripheral. This peripheral can encrypt and decrypt on-the-fly external firmware and data stored in external flash memory connected to STM32 microcontrollers through the OCTOSPI interface. The OTFDEC can handle up to 4 regions of external flash memory, each one with its own dedicated Key. The OTFDEC uses standard AES CTR 128-bit algorithm for encryption and decryption operations. Refer to the OTFDEC section of the STM32 microcontroller reference manual to get more insight.

OEM can ensure the confidentiality of external firmware and data within external flash memory through 3 different use cases that are depicted within next sections.

External flash memory encryption without secure bootloader

The cryptographic engine responsible for the on-the-fly external flash memory decryption (OTFDEC) supports AES standard cryptographic algorithm. Thanks to this standard algorithm, OEM can encrypt external firmware and data on host before programming external flash memory, without using secure bootloader.

If external flash memory programming is done within a non-trusted facility, OEM must encrypt the external firmware and data before sending them to the non-trusted facility.

OEM internal firmware must handle the configuration of the OTFDEC peripheral with the AES key for external flash memory decryption. OEM must implement this part within the secure internal firmware in order to guaranty the confidentiality of the external flash memory AES encryption keys.

OEM internal firmware must also handle external flash memory drivers (through OCTOSPI) in order to get access to the external firmware and data.

Since OEM programs external flash memory on host, OEM must not encrypt external firmware and data thanks to STM32 Trusted Package Creator. However, OEM must send the external firmware and data AES encryption keys within the SFI image. Then, when building the SFI image thanks to STM32 Trusted Package Creator, OEM must create the SFI image with at least:

Figure 2 below shortly depicts SFI of an internal firmware that manages external firmware and data. The sequence part that addresses internal flash memory is the same than the one depicted in section Section 2.1.1: SFI and internal flash memory.

Figure 2 shows that the secure programming of internal flash memory(1) and the encryption plus programming of external firmware and data(2) are done in two separated flows within SFI. The first flow uses secure bootloader, the second one uses host for programming respectively internal flash memory and external flash memory.

Figure 2. SFI and external flash memory encryption without secure bootloader

Diagram illustrating SFI of internal firmware managing external firmware and data, with separate flows for internal and external memory programming.

External flash memory encryption with secure bootloader and global key

In the next two sections, this document focuses on SFI use cases with encryption of the external firmware and data by the secure bootloader. The STM32 receives encrypted external firmware and data, decrypts them with the SFI OEM key, and re-encrypts them with an external flash memory AES key common to all devices to be programmed or with a unique external flash memory AES key per device. This section focuses on the first scenario: a key common to all devices.

The STM32 secure bootloader uses the OTFDEC peripheral to encrypt external firmware and data, the STM32 secure bootloader stores the encryption result within SRAM. Then an external flash memory loader takes the previous result and program it within the external flash memory.

The external flash memory programming is under the responsibility of OEM, meaning that OEM must use an external flash memory loader that fits its external flash memory specificities. ST does not provide such external flash memory loader, except for demonstration purpose on ST boards supporting external flash memory.

Consequently, OEM must implement in internal flash memory the firmware parts dedicated to external flash memory handling (external flash memory keys and drivers).

OEM must create SFI image with:

OEM must take care to specify, in STM32 TPC, the same address in internal flash memory for external firmware and data AES key than the one its internal firmware uses for external flash memory on-the-fly decryption with OTFDEC peripheral.

The picture below shortly depicts an SFI sequence where STM32 secure bootloader handles both internal firmware installation and external firmware installation with the help of external flash memory loader.

Figure 4. External flash memory encryption with secure bootloader and global AES Key

Diagram illustrating SFI sequence with secure bootloader handling internal and external flash memory installation using a global AES key.

Figure 4 above shows that internal firmware and external firmware and data AES key must be installed first(1), then the previously mentioned key is copied within the OTFDEC peripheral (2) that is used to encrypt the external firmware and data for external flash memory(3). At last, OEM external flash memory loader programs the encrypted external firmware and data into the external flash memory(4).

Figure 5 below depicts the execution of the same internal firmware that, among other tasks, manages external firmware and data decryption.

Figure 5. Internal firmware and external flash memory handling (using global key)

Diagram showing internal firmware managing external firmware and data decryption using a global key.

External flash memory encryption with secure bootloader and unique key

This section focuses on the scenario where the secure bootloader encrypts the external firmware and data with a unique key per device. During SFI, the STM32CubeProgrammer first performs secure programming of the internal flash memory(1) then it requests the STM32 to randomly generate a key dedicated to the external flash memory encryption(2). The STM32 uses the TRNG peripheral to generate this key. After key generation the secure bootloader programs this last key(3) in the internal flash memory.

The STM32 uses the OTFDEC peripheral to encrypt the external firmware and data(4)(5). The STM32 stores the encryption result within SRAM. Then an external flash memory loader takes the previous result to program it within the external flash memory(6).

The external flash memory programming is under the responsibility of OEM, meaning that OEM must use an external flash memory loader that fits its external flash memory specificities. ST does not provide such external flash memory loader, except for demonstration purpose on ST boards supporting external flash memory.

Consequently, OEM must implement in internal flash memory the firmware parts dedicated to external flash memory handling (external flash memory keys and drivers).

OEM must create the SFI image with:

The STM32CubeProgrammer requests the STM32 secure bootloader to randomly generate a unique set of keys during the SFI sequence. Then OEM must take care to specify, within STM32 TPC, the same address in internal flash memory for key generation than the one its internal firmware uses for external flash memory on-the-fly decryption with OTFDEC peripheral.

The picture below shortly depicts an SFI sequence where the STM32 secure bootloader handles both internal firmware installation and external firmware installation with a unique external flash memory AES key and the help of an external flash memory loader.

Figure 6. External flash memory encryption with secure bootloader and unique AES Key

Diagram illustrating SFI sequence with secure bootloader handling internal and external flash memory installation using a unique AES key.

Figure 7 below depicts the way the internal firmware manages the OTFDEC and external flash memory unique key to decrypt on-the-fly external firmware and data.

Figure 7. Internal firmware and external flash memory handling (using unique key)

Diagram showing internal firmware managing external firmware and data decryption using a unique key.

SFI security features

The SFI security features are the following:

STM32 secure bootloader

STM32H75xxx/STM32H7B0xx/STM32H7B3xx/STM32H730xx/STM32H733xx/STM32H735xx

Secure bootloader overview

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

The STM32H75xxx/ STM32H7B0xx/STM32H7B3xx/ STM32H730xx/STM32H733xx/STM32H735xx 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/STM32H7B0xx/STM32H7B3xx/STM32H730xx/STM32H733xx/STM32H735xx secure bootloader

Diagram of the STM32H7 secure bootloader architecture, showing interfaces and memory components.

1. OTFDEC peripheral is only available on STM32H7B0xx/STM32H7B3xx/STM32H730xx/STM32H733xx/STM32H735xx devices.

User flash memory mapping

On STM32H75xxx/ STM32H7B0xx/STM32H7B3xx/ STM32H730xx/STM32H733xx/STM32H735xx, 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).

STM32H7RS

Hereafter, "STM32" refers to STM32H7RS (applicable to whole Section 3.2).

Secure bootloader overview

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.

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

Diagram of the STM32H7RS secure bootloader architecture, showing interfaces and memory components.

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.

STM32L5, STM32U5, STM32WBA5 and STM32H5

Hereafter, "STM32" refers to STM32L5, STM32U5, STM32WBA5 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

Diagram of a generic STM32 secure bootloader architecture, showing interfaces and memory components.

User flash memory mapping

On STM32, the secure bootloader is stored in system memory and SRAM, the products are delivered in RDP level0 and all the user flash memory is available for OEM.

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.

STM32TRUSTEE (only on STM32H5)

Only a part of the user flash memory is available for OEM firmware (see 4.3.2)

STM32WL5

Secure bootloader overview

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 SRAM2 through the supported COM ports. The supported COM ports are USART, SPI and JTAG. The second part runs in SRAM2 and is responsible for executing the SFI process and applying the SFI protocol thanks to the commands received through the above mentioned supported COM ports.

The secure bootloader permits to run the SFI process several times. For this, the STM32WL5 has been reprogrammed to its initial OB configuration (as delivered by STMicroelectronics).

For more details on the STM32 bootloader protocols, refer to [AN3155] (USART protocol) and [AN4286] (SPI protocol).

Figure 11. STM32WL5 secure bootloader

Diagram of the STM32WL5 secure bootloader architecture, showing interfaces and memory components.

User flash memory mapping

The secure bootloader is stored in system memory and SRAM2, the products are delivered in RDP level0 and all the user flash memory is available for OEM.

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 SRAM2 is fully available for OEM.

Secure boot path

In order to get the STM32WL5 booting on secure user flash memory after successful SFI, it is recommended to set nSWBOOTO to 0 and nBOOT0 to 1 in FLASH_OPTR register.

More information is available in [RM0453].

SFI image preparation

SFI firmware image format

The SFI format is an encryption format for firmware created by STMicroelectronics. It uses AES-GCM algorithm with a 128-bit key to transform a firmware in Elf, Hex, Bin or Srec formats into an encrypted and authenticated firmware in SFI format.

An SFI firmware image is composed of a header plus several areas. The areas are usually contiguous firmware areas. The last area is the configuration area containing the option byte values to be programmed when the SFI is complete.

SFI firmware image creation procedure for STM32H7/L5/U5/WBA5

To obtain SFI firmware images in the correct format (see Section 4.1: SFI firmware image format), the OEM must follow the steps below to build an SFI image:

  1. Build the firmware image(s) using regular development tools.
  2. Build the option byte configuration file. This file contains the option bytes that the customer plans to apply on the STM32 and that are programmed thanks to SFI. Among option bytes, the user must define the intended RDP value to be applied in order to enable the protection of user firmware and data against debug connection. Refer to applicable reference manual for more details on RDP level.
  3. Generate the binary image(s). A binary image does not need to be contiguous (that is it can cover multiple disjoint areas).
Table 3. Minimum RDP requirements
MicrocontrollerUse CaseMin RDP level
STM32H75xxxSFI on internal flash memory1
STM32H7B0xx / STM32H7B3xxSFI on internal flash memory and external flash memories1
STM32H730xx/ STM32H733xx/ STM32H735xxSFI on internal flash memory and external flash memories1
SFI on internal flash memory0.5
Protection of secure internal flash memory only
STM32L5SFI on internal flash memory1
STM32U5Protection of secure and non-secure internal flash memory only
STM32WBA5SFI on internal and external flash memories (1)1
Protection on both memories
STM32WL5SFI on internal flash memory0(2)
Protection of secure internal flash memory only
SFI on internal flash memory1
Protection of secure and non-secure internal flash memory only

1. Applicable to STM32L562xx, STM32U585xx, STM32U5Axxx and STM32U5Gxxx only (with OTFDEC).

2. With DDS = 1 and FSD = 0.

Figure 14. SFI image preparation procedure

Diagram illustrating the SFI image preparation procedure using STM32 Trusted Package Creator.

Internal flash memory only

To successfully generate an SFI image from the supported input firmware formats, click the SFI GUI tab, select the targeted micro-controller and fill in the interface fields with valid values:

Figure 15. SFI image generation tab example

Screenshot of the STM32 Trusted Package Creator GUI for generating an SFI image for internal flash memory.
  1. Add the firmware file using the Add button located within the Firmware files area appended to the input firmware files list.
  2. Make sure you are referring to the right valid firmware. Details are available in the Firmware information section once you have the Input firmware file is selected.
  3. Select the Encryption key and Nonce files. They can be selected either by entering their absolute or relative paths, or by selecting them with the Open button.
  4. Make sure that the size of the Encryption key file (16 bytes) and the Nonce file (12 bytes) are respected. In order to properly protect the firmware confidentiality, the AES secret key must be different every time the OEM encrypts a new firmware or a new release of the same firmware.
  5. Select the Option bytes file in .csv format. This is the only format supported.
  6. Enter the image version of the SFI to be generated. It must range from 0 to 255.
  7. Select Random key area file using the Open button (this is optional). Key area requests STM32 to randomly generate data of a specified size and at a specified address filled by user within key area file in .kcsv format.
  8. The Generate Hash option must be enabled on all STM32 devices supporting SFI.
  9. Select MCU to fill available RAM size for the SFI operation.
  10. Select the address where the continuation token is going to be stored. This field is only relevant for STM32H75xxx/ STM32H7B0xx/STM32H7B3xx/ STM32H730xx/STM32H733xx/STM32H735xx products, depending on firmware mapping, 0x081FF000 can be used as a nominal value (0x080FF000 as nominal value for STM32H733xx/STM32H735xx).
  11. For STM32H75xxx/ STM32H7B0xx /STM32H7B3xx/ STM32H730xx/STM32H733xx/STM32H735xx only, select SMI files, if any (optional field).
  12. Select the Output file folder path where the SFI image, out.sfi, is going to be generated.

Figure 16. SFI image successful generation

Screenshot of the STM32 Trusted Package Creator showing a successful SFI image generation.

13. Generate the SFI file by clicking the Generate SFI button. If all the fields are filled properly, the "SFI created successfully" message is displayed. More information is available in [UM2238].

Note: SMI files selection is only mandatory for secure module installation process. It is only supported on STM32H75xxx/ STM32H7B0xx/STM32H7B3xx/ STM32H730xx/STM32H733xx/STM32H735xx products.

Both internal and external flash memories

To successfully generate a SFI image including external FW and Data (also called SFIx image) from the supported input firmware formats, click the SFIx GUI tab, select the targeted micro-controller and fill in the interface fields with valid values:

Figure 17. SFIx image generation tab example

Screenshot of the STM32 Trusted Package Creator GUI for generating an SFIx image for both internal and external flash memories.
  1. Add the internal firmware file(s) using the Add button located within the Internal firmware files area appended to the input firmware files list. If the file is in bin format, the destination address has to be filled. If OEM uses global AES external flash memory keys, then internal firmware files must include those keys at the right address.
  2. Add the external firmware file(s) using the Add button located within the external firmware files area appended to the input firmware files list. When adding an external firmware, several additional fields have to be filled (destination address in external flash memory, OTFD region number, OTFD mode and global AES external flash key address).
  3. Select key area file using the Open button (this is optional). Key area requests STM32 to randomly generate data of a specified size and at a specified address filled by user within key area file in .kcsv format.
  4. Select the Encryption key and Nonce files. They can be selected either by entering their absolute or relative paths, or by selecting them with the Open button.
  5. Make sure that the size of the Encryption key file (16 bytes) and the Nonce file (12 bytes) are respected. In order to properly protect the firmware confidentiality, the AES secret key must be different every time the OEM encrypts a new firmware or a new release of the same firmware.
  6. Select the Option bytes file in .csv format. This is the only format supported.
  7. Enter the image version of the SFIx image to be generated. It must range from 0 to 255.
  8. The Generate Hash option must be enabled on all STM32 devices supporting SFI.
  9. Select MCU to fill available RAM size for the SFIx operation.
  10. Select the address where the continuation token is going to be stored. This field is only relevant for STM32H75xxx/STM32H7B0xx/STM32H7B3xx/STM32H730xx/STM32H733xx/STM32H735xx products, depending on firmware mapping, 0x081FF000 can be used as a nominal value (0x080FF000 as nominal value for STM32H733xx/STM32H735xx).
  11. Select the Output file folder path where the SFIx image, out.sfix, is going to be generated.

12. Generate the SFIx image file by clicking the "Generate SFIx" button. If all the fields are filled properly, the "SFIx created successfully" message is displayed. More information is available in [UM2238].

OEM Passwords for RDP Regression (STM32U5 and WBA5 series only)

On STM32U5 and STM32WBA5, it is possible to set the OEM1 and OEM2 passwords during the option bytes programming. To do so, the OEM must provide passwords different than 0x00000000 or 0xFFFFFFFF in the dedicated fields inside the Option-Bytes configuration file.

The OEM can also decide to diversify these passwords for each programmed chips thanks to the KEYDIVERS field in the Option-Bytes configuration file. This diversification is done during the secure programming of the SFI image using the KDF256 algorithm, with the two OEM-Key registers and the chip's Device Authentication ID as inputs.

Figure 19. OEM password diversification scheme

Diagram illustrating the OEM password diversification scheme using KDF256.

Knowing the master keys, the OEM can read the Authentication ID from the DBG_MCU interface, compute the chip's diversified keys on his own and then trigger the desired RDP regression.

The OEMDIVERS field from the Option-Bytes can be configured in multiple ways:

SFI firmware image creation for STM32H5

No STM32TRUSTEE

The steps are the same than in 4.2 with the following 2 modifications:

Figure 20. SFI image generation tab for STM32H5

Screenshot of the STM32 Trusted Package Creator GUI for generating an SFI image for STM32H5.

Debug authentication

Provision OBK to be able to perform debug authentication procedure that is used to:

STM32TRUSTEE

See [WikiSTM32H5].

SFI firmware image creation for STM32H7RS

Internal flash memory only

The steps are the same than in 4.2 plus the OBK to provision, SFIx is not supported on STM32H7RS:

Figure 21. SFI image creation tab for STM32H7RS

Screenshot of the STM32 Trusted Package Creator GUI for creating an SFI image for STM32H7RS.

Minimum OB requirements

For FLASH_ROTSRP register, it is mandatory to follow these rules:

OBK provisioning

The OBK must be provisioned to be able to perform the debug authentication procedure that is used to:

Optionally, provision the OBK to configure firmware application. It is mandatory to provision debug authentication OBK first.

More information is available in [RM0477].

SFI HSM key provisioning

HSM smartcard configuration is done using STM32 Trusted Package Creator tool following the below steps:

Note: HSM configuration can be done only once, the HSM is locked after successful programming. Contact ST sales representative for HSM ordering information.

  1. Insert a virgin HSM in smartcard reader.
  2. Select HSM tab of STM32 Trusted Package Creator.
  3. Add a firmware identifier (allows OEM to identify the correct HSM for a given firmware).
  4. Open the Encryption key and Nonce files. They can be selected either by entering their absolute or relative paths, or by selecting them with the Open button. In order to properly protect the firmware confidentiality, the AES secret key must be different every time the OEM encrypts a new firmware or a new release of the same firmware.
  5. On HSM V2, select the personalization data file according to specific STM32 MCU, productID and license type (stm32xx_productID_licenseType_....enc.bin). ProductID is defined in STM32 chip certificate and the different license types are detailed in Section 6.2. For security reasons, it is advised to use the most recent personalization data file available in the latest STM32CubeProgrammer version. More info on personalization data in [AN5054].
  6. Configure the maximum installation counter.
  7. Configure HSM by clicking the Program HSM button. A feedback window indicating that HSM is going to be completely locked is displayed, to confirm and continue the procedure click Yes. If all the fields are filled properly, the "HSM programmed successfully" message is displayed.

After key provisioning, HSM can be used to secure install protected firmware on counter number of STM32 devices.

More information on HSM provisioning is available in [AN5054].

Figure 22. HSM V1 key provisioning example

Screenshot of the STM32 Trusted Package Creator GUI for HSM V1 key provisioning.

Figure 23. HSM V2 key provisioning example

Screenshot of the STM32 Trusted Package Creator GUI for HSM V2 key provisioning.

SFI image programming by OEMs or CMs

Secure firmware installation flow

Once the SFI image has been prepared using the STM32 Trusted Package Creator, the OEM sends it to the CMs. CM production lines need to be equipped with a flash memory programming tool (FT). This tool is used to:

  1. Download the SFI image prepared with STM32 trusted package creator, including the image header and the encrypted part of the SFI image.
  2. For each STM32 device:
  1. STM32L5, STM32U5, STM32WBA5 and STM32WL5: load secure bootloader part II within SRAM.
  2. Request the device certificate from the secure bootloader.
  3. Request a dedicated license from the HSM. The HSM uses the device certificate to produce a dedicated license for a given firmware to be stored in this particular STM32 device. HSM can generate different license types according to the provisioned personalization data file in HSM (see Section 5 step 5). The different licenses types are detailed in Section 6.2.
  4. Ask the secure bootloader to process the license, decrypt and flash the SFI image in internal flash memory.
  5. Ask secure bootloader to decrypt and re-encrypt SFI image section dedicated to external flash memory if applicable.
  6. Ask external flash loader to program encrypted external flash section to external flash memory if applicable.
  7. Program STM32 option bytes.

STM32CubeProgrammer is the flash memory programming tool provided by STMicroelectronics. It is available in CLI mode and can be downloaded free of charge from www.st.com.

STM32CubeProgrammer is not certified for production lines, but can be used for testing SFI.

It supports the secure programming of SFI images for:

STM32CubeProgrammer communicates with the chosen interface that triggers the secure bootloader in order to handle the OEMs' encrypted SFI image during SFI operations.

On STM32H75xxx/STM32H7B0xx/STM32H7B3xx/STM32H730xx/STM32H733xx/STM32H735xx only, to start the SFI process, the bootloader activates the security via OB programming, which in turn activates the secure bootloader.

On STM32U5 and STM32WBA5, if OEM password keys have been set, it is necessary to reset them to start a SFI or SFIx. The value 0xFFFFFFFF must be written in OEM password keys to reset these keys.

STM32CubeProgrammer example command using USART interface on STM32 devices supporting SFI and with HSM smartcard usage:

sfi command example allowing secure installing of firmware "data.sfi" into STM32 user flash memory:

STM32_Programmer_CLI.exe -c port=COM1 -sfi "C:\SFI\data.sfi" hsm=1 slot=1

More information is available in [UM2237] and [AN5054].

License types

Here are the different license types generated by the HSM depending on the selected personalization data file:

Table 4. SFI licenses
typeLicenses descriptionPlatforms
WL5L5U5H5WBA5H7H7RS
SFI.HSM license for firmware installYesYesYesYesYesNoYes
SMI.HSM license for module installNoNoNoNoNoYesNo
SFIA.HSM license for firmware install without user flash mass eraseYesYesYesNoYesYesYes

Note: Be careful when selecting SFIA license, it is used to load firmware or data in user flash before launching SFI. If SFIA personalization data file is not available under STM32CubeProgrammer, contact ST sales representative.

In order to properly protect customer firmware confidentiality when using SFIA license, SFI installed firmware must control and restrict preloaded firmware or data during OEM firmware boot and execution.

By default, "SFI." license must be used so that user flash is erased or checked during SFI installation.

Known limitations

STM32H75xxx known limitations

SFI limitation

During a SFI involving a firmware which has to be written on last word of a flash memory bank, an error is raised by the secure bootloader and the firmware is not programmed.

Recommendation

If the firmware to program in internal flash memory exceeds the size of one memory bank, it must be splitted in two parts (from linker point of view) with the first part avoiding the last word of the bank.

STM32U5 known limitations

SFI limitation

For SFI on STM32U575I evaluation board (STM32U575I-EV), SWD frequency must not exceed 8000 kHz. On the STM32U5G9J-DK2 board SFIx is unavailable.

STM32WBA5 known limitations

SFI limitation

SFI can only run on samples Revision B. SFI can only run on products with 128 kB of RAM.

Revision history

Table 5. Document revision history
DateRevisionChanges
20-Dec-20181Initial release.
12-Mar-20192Added Table 1. Applicable products with indication of the STM32L462CEU6F (special order) code.
11-Jun-20193Document is declassified.
11-Sep-20194Restored and updated missing Figure 8. STM32H75xxx/STM32H7B0xx/STM32H7B3xx/STM32H730xx/STM32H733xx/STM32H735xx secure bootloader.
07-Oct-20195Updated Table 2. Glossary terms. Updated Section 3.3.1: Secure bootloader overview. Updated Section 3.3.2: User flash memory mapping. Added Section 7: Known limitations. Added support for STM32L5 series: Updated Table 1. Applicable products. Updated Section 1.1: Related documents. Updated Section 1.2: Glossary. Updated Section 2.1: SFI principles overview. Added Section 2.1.2: SFI and external flash memory. Updated Section 2.2: SFI security features. Added Section 3.3: STM32L5, STM32U5, STM32WBA5 and STM32H5. Updated Section 4.2: SFI firmware image creation procedure for STM32H7/L5/U5/WBA5. Added Section 4.2.2: Both internal and external flash memories. Updated Section 6.1: Secure firmware installation flow.
20-Dec-20196Introduced STM32H7B3xx. Updated Table 1. Applicable products. Updated title of Section 2.1.2: SFI and external flash memory. Updated Section 3.1: STM32H75xxx/STM32H7B0xx/STM32H7B3xx/STM32H730xx/STM32H733xx/STM32H735xx. Updated Table 3. Minimum RDP requirements. Updated Section 4.2.1: Internal flash memory only. Updated Section 6.1: Secure firmware installation flow.
14-Jan-20207Introduced STM32H733xx/STM32H735xx. Updated Table 1. Applicable products. Updated Section 1.1: Related documents. Updated title of Section 2.1.2: SFI and external flash memory. Updated Section 3.1: STM32H75xxx/STM32H7B0xx/STM32H7B3xx/STM32H730xx/STM32H733xx/STM32H735xx. Updated Table 3. Minimum RDP requirements. Updated Section 4.2.1: Internal flash memory only. Updated Section 6.1: Secure firmware installation flow.
26-Aug-20208Updated Table 1. Applicable products. Updated Section 1.1: Related documents. Updated title of Section 2.1.2: SFI and external flash memory. Updated Section 3.1: STM32H75xxx/STM32H7B0xx/STM32H7B3xx/STM32H730xx/STM32H733xx/STM32H735xx. Updated Table 3. Minimum RDP requirements. Updated Section 4.2.1: Internal flash memory only. Updated Section 6.1: Secure firmware installation flow.
13-Nov-20209Introduced STM32WL5. Updated Table 1. Applicable products. Updated Section 1.1: Related documents. Updated Section 2.1: SFI principles overview. Updated Section 2.2: SFI security features. Updated Section 3.3.1: Secure bootloader overview. Updated Section 3.3.1: Secure bootloader overview. Updated Section 3.3.1: Secure bootloader overview. Updated Section 3.4.1: Secure bootloader overview. Updated Table 3. Minimum RDP requirements. Added Section 3.4: STM32WL5. Updated Section 5: SFI HSM key provisioning. Updated Section 6.1: Secure firmware installation flow.
28-Jan-202110All updates are STM32L462CE related only. Updated 3.3.1: Secure bootloader overview. Updated 3.3.1: Secure bootloader overview. Updated Figure 11. STM32L462CE internal user flash memory mapping with SFI. Updated footnote in Table 3. Minimum RDP requirements. Updated Section 7.2: STM32L462CE known limitations.
07-Sep-202111Introduced STM32U5. Updated Table 1. Applicable products. Updated Section 1.1: Related documents. Updated Section 2.1.2: SFI and external flash memory. Updated 3.3.1: Secure bootloader overview including Figure 10. STM32L462CE secure bootloader. Updated Section 3.3: STM32L5, STM32U5, STM32WBA5 and STM32H5. Updated Table 3. Minimum RDP requirements. Updated Section 5: SFI HSM key provisioning including Figure 22. HSM V1 key provisioning example and new Figure 23. HSM V2 key provisioning example. Updated Section 6.1: Secure firmware installation flow. Updated Section 7.2: STM32L462CE known limitations.
10-Mar-202212Updated Table 1. Applicable products. Updated Section 1.1: Related documents. Updated Section 2.1: SFI principles overview. Updated Section 2.1.2.3: External flash memory encryption with secure bootloader and unique key. Updated Section 4: SFI image preparation introduction. Added Figure 12. STM32 Trusted Package Creator - SFI option bytes. Updated Figure 13. STM32 Trusted Package Creator - SFI image creation. Updated Section 4.2.1: Internal flash memory only. Updated Figure 15. SFI image generation tab example. Updated Figure 16. SFI image successful generation. Updated Section 4.2.2: Both internal and external flash memories. Updated Figure 17. SFIx image generation tab example. Updated Figure 18. SFIx image successful generation.
28-Jun-202213Added STM32H730xx and STM32H7B0xx in the whole document. Replaced STM32H75xxl by STM32H75xxx in the whole document. Replaced STM32H7B3xl by STM32H7B3xx in the whole document. Updated Section 3.1.4: Secure boot path. Updated Section 4: SFI image preparation introduction. Updated Section 4.2: SFI firmware image creation procedure for STM32H7/L5/U5/WBA5. Updated Section 5: SFI HSM key provisioning. Updated Section 6.1: Secure firmware installation flow. Added Section 7.2: STM32U5 known limitations.
14-Feb-202314Extended the scope of the document to entire STM32U5 series (instead of only STM32U575/585 lines) with updates in: Table 1. Applicable products. [RM0456]. Section 3.3: STM32L5, STM32U5, STM32WBA5 and STM32H5. Section 3.3.3: External flash memory mapping. Table 3. Minimum RDP requirements. Section 6.1: Secure firmware installation flow. Section 7.2: STM32U5 known limitations.
28-Sep-202315Added STM32U5 in the whole document. Updated document title. Updated: Section Introduction. Section 1: Preamble. Section 2: STM32 secure firmware install (SFI). Section 3.3.2: User flash memory mapping. Section 4: SFI image preparation. Section 7.2: STM32U5 known limitations. Added: Section 3.3.2.1: No STM32TRUSTEE. Section 3.3.2.2: STM32TRUSTEE (only on STM32H5). Section 4.2.3: OEM Passwords for RDP Regression (STM32U5 and WBA5 series only). Section 4.3: SFI firmware image creation for STM32H5. Figure 20. SFI image generation tab for STM32H5.
29-Feb-202416Added STM32H7RS and STM32WBA5 in the whole document. Suppressed STM32L4 devices in the whole document. Updated Table 1. Applicable products. Updated Section 1.1: Related documents. Updated Section 2.1: SFI principles overview. Updated Section 2.1.1: SFI and internal flash memory. Updated Section 2.1.2: SFI and external flash memory. Updated Section 2.2: SFI security features. Updated Section 3.3: STM32L5, STM32U5, STM32WBA5 and STM32H5 introduction. Updated Figure 10. STM32 secure bootloader title. Updated Section 3.3.4: Secure boot path. Updated Section 4.2: SFI firmware image creation procedure for STM32H7/L5/U5/WBA5. Updated Section 4.3.1: No STM32TRUSTEE. Added Section 4.4: SFI firmware image creation for STM32H7RS. Updated Section 5: SFI HSM key provisioning. Updated Section 6: SFI image programming by OEMs or CMs. Added Section 6.2: License types. Added Section 7.3: STM32WBA5 known limitations.

File Info : application/pdf, 42 Pages, 2.23MB

PDF preview unavailable. Download the PDF instead.

dm00355688-stm32-mcus-secure-firmware-install-sfi-overview-stmicroelectronics

References

C2 v20.4.0000 build 240 - c2 rendition config : Techlit Active Antenna House PDF Output Library 7.2.1732; modified using iText 2.1.7 by 1T3XT

Related Documents

Preview STM32 MCUs Secure Firmware Install (SFI) Overview
This application note provides an overview of the STM32 Secure Firmware Install (SFI) solution, detailing its principles, implementation, and use cases for protecting OEM firmware during contract manufacturing. It covers secure programming, encryption, and the role of hardware security modules.
Preview Introduction to System Memory Boot Mode on STM32 MCUs
This application note from STMicroelectronics provides a comprehensive guide to the system memory boot mode on STM32 microcontrollers. It details supported peripherals, hardware requirements, and the bootloader's role in downloading application programs via various serial interfaces. The document covers different STM32 series and their specific bootloader configurations, selections, and versions.
Preview STM32U585xx Security Guidance for PSA Certified Level 3 with SESIP Profile
This user manual provides detailed security guidance for STMicroelectronics STM32U585xx microcontrollers, focusing on achieving compliance with SESIP Profile for PSA Certified Level 3. It covers essential preparative procedures, secure installation steps, and operational guidance for integrators, including configuration options, security measures, and modes of operation.
Preview STM32CubeProgrammer v2.19.0 Release Notes
This document provides release notes for STM32CubeProgrammer version 2.19.0, detailing new features, fixed issues, and known problems for the STM32 microcontroller programming tool.
Preview STM32CubeProgrammer Release Note v2.7.0
This release note details the evolution, problems, and limitations of the STM32CubeProgrammer software, including new features and fixed issues across various versions.
Preview Getting Started with STM32CubeU5 TFM Application
Learn how to implement a root of trust solution with Secure Boot and Secure Firmware Update using the STM32CubeU5 TFM application. This guide details the integration of the open-source Trusted Firmware-M (TF-M) on STM32U5 microcontrollers, leveraging hardware security features for enhanced device protection.
Preview STM32U5 系列 STM32Cube MCU 包示例
STM32CubeU5 MCU 包提供了一系列丰富的示例,这些示例在意法半导体 (ST) 的开发板上运行。这些示例按开发板进行组织,并为主要的工具链提供了预配置的项目。
Preview STM32 Low-Power Timer (LPTIM) Application Note: Use Cases and Features
This application note from STMicroelectronics details the features, clock sources, power modes, and practical use cases of the Low-Power Timer (LPTIM) integrated into STM32 microcontrollers. It covers asynchronous pulse counting, PWM generation, and timeout wakeup functionalities, emphasizing low-power operation.