cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7S7 How to write to external flash

evervoid
Associate II

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!

1 ACCEPTED SOLUTION

Accepted Solutions
mƎALLEm
ST Employee

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.

View solution in original post

4 REPLIES 4
mƎALLEm
ST Employee

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.

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?

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.

Thanks for your help.

It should be possible as long as the read (XIP) and write happens in different banks according to AN6228 . 

But due to the construction of the stm32h7s78-dk board, I need to use 1 xspi for PSRASM. I think I just store the data in the SD card for now before making a custom board.