feat(pack): v2 双固件 profile 打包 — fw_pack 公共库 + CLI 重构 + GUI 打包弹窗
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
"""Independent byte-level verification of gd32e230_firmware_tool.py outputs.
|
||||
|
||||
Layout (GD32E230F8, 64KB):
|
||||
0x08000000 Bootloader (8KB region)
|
||||
0x08002000 APP (max 54KB = 55296B)
|
||||
0x0800F800 Calibration page (1KB, must stay 0xFF)
|
||||
0x0800FC00 Flag page (1KB); flag word 0x0000EEEE at 0x0800FFFC
|
||||
0x08010000 Flash end
|
||||
"""
|
||||
import hashlib
|
||||
import struct
|
||||
import sys
|
||||
|
||||
ok = True
|
||||
|
||||
|
||||
def check(cond, label):
|
||||
global ok
|
||||
print(('PASS ' if cond else 'FAIL ') + label)
|
||||
if not cond:
|
||||
ok = False
|
||||
|
||||
|
||||
bl_img = open('LDC1612_V1.0.1_APP_2026-09-26_BL.bin', 'rb').read()
|
||||
upd = open('LDC1612_V1.0.1_APP_2026-09-26_update.bin', 'rb').read()
|
||||
boot = open('gd32e230f8_bootloader_hulk.bin', 'rb').read()
|
||||
app = open(r'E:\Hulk-Coding\ldc1612_cmake_vscode\Build\codex-bootloader-test'
|
||||
r'\LDC1612_V1.0.1_APP_2026-09-26.bin', 'rb').read()
|
||||
|
||||
print('=== sizes / SHA-256 ===')
|
||||
for name, blob in [('BL image', bl_img), ('OTA update', upd),
|
||||
('bootloader', boot), ('APP bin', app)]:
|
||||
print('%-11s %6dB %s' % (name, len(blob), hashlib.sha256(blob).hexdigest()))
|
||||
|
||||
print('=== BL image (full-chip) ===')
|
||||
check(len(bl_img) == 65536, 'BL image total length == 64KB (65536B)')
|
||||
check(bl_img[0:len(boot)] == boot, 'offset 0x0000: bootloader image (3512B) matches source bin')
|
||||
check(all(b == 0xFF for b in bl_img[len(boot):0x2000]),
|
||||
'gap 0x0DB8-0x2000 filled with 0xFF (erased flash)')
|
||||
check(bl_img[0x2000:0x2000 + len(app)] == app, 'offset 0x2000: APP image (12280B) matches source bin')
|
||||
check(all(b == 0xFF for b in bl_img[0x2000 + len(app):0xF800]),
|
||||
'APP tail up to cal page filled with 0xFF')
|
||||
check(all(b == 0xFF for b in bl_img[0xF800:0xFC00]),
|
||||
'calibration page 0x0800F800-0x0800FBFF untouched (0xFF)')
|
||||
check(all(b == 0xFF for b in bl_img[0xFC00:0xFFFC]),
|
||||
'flag page body 0x0800FC00-0x0800FFFB stays 0xFF')
|
||||
flag = struct.unpack_from('<I', bl_img, 0xFFFC)[0]
|
||||
check(flag == 0x0000EEEE, 'flag word @0x0800FFFC == 0x0000EEEE (LE bytes EE EE 00 00), got 0x%08X' % flag)
|
||||
check(bl_img[0xFFFC:0x10000] == b'\xee\xee\x00\x00', 'flag raw bytes @0x0800FFFC == EE EE 00 00')
|
||||
check(bl_img[0xFFF0:0xFFFC] == b'\xff' * 12, 'bytes before flag untouched (0xFF)')
|
||||
|
||||
print('=== OTA update package ===')
|
||||
check(len(upd) == 12288, 'OTA size == 12288B (12 x 1KB, page aligned)')
|
||||
check(len(upd) % 1024 == 0, 'OTA size 1KB aligned')
|
||||
check(len(upd) - len(app) == 8, 'OTA pad length == 8B (12280 -> 12288)')
|
||||
check(upd[0:len(app)] == app, 'OTA payload == APP bin')
|
||||
check(all(b == 0xFF for b in upd[len(app):]), 'OTA pad bytes all 0xFF')
|
||||
check(len(upd) <= 55296, 'OTA size within 54KB APP limit')
|
||||
|
||||
print()
|
||||
print('OVERALL: ' + ('ALL CHECKS PASSED' if ok else 'FAILURES PRESENT'))
|
||||
sys.exit(0 if ok else 1)
|
||||
Reference in New Issue
Block a user