Skip to main content
Associate II
March 11, 2026
Solved

STM32H7S7 How to write to external flash

  • March 11, 2026
  • 1 reply
  • 320 views

HI,

 

I'm using stm32h7s78-dk, and setup the external flash following this tutorial 

The "appli" project is in external flash and runs with no issue. Now I want to write some config data such as display brightness to the external flash according to user input but I can't find a way to do that.

 

I tried HAL_FLASH_Program(), but it seems can only modify the internal flash. Then I tried to enable EXTMEM_MANAGER_APPLI in CubeMX to use EXTMEM_WriteInMappedMode(). However, I can't reinitialize the xspi in "appli" project..

What is the appropriate way to do this?

 

Any input is much appreciated!

Best answer by mƎALLEm

Hello,

Please refer to this example provided in the CubeH7RS package in github.

The readme file indicates that the code is executed from Bank0 and the write is performed to Bank1.

1 reply

mƎALLEm
mƎALLEmBest answer
Technical Moderator
March 11, 2026

Hello,

Please refer to this example provided in the CubeH7RS package in github.

The readme file indicates that the code is executed from Bank0 and the write is performed to Bank1.

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question."
evervoidAuthor
Associate II
March 11, 2026

Thanks for reply!

My current setup is using xspi1 to interface with PSRAM, xspi2 for external flash. According to the example you mentioned, I need to use both xspi1 and xspi2 on the flash chip to be able to read and write at the same time.

So I have to use other method to interface with external ram, or have a dedicated chip such as a EEPROM to store the config data.

Am I understanding this correctly?

mƎALLEm
Technical Moderator
March 12, 2026

I'm not expert of that interface but I think that's not possible to write to the same external memory flash while executing from it as you may stall the XSPI interface/the CPU.

So maybe you need to relocate the program that writes to the external flash to another memory (internal SRAM/Flash or even the external SRAM you are using). After achieving the write operation you need to jump again to your program stored in the XSPI flash.

Or for simply use an EEPROM or FRAM to store your data.

 

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question."