How to start with OEMiRoT on STM32U0

Revision as of 17:01, 14 May 2024 by Registered User

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 more recent.
    • 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 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 OK

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.
  • Select the RDP level. (Don't use 2 unless you are certain about the OEM2 password correctly set in prior, see Using RDP regression on the STM32U0 for more information). Select 0 for start and read RDP for STM32U0 before trying other values.
provisioning batch execution - RDP phase

1.2. Image generation

Check that the STM32U0 IAR™ provided patch is correctly installed and check that your 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
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. You can check these default parameters in 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 CPU core should be automatically recognized and you should see the following window:
Screenshot from Embedded Workbench

If the device is not recognized, check that the STM32U0 IAR™ provided patch is correctly installed, and check that your 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: Projects\NUCLEO-U08RC\Applications\ROT\OEMiROT_Boot\Binary\OEMiROT_Boot.bin

1.2.3. OEMiROT_Appli project compilation

The provisioning batch will pass the changes made to the flash layout file to configuration of application and it's 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 will pass the changes made to the flash layout file to configuration of loader and it's 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
  • Flash the previously generated image in the downloads area
  • Perform the needed reset to install the code
  • Set 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 (and see the figure below for other configurations) -> New Setting
teraterm config.png
  • Press the reset button (black button of the discovery board)
  • The OEMiRoT application is executed (figure below)
Screenshot of the terminal window
Info white.png Information
If you have the terminal already running when the provisioning script finishes, you can directly observe the initial execution log. No need to hit the reset button then.

1.4.1. Using the loader

From the application menu, select option 2, "New Firmware Image".
The application will expect to receive an encrypted and signed binary generated here:
Projects\NUCLEO-U08RC\Applications\ROT\OEMiROT_Appli\Binary\rot_app_enc_sign.bin
Experiment changing 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.
Using your terminal select option 2 from the application menu again. As the application is waiting select YMODEM send and the new application file.
The loader will apply the new application on next reboot.


[[Category:Getting_started_with_STM32U0_security|30]]


No categories assignedEdit