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/prepare_smps_patch.py
#!/usr/bin/env python3
import difflib, hashlib, json, pathlib
H=pathlib.Path(__file__).resolve().parent;R=H.parents[3]
source=R/'work/agents/firmware/sources/panda/board/stm32h7/clock.h'
s=source.read_text();a='static PackageSMPSType get_package_smps_type(void) {\n';z=' return ret;\n}\n'
assert s.count(a)==1 and s.count(z)==1
m=s.replace(a,a+'#ifdef PCBGOLF_H725100\n return PACKAGE_WITH_SMPS; // H725VGT6 direct-SMPS board: applies to bootstub and app.\n#else\n').replace(z,' return ret;\n#endif\n}\n')
p=H/'predecessor-patch/board/stm32h7/clock.h';p.parent.mkdir(parents=True,exist_ok=True);p.write_text(m)
(H/'direct-smps.patch').write_text(''.join(difflib.unified_diff(s.splitlines(True),m.splitlines(True),fromfile='a/board/stm32h7/clock.h',tofile='b/board/stm32h7/clock.h')))
(H/'predecessor-provenance.json').write_text(json.dumps({'source_repo':'https://github.com/commaai/panda','source_commit':'78cf69904c332c599a297fcc2a09c08d10d429d5','source_clock_sha256':hashlib.sha256(source.read_bytes()).hexdigest(),'modified_clock_sha256':hashlib.sha256(p.read_bytes()).hexdigest(),'build_flag':'-DPCBGOLF_H725100','scope':'Only direct-SMPS startup fix; six-port predecessor is not the PCBGolf application.'},indent=2)+'\n')