Introduction to External memory Manager

1. External Memory Manager

1.1. Introduction

The External Memory Manager module was implemented to assist in the development of ROMless applications, although it can also be used on other applications that use external memory in raw mode (without any file system management). It is STM32 middleware, providing two levels of services:

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

1.2. External Memory Manager driver

The External Memory Manager provides a unique interface for all supported memories. It contains a driver part that is responsible for adapting the request to the context of the physical memory as well as the hardware used. Depending on the type of memory, certain services may not make sense or may not be of interest. In this case, the APIs return an EXTMEM_ERROR_NOTSUPPORTED error code.

API name Description Parameters
EXTMEM_Init This function manages memory initialization uint32_t MemId: Memory ID

uint32_t ClockInput: clock frequency applied on the HW link used by the memory

EXTMEM_DeInit This function manages memory deinitialization uint32_t MemId: Memory ID
EXTMEM_Read This function manages memory reading uint32_t MemId: Memory ID

uint32_t Address: memory address to read from

uint8_t* Data: destination data buffer

uint32_t Size: size in bytes

EXTMEM_Write This function manages memory writing uint32_t MemId: Memory ID

uint32_t Address: memory address to write at

const uint8_t* Data: source data buffer

uint32_t Size: size in bytes

EXTMEM_WriteInMappedMode This function manages memory writing in memory mapped mode uint32_t MemId: Memory ID

uint32_t Address: memory address to write at

const uint8_t* Data: source data buffer

uint32_t Size: size in bytes

EXTMEM_EraseSector This function manages memory sector erase uint32_t MemId: Memory ID

uint32_t Address: memory address in sector to erase

uint32_t Size: size in bytes

EXTMEM_EraseAll This function manages complete memory erase uint32_t MemId: Memory ID
EXTMEM_GetInfo This function allows to retrieve memory information uint32_t MemId: Memory ID

void *Info: memory information

EXTMEM_MemoryMappedMode This function allows to enable or disable the memory mapped mode uint32_t MemId: Memory ID

EXTMEM_StateTypeDef State: EXTMEM_ENABLE/EXTMEM_DISABLE

EXTMEM_GetMapAddress This function returns the mapped address of the memory uint32_t MemId: Memory ID

uint32_t *BaseAddress: returned value containing the memory base mapped address

1.3. Supported memories

The External Memory Manager middleware is designed to support a variety of external memory types, such as:

  • NOR_SFDP (Serial Flash Discoverable Protocol-compliant NOR flash memory)
  • PSRAM
  • SDCARD

1.4. BOOT Manager

The role of the BOOT Manager is to start the execution of the application. It supports two modes:

  • XIP: eXecute In Place; the application is executed from the external memory.
  • LRUN: Load and Run; the application is loaded from an external memory into an internal or external memory and is executed from this memory.

The service is available through a single BOOT_Application API. The service can be called only after the initialization of the selected memory or memories.

1.4.1. XIP use case

  • The XIP use case is based on code execution directly from the external nonvolatile memory used for code storage. This execution model requires memory-mapped support to grant the CPU direct access to the executed-code user application.

XIP.png

1.4.2. LRUN use case

  • The LRUN use case corresponds to the use case where an application is loaded into a memory and then executed from this memory. In this process, the application code is first loaded into volatile memory (RAM). Once the code is loaded into the RAM, the processor can execute it.

LRUN.png