mirror of
https://github.com/imjasonh/esp32
synced 2026-07-06 23:52:24 +00:00
src/ota.rs polls ghcr.io every 60s on a dedicated 32 KB pthread, fetches the manifest with an anonymous Bearer token, and on a digest mismatch streams the layer into the inactive OTA partition while verifying SHA256 against the descriptor as it goes. Aborts and bails on size or SHA mismatch; otherwise sets the boot partition, persists pending_digest to NVS, and reboots. main.rs detects PENDING_VERIFY on boot and only calls esp_ota_mark_app_valid_cancel_rollback() after Wi-Fi + the existing HTTPS bringup checks pass -- so an OTA that breaks networking auto-reverts on the bootloader's next boot. After mark-valid, pending_digest is promoted to last_digest in NVS. GIT_SHA is baked into the firmware via env!() at compile time (set by the Makefile from `git rev-parse --short HEAD`) and logged on boot, so we can see which build is running. Bumped CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT to 16 KB; 8 KB stack-overflowed during HTTPS + JSON + SHA work. `make monitor` now auto-passes --non-interactive when stdout is not a TTY, so it works in scripts and background tasks. Verified end-to-end against ghcr.io/imjasonh/esp32 -- published v1, flashed via USB, bumped a visible version string, published v2, and the device polled, downloaded, SHA-verified, rebooted, and marked the new image valid after bringup. Zero USB intervention. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
6 lines
213 B
Rust
6 lines
213 B
Rust
fn main() {
|
|
println!("cargo:rerun-if-env-changed=WIFI_SSID");
|
|
println!("cargo:rerun-if-env-changed=WIFI_PASS");
|
|
println!("cargo:rerun-if-env-changed=GIT_SHA");
|
|
embuild::espidf::sysenv::output();
|
|
}
|