dm00514974 External Memory Code Execution On stm32f7x0 Value Line and stm32h750 Value Line Mcus Stmicroelectronics
dm00514974 External Memory Code Execution On stm32f7x0 Value Line and stm32h750 Value Line Mcus Stmicroelectronics
Application note
Introduction
There is an increased demand for applications able to support new and complex features, and as a consequence there is an
increased demand for devices with a bigger Flash-memory area.
The use of external Flash memory provides higher storage capabilities with comparable performance levels while supplying a
cost efficient solution for the demand of an increased Flash-memory area.
The STM32F7x0 Value line, the STM32H750 Value line and the STM32H7B0 Value line devices respond to the market demand
with a reduced inner Flash-memory area.
This application note describes the steps needed to build an application with code execution from external memory on these
Value line devices.
It provides details on how to boot from internal Flash memory, and then jump to user-application execution from an external
memory.
Related documents
Available from the STMicroelectronics website at www.st.com:
• STM32Cube MCU Package for STM32F7 Series with HAL, low-layer drivers and dedicated middleware databrief (DB2601)
• STM32Cube MCU Package for STM32H7 Series with HAL and dedicated middleware databrief (DB3259)
• STM32F75xxx and STM32F74xxx advanced Arm®-based 32-bit MCUs reference manual (RM0385)
• STM32H743/753 advanced Arm®-based 32-bit MCUs reference manual (RM0433)
• STM32H7A3/B3 and STM32H7B0 Value line advanced Arm®-based 32-bit MCUs reference manual (RM0455)
• STM32F7 Series system architecture and performance application note (AN4667)
• Quad-SPI (QSPI) interface on STM32 microcontrollers application note (AN4760)
• Getting started with STM32H7x3 hardware development application note (AN4938)
• Getting started with STM32F7 Series MCU hardware development application note (AN4661)
• Octo-SPI (OSPI) interface on STM32 microcontrollers application note (AN5050)
• STM32CubeProgrammer software description user manual (UM2337)
• Evaluation board with STM32H7B3LI MCU user manual (UM2662)
1 General information
Application Description
Shows how to boot from internal Flash memory, configure external memories
and then jump to user application located on external memory.
ExtMem_Boot
The user can select QSPI/OSPI Flash memory, FMC-NOR Flash memory,
external SDRAM or external SRAM for code execution.
Sample application running from external Flash memory (QSPI/OSPI Flash
ExtMem_Application\LedToggling
memory or FMC-NOR Flash memory), external SRAM or external SDRAM
Sample FreeRTOS application with execution from external Flash memory
ExtMem_Application\FreeRTOS (QSPI/OSPI Flash memory or FMC-NOR Flash memory), external SRAM or
external SDRAM
The external memory boot application is in charge of initializing the required resources to make the external
memories available and ready to use. This application initializes the required resources as per the user
configuration (see Section 3.3 Configuration).
The external memory boot application must setup the main stack pointer and configure the application to be
executed on external memory. This type of boot schema enables the support of sizable user applications.
The external memory boot application ensures that any resources that are no longer needed after the setup
phase are reset or free before jumping to the user application. The figure below presents an overview of this boot
schema.
1
Initialize volatile memory
6 FMC
Jump to the NOR PSRAM
PSRAM/
SRAM memory
user controller
SRAM
Configuration
application registers
PC
QSPI/OSPI
MSP
QSPI/OSPI QSPI/
memory OSPI
controller Flash
Configuration
5 registers
Update 3
MSP to use For BootROM
the user model, copy the
defined binary content
location from the storage
memory to the
execution
SDMMC memory
µSD memory
µSD
controller
Configuration
registers
2
Initialize the
non-volatile memory
4
De-initialize the non-
volatile memory
MCU reset
DATA_AREA ≠ USE_INTERNAL_SRAM
Data memory
configuration
MCU reset
DATA_AREA ≠ USE_INTERNAL_SRAM
Data memory
configuration
3.3 Configuration
The user configuration is defined by the following defines:
• DATA_AREA: it is used to specify the volatile memory that is used for data holding. Supported memories
(depending on the board used) are:
– USE_EXTERNAL_SDRAM: external SDRAM is used for data holding
– USE_EXTERNAL_SRAM: external SRAM is used for data holding
– USE_EXTERNAL_PSRAM: external PSRAM is used for data holding
– USE_INTERNAL_SRAM: internal SRAM is used for data holding
• CODE_AREA: it is used to specify the execution location of the user application. This area can be a volatile
memory for the BootROM schemas or a non-volatile for the XiP schemas. The supported memories
(depending on the hardware used) are:
– XiP model: BINARY_AREA must be undefined:
◦ USE_QSPI: QSPI Flash is used for code execution
◦ USE_OSPI: OSPI Flash is used for code execution
◦ USE_NOR: FMC-NOR is used for code execution
– BootROM model: BINARY_AREA must be defined
◦ USE_EXTERNAL_SDRAM: external SDRAM is used for code execution
◦ USE_EXTERNAL_SRAM: external SRAM is used for code execution
◦ USE_EXTERNAL_PSRAM: external PSRAM is used for code execution
◦ USE_INTERNAL_SRAM: internal SRAM is used for code execution
• BINARY_AREA: is defined in the BootROM model only. It is used to specify the location of the binary
containing the user application. Additional defines are needed depending on the chosen configuration.
Supported memories (depending on the hardware used):
– USE_SPI_NOR: SPI NOR Flash is used for binary storage
◦ BINARY_BASE_OFFSET: offset of the binary within SPI NOR Flash
◦ BINARY_SIZE: size of the binary image
– USE_SDCARD: SDCard is used for binary storage
◦ BINARY_FILENAME: name of the binary file to be executed
The user must make sure that the selected memories contain code and data to cover at least a proper user
application startup. Afterwards, the user application can initialize any other memory needed.
Any resources that are no longer needed after initialization (interruption, ongoing transfers, unused pins) must be
released before jumping to the user application. This must be done to avoid an extra power consumption and to
limit any interference with the user application. Especially for the BootROM model, as the peripherals used for
binary storage are no longer required, they must be reset.
The user must consider the amount of resources used by the external memory boot application in order to ensure
that the external memory interface remains up and running. The resources constraints are linked to:
• The allocation and configuration of the pins
• The configuration of the interface (QSPI/OSPI IP register must not be modified, the FMC IP register can be
partially updated)
• The RCC configuration to avoid IP reset clock disabling and clock frequency/source update in a harmful way.
The pin allocation table below is provided as reference and is valid for a pin selection according to the used
board. Other pin selection could be used based on the available alternate functions.
The following table summarizes the resources that must be kept unmodified. It describes a list of peripherals (or
part of peripheral) that must not be modified in order to avoid the unavailability of external storage. The mentioned
peripherals must not be reset or clock disabled, nor reconfigured in a manner that can alter their behavior.
Note: Some elements might change based on the external memory boot application configuration chosen for the
selected board. and on the platform's hardware.
Note: Single QSPI mode is not supported with the external loaders as long as the external memories are all Twin
Quad SPI Flash
Figure 5. STM32CubeProgrammer
6 Performance characterization
When executing from external memory the performances are impacted due to the external Flash memory latency
and the longer instruction/data path. By using the STM32F7x0 Value line, STM32H750 Value line and
STM32H7B0 Value line devices, this impact is reduced thanks to the Cortex-M7 L1-cache.
The table below summarizes the EEMBC® CoreMark® scores achieved for each combination of ROM/RAM. The
best performances can be achieved when executing from the internal Flash memory. Nevertheless the loss is
significantly reduced when execution from an external memory.
These figures illustrate the impact on CPU performance when operating from external memories. The internal
Flash configuration score is provided as reference.
Revision history
Contents
1 General information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 External memory code execution overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1 External memory code execution principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 External memory boot application description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
List of tables
Table 1. Application details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Table 2. External memories used on each board by boot model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Table 3. Pins allocated for each memory by board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Table 4. Peripherals required by memory type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Table 5. EEMBC® CoreMark® score per configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Table 6. Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
List of figures
Figure 1. External memory code boot schema . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Figure 2. External memory boot application superset of source files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Figure 3. XiP model operational flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Figure 4. BootROM model operational flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Figure 5. STM32CubeProgrammer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Figure 6. Debugger command line options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15