cancel
Showing results for 
Search instead for 
Did you mean: 

Debugging application from external flash

Kutlu
Associate II

Hi All,

I have interfaced  Winbond W25Q128 external flash and IS42S32400F-7TL external RAM to STM32H750IBK micro on my custom board. I have found an external loader file (stldr) for my pin configuration from a community member.

I can program, read and erase my external flash memory with the stldr file using STMCube Programmer.

I have also prepared a bootloader application that initializes the clock at 64 MHz, initializes the QSPI and brings it into memory mapped mode and then jumps to the application in the external memory. This also works fine, I can successfully jump to external app after re powering my board and I can see that the application on the external memory is running.

However I could not find a way to debug my external application either alone or starting from the bootloader app in STMCube IDE. It gives me "Break at address "0x8000550" with no debug information available, or outside of program code."

And when I use OPEN OCD for debugging I get Error: 'stldr' driver rejected flash bank at 0x00000000; usage: (null) error.

 

I added

add-symbol-file ./Debug/externalapp1.elf 0x900002D0
delete mem 2

mem 0x90000000 0x900FFFFF ro

into the debug configuration but with or without adding it still same error occurs.

 

Please let me know these;

1-Can I debug only my external application without having a bootloader application loaded in the internal flash. I assume that the external loader can facilitate such a debugging (without having a bootloader in the internal flash) am I wrong.

2-If I need to also flash the internal flash memory with the bootloader and start debugging from here and then jump to external application shall I make some adjustments on the debugging options in STMCUBE IDE.

Notes:

1-I am resetting the vector table at 0x90000000 on the system file of the external app.

2-When I flash the internal bootloader application I do not re adjust the clock and re enable the QSPI in the external app as this is already done in the bootloader application and my external application runs as expected.

3-I am almost sure that my memory mapping is correct in the LD files but I can share them incase you demand.

Briefly can you give me some information on how to debug my external application with or without the internal flash memory already loaded with the bootloader.

Thanks,

 

1 ACCEPTED SOLUTION

Accepted Solutions
Pavel A.
Evangelist III

It is more a question how to setup your IDE with two projects

In the debug settings of the project that starts in the internal flash (call it bootloader or whatever): specify additional ELF file of the app in the QSPI flash, but only load debug info from it, do not load the binary code.

Loading the binary into QSPI flash should be done before the debug session - either using CubeIDE with ext. loaders or CubeProgrammer. 

Then start the debugger and run to the point where the QSPI is set up. Verify that this succeeded, Run to the point where you call the code in QSPI. Step into QSPI code, verify it can be executed and the debugger sees the debug info of QSPI code. Then run at full speed.

 

View solution in original post

8 REPLIES 8
KDJEM.1
ST Employee

Hello @Kutlu ,

 

May AN4852 Application note "Programming an external Flash memory using the UART bootloader built-in STM32 microcontrollers" help you  program an external Quad-SPI Flash memory using the internal bootloader.

Also, I advise you to take a look at:

I hope this help you.

Kaouthar

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

For my understanding:
the code in external QSPI flash is a separate project. Even you should be able to debug in assembly code mode and with HW breakpoints: your main project (launched from internal flash memory) has no references to the source code for executed code in external flash.

At least: you should build the code for external flash with full debug options (and flash code plus debug info), but I guess still an issue that the sub-project for the code in external flash is not part of your main project.

It is more a question how to setup your IDE with two projects, to have also the source code linked in IDE for the code in external flash. (not a HW issue, an issue how to setup IDE).

Pavel A.
Evangelist III

It is more a question how to setup your IDE with two projects

In the debug settings of the project that starts in the internal flash (call it bootloader or whatever): specify additional ELF file of the app in the QSPI flash, but only load debug info from it, do not load the binary code.

Loading the binary into QSPI flash should be done before the debug session - either using CubeIDE with ext. loaders or CubeProgrammer. 

Then start the debugger and run to the point where the QSPI is set up. Verify that this succeeded, Run to the point where you call the code in QSPI. Step into QSPI code, verify it can be executed and the debugger sees the debug info of QSPI code. Then run at full speed.

 

Hi Pavel,

Thanks for the reply.

Actually it is sufficient if I can debug only my external application alone since the internal application or the bootloader just initializes the clock, QSPI and jumps to external application. But since I could not manage to debug it alone i decided to start from the internal application(bootloader)

Attached I am sending some files that show the status of the registers when starting a debug session from bootloader(the project name is fmcspi ), before jumping to the external application, after jumping to the external application  application jumps. I can see that the external application is running when I make a jump to external app but the debug session gives error that there is no debug information available. Please see attached pictures.

I have also attached my debug configuration for the loader.

As you have stated I have added the elf file of the external application to the debug configuration of the internal bootloader.

I first program the external qspi memory (16MByte Winbond Flash) using STMCube Programmer by the bin file of the external app and then start a debug session from the internal bootloader. There is no problem on programming/reading or deleting from external flash when using the Cube Programmer and external loader.

Interestingly I can physically see that both internal and external application are running on the board. I can debug the internal app but the problem is only on debugging external app either alone or together with the bootloader.

One thing I want to also note that I also have an external RAM and I do not configure MPU both for QSPI and the RAM.

I suspect the msp does not point to correct location by the way.

Thanks

 

Kutlu
Associate II

Hi All,

I think my problem is solved, at least for now.

I compiled and flashed the real application elf file into the external qspi flash using an external loader and cube programmer.

Then in the debug configuration of the bootloader application in Cube IDE, I have added the elf file file of the external application under the startup tab.(Please see the attached picture).I have only loaded the symbols.

Starting from bootloader in the internal flash i can jump to external app and single step through the code.

I was not able to set break points on the external app at first but when I added delete mem 2 and mem 0x90000000 0x90FFFFFF ro lines in the Run Commands window and I can set break points now.

Thanks all for the support,

 

Hello @Kutlu ,

I use the same MCU and flash as yours. When I added the `delete mem 2` and `mem 0x90000000 0x90FFFFFF ro` in the run commands, the debug was blocked as below

hbZhao_3-1723928298332.png

The below is the ld configuration

hbZhao_2-1723925210344.png

 

May I know if you can debug the application on the external flash? If you can, may I know if any other configurations need to be set?

Thanks.

KB: Debugging in external memory on STM32CubeIDE 

- If someone's post helped resolve your issue, please thank them by clicking "Accept as Solution".
- Please post an update with details once you've solved your issue. Your experience may help others.

Hello,

I start debugging from my bootloader project(located in the internal flash) and ten  jump to my real application located in the external flash memory. To do so I first program my external flash with the real application using STMCube Programmer and selecting the External Loader File. Therefore you need an External Loader script specifically written for your microcontroller and external flash to able to load your application into external flash.

After loading external flash (with the real application) I start a debug session on my internal application with the configuration given in my first reply. Please note that you only need to load the symbols of the external application.

Then in my FLASH.LD File of the internal application I define a region for external memory(which in my case is named as QUADSPI.

MEMORY

{

FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 128K

DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K

RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K

RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K

RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K

ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K

QUADSPI (xrw) : ORIGIN = 0x90000000, LENGTH = 16M

}

Please add the last line according to your memory size and start address.

Then starting from internal application I can jump to external application located in external flash.