External QSPI NOR flash read and write operation
- April 23, 2026
- 2 replies
- 105 views
Hi,
Current usage
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:
- UI assets region (read-only at runtime)
- User structure region (needs occasional write/erase/program)
How it’s configured right now
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);Problem
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).
Questions
Is it safe / supported to temporarily exit memory-mapped mode, perform:
- sector erase (as needed)
- page program for the structure and then re-enter memory-mapped mode (DTR/QPI) again?
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).- Is a mutex/semaphore around any access to the memory-mapped region the right approach?
Cache coherency:
When returning to memory-mapped mode after writing, do I need to do DCache clean/invalidate.
