Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
esp-hal-ota
OTA for esp-hal (no-std).
Until esp-bootloader-esp-idf 0.3, esp-hal had no OTA support and this crate (a port of ESP-IDF's
C OTA logic) was the only OTA solution for esp-hal. esp-hal now ships basic OTA primitives
(OtaUpdater); this crate still uses its own implementation because upstream currently mishandles
a few real-world cases (erased otadata after flashing, a corrupt otadata entry), and adds a
complete streaming updater on top:
- streaming writes of image chunks
- CRC32 check against the expected image CRC
- read-back verify before activation
- progress and resume of interrupted updates
- rollback / mark valid on the booted partition
- tolerant of an erased or corrupt otadata entry
Limitations
I cannot test if it works properly on esp32s2,esp32c2,esp32c6 and esp32h2. But esp32s3, esp32c3 and esp32 are working perfectly fine.
Features
- Obviously OTA updates
- Dynamic partitions reading (so no macros, no reading from partitions.csv) - fully automatic
- Checking currently booted partition (using some pointer magic from ESP-IDF)
- CRC32 verification
- No allocations, no panics (errors are returned)
Getting started
- Enable the
embedded-storagefeature ofesp-storage(opt-in sinceesp-storage0.10) - Create
partitions.csvfile in project root (copypartitions.csv.templatefile) - In your project edit
./.cargo/config.tomlfile and append--partition-table ./partitions.csvto therunnerattribute - Optionally append
--erase-parts otadatato./cargo/config.tomlto fix some ota issues
[]
= "espflash flash --monitor --partition-table ./partitions.csv --erase-parts otadata"
Upgrading
See MIGRATING.md for breaking changes between versions.
Example
To see real-world example look at ./examples and ./simple-ota-server dirs.
let flash_size = 1234; // get it from OTA server
let target_crc = 65436743; // get it from OTA server (crc32, e.g. `crc32fast::hash`)
let mut ota = new?;
ota.begin?;
let mut buf = ;
loop
After booting the new image call ota.mark_app_valid(), otherwise (with rollbacks enabled)
the bootloader goes back to the previous image on the next reset.
Running example
- You can compile your .bin file using esp-flash
This will generate .bin file from build file for chip.
Todo
- Fully working library
- Simple example
- Better errors
- Other esp32's (like esp32c3, esp32s2, etc..)
- Rollbacks
Resources
- https://github.com/esp-rs/espflash (this led me to esp-idf-part)
- https://github.com/esp-rs/esp-idf-part
- https://github.com/espressif/esp-idf/blob/master/docs/en/api-reference/system/ota.rst (especially Python API)
- https://github.com/python/cpython/blob/main/Modules/binascii.c (internal_crc32)
- https://github.com/espressif/esp-idf/blob/master/components/app_update/esp_ota_ops.c#L552 (esp get current partition (paddr))
- https://github.com/bjoernQ/esp32c3-ota-experiment (i've only seen this after first experiments, so haven't looked at it yet)