How to start with OEMiRoT on STM32U0

Literature

  • UM2237 STM32CubeProgrammer software description

Target description
The purpose of this article is to explain step by step how to use the STM32CubeFW example provided by ST, for OEMiRoT, using the Nucleo-STM32U083RC board:

  • How to use the script provided by ST and perform all the required steps.
  • How to install and run the user application example which is provided.

Based on this STM32CubeFW example, additional exercises are proposed:

  • To perform a firmware upgrade using the loader

Introduction

One example of OEMiRoT is provided in the STM32Cube_FW_U0 that is used in this "getting started".

Through this practical example you will learn:

  • What OEMiRoT is and how to use the STM32CubeFW example which is provided.
  • How to configure the OEMiRoT.
  • How to generate an encrypted and signed image for the user application firmware and user data.
  • What the device provisioning is and how to perform the setup of the device.
  • How the user application is installed.
  • How to execute the example user application.
  • How to update the application using the loader.

Prerequisites

  • Hardware
    • STM32U083 Nucleo board
    • USB-C cable
Nucleo-U083
  • Required tools
    • STM32Cube_FW_U0_V1.0.0 or later
    • STM32CubeProgrammer_rev2.16.0 or later
    • IAR Embedded Workbench® rev 9.20.4 or later
    • Tera Term / Putty or equivalent terminal emulator
  • STM32Cube Firmware
    • Download the STM32Cube_FW_U0 Cube firmware (avoid long paths in the location).
    • A directory NUCLEO-U083RC is included in "STM32Cube_FW_U0_V1.x.x\Projects".
  • Open the env.bat file in the ROT_Provisioning sub-folder.
  • 1- If the STM32CubeProgrammer has not been installed in the default folder

C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer, the customized installation path needs to be updated.

  • 2- Check that the OEMiRoT_Appli path is correct.


1. Example configuration

This chapter explains how to start with the provisioning script.
It is used to configure the OEMiRoT and generate the signed application image.

1.1. Preliminary stage

The different steps to configure and use the OEMiRoT are based on a script provided in the STM32CubeFW:
Projects\NUCLEO-U08RC\ROT_Provisioning\OEMiROT\provisioning.bat The following documentation is a guide through all the steps of this script, and explains how to perform each of them.

The figure below shows where the script is located in the STM32CubeFW.

The location of the batch file

Launch the script provisioning.bat (double click) and keep it running during all the following steps:

provisioning batch execution - RDP phase

1.2. Image generation

Check that the STM32U0 IAR™ patch provided is correctly installed, and check that the IAR Embedded Workbench™ version is recent enough.

The example for IAR Embedded Workbench™ consists of three parts:

  • OEMiROT_Boot corresponds to the Secure Boot.

It performs authenticity and integrity checks of the project firmware and data images. It also verifies the security settings such as WRP and HDP are in place.

  • OEMiROT_Appli is an example of application managed by OEMiROT.

It displays the menu using the Virtual COM port console.

  • OEMiROT_Loader is responsible for loading the application part update.

Build each of them when asked by the provisioning batch.

Continuation of the provisioning batch execution

1.2.1. OEMiROT_Boot project configuration

The step 2 of the script is the generation of the firmware images.

  • Open the Project.eww located in the EWARM directory: Projects\NUCLEO-U08RC\Applications\ROT\OEMiROT_Boot\EWARM

Number of code images and data images is defined in the
flash_layout.h file in the ./Projects\NUCLEO-U08RC\Applications\ROT\OEMiROT_Boot\Inc folder.

This example is configured by default for one application image and a data image. Default parameters are localed in the file flash_layout.h as shown in figure below:

The flash layout file settings screenshot
Info white.png Information
During the OEMiROT_Boot execution, if the number of images is wrong, Bootloader is launched to load new code and/or data images.

1.2.2. OEMiROT_Boot project compilation

  • Open Project -> Option -> General Options. The device and the CPU core should be automatically recognized:
Screenshot from Embedded Workbench

If the device is not recognized, check that the STM32U0 IAR™ patch provided is correctly installed, and check that the IAR Embedded Workbench™ version is recent enough.

  • Perform: Project -> Rebuild all (don’t upload the code, only perform a compilation)

The following binary is created in Projects\NUCLEO-U08RC\Applications\ROT\OEMiROT_Boot\Binary\OEMiROT_Boot.bin.

1.2.3. OEMiROT_Appli project compilation

The provisioning batch passes the changes made to the flash memory layout file to the application configuration. It is necessary to rebuild them as well.

  • Open the Project.eww located in the EWARM directory:

Projects\NUCLEO-U08RC\Applications\ROT\OEMiROT_Appli\EWARM

  • Open Project -> Option -> General Options

The device and CPU core should be automatically recognized.

  • Perform: Project -> Rebuild all (don’t upload the code, only perform a compilation)

The following image is created: Projects\NUCLEO-U08RC\Applications\ROT\OEMiROT_Appli\Binary\rot_app_enc_sign.bin Don’t close the EWARM project.

1.2.4. OEMiROT_Loader project compilation

The provisioning batch passes the changes made to the flash memory layout file to the loader configuration. It is necessary to rebuild them as well.

  • Open the Project.eww located in the EWARM directory:

Projects\NUCLEO-U08RC\Applications\ROT\OEMiROT_Loader\EWARM

  • Open Project -> Option -> General Options

The device and CPU core should be automatically recognized.

  • Perform: Project -> Rebuild all (don’t upload the code, only perform a compilation).

The following image is created: Projects\NUCLEO-U08RC\Applications\ROT\OEMiROT_Loader\Binary\OEMiROT_Loader.bin. Don’t close the EWARM project.

1.3. Board programming

In the next steps the script will automatically perform:

  • The provisioning of the option byte.
  • Flashing the previously generated image in the download area.
  • Performing the needed reset to install the code.
  • Setting the final state of the product.
Programming the device in provisioning batch
  • If all the steps have been executed successfully, a confirmation is displayed as shown in the figure above.

1.4. OEMiRoT application execution

  • Close the script.
  • Launch the Teraterm (or equivalent):
  • File -> New connection
  • The COM port number should be the same as indicated by your Windows device manager.
  • Setup -> Serial port -> update to 115200 -> New Setting (see the figure below for other configurations)
teraterm config.png
  • Press the reset button (black button of the discovery board).
  • The OEMiRoT application is executed (see the figure below).
Screenshot of the terminal window
Info white.png Information
If the terminal is already running when the provisioning script finishes, it is possible to directly access the initial execution log. There is no need for reset.

1.4.1. Using the loader

From the application menu, select option 2, "New Firmware Image".
The application expects to receive an encrypted and signed binary generated here:
Projects\NUCLEO-U08RC\Applications\ROT\OEMiROT_Appli\Binary\rot_app_enc_sign.bin
Try to change the UserAppId value in the application to get immediate confirmation of successful update. Rebuild the application and the postbuild batch should generate a new binary.
Use the terminal to select option 2 from the application menu again. As the application is waiting, select YMODEM send and the new application file.
The loader applies the new application on next reboot.