FATFS upgrade via OTA

User avatar
brp80000
Posts: 138
Joined: Thu Oct 04, 2018 7:13 pm

FATFS upgrade via OTA

Postby brp80000 » Thu Nov 15, 2018 6:44 am

I use OTA to update my program. I have 16Mb chip.
1. How can I additionally update FATFS via OTA?
2. As .CSV should look like?

My now date .csv here:
nvs, data, nvs, 0x9000, 0x4000
otadata, data, ota, 0xd000, 0x2000
phy_init, data, phy, 0xf000, 0x1000
factory, app, factory, 0x10000, 1M
ota_0, app, ota_0, 0x110000, 1M
ota_1, app, ota_1, 0x210000, 1M
storage, data, fat, 0x400000, 2M

User avatar
brp80000
Posts: 138
Joined: Thu Oct 04, 2018 7:13 pm

Re: FATFS upgrade via OTA

Postby brp80000 » Sun Nov 18, 2018 5:06 am

Should I make a factory partition for fatfs
And then two OTA sections to alternate with updates?

date .csv :
nvs, data, nvs, 0x9000, 0x4000
otadata, data, ota, 0xd000, 0x2000
phy_init, data, phy, 0xf000, 0x1000
factory, app, factory, 0x10000, 1M
ota_0, app, ota_0, 0x110000, 1M
ota_1, app, ota_1, 0x210000, 1M
storage, data, fat, 0x400000, 2M
ota_0, data, fat, 0x600000, 2M
ota_1, data, fat, 0x800000, 2M

ESP_Mahavir
Posts: 190
Joined: Wed Jan 24, 2018 6:51 am

Re: FATFS upgrade via OTA

Postby ESP_Mahavir » Mon Nov 19, 2018 6:06 am

Right now OTA firmware upgrades are only supported for partitions with app:ota_o/ota_15 as type:subtype (Please refer https://github.com/espressif/esp-idf/bl ... _ops.c#L72). Hence OTA upgrade for fatfs partition is not something that is supported right now even if you add multiple/duplicate partitions in custom csv. We have had few requests for having support for this feature (custom partition upgrade), and will keep you posted for progress around it.

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: FATFS upgrade via OTA

Postby Ritesh » Mon Nov 19, 2018 6:24 pm

brp80000 wrote:
Thu Nov 15, 2018 6:44 am
I use OTA to update my program. I have 16Mb chip.
1. How can I additionally update FATFS via OTA?
2. As .CSV should look like?

My now date .csv here:
nvs, data, nvs, 0x9000, 0x4000
otadata, data, ota, 0xd000, 0x2000
phy_init, data, phy, 0xf000, 0x1000
factory, app, factory, 0x10000, 1M
ota_0, app, ota_0, 0x110000, 1M
ota_1, app, ota_1, 0x210000, 1M
storage, data, fat, 0x400000, 2M
Hi,

I think you can update fatfs directly without using OTA0 and OTA1 partition as you just need to update fatfs partition which can be done using normal flash operations after getting file for that update.

Let me correct if I understood anything wrong as per your requirement.
Regards,
Ritesh Prajapati

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

Re: FATFS upgrade via OTA

Postby loboris » Mon Nov 19, 2018 7:17 pm

brp80000 wrote:
Thu Nov 15, 2018 6:44 am
How can I additionally update FATFS via OTA?

Why would you need to "update" FatFS partition?
You can do whatever you want with the files on it, update, delete, create or get the file from remote server, or even reformat the partition.
What would be the point updating the partition as a whole via OTA? (BTW, it can be done, it just makes no sense).
Last edited by loboris on Mon Nov 19, 2018 8:37 pm, edited 1 time in total.

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: FATFS upgrade via OTA

Postby Ritesh » Mon Nov 19, 2018 7:23 pm

loboris wrote:
Mon Nov 19, 2018 7:17 pm
brp80000 wrote:
Thu Nov 15, 2018 6:44 am
How can I additionally update FATFS via OTA?

Why would you need to "update" FatFS partition?
You can do whatever you want with the files on if, update, delete, create or get the file from remote server, or even reformat the partition.
What would be the point updating the partition as a whole via OTA? (BTW, it can be done, it just makes no sense).
Yeah. You are also correct which same thing I have explained earlier that there is no need to update partition for FATFS which can be simply updated using FATFS User APIs as well. Hope we have explained better way to concern person.
Regards,
Ritesh Prajapati

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: FATFS upgrade via OTA

Postby ESP_igrr » Tue Nov 20, 2018 12:08 am

One nice property of updating the entire partition is atomicity. That is, either the update takes place, and everything is updated, or the update doesn't take place. If the entire partition is updated, then you can't find yourself in a situation of half-finished update due to e.g. power turned off in the middle. If the update does not finish, you keep using the old version in partition fatfs0, if it does finish, you use the new version in partition fatfs1.

Although IDF does not at the moment assist in implementing synchronized updates of application and filesystem, it is not impossible to achieve. If you take as a rule that whenever application partition ota0 is used, filesystem partition will be fatfs0, and likewise with ota1 and fatfs1. Then you can use OTA APIs to update the application binary, followed by updating the filesystem binary into the matching partition, and then using OTA API to flip the active partition.

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: FATFS upgrade via OTA

Postby Ritesh » Tue Nov 20, 2018 12:49 pm

ESP_igrr wrote:
Tue Nov 20, 2018 12:08 am
One nice property of updating the entire partition is atomicity. That is, either the update takes place, and everything is updated, or the update doesn't take place. If the entire partition is updated, then you can't find yourself in a situation of half-finished update due to e.g. power turned off in the middle. If the update does not finish, you keep using the old version in partition fatfs0, if it does finish, you use the new version in partition fatfs1.

Although IDF does not at the moment assist in implementing synchronized updates of application and filesystem, it is not impossible to achieve. If you take as a rule that whenever application partition ota0 is used, filesystem partition will be fatfs0, and likewise with ota1 and fatfs1. Then you can use OTA APIs to update the application binary, followed by updating the filesystem binary into the matching partition, and then using OTA API to flip the active partition.
Great. Thanks for providing useful information for that
Regards,
Ritesh Prajapati

User avatar
brp80000
Posts: 138
Joined: Thu Oct 04, 2018 7:13 pm

Re: FATFS upgrade via OTA

Postby brp80000 » Wed Nov 21, 2018 6:20 am

My fatfs partition contains http server files, so I need to update this partition when errors are found or content is updated. If section ota0 associated with fatfs0, and section ota1 is connected with fatfs1 when you upgrade it is necessary to control that the whole pair of ota and fatfs updated successfully and then change the active flag for the partition of ota.
This is an acceptable way for me.
1. I don't know what mine should look like .CSV
2. How and where should I link pairs of sections

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: FATFS upgrade via OTA

Postby ESP_igrr » Thu Nov 22, 2018 6:03 am

Partition table may look like this (i have omitted offsets and sizes):

Code: Select all

nvs, data, nvs
otadata, data, ota
(phy_init, data, phy) - optional
ota_0, app, ota_0
ota_1, app, ota_1
storage_0, data, fat
storage_1, data, fat
At application start, determine which OTA partition you are running from, and then select the matching FATFS partition.
(Pseudocode, might not directly compile)

Code: Select all

const esp_partition_t* running_app_partition = esp_ota_get_running_partition();
const char* fat_partition_name;
if (running_app_partition->subtype == ESP_PARTITION_SUBTYPE_APP_OTA_0) {
    fat_partition_name = "storage_0";
} else {
    fat_partition_name = "storage_1";
}
Now that we know fat_partition_name, it can be used to initialize fatfs/wear_levelling:

Code: Select all

esp_vfs_fat_spiflash_mount("/fatfs", fat_partition_name, &mount_config, &handle);
(refer to wear_levelling example)

Who is online

Users browsing this forum: Corand, Majestic-12 [Bot] and 74 guests