diff options
| author | kkard2 <[email protected]> | 2025-10-30 14:08:15 +0100 |
|---|---|---|
| committer | kkard2 <[email protected]> | 2026-03-07 14:21:55 +0100 |
| commit | 3ec7bf19b2be910ee28a89da9487c9725d86fe24 (patch) | |
| tree | e5b6807a8ea281745a439a2128212e160520ae60 /_linux/scripts/flash_kb.sh | |
| parent | a1b2c814e43161401889d7e0abdea2f46c7ed0ef (diff) | |
i use linux btw
Diffstat (limited to '_linux/scripts/flash_kb.sh')
| -rwxr-xr-x | _linux/scripts/flash_kb.sh | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/_linux/scripts/flash_kb.sh b/_linux/scripts/flash_kb.sh new file mode 100755 index 0000000..57d5a92 --- /dev/null +++ b/_linux/scripts/flash_kb.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +set -euo pipefail + +FIRMWARE="$1" + +if [[ ! -f "$FIRMWARE" ]]; then + echo "❌ Firmware file not found: $FIRMWARE" + exit 1 +fi + +# Ask for sudo upfront +sudo -v +# Keep-alive: update existing sudo timestamp until script finishes +while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & + +declare -A LABELS=( ["left"]="GLV80LHBOOT" ["right"]="GLV80RHBOOT" ) +declare -A MOUNTPOINTS=( ["left"]="/mnt/kb_left" ["right"]="/mnt/kb_right" ) + +flash_half() { + local side="$1" + local label="${LABELS[$side]}" + local mount_point="${MOUNTPOINTS[$side]}" + + echo "" + echo "⚙️ Waiting for $side half ($label) to appear in bootloader mode..." + + # Wait until device with correct label appears + while true; do + DEV=$(lsblk -o NAME,LABEL,PATH -nr | awk -v lbl="$label" '$2 == lbl {print $3}' || true) + if [[ -n "$DEV" ]]; then + echo "✅ Found $side half at $DEV" + break + fi + sleep 1 + done + + sudo mkdir -p "$mount_point" + echo "📦 Mounting $DEV to $mount_point..." + sudo mount "$DEV" "$mount_point" + + echo "📤 Copying firmware..." + sudo cp "$FIRMWARE" "$mount_point"/ + sync + + echo "💾 Unmounting..." + sudo umount "$mount_point" + + echo "✅ $side half flashed successfully!" +} + +flash_half "left" +flash_half "right" + +echo "" +echo "🎉 Both halves flashed successfully!" |
