cancel
Showing results for 
Search instead for 
Did you mean: 

Debugging program in external flash XIP mode STM32N6

sai2
Associate

Hi,

I am trying to debug STM32N6 program loaded in external flash. When I started the debugger in the FSBL project I can put a breakpoint just before it jumps into application inside external flash. It is obvious I wont be able to see the symbols since it is not loaded. So I loaded my application elf file under debug_configuration/Startup/Load Image and Symbols (See attached image). When I start my debugging session, I encounter the following error and was unable to debug even FSBL code.

Board: STM32N6 DK

STM32CubeIDE: 1.17.0

Platform: Window

project: Template_XIP_FSBL (found under Stcube package for N6).

Here is the error:

STMicroelectronics ST-LINK GDB server. Version 7.9.0
Copyright (c) 2024, STMicroelectronics. All rights reserved.

Starting server with the following options:
        Persistent Mode            : Disabled
        Logging Level              : 1
        Listen Port Number         : 61234
        Status Refresh Delay       : 15s
        Verbose Mode               : Disabled
        SWD Debug                  : Enabled
        InitWhile                  : Enabled

Waiting for debugger connection...
Debugger connected
Waiting for debugger connection...
Debugger connected
Waiting for debugger connection...
Failed to read all registers from target
Failed to read all registers from target
Failed to read all registers from target
Failed to read all registers from target

sai2_0-1744868672813.png

Thanks

1 REPLY 1
Ghofrane GSOURI
ST Employee

Hello @sai2 

First make sure to add this 

GhofraneGSOURI_2-1744882453792.png

GhofraneGSOURI_3-1744882483339.png

Select ST-LINK (OpenOCD) as the [Debug probe] in the debug configuration of the Template_ XIP_FSBL 

Also let's try to generate the trusted binary, this could resolve the issue .

The binary file of the application that you want  to load in the memory need to be signed. 
This operation is done using the STM32_SigningTool_CLI.exe which is included in the STM32Cubeprogrammer package. 

You an access this tool using one of two ways: 

1- Under the STM32CubeIDE installation path: (Windows example) C:\ST\STM32CubeIDE_1.17.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_2.2.0.202409170845\tools\bin\ 

2- Under the STM32CubeProgrammer path: (Windows example) C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin 

To sign the binary we need to launch this command: STM32_SigningTool_CLI.exe -bin Template_XIP_AppS.bin -nk -of 0x80000000 -t fsbl -o Project-trusted.bin -hv 2.3 -dump Project-trusted.bin 

This step could be done also from within the STM32CuebIDE tool using the post build command option as described below. 

1-Right Click on Template_XIP_AppS(in Apps), [Properties]>[[C/C++ Build]> [Settings] [Build Steps]  

2- Tap on the Post-build steps this command: C:\ST\STM32CubeIDE_1.17.0\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.cubeprogrammer.win32_2.2.0.202409170845\tools\bin\STM32_SigningTool_CLI.exe -bin Template_XIP_AppS.bin -nk -of 0x80000000 -t fsbl -o Project-trusted.bin -hv 2.3 -dump Project-trusted.bin 

GhofraneGSOURI_0-1744881859891.png

 

3-Click on [Apply], then build the Template_XIP_AppS to generate Project-trusted.bin  

GhofraneGSOURI_1-1744881924514.png

after generating the trusted bin go to 

GhofraneGSOURI_4-1744882590644.png

 

select add in order to add Project_trusted.bin and make sure to choose the download address for the Themplate_FSBL_XIP :0x70100000. 

GhofraneGSOURI_6-1744882888977.png

GhofraneGSOURI_0-1744883337075.png

 

Please check Readme under C:\Users\XXXXX\STM32Cube\Repository\STM32Cube_FW_N6_V1.1.1\Projects\STM32N6570-DK\Templates\Template_FSBL_XIP