Files
story/firmware/echoear-platform-agent/tools/flash-com6-controls.py
T
Codex Local bf1233d5df
ci / verify (push) Canceled after 0s
feat: expand companion platform, device controls, and memoir workflows
Add customer and operator login, BLE provisioning, device fleet controls, call memory, memoir generation, and refreshed family and maintenance portals. Include API contracts, migrations, firmware sources, tests, assets, and deployment documentation.
2026-10-08 10:06:44 +08:00

27 lines
1.9 KiB
Python

"""Migrate this backed-up COM6 board to A/B without erasing identity or Wi-Fi."""
import hashlib,json,pathlib,subprocess,sys
project=pathlib.Path(__file__).resolve().parents[1]
evidence=pathlib.Path('E:/Codex/story/.local-evidence/com6-controls-20260922')
backup=evidence/'before-controls-16mb.bin'
assert backup.stat().st_size==0x1000000
assert hashlib.sha256(backup.read_bytes()).hexdigest()=='df426d931d3208ea3714f3393e65c06de75da31606dd6668d9afa027e4d0a187'
tool='E:/Codex/toolchains/esp-idf-v5.5.1/components/esptool_py/esptool/esptool.py'
base=[sys.executable,tool,'--chip','esp32s3','--port','COM6','--baud','921600']
probe=subprocess.check_output(base+['read_mac'],text=True,stderr=subprocess.STDOUT)
assert 'b4:3a:45:16:34:a8' in probe.lower(),'wrong physical board'
files=[(0x0,'bootloader/bootloader.bin',0x8000),(0x8000,'partition_table/partition-table.bin',0x1000),
(0x10000,'VolcRTCDemo.bin',0x400000),(0x810000,'ota_data_initial.bin',0x2000),
(0x812000,'srmodels/srmodels.bin',0x80000)]
args=[];manifest=[]
for offset,relative,maximum in files:
path=project/'build'/relative;data=path.read_bytes()
assert 0<len(data)<=maximum
assert not (offset<0x10000 and offset+len(data)>0x9000),'NVS overlap'
assert offset+len(data)<=0x892000,'protected resource overlap'
manifest.append({'offset':hex(offset),'file':relative,'size':len(data),'sha256':hashlib.sha256(data).hexdigest()})
args += [hex(offset),str(path)]
(evidence/'flash-manifest.json').write_text(json.dumps(manifest,indent=2))
with (evidence/'flash-controls.log').open('w',encoding='utf-8') as log:
subprocess.run(base+['write_flash','--flash_mode','dout','--flash_size','16MB','--flash_freq','80m']+args,stdout=log,stderr=subprocess.STDOUT,check=True)
print(json.dumps({'result':'flashed_and_verified','board':'B4:3A:45:16:34:A8','regions':manifest,'protected':'NVS, storage, display resources, factory identity'}))