ESP32 loading .bin from SPIFFS
Posted: Thu Jan 20, 2022 10:33 am
Hello. In my program, I need to update device from SPIFFS. I have found an older forum post:
viewtopic.php?t=22441
There is described how to do it and a code snippet is attached.
I have some questions:
1. In the same post, a guy shared his partition table:
Could someone help me understand what is the point of having 3 partitions for app? We have a factory partition, ota_0 and ota_1. Why we need all three?
Just for the experimentation sake, I have tried to completely remove factory and just leave ota_0 and ota_1. My partition table looks :
Now when I flash the device, I think it automatically uses the ota_0 instead of factory, the rest is seems to be working exactly the same as with 3 partition tables. So what is the point of having 3 partition tables for the app? (factory, app_0, app_1)
2. I would like to understand what exactly is happening when I update the firmware over the SPIFFS. From what I understand, by default, my whole program sits in ota_0. When I initiate firmware update over the SPIFFS, all data from my spiffs storage is being written to ota_1.
What exactly happens next? Is ota_1 being automatically chosen as a default partition that the device boots from? How does the program know which partition to choose?
viewtopic.php?t=22441
There is described how to do it and a code snippet is attached.
I have some questions:
1. In the same post, a guy shared his partition table:
Code: Select all
nvs,data,nvs,0x9000,200K,
otadata,data,ota,0x3b000,8K,
phy_init,data,phy,0x3d000,4K,
factory,app,factory,0x40000,1200K,
ota_0,app,ota_0,0x170000,1200K,
ota_1,app,ota_1,0x2a0000,1200K,
Just for the experimentation sake, I have tried to completely remove factory and just leave ota_0 and ota_1. My partition table looks :
Code: Select all
nvs, data, nvs, 0x9000, 0x4000,
otadata, data, ota, 0xd000, 0x2000,
phy_init, data, phy, 0xf000, 0x1000,
ota_0, app, ota_0, 0x10000, 0x200000,
ota_1, app, ota_1, , 0x200000,
storage, data, spiffs, , 0x100000,
2. I would like to understand what exactly is happening when I update the firmware over the SPIFFS. From what I understand, by default, my whole program sits in ota_0. When I initiate firmware update over the SPIFFS, all data from my spiffs storage is being written to ota_1.
What exactly happens next? Is ota_1 being automatically chosen as a default partition that the device boots from? How does the program know which partition to choose?