seveibar/am3352-dev-board-4layer-dogbone

Defines PCB footprints and pin mappings for a TI AM3352ZCZ100 processor, JST GH connectors, and assembly-part lookup helpers for capacitors, resistors, and headers.

Version
0.1.5
License
unset
Stars
0

scripts/package-completed-board.py

"""Bundle the compiled site and reproducible source, excluding routing experiments."""
import json,zipfile,hashlib,os
from pathlib import Path
preview=os.environ.get('BOARD_PREVIEW_URL','http://localhost:8000/#file=index.circuit.tsx')
root=Path.cwd();out=root.parents[1]/'outputs/am3352-four-layer-dogbone';out.mkdir(parents=True,exist_ok=True)
validation=json.load(open('design/validation.json'));assert validation['fullyRouted']
sha=hashlib.sha256(Path('dist/index/circuit.json').read_bytes()).hexdigest()
assert json.load(open('design/copper-audit.json'))['circuitSha256']==sha
assembly=json.load(open('design/assembly-check.json'));assert assembly['circuitSha256']==sha and assembly['unresolvedRotations']==0
assert json.load(open('assembly/orientation-audit.json'))['circuitSha256']==sha
assert json.load(open('design/ddr-skew-check.json'))['circuitSha256']==sha
pad_report=json.load(open('design/no-via-in-pad.json'));assert pad_report['circuitSha256']==sha and pad_report['viaCount']>0 and not pad_report['violations']
topology=json.load(open('design/ddr-topology.json'));assert topology['circuitSha256']==sha and topology['netsChecked']==46 and not topology['errors']
p=Path('design/fabrication-rules.json');rules=json.loads(p.read_text());rules['status']='Routing and geometric validation completed; fabrication and signal-integrity signoff not performed';p.write_text(json.dumps(rules,indent=2)+'\n')
script_names=['audit-copper.py','check-ddr-skew.py','via_travel.py','verify.mjs','check-four-layer-stack.py','via-manifest.py','verify-decoupling.py','update-decoupling-via-distances.py','verify-interfaces.mjs','patch-endpoint-inference.mjs','patch-via-connectivity.mjs','patch-pour-connectivity.mjs','check-endpoint-inference.mjs','check-via-connectivity.mjs','check-pour-connectivity.mjs','test-ddr-validator.py','test-via-travel.py','check-no-via-in-pad.py','test-no-via-in-pad.py','check-ddr-topology.py','test-ddr-topology.py','render-previews.mjs','render-schematic.mjs','update-validation-docs.py','package-completed-board.py','export-assembly.mjs','check-led-polarity.mjs','cache-assembly-orientations.mjs','check-assembly.py','pre-fab-review.py','render-assembly.mjs']
skip_design={'bga-escape-report.json','ddr-fanout-assignment.json','ddr-pair-targets.json','ddr-pinmap.json','four-layer-power-escape-report.json','maze-report.json','ddr-pair-tuning-progress.json'}
files=[p for p in root.iterdir() if p.is_file() and p.suffix in ['.json','.tsx','.md','.txt','.png','.svg']]
for folder in ['components','imports','design','dist','assembly']:
 files += [p for p in (root/folder).rglob('*') if p.is_file() and not (folder=='design' and p.name in skip_design)]
files += [root/'scripts'/n for n in script_names]
archive=out/'am3352-four-layer-dogbone.zip'
with zipfile.ZipFile(archive,'w',zipfile.ZIP_DEFLATED,compresslevel=6) as z:
 for p in sorted(set(files)):z.write(p,Path('am3352-dev-board-4layer-dogbone')/p.relative_to(root))
with zipfile.ZipFile(archive) as z:
 assert z.testzip() is None
 assert hashlib.sha256(z.read('am3352-dev-board-4layer-dogbone/dist/index/circuit.json')).hexdigest()==sha
out.joinpath('README.md').write_text(f'''# Completed four-layer dogbone board

Open the live preview at {preview}.

`am3352-four-layer-dogbone.zip` contains the completed source, compiled site and validation reports.

Circuit JSON SHA-256: `{sha}`.

Build: zero native DRC errors. Independent copper audit: all 138 nets connected, zero clearance violations. All via annuli have at least 0.1 mm clearance from SMT pads on both faces, including same-net pads. Independent DDR validation: all 19 groups pass, including used via travel. See the included README for verification scope.
''')
print(archive,archive.stat().st_size,'bytes;',len(files),'files')