Registered User mNo edit summary Tag: 2017 source edit |
Registered User mNo edit summary |
||
Line 7: | Line 7: | ||
*How to use the script provided by ST and perform all the required steps. | *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. | *How to install and run the user application example which is provided. | ||
<big><big>'''Introduction'''</big></big><br> | <big><big>'''Introduction'''</big></big><br> | ||
Line 19: | Line 18: | ||
** STM32U031 Nucleo board: the STM32U031 does not support a hardware crypto accelerator. <br> | ** STM32U031 Nucleo board: the STM32U031 does not support a hardware crypto accelerator. <br> | ||
** USB-C cable | ** USB-C cable | ||
[[File:NucleoU031.png| | [[File:NucleoU031.png|352x352px|frameless|center|Nucleo-U031]] | ||
*'''Required tools''' | *'''Required tools''' | ||
Line 38: | Line 37: | ||
__TOC__ | __TOC__ | ||
= Example configuration = | ==Example configuration== | ||
This chapter explains how to start with the provisioning script. <br> | This chapter explains how to start with the provisioning script. <br> | ||
It is used to configure the OEMiSB and generate the binary image. <br> | It is used to configure the OEMiSB and generate the binary image. <br> | ||
== Example contents == | ===Example contents === | ||
The example for IAR Embedded Workbench® consists of two parts: | The example for IAR Embedded Workbench® consists of two parts: | ||
Line 50: | Line 49: | ||
It displays the menu using the virtual COM port console. | It displays the menu using the virtual COM port console. | ||
== OEMiSB project configuration == | ===OEMiSB project configuration=== | ||
To ease the example generation and loading, a script is provided in the STM32Cube package. The script called “provisioning” is available in \Projects\NUCLEO-U031R8\ROT_Provisioning\OEMiSB. <br> | To ease the example generation and loading, a script is provided in the STM32Cube package. The script called “provisioning” is available in \Projects\NUCLEO-U031R8\ROT_Provisioning\OEMiSB. <br> | ||
The following steps configure the example: <br> | The following steps configure the example: <br> | ||
=== Configuration management === | ====Configuration management==== | ||
* RDP selection (Do not use 2 unless you are certain about the OEM2 password correctly set in prior, see [[Security:RDP_for_STM32U0| Using RDP regression on the STM32U0]] for more information) | *RDP selection (Do not use 2 unless you are certain about the OEM2 password correctly set in prior, see [[Security:RDP_for_STM32U0| Using RDP regression on the STM32U0]] for more information) | ||
* Data size selection | *Data size selection | ||
[[File:Security_u0-sb-provisioning1.png|600px|frameless|center|Provisioning script screenshot]] | [[File:Security_u0-sb-provisioning1.png|600px|frameless|center|Provisioning script screenshot]] | ||
* Batch modifies header files automatically. | *Batch modifies header files automatically. | ||
===OEMiSB_Boot project build === | ====OEMiSB_Boot project build ==== | ||
The step 2 of the script is the generation of the firmware images. | The step 2 of the script is the generation of the firmware images. | ||
Line 69: | Line 68: | ||
*Open '''Project ⇒ Option ⇒ General Options''': The device and CPU core should be automatically recognized and you should see the following window: | *Open '''Project ⇒ Option ⇒ General Options''': The device and CPU core should be automatically recognized and you should see the following window: | ||
[[File:Security_general options u031.png|600px|frameless|center|Screenshot of embedded workbench dialog]] | [[File:Security_general options u031.png|600px|frameless|center|Screenshot of embedded workbench dialog]] | ||
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. | 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''' (do not upload the code, only perform a compilation) | *Perform: '''Project ⇒ Rebuild all''' (do not upload the code, only perform a compilation) | ||
The following binary is created: '''Projects\NUCLEO-U031R8\Applications\ROT\OEMiSB_Boot\Binary\OEMiSB_Boot.bin'''<br> | The following binary is created: '''Projects\NUCLEO-U031R8\Applications\ROT\OEMiSB_Boot\Binary\OEMiSB_Boot.bin'''<br> | ||
Return to the window where the batch is executed and press a key to continue. | Return to the window where the batch is executed and press a key to continue. | ||
===OEMiSB_Appli project compilation=== | ====OEMiSB_Appli project compilation==== | ||
The provisioning batch passes the configuration (like selected data size) to the application source files. It is necessary to rebuild it to have the binary up-to-date and synced with the boot project. <br> | The provisioning batch passes the configuration (like selected data size) to the application source files. It is necessary to rebuild it to have the binary up-to-date and synced with the boot project. <br> | ||
*Open the Project.eww located in the EWARM directory: | *Open the Project.eww located in the EWARM directory: | ||
'''Projects\NUCLEO-U031R8\Applications\ROT\OEMiSB_Appli\EWARM''' | '''Projects\NUCLEO-U031R8\Applications\ROT\OEMiSB_Appli\EWARM''' | ||
*Open '''Project ⇒ Option ⇒ General Options''' | *Open '''Project ⇒ Option ⇒ General Options''' | ||
The device and CPU core should be automatically recognized. | The device and CPU core should be automatically recognized. | ||
*Perform: '''Project ⇒ Rebuild all''' (do not upload the code, only perform a compilation) | *Perform: '''Project ⇒ Rebuild all''' (do not upload the code, only perform a compilation) | ||
Line 89: | Line 88: | ||
[[File:Security_u0-sb-provisioning2.png|900px|frameless|center|Second screenshot of the provisioning batch]] | [[File:Security_u0-sb-provisioning2.png|900px|frameless|center|Second screenshot of the provisioning batch]] | ||
=== Provisioning === | ==== Provisioning==== | ||
In the final phase, the batch execution shall: | In the final phase, the batch execution shall: | ||
* Remove old protections and initialize option bytes. | *Remove old protections and initialize option bytes. | ||
* Perform mass erase. | *Perform mass erase. | ||
* Download application, boot, and hash. | *Download application, boot, and hash. | ||
* Engage security hardening by enabling HDP and WRP. | *Engage security hardening by enabling HDP and WRP. | ||
[[File:Security_u0-sb-provisioning3.png|600px|frameless|center|Third screenshot of the provisioning]] | [[File:Security_u0-sb-provisioning3.png|600px|frameless|center|Third screenshot of the provisioning]] | ||
* | *Lastly the preselected RDP level is programmed in the OB. | ||
A scripted approach is useful to automate hash generation, which would have to be manually imported into the binary on each build. Application hash checked by the immutable secure boot is an important part of the root of trust.<br> | A scripted approach is useful to automate hash generation, which would have to be manually imported into the binary on each build. Application hash checked by the immutable secure boot is an important part of the root of trust.<br> | ||
==OEMiSB application execution== | ===OEMiSB application execution === | ||
*Close the script | *Close the script | ||
*Launch the Tera Term (or equivalent) | *Launch the Tera Term (or equivalent) | ||
* File ⇒ New connection | *File ⇒ New connection | ||
*The COM port number should be the same as indicated by your Windows device manager | *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 | *Setup ⇒ Serial port ⇒ update to 115200 (and see the figure below for other configurations) ⇒ New Setting | ||
[[File:teraterm config.png|frameless|center|1000px]] | [[File:teraterm config.png|frameless|center|1000px]] | ||
*Press the reset button (black button of the discovery board) | *Press the reset button (black button of the discovery board) | ||
Line 120: | Line 119: | ||
<noinclude> | <noinclude> | ||
[[Category: | [[Category:Getting started with STM32U0 security|40]] | ||
{{PublicationRequestId | 30397| 20/03/2024|}} | {{PublicationRequestId | 30397| 20/03/2024|}} | ||
</noinclude> | </noinclude> |
Latest revision as of 10:06, 11 March 2025
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 OEMiSB, using the Nucleo-STM32U031R8 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.
Introduction
A theoretical introduction article is available here.
The example solution is provided with the STM32CubeU0 package and consists of 2 parts:
- Firmware/Projects/NUCLEO-U031R8/Application/ROT/OEMiSB_Boot
- Firmware/Projects/NUCLEO-U031R8/ Application/ROT/OEMiSB_Appli (a simple WRP demo)
Prerequisites
- Hardware
- STM32U031 Nucleo board: the STM32U031 does not support a hardware crypto accelerator.
- USB-C cable
- STM32U031 Nucleo board: the STM32U031 does not support a hardware crypto accelerator.
- 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 firmware location)
- Check that the STM32U0 IAR™ provided patch is correctly installed in your IAR Embedded Workbench®.
- A directory NUCLEO-U031R8 is included in "STM32Cube_FW_U0_V1.x.x\Projects"
- Open the env.bat file in the ROT_Provisioning subfolder
- 1- If the STM32CubeProgrammer has not been installed in the default 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 OEMiSB_Appli path is OK
1. Example configuration
This chapter explains how to start with the provisioning script.
It is used to configure the OEMiSB and generate the binary image.
1.1. Example contents
The example for IAR Embedded Workbench® consists of two parts:
- OEMiSB_Boot corresponds to the secure boot.
It performs an integrity check of the project firmware and verifies that the security settings such as WRP and HDP are in place.
- OEMiSB_Appli is an example of an application protected by OEMiSB
It displays the menu using the virtual COM port console.
1.2. OEMiSB project configuration
To ease the example generation and loading, a script is provided in the STM32Cube package. The script called “provisioning” is available in \Projects\NUCLEO-U031R8\ROT_Provisioning\OEMiSB.
The following steps configure the example:
1.2.1. Configuration management
- RDP selection (Do not use 2 unless you are certain about the OEM2 password correctly set in prior, see Using RDP regression on the STM32U0 for more information)
- Data size selection
- Batch modifies header files automatically.
1.2.2. OEMiSB_Boot project build
The step 2 of the script is the generation of the firmware images.
- Open the Project.eww located in the EWARM directory: Projects\NUCLEO-U031R8\Applications\ROT\OEMiSB_Boot\EWARM
- Open Project ⇒ Option ⇒ General Options: The device and CPU core should be automatically recognized and you should see the following window:
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 (do not upload the code, only perform a compilation)
The following binary is created: Projects\NUCLEO-U031R8\Applications\ROT\OEMiSB_Boot\Binary\OEMiSB_Boot.bin
Return to the window where the batch is executed and press a key to continue.
1.2.3. OEMiSB_Appli project compilation
The provisioning batch passes the configuration (like selected data size) to the application source files. It is necessary to rebuild it to have the binary up-to-date and synced with the boot project.
- Open the Project.eww located in the EWARM directory:
Projects\NUCLEO-U031R8\Applications\ROT\OEMiSB_Appli\EWARM
- Open Project ⇒ Option ⇒ General Options
The device and CPU core should be automatically recognized.
- Perform: Project ⇒ Rebuild all (do not upload the code, only perform a compilation)
The following binary is created:
Projects\NUCLEO-U031R8\Applications\ROT\OEMiSB_Appli\Binary\OEMiSB_Appli.bin
The script computes also the application hash and generate a hash area binary.
You do not need to close the EWARM project.
This is the state of the batch execution at this point. Press the key to let the execution continue.
1.2.4. Provisioning
In the final phase, the batch execution shall:
- Remove old protections and initialize option bytes.
- Perform mass erase.
- Download application, boot, and hash.
- Engage security hardening by enabling HDP and WRP.
- Lastly the preselected RDP level is programmed in the OB.
A scripted approach is useful to automate hash generation, which would have to be manually imported into the binary on each build. Application hash checked by the immutable secure boot is an important part of the root of trust.
1.3. OEMiSB application execution
- Close the script
- Launch the Tera Term (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
- Press the reset button (black button of the discovery board)
- The OEMiSB application is executed (figure below)
Though the menu items may suggest there is actual data being sent or written, there are none. The meaning of the demo is rather to provide an example of determining the ceiling of the write protection.