How to disable TrustZone in STM32L5xx devices during development phase

Revision as of 17:12, 14 October 2020 by Registered User

1. What is TrustZone®?

The STM32L5 series is based on the Cortex®-M33 core which is part of the Arm Cortex®-M group of 32-bit RISC cores. It implements the Armv8-M mainline architecture. The processor implements ARM TrustZone® technology, using the ARMv8-M Security Extension.

TrustZone technology for Arm Cortex-M processors enables robust levels of protection at all cost points for IoT devices. The technology reduces the potential for attack by isolating the critical security firmware and private information from the rest of the application. It provides the perfect starting point for establishing a device root of trust based on Platform Security Architecture (PSA) guidelines.

2. How TrustZone® is enabled in STM32L5xx devices?

All STM32L5xxx devices support the TrustZone®. TrustZone® is disabled by default in all STM32L5xx devices. It is activated by setting the TZEN option bit in FLASH_OPTR when RDP level is set to Level 0.

3. Steps to disable the TrustZone® in STM32L5xx devices

Once TrustZone® is activated on the device, it can only be deactivated during an RDP regression to level 0 (either from RDP level 1 to level 0 or from RDP level 0.5 to level 0).

Consequently, to do TZEN regression, the part must be already in RDP level 1 or level 0.5. Let’s remind that when TrustZone® is activated:

  • The Cortex-M33 CPU is in secure state after reset and the boot address must be in a secure address.
  • In RDP level 0.5 and level 1:

→When the CPU is in secure state, it is not possible to connect to the target through JTAG/SWD so it is not possible to do TZEN/RDP regression. →When the CPU is in non-secure state, the connection to the target through JTAG/SWD and RDP regression are possible.

In case of boot from user Flash, if the non-secure code is not called by the secure code, the CPU always remains in the secure state and the RDP regression cannot be done through JTAG / SWD with a boot from the user Flash memory.

Here let’s assume that the boot is done from the user Flash. An STM32L5 Nucleo-144 board (MB1361) is used.

Before programming the RDP level 0.5 or RDP level 1, the user must always ensure that the secure application calls the non-secure application so that the connection to the target is possible.

Step 1: Use the GPIO_IOToggle_TrustZone example provided within the STM32CubeL5. Follow the different guidelines provided in the example readme file and make sure that the example is running correctly.

Step 2: Set RDP level to level 1.


RDP1.jpg

Note that once the RDP level is set to level 1:

  • Only Hotplug connection is possible (in order to not reset the cpu during connection).
  • A power supply different from ST-LINK must be used in order to be able to connect to the target. For more details, please refer to the section 7.1 RDP level 1 in the AN5347.

Step3: Do TZEN and RDP regression


RDP reg.jpg

RDP reg1.jpg

If Step 1 was skipped, the only way to do regression is through JTAG (or SWD) /bootloader with a boot from RSS (See Note below). For more details about the different boot options, refer to Reference manual STM32L552xx and STM32L562xx advanced Arm®-based 32-bit MCUs (RM0438).

  • If the boot is based on the BOOT0 pin level, so it is possible to boot from RSS and do the regression.
  • If the boot is based on the nBOOT0 option bit, so it is no more possible to program the option bytes so not possible to boot from RSS so not possible to do regression.

Note: This is because there is a jump from RSS (secure) to Bootloader (non-secure) so with a boot from RSS, we guarantee that the cpu state will switch from secure to non-secure and the connection to the target is possible.

4. Video related to STM32 and TrustZone®

pc videol.png

STM32 Security features - 18 - TrustZone theory

pc videol.png

STM32 Security tips - 1 Isolation example with STM32L5 TrustZone

pc videol.png

How to enable TrustZone® and start a project with STM32L5

5. STMicroelectronics Ressources

RM0438 Reference manual

AN5347 STM32L5 Series TrustZone® features Application note


No categories assignedEdit