Skip to content

Instantly share code, notes, and snippets.

@Cdaprod
Created August 15, 2026 22:49
Show Gist options
  • Select an option

  • Save Cdaprod/9a06eba2af448a52b19c7983917840cd to your computer and use it in GitHub Desktop.

Select an option

Save Cdaprod/9a06eba2af448a52b19c7983917840cd to your computer and use it in GitHub Desktop.
USB Gadget Diagnostics Command
echo
echo "========== IDENTITY =========="
hostname
tr -d '\0' </proc/device-tree/model 2>/dev/null
echo
uname -a
echo
echo "========== OS =========="
cat /etc/os-release
echo
echo "========== USB GADGET COMMAND =========="
command -v rpi-usb-gadget || echo "rpi-usb-gadget command not installed"
dpkg -l rpi-usb-gadget 2>/dev/null | grep '^ii' || true
echo
echo "========== KERNEL MODULES =========="
lsmod | grep -E '(^dwc2|g_ether|libcomposite|usb_f_|u_ether)' || \
echo "No gadget-related modules currently loaded"
echo
echo "========== UDC =========="
ls -la /sys/class/udc/
echo
echo "========== UDC STATE =========="
for u in /sys/class/udc/*; do
[ -e "$u" ] || continue
printf '%s: ' "$(basename "$u")"
cat "$u/state"
done
echo
echo "========== NETWORK INTERFACES =========="
ip -br link
echo
echo "========== IP ADDRESSES =========="
ip -br addr
echo
echo "========== NETWORKMANAGER =========="
nmcli device status 2>/dev/null || true
echo
echo "========== BOOT CONFIG =========="
for f in /boot/firmware/config.txt /boot/config.txt; do
if [ -f "$f" ]; then
echo "--- $f ---"
grep -nEi 'dwc2|otg|dr_mode' "$f" || echo "No dwc2/OTG lines"
fi
done
echo
echo "========== CMDLINE =========="
for f in /boot/firmware/cmdline.txt /boot/cmdline.txt; do
if [ -f "$f" ]; then
echo "--- $f ---"
cat "$f"
echo
fi
done
echo
echo "========== CONFIGFS GADGETS =========="
if [ -d /sys/kernel/config/usb_gadget ]; then
sudo find /sys/kernel/config/usb_gadget \
-maxdepth 4 \
-type d \
-print
else
echo "usb_gadget ConfigFS directory not present"
fi
echo
echo "========== PROJECT CHECK =========="
cd ~/pitft/pitft-fallback-console 2>/dev/null || true
printf 'PWD: '
pwd
echo
echo "--- git status ---"
git status --short --branch 2>/dev/null || true
echo
echo "--- recent commits ---"
git log --oneline -8 2>/dev/null || true
echo
echo "--- USB-related Make targets ---"
grep -nEi 'usb|gadget|ether' Makefile 2>/dev/null || true
echo
echo "========== RECENT USB KERNEL LOG =========="
sudo dmesg | grep -Ei 'dwc2|gadget|udc|usb' | tail -80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment