Showing results for 
Search instead for 
Did you mean: 

how to save values in non-volatile memory qspi

Associate III


how to save (int, float...) values, in non-volatile memory on a riverdi RVT70HSSFWCA0 screen. It has an external qspi flash. Can you give me some simple basic examples or a demo file? I think we should use HAL FLASH? and the code should be put in which part of the project (in part touchgfx or stm32 cm7 (main.c ...)), I admit that I am a little disoriented with object programming on cubeide!

Andrew Neil

@NicoEFI wrote:

on a riverdi RVT70HSSFWCA0 screen

Have you asked Riverdi that?

They would be the ones to provide examples targetted for their particular boards: 



Yes I sent them an email request but still no response. 

The Internal FLASH commands and API will be no use for QSPI

You can't interact with the memory while in Memory Mapped Mode.

Hopefully there would be BSP code to bring up the memory, or facilitate an External Loader, if not you'd need to add functions to erase and write.

You'd need to erase a sector, typically smallest being 4KB, and then write up to a page (256 bytes) at an aligned boundary.

For configuration data I'd use a structure that I can update / use in RAM, and flush to QSPI FLASH when things change.

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

@Tesla DeLorean wrote:

The Internal FLASH commands and API will not use for QSPI

@NicoEFI - but maybe you could use the internal Flash instead ... ?

Then you wouldn't have any dependencies on Riverdi's external hardware ...

yes maybe, so I could use the standard hal flash library?

Pavel A.
Evangelist III

The chip in the Riverdi board is STM32H757XIH6, which is close relative of STM32H747.

Look in ST examples for STM32H747 boards:

They have both QSPI flash examples and internal flash examples. The "standard HAL flash library" is good for the latter. Because there are so many QSPI flash memories, the "standard HAL flash library" has only the basic driver for the QSPI controller itself. Drivers for some QSPI memories are in the "BSP" branch of the Cube library package. If the Riverdi board has one of these flash chips, you're lucky.



Associate III

ok thank you for your answer, then I write in the internal flash and I use this code to write a variable, at the address 0x080E0000, sector 7, on an STM32H757XIH6 using the library stm32h7xx_hal_flash.h
To write a byte I have to take the place of a word if I understand correctly!
HAL_FLASH_Program(FLASH_TYPEPROGRAM_FLASHWORD, 0x080E0000, 0x13); // save data to flash
Now, if I want to erase this variable after having written it, to write another variable instead and without erasing the other variables in the sector, how do I do it ? or should I emulate as an eeprom ?

@NicoEFI wrote:

should I emulate as an eeprom ?

That sounds like the functionality you're looking for!


BTW: use this button to properly post source code: