mirror of
https://github.com/bleackstorm/SteamFrame-FPV-Control-Center.git
synced 2026-12-03 07:31:57 +01:00
89 lines
3.2 KiB
Bash
Executable File
89 lines
3.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOTFS="${1:-/run/media/${USER:-bleack}/rootfs}"
|
|
|
|
if [ ! -d "${ROOTFS}/etc" ]; then
|
|
echo "Erreur : La partition rootfs n'est pas montée dans ${ROOTFS}"
|
|
echo "Usage : $0 [/chemin/vers/rootfs]"
|
|
exit 1
|
|
fi
|
|
|
|
echo "=== Configuration du mode USB Gadget (RNDIS / CDC) sur la Radxa Zero 3W (${ROOTFS}) ==="
|
|
|
|
# 1. Activer l'overlay device-tree rk3568-dwc3-peripheral
|
|
echo "[1/5] Activation de l'overlay DWC3 Peripheral mode..."
|
|
if [ -f "${ROOTFS}/boot/dtbo/rk3568-dwc3-peripheral.dtbo.disabled" ]; then
|
|
cp "${ROOTFS}/boot/dtbo/rk3568-dwc3-peripheral.dtbo.disabled" "${ROOTFS}/boot/dtbo/rk3568-dwc3-peripheral.dtbo"
|
|
fi
|
|
|
|
EXTLINUX="${ROOTFS}/boot/extlinux/extlinux.conf"
|
|
if [ -f "${EXTLINUX}" ] && ! grep -q "rk3568-dwc3-peripheral.dtbo" "${EXTLINUX}"; then
|
|
sed -i '/fdtdir/a \ fdtoverlays /boot/dtbo/rk3568-dwc3-peripheral.dtbo' "${EXTLINUX}"
|
|
fi
|
|
|
|
# 1b. Forcer l'activation de la sortie HDMI en mode headless (1280x720@60e cohérent avec Ruby)
|
|
# et persister dans /etc/default/u-boot pour survivre à u-boot-update
|
|
echo "[1b/5] Forçage de la sortie HDMI virtuelle (headless 1280x720@60e)..."
|
|
HDMI_PARAMS="drm.edid_firmware=HDMI-A-1:edid/edid.bin video=HDMI-A-1:1280x720@60e"
|
|
if [ -f "${EXTLINUX}" ]; then
|
|
if ! grep -q "video=HDMI-A-1" "${EXTLINUX}"; then
|
|
sed -i "/append/ s|\$| ${HDMI_PARAMS}|" "${EXTLINUX}"
|
|
else
|
|
sed -i "s|video=HDMI-A-1:[^ ]*|video=HDMI-A-1:1280x720@60e|g" "${EXTLINUX}"
|
|
fi
|
|
fi
|
|
|
|
UBOOT_DEFAULT="${ROOTFS}/etc/default/u-boot"
|
|
if [ -f "${UBOOT_DEFAULT}" ]; then
|
|
if ! grep -q "video=HDMI-A-1" "${UBOOT_DEFAULT}"; then
|
|
sed -i "s|^U_BOOT_PARAMETERS=\"\\(.*\\)\"|U_BOOT_PARAMETERS=\"\\1 ${HDMI_PARAMS}\"|" "${UBOOT_DEFAULT}"
|
|
else
|
|
sed -i "s|video=HDMI-A-1:[^ \"]*|video=HDMI-A-1:1280x720@60e|g" "${UBOOT_DEFAULT}"
|
|
fi
|
|
fi
|
|
|
|
# 2. Charger le module g_cdc au boot
|
|
echo "[2/5] Ajout du module g_cdc dans /etc/modules..."
|
|
if ! grep -q "g_cdc" "${ROOTFS}/etc/modules"; then
|
|
echo "g_cdc" >> "${ROOTFS}/etc/modules"
|
|
fi
|
|
|
|
# 3. Configurer l'IP statique 192.168.1.1 sur usb0
|
|
echo "[3/5] Configuration réseau de usb0 (192.168.1.1/24)..."
|
|
cat << 'EOF' > "${ROOTFS}/etc/network/interfaces.d/usb0"
|
|
auto usb0
|
|
allow-hotplug usb0
|
|
iface usb0 inet static
|
|
address 192.168.1.1
|
|
netmask 255.255.255.0
|
|
EOF
|
|
|
|
cat << 'EOF' > "${ROOTFS}/etc/systemd/system/usb0-setup.service"
|
|
[Unit]
|
|
Description=SteamFrame FPV USB0 IP Setup
|
|
After=network.target
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
ExecStart=/bin/sh -c 'sleep 2; ip link set usb0 up && ip addr add 192.168.1.1/24 dev usb0 || true'
|
|
RemainAfterExit=yes
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
|
|
mkdir -p "${ROOTFS}/etc/systemd/system/multi-user.target.wants"
|
|
ln -sf /etc/systemd/system/usb0-setup.service "${ROOTFS}/etc/systemd/system/multi-user.target.wants/usb0-setup.service"
|
|
|
|
# 4. Ajuster le port vidéo dans controller_settings.cfg vers 5600
|
|
echo "[4/5] Configuration du port vidéo Ruby vers 5600..."
|
|
if [ -f "${ROOTFS}/home/radxa/ruby/config/controller_settings.cfg" ]; then
|
|
sed -i 's/video_usb: 1 [0-9]\+ 1024/video_usb: 1 5600 1024/g' "${ROOTFS}/home/radxa/ruby/config/controller_settings.cfg"
|
|
fi
|
|
|
|
echo "[5/5] Synchronisation des fichiers..."
|
|
|
|
sync
|
|
echo "[+] Configuration terminée avec succès !"
|