Skip to content

Instantly share code, notes, and snippets.

@robotdad
Created March 5, 2023 03:30
Show Gist options
  • Save robotdad/2d308cdec85e1f5cbe99140c51cf7ce2 to your computer and use it in GitHub Desktop.
Save robotdad/2d308cdec85e1f5cbe99140c51cf7ce2 to your computer and use it in GitHub Desktop.
Disable TrustZone on STM32 boards

Sometimes you need to disable TrustZone on a board to run a sample that isn't configured for it. I've never been able to do that with the interactive STM programmer tool, but these instructions have been pretty solid.

Connect your board. Use the interactive STM32CubeProgrammer to see if the option byte TZEN is enabled. If so run the following steps if you need to disable TrustZone for other demos.

I have seen the need to occasionally reconnect the board between some of these steps. You'll know to do that if you get errors, particularly about an unsupported device.

Run the following commands in a command prompt. Note that the programmer might be under C:\Program Files (x86).

set ST_PROGRAMMER_PATH="C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin\STM32_Programmer_CLI.exe"
%ST_PROGRAMMER_PATH% -c port=SWD mode=HotPlug -ob nSWBOOT0=0 nBOOT0=0
%ST_PROGRAMMER_PATH% -c port=SWD mode=HotPlug -ob RDP=0xDC
%ST_PROGRAMMER_PATH% -c port=SWD mode=HotPlug -ob RDP=0xAA TZEN=0
%ST_PROGRAMMER_PATH% -c port=SWD mode=HotPlug -ob nSWBOOT0=1 nBOOT0=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment