Skip to main content
Associate III
June 14, 2025
Solved

Trustzone debugging in VSCode

  • June 14, 2025
  • 3 replies
  • 863 views

Hi,

I am using Nucleo-WBA65RI and I have enabled trustzone. I generated the project using CubeMX and it generated a secure and a non-secure project. I have enabled the trustzone option byte and am able to run an example project with secure and non-secure projects on my board. The problem is, I am not using CubeIDE for my project. I am using VSCode and am able to debug the secure project but it crashes when it is supposed to jump to non-secure project. And I am unable to debug the non-secure project.

Can anyone provide me a working launch.json script using cortex-debug and stlink? 

If my project behavior indicates some other problem, please suggest me a solution for that too.

Thanks!

Best answer by fa31

Hi,

Thanks a lot for offering to help, @Nawres GHARBI . I managed to fix the issue today.

It turned out the problem wasn’t in the launch.json file. I’m not entirely sure what the root cause was, but deleting and regenerating the CubeMX project solved it.

3 replies

ST Employee
June 16, 2025

Hi, 

In order to debug the non-secure project after jumping from secure, you need to include the precompiled .out file of the secure project into the additional libraries option. We do this in IAR IDE in the linker section. 

The reason you are getting a hard fault when you are jumping from secure to non-secure is because the secure code is not able to find your non-secure main. 

Hope this helps!

fa31Author
Associate III
June 16, 2025

Hi,

Thank you for the reply!

If you are referring to the secure_nsclib.o library, I have already added that in my CMakeLists.txt of the non-secure project.

I think the error has something to do with the launch.json file in VSCode. Flashing the Secure project works well until the jump, but the Non-secure project crashes already before it stops at the entry point. 

Nawres GHARBI
Technical Moderator
June 25, 2025

Hi @fa31 

could you share your launch.json please I'll help you to make the debug work fine

ST Employee
June 17, 2025

Hello,

I found a thread on ST community - TrustZone with VScode extension - STMicroelectronics Community Please go through this if you have already not come across this. 

This might probably help you. 

fa31Author
Associate III
June 17, 2025

Hi,

Thank you for the suggestion but I have already gone through this. The problem is that this post does not have any solution, and I am not using the STM32 extension.

But I did try try the STM32 extension as well, the problem is that I have CubeMX project integrated into my bigger CMake project. Even though the CubeMX generated code is untouched, I generated it with Makefile and wrote my own CMakeLists, so the extension is having trouble finding the correct project setup. 

 

fa31AuthorBest answer
Associate III
June 25, 2025

Hi,

Thanks a lot for offering to help, @Nawres GHARBI . I managed to fix the issue today.

It turned out the problem wasn’t in the launch.json file. I’m not entirely sure what the root cause was, but deleting and regenerating the CubeMX project solved it.