cancel
Showing results for 
Search instead for 
Did you mean: 

Placing files in flash memory (json)

pmppires
Associate II

I'm trying to place a json file from my computer in qspi memory, to then read it.

I'm not quite sure how to save the file on the board and then access it. Doing it on the simulator is easy but once I run the code on my stm32f769i-disc it crashes because it cant access the file

3 REPLIES 3
cameronf
Senior

In general you need to create an array containing the raw binary of the file and mark it for linker placement in the external flash. If you look at the .cpp files generated for the asset files by touchgfx, you can see how it needs to be setup. Since your json file is just ASCII you could use something like this to create your c array:

http://tomeko.net/online_tools/ascii.php?lang=en

pmppires
Associate II

Thanks for the promptly reply!

Isn't there any other way? because the final goal would be to download the file via wifi and open it from there, that way i couldnt create de c array that way

cameronf
Senior

If you want to be able to read and write it from firmware you'll have to do something a bit more complicated. In either case you'll probably want to partition off part of the external flash for your generic file/data use (when you do that, modify the linker script to have a smaller "external flash" region to exclude your new section so touchgfx doesn't try to use it for assets. Then you're options are to just read/write raw data to this section with a custom organization scheme or to implement a filesystem on top of it. If you want to add an actual file system this is a nice lightweight and safe one maintained by ARM: https://github.com/ARMmbed/littlefs/tree/v1.7.1