Files
uno-q-audio-synth/system/reset-usb-gadget.sh
T
david 8cd796e3dd Initial commit: Arduino Uno Q USB Audio Synth project
- USB gadget (UAC1 + MIDI) with boot persistence
- USB host mode with auto-detection
- Pure Data synth patch with ALSA + UDP netreceive MIDI input
- MIDI rawmidi-to-UDP bridge (midi-bridge.py)
- LED matrix visualization (led-matrix-viz.py via arduino-router RPC)
- MCU sketch for LED matrix control (Arduino_RouterBridge + ArduinoGraphics)
- Conftest/OPA Rego policy validation suite for .pd files
- gen_synth_pd.py: programmatic .pd file generator
- System services: midi-bridge, led-matrix-viz, pd-synth-auto, usb-role-detect
- Justfile with deploy, enable, diagnostic recipes
- Diagnostic script (diag.sh)
2026-06-22 22:46:36 -07:00

39 lines
1.0 KiB
Bash

#!/bin/bash
set -euo pipefail
# Reset USB controller and re-bind gadget
UDC="4e00000.usb"
GADGET="/sys/kernel/config/usb_gadget/g1"
# Find the driver binding
DRIVER=""
for d in /sys/bus/platform/drivers/*/; do
dname=$(basename "$d")
if [ -L "$d/$UDC" ] 2>/dev/null; then
DRIVER="$dname"
break
fi
done
if [ -z "$DRIVER" ]; then
# Try looking at the UDC device itself
UDC_PATH=$(readlink -f /sys/class/udc/$UDC/device 2>/dev/null || echo "")
if [ -n "$UDC_PATH" ]; then
DRIVER=$(basename "$(dirname "$UDC_PATH")" 2>/dev/null || echo "")
fi
fi
echo "Driver: ${DRIVER:-unknown}"
# Unbind
if [ -n "$DRIVER" ]; then
echo "$UDC" > "/sys/bus/platform/drivers/$DRIVER/unbind" 2>/dev/null && echo "Unbound" || echo "Unbind failed"
sleep 2
echo "$UDC" > "/sys/bus/platform/drivers/$DRIVER/bind" 2>/dev/null && echo "Rebound" || echo "Rebind failed"
sleep 1
fi
# Bind gadget
echo "$UDC" > "$GADGET/UDC" 2>&1 && echo "Gadget bound" || echo "Gadget bind failed"
cat /sys/class/udc/$UDC/state