on 2024-08-11 04:30 AM
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:
In this article, we mainly focus on the debugging in the OCTOSPI NOR flash memory (MX25LM51245GXDI00) connected to the OCTOSPI1 interface.
Firstly, let us download our external memory loader, which initializes the external memory. 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):
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:
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”
Once the external loader 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:
Right click on the project -> [Debug as] -> [Debug configurations…]
Double-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).
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.
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] ( ) when the debug enters into the main function.
For further details, refer to these resources below: