0hmX/pcbgolf-routing-checkpoint-20261012

A PCBGolf assembly combining a modeled PCB with copper/component bodies and seven native connector housings.

Version
0.0.3
License
unset
Stars
0

firmware-support/audit_board.py

#!/usr/bin/env python3
"""Run using KiCad Python; compare actual U3 pads against the generated firmware map."""
import hashlib,json,pathlib,pcbnew
H=pathlib.Path(__file__).resolve().parent;R=H.parents[3]
p=R/'work/candidates/two_layer_mvp/project/pcbgolf.kicad_pcb'
b=pcbnew.LoadBoard(str(p));u=next(f for f in b.GetFootprints() if f.GetReference()=='U3')
pads={int(p.GetNumber()):p.GetNetname() for p in u.Pads()};rows=json.loads((H/'board-map.json').read_text())['signals']
diff=[{'pin':r['package_pin'],'firmware_net':r['net'],'native_board_net':pads.get(r['package_pin'])} for r in rows if r['net']!=pads.get(r['package_pin'])]
report={'board':str(p),'sha256':hashlib.sha256(p.read_bytes()).hexdigest(),'mcu_value':u.GetValue(),'physical_pad_count':len(pads),'active_signals_compared':len(rows),'differences':diff,'status':'PASS' if not diff and len(pads)==100 and u.GetValue()=='STM32H725VGT6' else 'FAIL'}
(H/'native-pin-audit.json').write_text(json.dumps(report,indent=2)+'\n');print(json.dumps(report,indent=2));assert report['status']=='PASS'