Electrical – Creating a memory mapping to peripheral memory on STM boards

csramstm32

I am trying to find a way to load/execute code that is stored on an external SRAM chip without having to load it to the microcontroller internal memory. I'm not 100% sure of the name for what I'm trying to do but I think a memory mapping would work.

Reading the CMSIS driver for the board, this file (large file so no line numbers, but search for "#define APB1PERIPH_BASE" ) shows me that the peripherals of the boards, buses and such are already handled with memory mappings. So with this, I was thinking of mapping a region of code with an interrupt that would fire on memory accesses so I could fetch the data from the device using the SPI bus of my project's board. Doesn't need to be fast.

I thought also of using DMA but I'm similarly stumped.

I can't seem to find any definitive documentation either on creating a memory map or handling DMA with Peripheral->Device and Device->Peripheral transfers. I have a bunch of documentation on DMA internals but nothing with concrete information regarding memory maps.

I'm assuming that the STM32Cube CMSIS library has specific initialization code to setup the existing memory maps for the board but it must be using a precompiled driver because I can't see the source files, only headers.

I'm otherwise lost in the vastness of the ARM documentation and it is taking a long time to skim the documentation since I can't exactly name the thing I need in the same terms as in the documentation.

To keep it in simple terms, how can I create a memory map for an STM board using the STM32CubeF7 so I can transfer information to and from an external chip without loading/storing parts of the data in the main microcontroller memory.

Code examples would be great but I'm also looking for documentation for how it works in details.

EDIT 1 :

I have begun reading in more details the ARM Cortex M7 – Generic User Guide (page 28), and it in they mention a range of memory used for External RAM. What I am really looking for is how to wire up external RAM on my board to be used as external RAM.

ARM M7 Generic User Guide

I will keep analyzing the document but I have not seen specific documentation on using external SRAM chips as an ARM external RAM.

EDIT 2 :

I have found several questions on StackOverflow regarding programming STM boards with external memory chips. One of them was using FMC and it linked to a document by STM. Now I think I understand better what the current situation is and what the answers and comments on this question were saying.

Since I am using SPI right now, it would be impossible to map this directly to memory. Instead there are protocols like FMC and QuadSPI (or QSPI?) where the protocol and external chip specs can function with memory mapping. The linked document above (AN4761) shows examples on how to setup such functionality using SRAM, NAND and other chip types.

Reference material :

Best Answer

The only peripherals that have memory mapped external buses are FMC and QSPI, so execution is only supported from external memory types that those two peripherals support. But you can't boot from them, so you need a program (bootloader) that initializes the necessary peripherals and jumps to execute from FMC/QSPI address you want.

All other types of external storage (SPI, I2C, SD card etc) needs the contents to be loaded to memory that supports execution (on external FMC/QSPI bus or internal RAM/Flash). There is no way to change how the memory is mapped.