stm32U5 NonSecure_Init Hard Fault
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-12 01:43 PM
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
__TZ_set_MSP_NS((*(uint32_t *)VTOR_TABLE_NS_START_ADDR))
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:
load C:\\...\\STM32U5_TZ_Enabled\\NonSecure\\Debug\\STM32U5_TZ_Enabled_NonSecure.elf
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.
- Labels:
-
STM32U5 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-14 01:49 PM
Hello @ttatakis ,
Why do you think we are providing examples ? :grinning_face:
Here is the GPIO Toggle example;
STM32Cube_FW_U5_V1.4.0\Projects\NUCLEO-U575ZI-Q\Examples\GPIO\GPIO_IOToggle_TrustZone
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
Best regards
Jocelyn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-15 11:53 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-19 09:41 AM
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
Best regards
Jocelyn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-06 02:03 AM
Hi Tattakis!
I have the same problem, but with STM32U575RIT6. How did you find the correct address (0x0C080000)?
Thank you in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-06 06:05 AM
That was a while ago! And that project has been discontinued- however, I believe I just got that address from the the memory map for the device.