Skip to main content
Visitor II
March 4, 2025
Question

TrustZone with VScode extension

  • March 4, 2025
  • 4 replies
  • 1071 views

Hi,

I'm using an STM32L562 Discovery Kit, and trying to use the VSCode extension to debug.

For now, I am only working with a basic code to blink LD10 with TrustZone activated.

Now, I have an issue when flashing the MCU : the program doesn't seam to be running with TrustZone, but the same code without TrustZone runs as expected.

 

I saw that when debugging (with STM32CubeIDE) I need to tell that I want to start in the Secure world.

https://youtu.be/R9DsR-qF3bw?si=qIQG0d2XnSpl39vA&t=1970 

Do I need to set this somewhere in VSCode too, or is the default mode ?

Is "Build & Debug Microcontroller Secure and NonSecure - ST-Link" doing it by default ?

 

Thank you in advance,

Adrian

    This topic has been closed for replies.

    4 replies

    ST Employee
    March 11, 2025

    Hello @Adrian_

    Using VS Code, you should flash 2 images starting from the non secure than the secure one!

    First, you have to build the project to have the binaries then the images that will be flashed to the MCU can be found in the launch.json file as follows (modify the launch.json file to add the 2nd image context)

    debug in secure mode.png

    Please note that the first context to be flashed is the NS one, the 2nd context is the Secure one! 

    This configuration can be stored so the next time you debug a secure project, you don't have to flash the MCU in that specific order, you just select the securedebug config

    Adrian_Author
    Visitor II
    March 12, 2025

    Thanks for your answer.

    My lauch.json file is quite different from yours, but it looks like the "symbolFiles" are already in the right order.

    Adrian__1-1741772766877.png

    I also tried to set "executable" to the SecureTarget, but still not running.

    Note: I am working on Ubuntu 24.04

     

    Graduate II
    May 29, 2025

    @Adrian_ your launch is based on https://marketplace.visualstudio.com/items?itemName=marus25.cortex-debug

    @Sarra.S is pointing brand new ST extentions you can install Thanks this pack https://marketplace.visualstudio.com/items?itemName=stmicroelectronics.stm32-vscode-extension see https://community.st.com/t5/stm32cube-for-visual-studio-code/new-stm32cube-for-visual-studio-code-extenstion-released-3-4-11/td-p/800040

    Not claiming one is better than other (have a try of both and let us know which one you prefer :-)) but you're not discussing the same

    ST Employee
    March 12, 2025

    Regarding the default six configurations; 

    • Build & Debug Secure Microcontroller - ST-Link: This option allows you to load the code onto the Secure microcontroller, and initiate debugging.
    • Attach to Secure Microcontroller - ST-Link: With this option, you can connect the debugger to the Secure core without downloading new firmware.
    • Build & Debug NonSecure Microcontroller - ST-Link: This option allows you to load the code onto the NonSecure microcontroller, and initiate debugging.
    • Attach to NonSecure Microcontroller - ST-Link: With this option, you can connect the debugger to NonSecure core without downloading new firmware.
    • Build & Debug Microcontroller Secure and NonSecure- ST-Link: This option allows you to load the code onto the Secure and NonSecure microcontroller, and initiate debugging.
    • Attach to Microcontroller Secure and NonSecure- ST-Link: With this option, you can connect the debugger to both the Secure and NonSecure without downloading new firmware.

    Try using Build & Debug NonSecure Microcontroller - ST-Link first then Build & Debug Secure Microcontroller - ST-Link

    Visitor II
    May 29, 2025

    Did you connect with Cube Programmer and enable the TZEN bit?