rushabhcodes/wireless-split-keyboard

Wireless Split Keyboard — custom routed nRF52840 split PCBs with a printable enclosure

Version
0.4.5
License
unset
Stars
0

Use with the tscircuit CLI

tsci is the tscircuit CLI. Install it with npm install -g tscircuit.

tsci clone rushabhcodes/wireless-split-keyboard  # download the package files into ./wireless-split-keyboard
tsci add rushabhcodes/wireless-split-keyboard    # add it to your project as @tsci/rushabhcodes.wireless-split-keyboard

In a cloned or new (tsci init) project: tsci dev starts a local preview, tsci build outputs Circuit JSON, and tsci push publishes to tscircuit.com.

scripts/record-firmware-build.py

"""Record actual compiler/linker evidence and artifact hashes, without flashing."""
from pathlib import Path
import hashlib,json,re,subprocess,sys,os
project=Path(__file__).resolve().parents[1]
workspace=Path(sys.argv[1])
out=project/'outputs/firmware'
def gitsha(path):return subprocess.check_output(['git','-C',str(path),'rev-parse','HEAD'],text=True).strip()
def sha(path):return hashlib.sha256(path.read_bytes()).hexdigest()
meta={'status':'COMPILE-TESTED DEVELOPMENT ONLY; not flashed or hardware-tested','zmk':gitsha(workspace/'zmk'),'zephyr':gitsha(workspace/'zmk/zephyr'),'sdk':Path(os.environ.get('ZEPHYR_SDK_INSTALL_DIR',workspace/'zephyr-sdk-0.17.4')).name,'targets':{}}
for half in ['left','right']:
 config=(out/f'{half}.config').read_text()
 assert 'CONFIG_USE_DT_CODE_PARTITION=y' in config,'Linker must use the reserved application partition'
 assert 'CONFIG_FLASH_LOAD_SIZE=0xf0000' in config,'Application must leave 64 KiB for settings'
 log=(out/f'build-{half}.log').read_text()
 flash=re.findall(r'FLASH:\s+(\d+) B\s+960 KB',log)
 ram=re.findall(r'RAM:\s+(\d+) B',log)
 assert flash and ram,'Successful link/memory report required'
 files={}
 for ext in ['hex','bin']:
  f=out/f'custom_sofle_{half}-DEVELOPMENT.{ext}'
  assert f.stat().st_size>0
  files[f.name]={'sha256':sha(f),'bytes':f.stat().st_size}
 meta['targets'][half]={'target':f'custom_sofle_{half}/nrf52840','flashBytes':int(flash[-1]),'ramBytes':int(ram[-1]),'applicationPartitionBytes':0xf0000,'settingsOffset':0xf0000,'files':files}
meta['sourceSha256']={str(f.relative_to(project/'firmware')):sha(f) for f in sorted((project/'firmware').rglob('*')) if f.is_file() and f.name!='README.md'}
meta['generatorSha256']=sha(project/'scripts/generate-firmware.ts')
meta['pinoutSha256']=sha(project/'src/pinout.ts')
(out/'build-manifest.json').write_text(json.dumps(meta,indent=2)+'\n')
print('Recorded both firmware builds; application regions limited to 960 KiB')