cancel
Showing results for 
Search instead for 
Did you mean: 

Does STM32U585 support DMA writes to internal flash?

BHamm
Associate II

Hello,

I've been unable to determine if it's possible to use the DMA to write data from internal RAM to internal flash on an STM32U585 device.

I've consulted the following, but don't see a clear answer:

I've also looked at the examples that can be imported into STM32CubeIDE. This includes a flash to RAM write using DMA example, and a flash erase/program example that does not involve the DMA.

If a DMA write from RAM to flash is possible, I'm also unclear on the limitations and benefits. The device has two flash banks, and some of the documentation above leads me to believe I should be able to write to one flash bank via the DMA, while continuing to execute code from the other flash bank while the DMA operation is in progress. If it is never possible to execute code from internal flash during a write to internal flash, then it doesn't seem like using the DMA would provide any benefit.

If a DMA write from RAM to flash is not possible, it looks like the next best thing is to do a flash write with an interrupt callback (using `HAL_FLASH_Program`). I am still unclear on the limitations and benefits of using this, and if code will continue to execute as long as it's in a separate bank, or if it's sufficient if it's in a separate page.

Any definitive answers and clearer guidance on what I should attempt would be greatly appreciated. Thank you!

6 REPLIES 6
Mohamed Aymen HZAMI
ST Employee

Hello @BHamm​ and welcome to the community,

There is an example in the STM32U5 firmware under this path:

"STM32Cube_FW_U5_V1.1.0\Projects\NUCLEO-U575ZI-Q\Examples\DMA\DMA_FLASHToRAM"

Also in the reference manual in Figure 1. System architecture in the bus matrix there is a link between the internal Flash and the GPDMA, so the GPDMA support writes to internal Flash.

the snapshot below highlight the communication link between the GPDMA and the internal Flash.

0693W00000QMHcUQAX.png 

Mohamed Aymen

BHamm
Associate II

@Mohamed Aymen HZAMI​ Thank you for taking the time to respond. Unfortunately, I do not think this provides any new information. I already mentioned the Flash-to-RAM example in my original post; that example doesn't tell me much about DMA transfers in the other direction (RAM-to-Flash). The diagram shows the DMA is linked to flash, but it doesn't clarify if it's really bi-directional.

I need clear direction on how to write to flash using the DMA, and if there's even any benefit to that approach over using HAL_FLASH_Program_IT. I know that HAL_FLASH_Program_IT is limited to a 128-byte burst, but I was hoping using the DMA would allow for larger chunks of data plus more granularity in transfer size.

(I've gotten confirmation that executing code from one flash bank is possible while erasing/writing the other flash bank. That answers the non-DMA portion of the question.)

I'd wager not. And that it's not a design/functional goal.

The MCU has a means of stalling, I don't think the DMA does.

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

Can you see the difference between RAM->FLASH and FLASH->RAM?

Hi @Piranha​ 

Yes, you have a difference between RAM->FLASH and FLASH->RAM

*RAM->FLASH there is a flash programming sequence to be executed before to transmet data with DMA you can find details about this process in RM:

7.3.5 Flash memory program and erase operations

FLASH->RAM you can send data by using DMA

Regards,

Diane

Hi @BHamm​ 

You don't really have an advantage in using the DMA to transmit data from RAM to flash because you area flash programming sequence to be executed before to transmit data with DMA  as I mentioned above. You can directly use your MCU to transmit data from your RAM to your FLASH.

Regards,

Diane