This commit is contained in:
Brad Stein 2025-06-06 20:45:09 -05:00
parent dff41b63f3
commit 2941508920
3 changed files with 42 additions and 33 deletions

View File

@ -64,6 +64,10 @@ WantedBy=multi-user.target
UNIT UNIT
sudo systemctl daemon-reload sudo systemctl daemon-reload
sudo systemctl enable --now navka-core.service navka-server.service sudo systemctl enable --now navka-core
sudo systemctl restart navka-core.service navka-server.service sudo systemctl restart navka-core
echo "✅ navka-core installed and restarted..."
sudo systemctl enable --now navka-server
sudo systemctl restart navka-server
echo "✅ navka-server installed and restarted..." echo "✅ navka-server installed and restarted..."

View File

@ -1,23 +1,30 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Proven Pi-5 configfs gadget: HID keyboard+mouse + stereo UAC2 # Proven Pi-5 configfs gadget: HID keyboard+mouse + stereo UAC2
# Still need Web Cam Support # Still need Web Cam Support
# navka-core one-shot gadget bring-up for Pi-5 / Arch-ARM
set -euo pipefail set -euo pipefail
echo "uboot_overlay_addr0=/boot/overlays/dwc2.dtbo" >> /boot/firmware/config.txt # 1) Ensure the dwc2 peripheral overlay is active exactly once
CFG=/boot/config.txt
grep -q 'dtoverlay=dwc2,dr_mode=peripheral' "$CFG" || echo 'dtoverlay=dwc2,dr_mode=peripheral' >> "$CFG"
modprobe dwc2 # 2) Load kernel modules (idempotent)
modprobe dwc2 || { echo "dwc2 missing; abort" >&2; exit 1; }
modprobe libcomposite || { echo "libcomposite not in kernel; abort" >&2; exit 1; } modprobe libcomposite || { echo "libcomposite not in kernel; abort" >&2; exit 1; }
# mountpoint -q /sys/kernel/config || mount -t configfs configfs /sys/kernel/config
# 3) Mount configfs once
mountpoint -q /sys/kernel/config || mount -t configfs none /sys/kernel/config mountpoint -q /sys/kernel/config || mount -t configfs none /sys/kernel/config
G=/sys/kernel/config/usb_gadget/navka G=/sys/kernel/config/usb_gadget/navka
# 4) Tear down any previous half-built gadget
if [[ -d $G ]]; then if [[ -d $G ]]; then
echo "" >"$G/UDC" 2>/dev/null || true echo "" > "$G/UDC" || true
find "$G/configs" -type l -delete || true find "$G/configs" -type l -delete || true
rmdir "$G/functions/"* 2>/dev/null || true rm -rf "$G/functions/"*; rmdir "$G" || true
rmdir "$G" 2>/dev/null || true
fi fi
# 5) Create gadget (boot-keyboard + UAC2 mic/spkr, 500 mA max)
mkdir -p "$G" mkdir -p "$G"
echo 0x1d6b >"$G/idVendor" # Linux Foundation echo 0x1d6b >"$G/idVendor" # Linux Foundation
echo 0x0104 >"$G/idProduct" # Multifunction Composite Gadget echo 0x0104 >"$G/idProduct" # Multifunction Composite Gadget
@ -39,21 +46,19 @@ echo -ne '\x05\x01\x09\x06\xa1\x01\x05\x07\x19\xe0\x29\xe7\x15\x00\x25'\
'\x08\x15\x00\x25\x65\x05\x07\x19\x00\x29\x65\x81\x00\xc0' \ '\x08\x15\x00\x25\x65\x05\x07\x19\x00\x29\x65\x81\x00\xc0' \
>"$G/functions/hid.usb0/report_desc" >"$G/functions/hid.usb0/report_desc"
# UAC2 stereo 48 kHz # -- Simple Audio
mkdir -p "$G/functions/uac2.usb0" mkdir -p $G/functions/uac2.usb0
echo 48000 >"$G/functions/uac2.usb0/c_srate" echo 48000 > $G/functions/uac2.usb0/c_srate
echo 2 >"$G/functions/uac2.usb0/c_ssize" echo 2 > $G/functions/uac2.usb0/c_ssize
echo 2 >"$G/functions/uac2.usb0/p_chmask" echo 2 > $G/functions/uac2.usb0/p_chmask
mkdir -p "$G/configs/c.1/strings/0x409" # -- Config and Binds
echo "Config 1" >"$G/configs/c.1/strings/0x409/configuration" mkdir -p $G/configs/c.1/strings/0x409
echo 500 >"$G/configs/c.1/MaxPower" echo "Config 1" > $G/configs/c.1/strings/0x409/configuration
echo 500 > $G/configs/c.1/MaxPower
ln -s $G/functions/hid.usb0 $G/configs/c.1/
ln -s $G/functions/uac2.usb0 $G/configs/c.1/
mkdir -p "$G/configs/c.1" "$G/configs/c.1/strings/0x409" # 6) Finally bind to first available UDC
echo "Keyboard" >"$G/configs/c.1/strings/0x409/configuration" echo $(ls /sys/class/udc | head -n1) > $G/UDC
echo "[navka-core] gadget ready on USB-C port"
ln -s "$G/functions/hid.usb0" "$G/configs/c.1/"
ln -s "$G/functions/uac2.usb0" "$G/configs/c.1/"
echo "$(ls /sys/class/udc | head -n1)" >"$G/UDC"
echo '[navka-core] gadget ready'

View File

@ -4,11 +4,11 @@ version = "0.1.0"
edition = "2024" edition = "2024"
[dependencies] [dependencies]
tokio = { version = "1.45", features = ["full", "fs"] } tokio = { version = "1.45", features = ["full", "fs"] }
tokio-stream = "0.1" tokio-stream = "0.1"
tonic = { version = "0.11", features = ["transport"] } tonic = { version = "0.11", features = ["transport"] }
anyhow = "1.0" anyhow = "1.0"
navka-common = { path = "../common" } navka-common = { path = "../common" }
tracing = { version = "0.1", features = ["std"] } tracing = { version = "0.1", features = ["std"] }
tracing-subscriber = "0.3" tracing-subscriber = "0.3"
libc = "0.2" libc = "0.2"