How to fill a a flash partition with files/data

User avatar
MickPF
Posts: 45
Joined: Tue Apr 03, 2018 8:47 pm

How to fill a a flash partition with files/data

Postby MickPF » Thu Jul 01, 2021 6:27 am

Hello,

I'd like to use in a (new) project with ESP32 (4 MB Flash and 4 MB PSRAM) and ESP-IDF 4.2 resources (binary files of up to 200 kB in size), which would be loaded after the reset from the flash via access to a "fatfs" Partition first into PSRAM and then passed via SPI to an other device.

1. I have created a partition table and entered it in "menuconfig". It all works so far.
2. From the manual I know how to (later) access the file system or the “fatfs” partition in order to read these files.

But nowhere does the manual say how to load the files onto the file system or onto the partition. Neither in the API reference nor in the API guides (at least in version 4.2 they are very sketchy). I can't recognize any "instructions" in the examples either. I don't "speak" python! I can read and understand it but I can't "write" python!

Would someone please explain how to do it step by step? Or where to find this information. I would be very grateful for that!

Thanks in advance,
Michael
Nobody is perfect!
My name is NOT Nobody...


Nobody lives forever to correct his mistakes someday in the future, if not right now!
Covid-19 is not responsible for any human failures!

User avatar
mbratch
Posts: 303
Joined: Fri Jun 11, 2021 1:51 pm

Re: How to fill a a flash partition with files/data

Postby mbratch » Fri Jul 02, 2021 11:53 am

Hello Michael
Great question. I don't have access to my laptop at the moment, but I believe the espressif example app for a rest API server uses a file system partition and the build config is set up to prepopulate the web page file hierarchy. Check out that example and see if that helps you along.

User avatar
MickPF
Posts: 45
Joined: Tue Apr 03, 2018 8:47 pm

Re: How to fill a a flash partition with files/data

Postby MickPF » Fri Jul 02, 2021 9:53 pm

I cannot find any such example.
there is an example something with "wearble", but it shows how to access the fatfs from esp32.
I would like to fill the filessytem or the partition from the host, which will be then flashed.
Can you be more precise, which example you mean?
Nobody is perfect!
My name is NOT Nobody...


Nobody lives forever to correct his mistakes someday in the future, if not right now!
Covid-19 is not responsible for any human failures!

Leander
Posts: 28
Joined: Thu Sep 26, 2019 8:50 pm

Re: How to fill a a flash partition with files/data

Postby Leander » Mon Jul 05, 2021 12:53 pm

I believe that the only way to populate the internal flash fatfs partition is to write files from the ESP to the partition.
The fatfs filesystem is useful for reading SD-Cards connected to the ESP as these are compatible with other operating systems such as Windows.
I'm using the SPIFFS storage myself to store larger files not suited for the NVS system. These files are self-generated (ex logs) or downloaded from a http server.

User avatar
MickPF
Posts: 45
Joined: Tue Apr 03, 2018 8:47 pm

Re: How to fill a a flash partition with files/data

Postby MickPF » Mon Jul 05, 2021 2:01 pm

Hello,

because some things in esp-idf have not been thought through or implemented to the end, I had to add an SD slot to the project, which I originally didn't want.

If an SD card is inserted in it, it is scanned by code and the resource files are first transferred to the flash memory and then to the devices according to their destination.

But I don't want to have a discussion about whether and how far some things are implemented in ESP-IDF.

I have a lot of experience with ESP-IDF and with STM32-Cube (with STM32H7) to know what is professionally done and what is not.
For me, ESP32 has only three advantages: WiFi, lower power consumption and lower hardware design costs. But it also has many disadvantages ...
Nobody is perfect!
My name is NOT Nobody...


Nobody lives forever to correct his mistakes someday in the future, if not right now!
Covid-19 is not responsible for any human failures!

User avatar
mbratch
Posts: 303
Joined: Fri Jun 11, 2021 1:51 pm

Re: How to fill a a flash partition with files/data

Postby mbratch » Tue Jul 06, 2021 4:34 pm

MickPF wrote:
Fri Jul 02, 2021 9:53 pm
I cannot find any such example.
there is an example something with "wearble", but it shows how to access the fatfs from esp32.
I would like to fill the filessytem or the partition from the host, which will be then flashed.
Can you be more precise, which example you mean?
Have a look at the protocols/http_server/restful_server example.

In this example, the create a folder structure that constitutes a web site, in essence. They define a custom partition table to include an additional partition, www, which is the home for this structure. If you look inside Makefile, you'll see a call as follows, which recreates the web page file structure on the www partition.

Code: Select all

$(eval $(call spiffs_create_partition_image,www,$(WEB_SRC_DIR)/dist))
There's further information in the documentation, SPIFFS File System. That page links another example, storage/spiffs.

Who is online

Users browsing this forum: No registered users and 246 guests