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

SFI firmware image creation for STM32H5

No STM32TRUSTEE

The steps are the same than in SFI firmware image creation procedure for STM32H7/L5/U3/U5/WBA5/WBA6/WL5 with the following 2 modifications:

Figure 21. SFI image generation tab for STM32H5


Debug authentication

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

  • perform a full or partial regression
  • open the debug for a given HDP level and security state (HDPL1_S, HDPL1_NS, HDPL2_S, HDPL2_NS, HDPL3_S, HDPL3_NS)

Minimum OB requirements

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

  • OEM_PROVD must be set to 0xB4 (provisioned)
  • DBG_AUTH must be set to 0x51, 0x8A or 0xB4 (ECDSA, password or Locked)
  • IROT_SELECT must be set to whether 0x6A or 0xB4 (configuration ignored on STM32H7R3/H7R7)

OBK provisioning

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

• perform a full regression

• open the debug for a given HDP level (HDPL1, HDPL2, HDPL3)

• force download (allow application update using BL)

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

More information is available in [RM0477].

SFI ST HSM key provisioning

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

Note:

ST HSM configuration can be done only once, the ST HSM is locked after successful programming.

Contact ST sales representative for ST HSM ordering information.

  1. Insert a virgin ST HSM in smartcard reader.
  2. Select HSM tab of STM32 Trusted Package Creator.
  3. Add a firmware identifier (allows OEM to identify the correct ST 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 ST 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 License types.

    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 ST HSM by clicking the Program HSM button. A feedback window indicating that ST 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, ST HSM can be used to secure install protected firmware on counter number of STM32 devices.

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

Figure 23. ST HSM V1 key provisioning example


Note:

When using ST HSM version 1, the "Personalization data file" field is ignored when programming starts. It is only used with ST HSM version 2.

When the card is successfully programmed, a popup window message "HSM successfully programmed" appears, and the ST HSM is locked. Otherwise an error message is displayed.

Figure 24. ST HSM V2 key provisioning example


Note:

When the card is successfully programmed, a popup window message "HSM successfully programmed" appears, and the ST HSM is locked. Otherwise an error message is displayed.

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, STM32U3, STM32U5, STM32WBA5, STM32WBA6, STM32WL5, and STM32H5: load secure bootloader part II within SRAM.
    2. Request the device certificate from the secure bootloader.
    3. Request a dedicated license from the ST HSM. The ST HSM uses the device certificate to produce a dedicated license for a given firmware to be stored in this particular STM32 device. ST HSM can generate different license types according to the provisioned personalization data file in ST HSM (see SFI ST HSM key provisioning step 5). The different licenses types are detailed in License types.
    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.

The supported interfaces (JTAG, USART, USB, SPI, ...) are listed in STM32CubeProgrammer user manual [UM2237].

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 only, to start the SFI process, the bootloader activates the security via OB programming, which in turn activates the secure bootloader.

On STM32U5, STM32WBA5, and STM32WBA6, 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. On STM32U3, if OEM password keys have been set, it is not possible to run SFI procedure on the sample anymore.

STM32CubeProgrammer example command using USART interface on STM32 devices supporting SFI and with ST 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].