The project aims at enabling firmware update of ESP32 Over-the-Air with compressed delta binaries. Testing was done with ESP32-DevKitC v4 board.
To run the OTA demo, you need an ESP32 dev board (e.g. ESP32-WROVER Kit) or ESP32 core board (e.g. ESP32-DevKitC). You can also try running on ESP32-S2, ESP32-C3 or ESP32-S3 dev boards and let me know how it worked out.
-
ESP-IDF v4.3 and above
You can visit the ESP-IDF Programmming Guide for the installation steps.
-
detools v0.49.0 and above
Binary delta encoding in Python 3.6+. You can follow the instructions here for installation.
-
Build the example
examples/http_delta_ota
-idf.py build
. You can use the binary built here as thebase_binary
.For example usage, a
while(1)
loop printing 'Hello World!' was added to this example to create theupdated_binary
. -
To generate the patch, we need 2 application binaries, namely
base_binary
andupdated_binary
.detools create_patch -c heatshrink base_binary.bin updated_binary.bin patch.bin
-
Open the project configuration menu (
idf.py menuconfig
) go toExample Connection Configuration
->- WiFi SSID: WiFi network to which your PC is also connected to.
- WiFi Password: WiFi password
-
In order to test the OTA demo ->
examples/http_delta_ota
:- Flash the firmware
idf.py -p PORT -b BAUD flash
. - Run
idf.py -p PORT monitor
and note down the IP assigned to your ESP module. The default port is 80.
- Flash the firmware
-
After getting the IP address, send the patch binary through a HTTP Post request over cURL.
curl -v -X POST --data-binary @- < patch.bin 192.168.201.9:80/ota
- Base binary:
assets/v1.bin
- Updated binary:
assets/v2.bin
- Patch binary:
assets/patch_1_2.bin
- After successfully patching and rebooting, you can see the
Hello World
logs.
ota_demo.mp4
Chip | Scenario | Base binary | Updated binary | Compressed binary patch (Heatshrink) | Patch-to-File % |
---|---|---|---|---|---|
ESP32 | test_basic_enable_small_feature | 168208 | 155136 | 11036 | 7.11% |
ESP32 | test_nvs_app_modification | 190656 | 199824 | 16245 | 8.13% |
ESP32 | test_http_upgrade_with_ssl | 672736 | 761184 | 138839 | 18.24% |
ESP32 | test_provisioning_upgrade_idf_patch_version | 966656 | 924448 | 234096 | 25.32% |
- As Heatshrink uses static allocation with small look-ahead buffers, it has almost no impact on heap memory.
-
test_basic_enable_small_feature: Enabling a small feature in an update
Base binary: Compile
get-started/hello-world
exampleUpdated binary: Same, but disable CONFIG_VFS_SUPPORT_IO option in sdkconfig
-
test_nvs_app_modification: Changing user application flow without changing the set of libraries used
Base binary: Compile
storage/nvs_rw_value
exampleUpdated binary: Compile
storage/nvs_rw_blob
example -
test_http_upgrade_with_ssl: Changing user application flow with new set of libraries added
Base binary: Compile
protocols/http_server/simple
exampleUpdated binary: Compile
protocols/https_server/simple
example -
test_provisioning_upgrade_idf_patch_version: Upgrading IDF to the next patch version
Base binary: Using IDF 4.3, compile
provisioning/wifi_prov_mgr
exampleUpdate binary: Same, but with IDF 4.3.1; sdkconfig is generated from scratch.
-
Experiments with more test scenarios, especially with bigger binaries
-
Add complete workflow example
- Currently patch is applied to the
ota_0
partition rather than thefactory
- Currently patch is applied to the
-
Optimize Heatshrink compression parameters
- Currently running on low memory usage mode (8, 7) and static allocation
- Memory usage and app binary size analysis
-
Binary patch with LZMA compression in detools
- LZMA is memory-heavy but will provide a greater compression ratio for the patch
- detool: Binary delta encoding in Python 3 and C 🡒 Source | Docs
- heatshrink: An Embedded Data Compression Library 🡒 Source | Blog
- Delta updates for embedded systems 🡒 Source | Docs
- bspatch for ESP32 🡒 Source
Distributed under the MIT License. See LICENSE
for more information.
Note: The delta
component is licensed under the Apache-2.0 License. Please see components/delta/LICENSE
for more information.