cancel
Showing results for 
Search instead for 
Did you mean: 

How to write stm32l5xx_hal_mmc DMA to stm32l5xx_hal_ospi?

DBark.2
Associate III

I’m attempting to optimize a process of loading a large file from eMMC flash memory directly into a SPI device with 8 data lanes. Originally, I meant to use peripheral to peripheral in the DMA component that comes internally with the STM32L5 series. However, the hal32l5xx_hal_mmc driver states

“No general propose DMA Configuration is needed, an Internal DMA for SDMMC Peripheral are used.�?

I’m trying to determine the most speed-efficient way to manage this transfer. I’m currently experimenting with directly calling the OctoSPI memory mapped location as the data buffer in the HAL_MMC_ReadBlocks_DMA function but I’m having little success.

Are there any examples of using MMC Peripheral to Peripheral DMA communication? How would this process be achieved? 

1 ACCEPTED SOLUTION

Accepted Solutions

Not using the L5 here, but I'm pretty sure based on other QSPI/OSPI implementations that a memory-mapped write isn't going to happen, and that most NOR SPI flash devices are slow to write, and need to be waited on and nursed along.

I'd do this using ping-pong buffers (2X 32KB) with the eMMC reading into one, and writing the QSPI/OSPI concurrently out the other, my money is on the eMMC out pacing the SPI

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

4 REPLIES 4

Not using the L5 here, but I'm pretty sure based on other QSPI/OSPI implementations that a memory-mapped write isn't going to happen, and that most NOR SPI flash devices are slow to write, and need to be waited on and nursed along.

I'd do this using ping-pong buffers (2X 32KB) with the eMMC reading into one, and writing the QSPI/OSPI concurrently out the other, my money is on the eMMC out pacing the SPI

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
DBark.2
Associate III

Hey Tesla, thanks so much for the response!

My worry for using the two buffers is that I wanted to avoid copying the data into the MCU memory to save time and simply pass the data directly through, but that may well be unavoidable.

Just to make sure I'm following, this would involve using a single HAL_MMCEx_ReadBlocksDMAMultiBuffer call for the entire load, then from each of the

"HAL_MMCEx_Read_DMADoubleBuf0CpltCallback" and

"HAL_MMCEx_Read_DMADoubleBuf1CpltCallback" callback functions

make an a "HAL_OSPI_Transmit_IT" call to send the information to the OSPI interface?

Then in the HAL_OSPI_Transmit_IT call I could just read the data directly from "IDMABASE0" and "IDMABASE1"?

ChahinezC
Lead

Hello @DB.7arke​,

First, you can configure the external Octo-SPI memory to memory mapped mode.

Once memory mapped mode is enabled, just configure the SDMMC to access the memory mapped region to transfer the data from the external eMMC using the internal DMA. The SDMMC will access the Octo-SPI's memory mapped region like an internal memory.

And can you specify the used external Octo-SPI memory? If it is an external flash, an Octo-SPI write enable command must be sent in indirect mode before performing any write from the SDMMC to the memory mapped region.

Chahinez.

DBark.2
Associate III

Hey @ChahinezC​ 

I'm using the OctoSPI peripheral to load an FPGA configuration. In this case, I was unable to find success with memory-mapped mode because of the FPGA timing and special data constraints. I did spend a solid week trying to get this method working.

Ultimately, I ended up following @Community member​'s suggestion and setting up and duel buffer system with DMA on the eMMC and OctoSPI peripherals for increased data flow, so one buffer can be written as the other is received.

I'm pretty happy with this system, though a direct line would be faster, I'm not sure it's possible for my use case.

The last curiosity I suppose I have, is it required to send the OctoSPI configuration before every single OctoSPI transmit_DMA command (or any transmit command). I would have though you'd only have to configure once, but if you don't repeat configuration, you get an incorrect hospi state.