Distribute master OTA images to slaves over ESP-NOW.

After UART OTA the master reads the staged partition in 4 KiB blocks (200 B ESP-NOW chunks), waits for per-slave block ACKs, and fixes the final partial block. Slaves reuse ota_uart; send pacing and logging improve reliability.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-19 01:00:56 +02:00
co-authored by Cursor
parent 4bf43d8a5e
commit 9b7bda8551
13 changed files with 835 additions and 33 deletions
+31
View File
@@ -1,5 +1,7 @@
syntax = "proto3";
import "nanopb.proto";
package alox;
enum EspNowMessageType {
@@ -9,6 +11,10 @@ enum EspNowMessageType {
ESPNOW_HEARTBEAT = 3;
ESPNOW_SET_ACCEL_DEADZONE = 4;
ESPNOW_UNICAST_TEST = 5;
ESPNOW_OTA_START = 6;
ESPNOW_OTA_PAYLOAD = 7;
ESPNOW_OTA_END = 8;
ESPNOW_OTA_STATUS = 9;
}
message EspNowUnicastTest {
@@ -33,6 +39,27 @@ message EspNowAccelDeadzone {
uint32 client_id = 2; // 0 = all slaves; otherwise only matching slave_id applies
}
// Master → slave: begin OTA (erase inactive slot; slave replies ESPNOW_OTA_STATUS).
message EspNowOtaStart {
uint32 total_size = 1;
}
// Master → slave: firmware chunk (up to 200 bytes); slave buffers 4 KiB before flash write.
message EspNowOtaPayload {
uint32 seq = 1;
bytes data = 2 [(nanopb).max_size = 200];
}
// Master → slave: finalize OTA (flush, esp_ota_end, set boot partition).
message EspNowOtaEnd {}
// Slave → master: status / block ACK (same status codes as UART OtaStatusPayload).
message EspNowOtaStatus {
uint32 status = 1;
uint32 bytes_written = 2;
uint32 error = 3;
}
message EspNowMessage {
EspNowMessageType type = 1;
oneof payload {
@@ -41,5 +68,9 @@ message EspNowMessage {
EspNowSlavePresence heartbeat = 4;
EspNowAccelDeadzone accel_deadzone = 5;
EspNowUnicastTest unicast_test = 6;
EspNowOtaStart ota_start = 7;
EspNowOtaPayload ota_payload = 8;
EspNowOtaEnd ota_end = 9;
EspNowOtaStatus ota_status = 10;
}
}