diff --git a/scripts/install-server.sh b/scripts/install-server.sh index f55e172..f4c94bd 100755 --- a/scripts/install-server.sh +++ b/scripts/install-server.sh @@ -64,6 +64,10 @@ WantedBy=multi-user.target UNIT sudo systemctl daemon-reload -sudo systemctl enable --now navka-core.service navka-server.service -sudo systemctl restart navka-core.service navka-server.service +sudo systemctl enable --now navka-core +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..." diff --git a/scripts/navka-core.sh b/scripts/navka-core.sh index 514994c..a775734 100644 --- a/scripts/navka-core.sh +++ b/scripts/navka-core.sh @@ -1,23 +1,30 @@ #!/usr/bin/env bash # Proven Pi-5 configfs gadget: HID keyboard+mouse + stereo UAC2 # Still need Web Cam Support + +# navka-core – one-shot gadget bring-up for Pi-5 / Arch-ARM 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; } -# 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 G=/sys/kernel/config/usb_gadget/navka +# 4) Tear down any previous half-built gadget if [[ -d $G ]]; then - echo "" >"$G/UDC" 2>/dev/null || true - find "$G/configs" -type l -delete || true - rmdir "$G/functions/"* 2>/dev/null || true - rmdir "$G" 2>/dev/null || true + echo "" > "$G/UDC" || true + find "$G/configs" -type l -delete || true + rm -rf "$G/functions/"*; rmdir "$G" || true fi +# 5) Create gadget (boot-keyboard + UAC2 mic/spkr, 500 mA max) mkdir -p "$G" echo 0x1d6b >"$G/idVendor" # Linux Foundation 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' \ >"$G/functions/hid.usb0/report_desc" -# UAC2 stereo 48 kHz -mkdir -p "$G/functions/uac2.usb0" -echo 48000 >"$G/functions/uac2.usb0/c_srate" -echo 2 >"$G/functions/uac2.usb0/c_ssize" -echo 2 >"$G/functions/uac2.usb0/p_chmask" +# -- Simple Audio +mkdir -p $G/functions/uac2.usb0 +echo 48000 > $G/functions/uac2.usb0/c_srate +echo 2 > $G/functions/uac2.usb0/c_ssize +echo 2 > $G/functions/uac2.usb0/p_chmask -mkdir -p "$G/configs/c.1/strings/0x409" -echo "Config 1" >"$G/configs/c.1/strings/0x409/configuration" -echo 500 >"$G/configs/c.1/MaxPower" +# -- Config and Binds +mkdir -p $G/configs/c.1/strings/0x409 +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" -echo "Keyboard" >"$G/configs/c.1/strings/0x409/configuration" - -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' +# 6) Finally bind to first available UDC +echo $(ls /sys/class/udc | head -n1) > $G/UDC +echo "[navka-core] gadget ready on USB-C port" diff --git a/server/Cargo.toml b/server/Cargo.toml index 619f1d9..f6a9646 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -4,11 +4,11 @@ version = "0.1.0" edition = "2024" [dependencies] -tokio = { version = "1.45", features = ["full", "fs"] } -tokio-stream = "0.1" -tonic = { version = "0.11", features = ["transport"] } -anyhow = "1.0" -navka-common = { path = "../common" } -tracing = { version = "0.1", features = ["std"] } -tracing-subscriber = "0.3" -libc = "0.2" +tokio = { version = "1.45", features = ["full", "fs"] } +tokio-stream = "0.1" +tonic = { version = "0.11", features = ["transport"] } +anyhow = "1.0" +navka-common = { path = "../common" } +tracing = { version = "0.1", features = ["std"] } +tracing-subscriber = "0.3" +libc = "0.2"