Skip to main content
pmppires
Associate II
March 21, 2019
Question

Placing files in flash memory (json)

  • March 21, 2019
  • 3 replies
  • 1883 views

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

This topic has been closed for replies.

3 replies

cameronf
Associate
March 21, 2019

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
pmppiresAuthor
Associate II
March 21, 2019

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
Associate
March 21, 2019

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