# -*- coding: utf-8 -*- """独立总校验:只看**交付物 + 固件镜像**,不看任何中间产物(不读 .work/)。 python tools/verify_all.py # 生成 docs/selfcheck_report.txt + 预览图 逐项判据(每项都是一条可证伪的断言): A 交付物形态:.face 魔数、watchface id = 462150103(两份共用)、b5=0、体积上限 B Lua 表:从 .face 里的 Lua 反解 pay / rb 表(各 61 条) C 等长:每条 pay 的长度 == 原厂槽位长度,且目标偏移就是 charging/chargeN.bin 的 数据偏移(61 条恰好一一覆盖,无重复无遗漏) D 可解码:每条 pay 是 480x480 I8+RLE,且 RLE 流**恰好**解出 usize = 1024+480*480 E 帧内容:把交付物里的每一帧解出来,与"用 q63 源帧独立做的 Lanczos 放大"比对, 平均差 < 1.0/255(吸附误差量级),并报最像的源帧号(证明 n 对 n 没错帧) F 版本指纹:replace 盘的 rb == **原厂**前 64 B(对固件镜像独立比对) restore 盘的 pay == **原厂**整条字节(逐字节) restore 盘的 rb == replace 盘 pay 的前 64 B(两份交付物互证) G 整镜像:用 replace 盘的负载重建改后镜像 -> inode 表 / superblock / 长度与原厂 逐位一致,且**除 61 个槽位外没有任何字节变化** H 预览:把交付物解出来的 61 帧拼成图(docs/decode_preview.png)便于肉眼复核 """ import os, re, sys, hashlib, struct sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from paths import PROJ, INPUTS, DOCS from romfs import Romfs import lvgl_bin as L from make_charge_payload import src_indexed from PIL import Image, ImageDraw import numpy as np W = H = 480 WF_ID = '462150103' DIRP = 'charging/' STOCK = os.path.join(INPUTS, 'target', 'vela_system.bin') SOURCE = os.path.join(INPUTS, 'source', 'vela_system.bin') FACES = {'replace': os.path.join(PROJ, 'dist', 'S5Chg.face'), 'restore': os.path.join(PROJ, 'dist', 'S5ChgRestore.face')} REPORT = [] ok = fail = 0 def log(s=''): print(s) REPORT.append(s) def ck(cond, msg, detail=''): global ok, fail if cond: ok += 1 else: fail += 1 log(' [%s] %s%s' % ('OK ' if cond else 'FAIL', msg, (' ' + detail) if detail else '')) return cond def num_of(p): return int(p.rsplit('charge', 1)[-1].replace('.bin', '')) def slots_of(path): rom = Romfs(path) d = {} for p, i in rom.entries(): if i.type == 1 or not p.startswith(DIRP) or not p.endswith('.bin'): continue d[i.data_off] = (num_of(p), i.size) return rom, d def decode(blob): h = L.parse_header(blob) m, csize, usize = struct.unpack(' ' + os.path.join(DOCS, 'selfcheck_report.txt')) sys.exit(1 if fail else 0)