cancel
Showing results for 
Search instead for 
Did you mean: 

Debugging in external memory on STM32CubeIDE

PapeLibasse
ST Employee

Introduction

This article describes how to debug in external memory on STM32CubeIDE based on the example provided in the following GitHub repository: STM32CubeH7/Projects/STM32H7B3I-EVAL/Applications/ExtMem_CodeExecution.
Regarding hardware, we use the STM32H7B3I-EVAL. We have several external memories (NOR flash, SDRAM, SRAM, microSD™ card) connected through OCTOSPI, FMC, and SDIO interfaces as illustrated in the figure below:

Pape_0-1722844618104.png

 

In this article, we mainly focus on the debugging in the OCTOSPI NOR flash memory (MX25LM51245GXDI00) connected to the OCTOSPI1 interface.


1. Downloading of the bootloader from the internal Flash memory:

Firstly, let us download our bootloader, which initializes the external memory in memory mapped mode. Set the vector table and main stack pointer before jumping to the location of the user application.
In our case, it is at 0x90000000 (the address of the OCTOSPI1):

1.1. Configure the project “ExtMem_Boot” to load the application at the OCTOPI1 address

This project example is available in this directory below: STM32Cube_FW_H7_V1.11.1\Projects\STM32H7B3IEVAL\Applications\ExtMem_CodeExecution\ExtMem_Boot).
To use the OCTOSPI interface, do the following:

  • Open the ExtMem_Boot\Inc\memory.h file
  • Change the line #define CODE_AREA USE_NOR to #define CODE_AREA USE_OSPI (see the screenshot below)

code change.png

As you can see, this project example allows users to define in which area they want to store data. It can be in external SRAM, external SDRAM, or internal SRAM. In our case, we store the data in the internal SRAM (#define DATA AREA USE_INTERNAL_SRAM).

Finally, [Build] and [Run] the project “ExtMem_Boot

Pape_2-1722845880991.png    Pape_3-1722845895581.png

2. Launch the debugging of the user application loaded in the external memory

Once the bootloader is downloaded into the board, we can debug and run the user application.
At this step, we use the “LedToggling” application provided through this directory:
STM32Cube_FW_H7_V1.11.1\Projects\STM32H7B3IEVAL\
Applications\ExtMem_CodeExecution\ExtMem_Application\LedToggling.

Note: The application is configured to run through the OCTOSPI1 interface by default. To run it through the FMC interface, the user has to follow the same steps.
Now, let us apply the following steps:

2.1. Configure the project “LedToggling” to debug in external memory

Right click on the project -> [Debug as] -> [Debug configurations…] 

Pape_5-1722846532505.pngDouble-click on the [STM32 C/C++ Application] section, normally, you should have a debug configuration section named LedToggling XIP_OSPI_InternalSRAM_Debug”, click it and go to the [Debugger] section. At this step, we add the external loader related to the external memory (MX25LM51245GXDI00) connected to the OCTOSPI1 interface.
To do this, go to the [External loaders] section and click [Add] for the corresponding external loader.
In our case, we choose: MX25LM51245G_STM32H7B3I-EVAL-REVB.stldr (see the screenshot below).

Pape_0-1722846995882.png

NOTE: Remember to check the [Initialize] checkbox as shown below. This permits automatic calls to the initialization function of the loader after the reset (see UM2609 for more information)

 At this step, you should have the setting below and then you have just to click on the [Debug] tab.

Pape_1-1722847142869.png

 

2.2. Attach the debugger and perform a reset

Executing the function SystemClock_Config() in the user application disconnects the OCTOSPI interface, and the debug is no longer retrieved.
To prevent this, user has to perform a [reset the chip and restart debug session] ( Pape_2-1722847274824.png) when the debug enters into the main function.

Related links

For further details, refer to these resources below:

 

Version history
Last update:
‎2024-12-09 06:17 AM
Updated by: