mirror of
https://github.com/bleackstorm/SteamFrame-FPV-Control-Center.git
synced 2026-12-03 07:31:57 +01:00
54 lines
1.7 KiB
Bash
Executable File
54 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Configure un gadget USB Ethernet CDC-ECM pur (0525:a4a1, sans port série ACM)
|
|
# avec une MAC administrée globalement (00:1a:11:f0:00:02) afin que le noyau
|
|
# Samsung / Android nomme l'interface `eth0` (reconnue nativement par One UI)
|
|
# tout en restant 100 % compatible Linux / SteamOS (Steam Frame).
|
|
|
|
set -euo pipefail
|
|
|
|
GADGET_DIR="/sys/kernel/config/usb_gadget/steamframe_ecm"
|
|
UDC_NAME="$(ls /sys/class/udc | head -n 1 || true)"
|
|
|
|
setup_configfs_ecm() {
|
|
[ -n "${UDC_NAME}" ] || return 1
|
|
modprobe usb_f_ecm || return 1
|
|
mountpoint -q /sys/kernel/config || mount -t configfs none /sys/kernel/config
|
|
|
|
if [ -d "${GADGET_DIR}" ] && [ -s "${GADGET_DIR}/UDC" ]; then
|
|
return 0
|
|
fi
|
|
|
|
mkdir -p "${GADGET_DIR}"
|
|
cd "${GADGET_DIR}"
|
|
echo 0x0525 > idVendor
|
|
echo 0xa4a1 > idProduct
|
|
echo 0x0100 > bcdDevice
|
|
echo 0x0200 > bcdUSB
|
|
echo 0x00 > bDeviceClass
|
|
echo 0x00 > bDeviceSubClass
|
|
echo 0x00 > bDeviceProtocol
|
|
|
|
mkdir -p strings/0x409
|
|
echo "SF-RADXA-001" > strings/0x409/serialnumber
|
|
echo "SteamFrame FPV" > strings/0x409/manufacturer
|
|
echo "Radxa VRX USB Ethernet" > strings/0x409/product
|
|
|
|
mkdir -p configs/c.1/strings/0x409
|
|
echo "CDC-ECM Ethernet" > configs/c.1/strings/0x409/configuration
|
|
echo 250 > configs/c.1/MaxPower
|
|
|
|
mkdir -p functions/ecm.usb0
|
|
# Bit 1 du 1er octet = 0 (MAC globale) : indispensable pour que cdc_ether sur Android nomme l'interface eth0
|
|
echo "00:1a:11:f0:00:02" > functions/ecm.usb0/host_addr
|
|
echo "00:1a:11:f0:00:01" > functions/ecm.usb0/dev_addr
|
|
|
|
ln -sf functions/ecm.usb0 configs/c.1/ecm.usb0
|
|
echo "${UDC_NAME}" > UDC
|
|
return 0
|
|
}
|
|
|
|
if ! setup_configfs_ecm; then
|
|
echo "[usb0-gadget] Fallback vers g_cdc" >&2
|
|
modprobe g_cdc || true
|
|
fi
|