2026-01-19 4:20 PM - edited 2026-01-19 4:27 PM
Hello,
I'm looking for advice / help with Trust-Zone enabled project. I'm just getting started with Trust-Zone so there is a bit of a learning curve I guess, and a lot I dont know. I'm debugging in VSCode. Debug config shown at bottom of message. To start, I programmed TZEN for my STM32U575 to 1, but no read out protection is enabled. The secure part of the project, which runs first (its ISR table is at 0xc000000 ) only does a handful of things currently, including running this - it is stock standard STM code I think.
static void NonSecure_Init(void)
{
funcptr_NS NonSecure_ResetHandler;
SCB_NS->VTOR = VTOR_TABLE_NS_START_ADDR;
/* Set non-secure main stack (MSP_NS) */
__TZ_set_MSP_NS((*(uint32_t *)VTOR_TABLE_NS_START_ADDR));
/* Get non-secure reset handler */
NonSecure_ResetHandler = (funcptr_NS)(*((uint32_t *)((VTOR_TABLE_NS_START_ADDR) + 4U)));
/* Start non-secure state software application */
NonSecure_ResetHandler();
}
When I start a debugging session, I assume that this code should have already run, right? And the debugger is waiting for me to start debugging from non-secure main();
The non-secure project initalises UART4, then does a hello world (debug printf) but when UART4 tx empty interrupt occurs I get hard faults. I found that the UART4 ISRs are non running in the non secure project. I added UART4 ISR handlers into the secure project, and found the PC was going there! I added the following to the secure project, in an attempt to make the interrupt non secure. (but i dont think this would fix it, as where we are vectoring is wrong).
NVIC_SetTargetState(UART4_IRQn);
HAL_GTZC_TZSC_ConfigPeriphAttributes(GTZC_PERIPH_UART4, GTZC_TZSC_PERIPH_NSEC);
This hasnt changed anything I can see -- the same vector table (the secure one) is being used.
If I look at SCB->VTOR, in the non-secure project, it is still 0xc0000000, which is the aliased secure vector table address. I'm not sure which VTOR this is ? The secure or non-secure ? How can I tell?
However, in the non secure project during debug, if I change the this to 0x08080000, the address of my non secure table, I just end up getting hard faults running other peripheral init code.
I'm not making easy headway debugging this as the debugger behaviour is inconsistent will lock up and refuse to show me various registers that might be helpful.
Looking for any tips from anyone whos been here.
Thanks, Nick.
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Debug Build",
"type": "stlinkgdbtarget",
"request": "launch",
"svdPath": "C:/tools/svd/stm32u575.svd",
"cwd": "${workspaceFolder}",
//"preBuild": "${command:st-stm32-ide-debug-launch.build}",
"runEntry": "main",
"imagesAndSymbols": [
{
"imageFileName": "${workspaceFolder}/Secure/build/fw_S.elf"
},
{
"imageFileName": "${workspaceFolder}/NonSecure/build/fw_NS.elf"
}
],
"verbose": false
},
]
}