I've been reading about OTA. Imagine I have two partitions for OTA program storage. Lets call them ota_1 and ota_2. I also believe I need the "factory" application.
Imagine I distribute an ESP32 pre-loaded with my end-user application. My understanding is that it will be hosted in the "factory" partition. When the device boots, it will run the factory application code ... end of story. Now imagine there is a button on the ESP32. When pressed, it should "check for new application versions". When I press the button, the logic in my "application" will connect to the network and determine (say by an HTTP request or socket call) whether or not a new version of the app is available. If there is one, then the ESP32 downloads it and saves it (using the OTA APIs) in partition ota_0. Now I reboot the device. Instead of running the "factory app", it now runs the app contained in partition "ota_0" and factory app is ignored. If I now press the button again and there is another new update, the story repeats with the new version loaded into partition "ota_1" and on boot the app in "ota_1" is executed, the code in both factory and ota_0 partitions are now ignored. If we repeat this story we toggle between partitions "ota_0" and "ota_1".
This is my model of understanding. Now some questions if I may ...
1) What is the purpose of the "factory" partition? Why not just have "ota_0" and "ota_1" with the app pre-loaded in "ota_0" and then toggle between "ota_0" and "ota_1"?
2. Do I need to prepare my applications in any special way to make them work? For example, if I'm reading the partition maps correctly then factory app starts at 0x1 0000, ota_0 at 0x11 0000 and ota_1 at 0x21 0000. Is the code we have built position independent code or is there some form of flash memory address mapping at work? I'm not sensing how compiled code can "live" at distinct flash memory addresses (and presumably distinct addresses spaces in the ESP32 memory map) and still run.
[Answered]: Building apps for OTA distribution ...
[Answered]: Building apps for OTA distribution ...
Last edited by kolban on Sat Jan 06, 2018 3:56 pm, edited 1 time in total.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: Building apps for OTA distribution ...
You don't need factory, it is optional.
Mmu will map the app into virtual memory and addresses will be relative to start address.
Mmu will map the app into virtual memory and addresses will be relative to start address.
Re: Building apps for OTA distribution ...
You can have only ota_0 & ota_1 partition, without factory partition. Good thing about factory partition is that it can contain not the "complete" user application, but only the basic, well tested application to download the "real" application to the ota partition. If used that way, it can be much smaller than the final application. It can act as kind of "safe" boot in case the updated application contains the code which makes it unusable.kolban wrote:1) What is the purpose of the "factory" partition? Why not just have "ota_0" and "ota_1" with the app pre-loaded in "ota_0" and then toggle between "ota_0" and "ota_1"?
Boot from the factory partition can be forced from application in ota partition, or by some external condition (button) - in which case the modified bootloader must be used (the current bootloader code does not support that feature).
It is possible to also update the code in factory partition from application running from ota partition.
The application don't need to be prepared in any special way. You must take care that the application binary is not larger than the ota partitions on your device.
Who is online
Users browsing this forum: No registered users and 103 guests