Getting started with External memory Manager and External memory loader

Revision as of 18:59, 2 February 2024 by Registered User

Target description

The first part of the article :

This article introduces the External Memory Manager and External Memory Loader middleware features in a bootflash application for the STM32H7R/H7S product in order to:

  • Provide an API that allows access to all types of memory.
  • Launch an application that is stored on an external memory .
  • Generate an External memory loader file.

The second part of the article :

Furthermore, the article presents a detailed tutorial on the implementation of External Memory Manager and External Memory Loader middleware functionalities.The article also features a configuration sample utilizing STM32CUBEMX, which can be used as a reference to apply these functionalities to:

  • Configure the External Memory manager.
  • Configure the External Memory Loader.
  • Build a BootFlash application.

Hardware

  • STM32H7R/H7S

Software

  • An IDE (IAR, KEIL, CubeIDE).
  • Software tool for STM32 products programming.

Literature

  • Getting started with Octo-SPI and Hexadeca-SPI Interface onSTM32microcontroller[1]

1. What is a BootFlash/Bootflash-like products

1.1. Definition

A BootFlash STM32H7R/H7S series is a product with no embedded Flash and the application is located in an external memory.
A BootFlash -like product corresponds to a product configuration with small embedded Flash for an initial boot step and the application is located in an external memory.

1.2. How to built a BootFlash/Bootflash-like projects

The purpose of this example is to build a BootFlash Application with CubeMx, which employs the external memory manager and external memory loader middlewares, to create a BOOT system that can launch an application stored on an external memory.
The image below shows STM32H7R/H7S Application Architecture.
bldiag.png

1.3. How STM32 ecosystem will help you to build such a project

1.3.1. External Memory Manager

The External Memory Manager module has been implemented to assist in the development of ROMLess applications, but of course it can also be used on other platforms. It is an STM32 middleware providing two services:

  • A unique API to access all types of memory.
  • A BOOT system to launch an application stored on an external memory.


External memory Manager
An overview STM32 External memory Manager

1.3.2. External Memory Loader

External Memory Loader is an STM32 middleware helping to develop different target of loader entry points:

  • EWARM  : contains the target entry points definition to build a loader compatible with the IAR embedded workbench IDE
  • MDK-ARM : contains the target entry points definition to build a laoder compatible with KEIL uVision 5 IDE.
  • STM32Cube  : contains the target entry points definition to build a loader compatible with the STM32Cube tools : STM32CubeProgrammer and STM32CubeIDE


External memory Loader
An overview STM32 External memory loader

1.3.3. STM32CubeMX Ecosystem Tool

STM32CubeMX is a graphical tool that allows a very easy configuration of STM32 microcontrollers and microprocessors, as well as the generation of the corresponding initialization C code for the Arm® Cortex®-M core or a partial Linux® Device Tree for Arm® Cortex®-A core, through a step-by-step process.
Additionally, STM32CubeMX also offers integration with the following middlewares:

  • External Memory Manager
  • External Memory Loader

mx.png

2. STM32CubeMX BootFlash Application Configuration

To get started on the project, it is necessary to utilize the STM32H7S7L8H6H board.
1. Select this board by referring to the Board Selector that is displayed in the figure below.
FS1.png

2. As the project manager, ensure that you name the project and verify that all three subprojects are selected.
subproject1.png

2.1. Boot subproject Configuration

The BootFlash BOOT subproject is mainly built using the middleware External Memory Manager and project will mainly perform three operations:

  • System initialization.
  • Initialization of external memories.
  • Application start (LRUN or XIP).

STEP1. Clock configuration.
1.To reach the highest performance, set the clock to max frequency for both BOOT/FSBL and EXTMEMLOADER subprojects :

Select the system clock at 600 Mhz:

  • Select HSI from PLL1 Source Mux.
  • Select PLLCLK from System Clock Mux.
  • Set HCLK to 600 MHz.

clk1.png

2.Set the XSPI2 clock to 200 Mhz and Lock it to 200 Mhz.

clk4.png

STEP2 Configure the MPU to define :

  • A backroung region to set default attributes for all region.
  • A region of RAM to store non cacheable buffer.

1. Enable ICACHE .
2. Enable DCACHE .
3. Enable MPU .

mpu.png


STEP2. To Configure the external memory peripheral, select on the peripheral connected to the external memory and Select the BOOT context .
1. In this example, XSPI2 instance corresponds to the interface to the serial NOR SFDP memory on H7RS Discovery board (MB1736-HS7S78-DK).

xspi22.png

2. Once the XSPI2 the clock configuration have been done, the user must configure the XSPI2 depending on the used external memory

  • Select OCTO SPI mode .
  • Select the Port and the chip select.
  • Set the parameters of XSPI2 instance like below to connect NOR SFDP memory.

xspi33.png

STEP4. To simplify the use of external memory manager ,select and configure the EXTMEM_MANAGER middleware.

1. Select the EXTMEMMANAGER middleware .
2. Activate the EXTMEMMANAGER middleware.
3. Select XSPI interface.
4. Select the DRiver of NOR SFDP memory.
emm1.png

5.Configure the boot usecase. (XIP)
emm6.png

6. Configure the memory (8 Lines).
emm5.png

STEP6. Enable IO HSLV.

ml2.png

Info white.png Information
Enabling the SBS IO HSLV has no effect if the option bytes are not correctly set.

2.2. ExtMemLoader subproject Configuration

ExtMemLoader is a subproject used to generate a binary library capable of downloading an application to external memory. This binary is called a "Loader" which can be used by the IDE or CubeProgrammer.
This system initialization function performs the following operations:

  • Initialize the system:
    • Irq disabling (a loader doesn't use any irq).
    • Enable the cache for performance purpose.
    • Initialize the HAL context.
    • Disbale any ongoing MPU configuration.
    • Clock configuration with maximun speed.
  • Initalize the memrory
    • peripheral associated with the memories.
    • used the EXTMEM Manager middleware to initialize the memory.

STEP6.Configure the External Memory loader.
1. Select the External Memory loader middleware .
2. Activate the External Memory loader middleware.
ml.png


2.3. Application subproject Configuration

The APPLICATION context is the end user application stored in the external memory and its execution is initiated by the BOOT context. This process causes the application to inherit from the configurations made by the BOOT context.

Info white.png Information
The scatter file of the application depends on the memories present in the syteme, CubeMX embbeds an algorithm which selects the file according to the EXTMEM_Manager configuration done in the BOOT subproject. This file is provides as template and can be modified by the application.

In this application, we use the PO1, PO5 LEDs to prepare a simple application and load it into the external NOR-SFDP memory.
app.png

2.1. Compile and flash

  • To view the address base of XSPI2 where the user application is loaded, open the memory view and observe the memory address 0x70000000.

app1.png

2.2. STM32CubeProgrammer loader file Generation

To Generate STM32CubeProgrammer loader file from the IAR ExtMemLoader project, You should follow the 4 steps below :

  • STEP1: change Defined Symbols C/C++/Assembler preprocessors.

st1.png

  • STEP2: Change the linker file

st2.png

  • STEP3:Set the generated loader in the STM32CubeProg

1.Rebuil the ExtMemLaoder Project.
2.Rename the *.out project to *.stldr.
3.Copy the *.stldr into binary path of the STM32Cube Programmer below :

  C:\ProgramFiles\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin\ExternalLoader\

4.Launch the STM32CubeProgrammer.
5.Connect the board.
6.Select the new added loader in the STM32CubeProgrammer.
prg.png

  • STEP3: Check Application using the new added loader.

st4.png

No categories assignedEdit