I have a board with an STM32U575CGTx on it and I am trying to execute a simple Trust Zone Enabled program. I have 2 sample projects attached 1.) Trust Zone Disabled, 2.) Trust Zone Enabled. The project with TZ Disabled runs perfectly, toggling a GPIO line. The Trust Zone Enabled project hard faults in NonSecure_Init (). It is trying to read location 0x08100000 while executing the
line and hard faults there.
I did this when the TZ=0 as show by the programmer tool.
I tried setting the TZ=1, but now the debugger fails to fully launch when it tried to load the non-secure side with the following message
Error in final launch sequence:
Failed to execute MI command:
I am still able to program the non-secure file with the programmer however. I did add the non-secure side as a 'startup' project in the secure project's debug configuration. That also fails to finish the loading with a similar message.
Any help pointing me to the proper settings to get Trust Zone enabled program to run is greatly appreciated.
Lastly, I've tried setting TZ=0 again, but I don't know how to go through a RDP regression. Any help there is also appreciated.
Thanks in advance.
Hello @ttatakis ,
Why do you think we are providing examples ? 😀
Here is the GPIO Toggle example;
Please read the readme provided with the example. You should find why it didn't work on your side. I would guess you didn't setup the secure watermark properly.
About setting back TZEN to 0, just type STM32U5 Disable TrustZone in Google, you should find your way through some posts in the same STCommunity. You should even find a video like this one
I have a STM32U575CGTx. The sample you reference does not run on that part. The code produced by CubeMx for the STM32U575CGTx I don't believe has a chance of running. The generated #define VTOR_TABLE_NS_START_ADDR 0x08100000UL in main.c
does not exist (or is 'reserved'). I changed that to 0x08080000 because that is where the non-secure code is linked. However, when the code in NonSecure_Init() tried to read that location, nothing is returned but 0's. I also got 0's in the debugger memory browser. I then changed that defined to 0x0C080000, and at least then it read the correct entry address and jumped to it. Now the Non-Secure side hard faults immediately on the first instruction. That seems to me most likely a security attribute somewhere, but I can not figure it out. If I change the water mark values from anything other than start =0 and end = 7f, the debugger can not load the code and fails with the 'failure to launch' message above. And yes, that water maker configuration may be the source of the run time failure. I have tried to modify the initialization of the SAU to compensate but no luck so far.
Creating the project in CubeMX was simple, try it and if you can get it to work on a STM32U575CGTx, let me know what magic pixie dust you sprinkled. Or just try the attached project.
I have scoured your community docs and manuals. With respect the disabling TZ video- I did eventually come across that after failing numerous times running through the same process spelled out in some of your FAQ's. What the FAQ's don't tell you is that the errors you get from Programmer app should be ignored. Something I only gleaned after watching the video and watching the presenter quickly click through them. Errors tend to make one a little apprehensive when bricking a board is a distinct possibility.
Hello @ttatakis ,
I'm sorry I didn't realize you had a 1MB derivative.
Yes in that case the base address VTOR_TABLE_NS_START_ADDR generated by CubeMX is wrong and you should set it to actual non secure boot address. The lnon secure linker file address is good. I will raise this issue.
Now, I checked on a STM32U5 with 2M flash but using only 1M and setting secure watermark on the first 512 KB and setting the rest of the flash as non secure, I could run your project.
So, I think you only miss the configuration of the secure watermark in the option bytes.
you should have something like start=0 / End = 0x3F for bank 1 and end>start for bank 2, and it should work