feat(v2): OTA firmware update over Ethernet
POST /ota writes the image to the idle app slot and reboots; GET /ota reports the running slot. App rollback is enabled, and a new image confirms itself after 10 s. Adds make ota HOST=<ip>, tools/ota.py and the led-tool --ota update. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8d78af1246
commit
6c16998691
8 files changed
+212
-4
No files matched your search
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Upload a firmware image to the controller over Ethernet.
|
||||
|
||||
ota.py <host> [build/led_controller_v2.bin]
|
||||
"""
|
||||
import http.client
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
host = sys.argv[1] if len(sys.argv) > 1 else sys.exit(__doc__)
|
||||
path = sys.argv[2] if len(sys.argv) > 2 else os.path.join(os.path.dirname(__file__), "..", "build", "led_controller_v2.bin")
|
||||
size = os.path.getsize(path)
|
||||
|
||||
conn = http.client.HTTPConnection(host, 80, timeout=60)
|
||||
conn.request("GET", "/ota")
|
||||
print("running:", conn.getresponse().read().decode())
|
||||
|
||||
print(f"uploading {path} ({size} bytes)")
|
||||
with open(path, "rb") as f:
|
||||
conn.request("POST", "/ota", body=f, headers={"Content-Length": str(size),
|
||||
"Content-Type": "application/octet-stream"})
|
||||
r = conn.getresponse()
|
||||
body = r.read().decode()
|
||||
print(r.status, body)
|
||||
sys.exit(0 if r.status == 200 else 1)
|
||||
Reference in new issue
Block a user