From 33e3afbf1374ca484de528f5b965817c16ce647d Mon Sep 17 00:00:00 2001 From: Takumi Sueda Date: Mon, 27 Mar 2023 19:37:52 +0900 Subject: [PATCH] Enable RNDIS gadget automatically --- os-brainux/override.sh | 3 +++ .../lib/systemd/system/rndis_gadget.service | 9 +++++++ .../override/usr/bin/enable_rndis_gadget | 25 +++++++++++++++++++ os-brainux/setup_brainux.sh | 3 +++ 4 files changed, 40 insertions(+) create mode 100644 os-brainux/override/lib/systemd/system/rndis_gadget.service create mode 100755 os-brainux/override/usr/bin/enable_rndis_gadget diff --git a/os-brainux/override.sh b/os-brainux/override.sh index f4eba6e..06f29aa 100755 --- a/os-brainux/override.sh +++ b/os-brainux/override.sh @@ -21,3 +21,6 @@ install -g 1000 -o 1000 -m 0644 $SRC/home/user/lxterminal/lxterminal.conf $DST/h install -g root -o root -m 0644 -D $SRC/etc/jwm/system.jwmrc $DST/etc/jwm/system.jwmrc install -g root -o root -m 0644 $SRC/lib/systemd/system/boot.mount $DST/lib/systemd/system/boot.mount + +install -g root -o root -m 0644 $SRC/lib/systemd/system/rndis_gadget.service $DST/lib/systemd/system/rndis_gadget.service +install -g root -o root -m 0755 $SRC/usr/bin/enable_rndis_gadget $DST/usr/bin/enable_rndis_gadget diff --git a/os-brainux/override/lib/systemd/system/rndis_gadget.service b/os-brainux/override/lib/systemd/system/rndis_gadget.service new file mode 100644 index 0000000..145c5cb --- /dev/null +++ b/os-brainux/override/lib/systemd/system/rndis_gadget.service @@ -0,0 +1,9 @@ +[Unit] +Description=Enable RNDIS USB Gadget + +[Service] +Type=oneshot +ExecStart=/usr/bin/enable_rndis_gadget + +[Install] +WantedBy=multi-user.target diff --git a/os-brainux/override/usr/bin/enable_rndis_gadget b/os-brainux/override/usr/bin/enable_rndis_gadget new file mode 100755 index 0000000..a0d738c --- /dev/null +++ b/os-brainux/override/usr/bin/enable_rndis_gadget @@ -0,0 +1,25 @@ +#!/bin/sh + +g=/sys/kernel/config/usb_gadget/eth + +mkdir ${g} + +echo "0x3066" > ${g}/bcdDevice +echo "1" > ${g}/os_desc/use +echo "0xcd" > ${g}/os_desc/b_vendor_code +echo "MSFT100" > ${g}/os_desc/qw_sign + +mkdir ${g}/functions/rndis.rn0 +echo "RNDIS" > ${g}/functions/rndis.rn0/os_desc/interface.rndis/compatible_id +echo "5162001" > ${g}/functions/rndis.rn0/os_desc/interface.rndis/sub_compatible_id +echo "8a:15:8b:44:3a:02" > ${g}/functions/rndis.rn0/dev_addr +echo "8a:15:8b:44:3a:01" > ${g}/functions/rndis.rn0/host_addr + +mkdir ${g}/configs/c.1 +ln -s ${g}/functions/rndis.rn0 ${g}/configs/c.1/ + +echo "ci_hdrc.0" > ${g}/UDC + +sleep 1 +ifconfig usb0 up +dhclient diff --git a/os-brainux/setup_brainux.sh b/os-brainux/setup_brainux.sh index 15e607b..90d7590 100755 --- a/os-brainux/setup_brainux.sh +++ b/os-brainux/setup_brainux.sh @@ -139,6 +139,9 @@ EOF # Enable /boot mount systemctl enable boot.mount +# Enable RNDIS gadget +systemctl enable rndis_gadget + # Get wild cat < /etc/apt/sources.list deb http://deb.debian.org/debian bullseye main contrib non-free