krishnax12/t113-minimal-linux

Allwinner T113-S3 dual-Cortex-A7 SoC with integrated 128MB DDR3, multi-rail decoupling, 24MHz and 32.768kHz oscillators, filtering, and exposed test points.

Version
0.1.1
License
unset
Stars
0

scripts/check-routing.py

"""Recheck the saved PCB copper; requires requirements-routing.txt."""
import hashlib
import json
import sys
from pathlib import Path

from routing_geometry import audit

project = Path(__file__).resolve().parent.parent
source = Path(sys.argv[1]) if len(sys.argv) > 1 else project / "dist/index/circuit.json"
destination = Path(sys.argv[2]) if len(sys.argv) > 2 else project / "routing/routing-check.json"
raw = source.read_bytes()
report = audit(json.loads(raw))
report["inputSha256"] = hashlib.sha256(raw).hexdigest()
report["rulesMm"] = {
    "copperClearance": 0.15,
    "padToPadClearance": 0.10,
    "drillToDrillClearance": 0.15,
    "nonplatedHoleClearance": 0.15,
    "trackAndViaBoardEdgeClearance": 0.19,
    "comparisonTolerance": 0.001,
}
report["scope"] = "Physical copper connectivity, clearances, drill spacing and board outline. Does not certify stackup, impedance, current capacity, assembly or prototype behavior."
destination.parent.mkdir(parents=True, exist_ok=True)
destination.write_text(json.dumps(report, indent=2) + "\n")
print(f"{'PASS' if report['passed'] else 'FAIL'}: {report['pcbTraces']} traces, {report['vias']} vias, {len(report['unconnectedNets'])} unconnected nets; violations: {report['violationCounts']}")
if not report["passed"]:
    raise SystemExit(1)