With a wide range of applications and the rise of cyberattacks, securing MCUs has become imperative; however, ensuring MCU performance is also crucial given how interconnected today’s systems are. This project examines the security and performance of next-generation microcontroller units (MCUs) leveraging new security solutions for IoT edge applications. By benchmarking these MCUs against key performance metrics, their viability will be assessed to facilitate the widespread adoption of this new firmware.
This project utilizes the STM32 toolchain and Nordic Semiconductor PPK II along with the nRF software. See the slides for more information.
To navigate to source code, choose a project (i.e UnoI2C) and select the Core
directory for non-secure projects or the Secure
directory and then the Core
directory for secure projects. Within Core
there should be an Src
folder which contains the code used in the selected application.
Developing Purely Secure/Non-Secure Applications
Adapted from: https://wiki.st.com/stm32mcu/wiki/Security:How_to_start_with_STM32CubeMX_STiRoT_Boot_path_on_STM32H57
- Click on Access to MCU Selector and select our device, the STM32H573I-DK, from the Series column
- Create the project and enable TrustZone
- Specify project name and path
- Select Secure or Non-secure project based on the use case (could be both then select both)
- Toolchain as STM32Cube IDE
- Go to File > Save Project
Once the project has been created…
- In Pinout and Configuration, click on pins for use case > GPIO_Output
- Pin Reserve to choose if it’s reserved for Secure or Non-Secure (Cortex M-33 Secure vs. Cortex M-33 non-secure)
- Optional but recommended: Enter a user label for pins
- Note: External documentation to know which LEDs to use
- For pin reservation for I2C and others
- For I2C, make sure SCL is PB6 and SDA is PB7
- LEDs
- LED1 is PI9
- LED2 is PI8
- LED3 is PF1
- LED4 is PF4
- See layout page 12 for more details
- Don't forget to reserve pins if needed
- Enter user labels for reserved pins for easy identification in the generated code
- Refer to the Hardware Layout Page 3 for pin layouts
- In System Core it will show what pins are configured for what
- In Boot Path and Debug Authentication > Select > STiRoT > Secure Application 9. Click on Finish and OK on the popup 10. Note: This does not need to be done for purely NS
- Select Edit Config Files (Opens the TPC)
In the TPC…
- Select/deselect “is the firmware full secure” based on use case
- If both secure and nonsecure, make sure enough resources are allocated to both
- Generate OBKey 2. Note: If you define your own code, you need to change the sizes and default settings to match your code size and regenerate OBKeys (our mistake before lol)
- Close TPC
Back in the Project Manager tab…
- In Boot Path and Debug Authentication > Configure
- Note: key may need to be regenerated but USUALLY NOT, otherwise VERY IMPORTANT to not lose the key!! (ok for this example to leave as is)
- Opens TPC again, then Generate OBKey
- Close TPC
- In Project Manager > Signature make sure Sign Binaries is selected
- Generate Code > Yes
- Then click “Open Project” on the popup
- Project opened in the IDE
- Insert modified code into secure/non-secure main based on use case
- Compile code, Project > Rebuild All
- Note: Secure code needs to be compiled BEFORE nonsecure code!
For device provisioning…
- Connect the board to computer through USB_STLink connector
- Go to File Explorer to project path
- Under project name > ROT_provisioning > STiRoT > provisioning.bat
- Follow instructions of script up until Step 3
- In Step 3 > set device state (usually CLOSED)
Code should be executing on board now!
To perform a regression (to be able to modify the running application and flash again)…
Note: Can also fully erase board like a factory reset in CubeProgrammer as well
Go to STM32CubeProgrammer
- Make sure the board is connected via ST-LINK
- If not found:
- Go to menu bar → Parallels Icon → Devices → USB/Bluetooth → Select STLINKV3
- If not found:
- Select the DA tab on the left (shield icon, last tab in top section)
- Click Discover
- Select "Full Regression" from the list below 2. This only shows if the lifecycle is CLOSED
- Select Execute 3. A success message should appear
- Don't forget to disconnect ST-LINK (it connect automatically on success)
- Find .project file in File Explorer and double click to open in STM32 IDE
- Build project
- If Secure -> in STiRoT, ROT provisioning find provisioning.bat and show in Explorer > double click to run
- Optional: FOR TROUBLESHOOTING 2. May have paths messed up… 1. In that case, open IOC file and update paths for firmware, regenerate code 2. Will have to update the main.c files 3. Then rebuild project 3. Don’t forget to install python as well (from command line type python > ENTER, install from Microsoft store)