SPIFFS: how to create more then one partitions?

newsettler_AI
Posts: 121
Joined: Wed Apr 05, 2017 12:49 pm

SPIFFS: how to create more then one partitions?

Postby newsettler_AI » Mon Sep 16, 2019 6:52 pm

Hi,

I want to keep some sensitive data on different spiffs partition, so I can erase/reflash other partitions freele.

So, I have some questions about this.

1) How should partitions table looks like?

Right now I'm thinking about this format, but not sure about fields "Name" , "SubType" .

Code: Select all

# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,   0x6000,
phy_init, data, phy,     0xf000,   0x1000,
factory,  app,  factory, 0x10000,  0x170000,
storage1,  data, spiffs,  0x180000, 0x270000,
storage2,  data, spiffs,  0x3F0000, 0x10000,
2) Does names in partition table realated somehow to actual partition name?

From IDF example I see this:

Code: Select all

    esp_vfs_spiffs_conf_t conf = {
      .base_path = "/spiffs",
      .partition_label = NULL,
      .max_files = 5,
      .format_if_mount_failed = true
    };
    
    // Use settings defined above to initialize and mount SPIFFS filesystem.
    // Note: esp_vfs_spiffs_register is an all-in-one convenience function.
    esp_err_t ret = esp_vfs_spiffs_register(&conf);
Does it neccessary to keep same names at base_path and Name/Subtype ?

3) Can I use different file prefixes to operate with different partitions?
Right now I'm operatin with files something like that:

Code: Select all

file = fopen("/spiffs/list.txt", "wb");
For example, I want open file "list.txt" located on other partition.

Can I just do this:

Code: Select all

file = fopen("/other_partition/list.txt", "wb");
Thanks in advance :)

Mr_Red
Posts: 23
Joined: Mon Sep 11, 2017 12:41 pm

Re: SPIFFS: how to create more then one partitions?

Postby Mr_Red » Mon Oct 07, 2019 5:28 pm

1) you got it. Just give a different name to your partitions.
2) The name of the partition comes from the partition table. However, the file system prefix (base_path) is not related (see below).
3) you can use different file system prefix for each partition and the prefix can be anything (does not have to match partition name).

You'd call esp_vfs_spiffs_register() with a different configuration for each partition you want to use.

Code: Select all

    esp_vfs_spiffs_conf_t conf1 = {
      .base_path = "/spiffs",
      .partition_label = "storage1",
      .max_files = 5,
      .format_if_mount_failed = true
    };
    esp_vfs_spiffs_conf_t conf2 = {
      .base_path = "/other_partition",
      .partition_label = "storage2",
      .max_files = 5,
      .format_if_mount_failed = true
    };    
   

Who is online

Users browsing this forum: Baidu [Spider] and 116 guests