esp-hal-ota

Crates.ioesp-hal-ota
lib.rsesp-hal-ota
version0.1.3
sourcesrc
created_at2024-07-22 18:19:21.548059
updated_at2024-09-08 16:07:11.913073
descriptionOTA library for esp-hal
homepage
repository
max_upload_size
id1311452
size24,585
(filipton)

documentation

README

esp-hal-ota

OTA for esp-hal (no-std).

crates.io MIT license

Limitations

For now only works on esp32c3,esp32s3 (and possibly on esp32s2 - no way of testing it).

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

Getting started

  • Create partitions.csv file in project root (copy partitions.csv.template file)
  • In your project edit ./.cargo/config.toml file and append -T ./partitions.csv to the runner attribute
  • Optionally append --erase-parts otadata to ./cargo/config.toml to fix some ota issues
[target.xtensa-esp32s3-none-elf]
runner = "espflash flash --monitor -T ./partitions.csv --erase-parts otadata"

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

let mut ota = Ota::new(FlashStorage::new()).unwrap();
ota.ota_begin(flash_size, target_crc);

let mut buf = [0; 4096];
loop {
    let n = read_next_chunk(&mut buf);
    if n == 0 {
        break;
    }

    let res = ota.ota_write_chunk(&buf[..n]);
    if res == Ok(true) { // end of flash
        if ota.ota_flush(true).is_ok() { // true if you want to verify crc reading flash
            esp_hal::reset::software_reset();
        }
    }

    let progress = (ota.get_ota_progress() * 100) as u8;
    log::info!("progress: {}%", progress);
}

Todo

  • Fully working library
  • Simple example
  • Better errors
  • Other esp32's (like esp32c3, esp32s2, etc..)
  • Rollbacks

Resources

Commit count: 0

cargo fmt