Trustzone debugging in VSCode
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-06-14 5:48 AM
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!
- Labels:
-
STM32 Security
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-06-16 12:42 AM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-06-16 5:23 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-06-16 8:27 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-06-17 4:26 AM - edited ‎2025-06-20 5:18 AM
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.
