r75-firmware/flash.sh
orca bc967ff54f R75 cyberdeck firmware: stock keymap, custom effects, host protocol
Vial firmware for the wired Royal Kludge R75 (WB32FQ95), based on
mossbed/r75 vialrgb and checked against RK's own R75 source:
- the keymap is generated from the factory keymap read off the keyboard
  (factory reset moved to Fn+RShift+Space)
- the Caps Lock LED uses RK's pin C4 instead of matrix column C9
- five custom RGB matrix effects (synthwave, glitch, heartbeat, plasma,
  scanner)
- raw HID command 0xC7: custom effect select, colour/speed for any
  effect, and alert overlays drawn over the running effect
- host simulator in sim/ to preview the effects as PNGs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 01:58:31 -04:00

28 lines
1.3 KiB
Bash
Executable file

#!/bin/sh
# Flash the R75. The keyboard must already be in DFU mode:
# stock firmware: Fn + Right Shift + Esc cyberdeck firmware: same, or hold Esc while plugging in
# ./flash.sh flash build/rk_r75_vial.bin (the cyberdeck firmware)
# ./flash.sh --stock restore RK's factory firmware from the backup
set -e
HERE=$(cd "$(dirname "$0")" && pwd)
STOCK=$HOME/.local/share/cyberdeck/r75-backup/r75-stock-firmware-2026-10-18.bin
case "${1:-}" in
--stock) FW=$STOCK; (cd "$(dirname "$STOCK")" && sha256sum -c SHA256SUMS) ;;
"") FW=$HERE/build/rk_r75_vial.bin ;;
*) FW=$1 ;;
esac
[ -f "$FW" ] || { echo "no firmware at $FW"; exit 1; }
python3 - "$FW" <<'PY'
import struct, sys
d = open(sys.argv[1], "rb").read()
sp, rv = struct.unpack("<II", d[:8])
ok = 0x20000000 <= sp < 0x20040000 and 0x08000000 < rv < 0x08040000 and len(d) <= 256 * 1024
print(f"{sys.argv[1]}: {len(d)} bytes, SP 0x{sp:08x}, reset 0x{rv:08x} -> {'ok' if ok else 'NOT A VALID IMAGE'}")
sys.exit(0 if ok else 1)
PY
if ! lsusb -d 342d:dfa0 >/dev/null; then
echo "keyboard is not in DFU mode (press Fn + Right Shift + Esc)"; exit 1
fi
wb32-dfu-updater_cli -D "$FW" </dev/null
wb32-dfu-updater_cli -R </dev/null
echo "flashed; the keyboard should come back on its own (replug if not)"