cancel
Showing results for 
Search instead for 
Did you mean: 

Attach Debugger To Running Target with TrustZone Enabled and Breakpoint in Secure App

cgj004
Associate II

I've been playing around with the TrustZone Enabled on the STM32H573 board and using this tutorial:

https://wiki.st.com/stm32mcu/wiki/Security:How_to_start_with_OEMiRoT_on_STM32H573_and_563%E2%80%93TrustZone_enabled

I had no trouble executing the tutorial, using the Debug Authentication, or changing the permission levels to attach the IAR Debugger to put breakpoints in the main functions of the Non Secure or Secure Applications.

However, my group uses the STM32 Cube IDE, and I've been having trouble doing the equivalent using that tool.  I know where to enable and set up the Debug Authentication, but I'm having trouble attaching to the running target, hitting the reset button (as instructed in the above tutorial), and having the program stop at the breakpoint I have enabled in the main function of the Secure Application (before it jumps to Non Secure Init) and displaying the associated source code.  I have built all the projects (OEMiROT Boot, OEMiROT_Appli_TrustZone_Secure, and OEMiROT_Appli_TrustZone_Secure) with their Debug Configurations, I have the correct Key and Certificate paths under the DA tab, I've used the Secure Programmer to set the debug level to Level 3 Secure, I've matched the debugger side to Debug Secure L3 -- I've tried different combinations but can't seem to get the code execution to properly stop at the breakpoint I set and display the source code.  It's not as easy as described in the tutorial for IAR.  Can you provide some instruction as to what I need to do to get this to work on STM32 Cube IDE Debugger?  My version of STM Cube IDE is 1.14.1, and I'm putting a breakpoint in the main function of the Secure Application.

I've attached screenshots of the tabs under my Debug Configuration settings.

I've included the Main, Debugger, and Startup tabs. here.

1 ACCEPTED SOLUTION

Accepted Solutions
cgj004
Associate II

I was actually able to figure it out.

I saw another post that reference a similar question; I just followed that to make sure I disabled auto build, Reset Behavior was set to None, under the Startup tab I made sure that only the symbols were downloaded, and under the Source tab I made sure to add all of the source lookup paths.  So somehow I got it to work similar to IAR, where I could press the reset button on the H5 board and saw that the code hit the breakpoint in Secure Main().

View solution in original post

4 REPLIES 4
cgj004
Associate II

I'm adding additional screenshots.  These additional attachments are from the Source and Common tabs under Debug Configurations.  Also, it appears that I am getting the code execution to stop in the Secure App's main function, however for some reason the source code is not showing up, but the disassembly is.  So I'd like some guidance as to if the settings I have are correct and what else do I need to do to view the source files under the Secure App when I apparently can view the disassembly code (so that tells me my Debug Authentication credentials are set up correctly)?

ecrin4130
Associate II

Hello, on the stm32H563, that works for me with  Debug Secure L2 because my Secure App is started just after the Boot App, and just before the NS app.

 

cgj004
Associate II

I was actually able to figure it out.

I saw another post that reference a similar question; I just followed that to make sure I disabled auto build, Reset Behavior was set to None, under the Startup tab I made sure that only the symbols were downloaded, and under the Source tab I made sure to add all of the source lookup paths.  So somehow I got it to work similar to IAR, where I could press the reset button on the H5 board and saw that the code hit the breakpoint in Secure Main().

Jocelyn RICARD
ST Employee

Hello @cgj004 ,

I will not directly answer to your concern as I never use this feature from STM32CubeIDE.

So, I give you how you can do it another way:

First open the debug using dbgauth.sh/bat in the DA directory. Select HDP Level 1 secure as this is the level fused OEMiROT Boot.

Once the debug is opened, you can connect to the target using simple CubeIDE Debug configuration as you would do if you were working in open mode.

Besides, you can also work in open mode with OEMiROT on H5, if you have a way to set BOOT0 pin to VDD on your board. If this is the DK board, you have a switch for that.

To do this, just select OPEN in the provisioning script and follow the instructions.

Best regards

Jocelyn