FatFS - how create a partition?

papadeltasierra
Posts: 28
Joined: Thu Nov 03, 2022 1:57 pm

FatFS - how create a partition?

Postby papadeltasierra » Tue Nov 07, 2023 3:59 pm

My assumption is that using just an esp32-c3, I can create a partition and tun FatFS against it to store configuration (which will change very rarely). If this is correct, how do I go about creating the initial partition? I need to understand:
1. First time creation
2. How to avoid trashing it during an OTA upgrade.
I have read the ESP32 docs on this but I've not yet gotten my head around the partition creation steps.
Thanks!

accacca
Posts: 34
Joined: Mon Aug 06, 2018 4:59 pm

Re: FatFS - how create a partition?

Postby accacca » Tue Nov 07, 2023 7:13 pm

I suggest use SPIFFS there are some limitations compared to FatFS but I don't think there will be any problems if you just need to store some files that you will rarely edit.

You must cerate a partition for SPIFFS in ESP3 flash This this can be done by creating a csv file describing the partitions
Example

Code: Select all

# Name,   Type, SubType, Offset,  Size, Flags
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
nvs,      data, nvs,     0x009000,  0x6000,
otadata,  data, ota,     0x00F000,  0x2000,
phy_init, data, phy,     0x011000,  0x1000,
storage,  data, spiffs,  ,          900K 
factory,  app,  factory, 0x100000,  2M,
ota_0,    app,  ota_0,   ,          2M,
ota_1,    app,  ota_1,   ,          2M,
Partition csv file contain spiffs partition and two ota partitions for OTA upgrade

You must also configure project with custom partition table (VScode example)
tmp.jpg
tmp.jpg (16.98 KiB) Viewed 2001 times

MicroController
Posts: 1708
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: FatFS - how create a partition?

Postby MicroController » Tue Nov 07, 2023 11:54 pm

https://docs.espressif.com/projects/esp ... -generator
But FAT is indeed pretty heavy for just "some" configuration data. Check out SPIFFS or NVS.

papadeltasierra
Posts: 28
Joined: Thu Nov 03, 2022 1:57 pm

Re: FatFS - how create a partition?

Postby papadeltasierra » Thu Nov 09, 2023 8:14 am

Thanks. The configuration includes some long strings (needed to provide authentication to connect to Microsoft Azure resources) which was why I was avoiding the "simpler" options. I expect this to mostly be one-time set-up with rare changes but I will look again at the SPIFFS stuff.

As to the CSV file, if I go look will I find a sample for the "standard" layout somewhere? I guess I'm just stealing space form the existing layout for my configuration partition (or using the existing NV/SPIFFS ones)?

Thanks.

MicroController
Posts: 1708
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: FatFS - how create a partition?

Postby MicroController » Thu Nov 09, 2023 11:41 am

papadeltasierra wrote:
Thu Nov 09, 2023 8:14 am
As to the CSV file, if I go look will I find a sample for the "standard" layout somewhere?
"Somewhere" would be here.

accacca
Posts: 34
Joined: Mon Aug 06, 2018 4:59 pm

Re: FatFS - how create a partition?

Postby accacca » Thu Nov 09, 2023 6:30 pm

Thanks. The configuration includes some long strings (needed to provide authentication to connect to Microsoft Azure resources) which was why I was avoiding the "simpler" options. I expect this to mostly be one-time set-up with rare changes but I will look again at the SPIFFS stuff.
You requested FatFS, I suggested SPIFFS with which you can manage the files (fopen fread fwrite...) exactly as on FatFS but storing the data in the internal flash of ESP32.
If you have few values that you rarely modify then I think MicroController solution of using NVS is most appropriate

papadeltasierra
Posts: 28
Joined: Thu Nov 03, 2022 1:57 pm

Re: FatFS - how create a partition?

Postby papadeltasierra » Tue Nov 14, 2023 9:54 am

Thanks for all the help and pointers.

Who is online

Users browsing this forum: bfredo123, Google [Bot] and 111 guests