2026-04-23 8:32 AM - last edited on 2026-04-23 8:53 AM by Andrew Neil
Hi,
At the moment, the external flash is mainly used to store UI assets (images/fonts/etc.) for a display. I’m not using the full flash capacity, so I’d like to use an unused region to store a small persistent structure (configuration/status/log header).
To keep things organized, I created a partitioning scheme using the linker file, reserving separate address ranges:
Since up to now I only needed runtime reads, the flash is configured in Memory-Mapped Mode (DTR, QPI). I enable it with:
MT25TL01G_EnableMemoryMappedModeDTR(&hqspi, MT25TL01G_QPI_MODE);I now need to write into the user structure region, but I understand that in Memory-Mapped Mode the peripheral is configured for read transactions and typical write/erase operations require switching back to indirect mode (command mode).
Is it safe / supported to temporarily exit memory-mapped mode, perform:
If yes, what is the recommended sequence on STM32H757 to exit memory-mapped mode cleanly?
For example: abort memory-mapped, re-init, switch to indirect, do erase/program, then enable memory-mapped again.
RTOS (ThreadX):
Even though only the CPU reads the memory-mapped region (no LTDC/DMA2D direct reads from external flash), I have multiple threads. While one thread is writing to flash, another thread might try to read UI assets (mapped reads).
Cache coherency:
When returning to memory-mapped mode after writing, do I need to do DCache clean/invalidate.
2026-04-23 11:05 AM
Hi,
I tried that once for HMI also and it didn't work very well!
Yet, you can try this sequence:
All NOR driver and QSPI should be put in RAM.
1- Disable Interrupts
2- Stop scheduler (suspend)
3- Do erase/write (You should use QSPI in polling)
4- Activate MMM
5- Enable Interrupts
6- Resume Scheduler
It worked very well but wasn't stable! Sometime I get hard faults. My solution was to use an SDRAM.
2026-04-24 2:03 AM
Hello @JonConesa
Yes, this is the correct approach: temporarily exit memory-mapped mode, perform erase/program in indirect mode, then re-enable memory-mapped mode.
With ThreadX, you should serialize all external flash access using a mutex and ensure no other thread reads the mapped region while a write is in progress.
Please refer to the example below:
2026-04-27 2:41 AM