OTA of factory app
OTA of factory app
In our project, the factory app is simply a bootloader that grabs the image from an http server. The OTA example shows how to update partitions OTA1 and OTA2. Is it possible to update factory partition using OTA as well, in case we want to push updates to the bootloader itself?
-
- Posts: 131
- Joined: Tue May 17, 2016 8:12 pm
Re: OTA of factory app
As I understand it, there is no such thing as Factory Partition. Either partition (assuming two A and B) is available by a system flag that tells it which was the LAST partition loaded from OTA and to boot that partition (lets say A). When you download a new app via OTA it puts this "new" app in the "other" partition (say B), complete the download and then tells the system that the "current" Partition is now B. If OTA fails for whatever reason, nothing happens and you keep your old App in Partition A.
When OTA is successful it will now boot from B EVEN if you do a USB/SERIAL download to A (most likely) !!!!! To get unstuck from booting from the last OTA download, you need to and then USB/SERIAL download.
When OTA is successful it will now boot from B EVEN if you do a USB/SERIAL download to A (most likely) !!!!! To get unstuck from booting from the last OTA download, you need to
Code: Select all
make erase_flash
Re: OTA of factory app
The partition table for two OTA has a factory partition:
nvs, data, nvs, 0x9000, 0x4000
otadata, data, ota, 0xd000, 0x2000
phy_init, data, phy, 0xf000, 0x1000
factory, 0, 0, 0x10000, 1M
ota_0, 0, ota_0, , 1M
ota_1, 0, ota_1, , 1M
I think the idea is that you always want to be able to revert to factory, even if you load a bad (malfunctioning) software into a partition and make it active.
nvs, data, nvs, 0x9000, 0x4000
otadata, data, ota, 0xd000, 0x2000
phy_init, data, phy, 0xf000, 0x1000
factory, 0, 0, 0x10000, 1M
ota_0, 0, ota_0, , 1M
ota_1, 0, ota_1, , 1M
I think the idea is that you always want to be able to revert to factory, even if you load a bad (malfunctioning) software into a partition and make it active.
Re: OTA of factory app
The short answer is no, if you call esp_ota_begin() with a factory partition then it will fail. The idea is that even if both OTA partitions are somehow corrupted beyond the ability to boot, you can return to the factory partition and start the update process fresh from there. In this configuration, the only thing the factory partition needs to be able to do is to successfully complete an OTA update into a newer firmware.kostyan5 wrote:In our project, the factory app is simply a bootloader that grabs the image from an http server. The OTA example shows how to update partitions OTA1 and OTA2. Is it possible to update factory partition using OTA as well, in case we want to push updates to the bootloader itself?
That said, If you edit the "is_ota_partition()" static function in components/app_update/esp_ota_ops.c then I believe this is the only check which prevents you from OTA flashing non-OTA partitions. So you could theoretically weaken this check (it's not something we're likely to support in IDF, though.)
It is possible to make a custom partition table that doesn't have a factory partition, in which case the first OTA app partition becomes the "factory" initial boot partition, and then each OTA slot is updated with subsequent updates. This is the recommended option if your SPI flash is too small to dedicate a factory partition.
Re: OTA of factory app
How do you instruct the tool to use OTA0 as the factory flash location? I put the correct offset into menuconfig, but I still get this:
I (12) boot: compile time 03:25:01
I (13) boot: Enabling RNG early entropy source...
I (13) qio_mode: Enabling QIO for flash chip ISSI
I (14) boot: SPI Speed : 80MHz
I (15) boot: SPI Mode : QIO
I (15) boot: SPI Flash Size : 2MB
I (16) boot: Partition Table:
I (17) boot: ## Label Usage Type ST Offset Length
I (18) boot: 0 nvs WiFi data 01 02 00009000 00004000
I (19) boot: 1 otadata OTA data 01 00 0000d000 00002000
I (21) boot: 2 phy_init RF data 01 01 0000f000 00001000
I (22) boot: 3 ota_0 OTA app 00 10 00010000 000f8000
I (23) boot: 4 ota_1 OTA app 00 11 00108000 000f8000
I (25) boot: End of partition table
E (25) boot: ota data partition invalid and no factory, can't boot
I (12) boot: compile time 03:25:01
I (13) boot: Enabling RNG early entropy source...
I (13) qio_mode: Enabling QIO for flash chip ISSI
I (14) boot: SPI Speed : 80MHz
I (15) boot: SPI Mode : QIO
I (15) boot: SPI Flash Size : 2MB
I (16) boot: Partition Table:
I (17) boot: ## Label Usage Type ST Offset Length
I (18) boot: 0 nvs WiFi data 01 02 00009000 00004000
I (19) boot: 1 otadata OTA data 01 00 0000d000 00002000
I (21) boot: 2 phy_init RF data 01 01 0000f000 00001000
I (22) boot: 3 ota_0 OTA app 00 10 00010000 000f8000
I (23) boot: 4 ota_1 OTA app 00 11 00108000 000f8000
I (25) boot: End of partition table
E (25) boot: ota data partition invalid and no factory, can't boot
Re: OTA of factory app
@ESP_Angus thanks for the explanation of the concept of the factory partition. I understand that it defeats the purpose of having a fail-safe factory app if one is able to write to it in the field.
But there will be (unusual) instances when we need to upgrade the factory partition via OTA.
And of course, my boss wants me to do just that.
We recently fixed a bug and will be incorporating the bugfix into newly built products,
But we have a bunch of already built-up product in inventory which is not accessible via UART- just Eth/Wifi OTA for programming. The boss doesn't want to just upload the fixed app to an OTA partition because if a user performs a factory reset it would revert to the old firmware with the bug.
I guess the IDF should have an "OTA factory override" function that I could use to create a special OTA which can write to the factory partition?
Also how hard would it be to create an OTA image which wraps the factory .bin file with some minimal code to flash it to the factory partition?
But there will be (unusual) instances when we need to upgrade the factory partition via OTA.
And of course, my boss wants me to do just that.
We recently fixed a bug and will be incorporating the bugfix into newly built products,
But we have a bunch of already built-up product in inventory which is not accessible via UART- just Eth/Wifi OTA for programming. The boss doesn't want to just upload the fixed app to an OTA partition because if a user performs a factory reset it would revert to the old firmware with the bug.
I guess the IDF should have an "OTA factory override" function that I could use to create a special OTA which can write to the factory partition?
Also how hard would it be to create an OTA image which wraps the factory .bin file with some minimal code to flash it to the factory partition?
Re: OTA of factory app
For future users who find this: changing factory app thru OTA should be doable.
I explain how we changed partition table in this other topic, using a very similar approach you should be able to change factory app I think: viewtopic.php?f=2&t=11482&p=48589#p48589
I explain how we changed partition table in this other topic, using a very similar approach you should be able to change factory app I think: viewtopic.php?f=2&t=11482&p=48589#p48589
Re: OTA of factory app
I'll shared my hack to allow update of the factory app partition. Please see here:
https://github.com/chmorgan/libesphttpd/pull/81
Enjoy, no warranties, use at your own risk, of course.
https://github.com/chmorgan/libesphttpd/pull/81
Enjoy, no warranties, use at your own risk, of course.
Who is online
Users browsing this forum: Corand and 62 guests