Merge branch 'master' of github.com:dpavlin/usb-otg
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 28 Jun 2019 20:19:50 +0000 (22:19 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 28 Jun 2019 20:19:50 +0000 (22:19 +0200)
rndis-ecm-adm.sh

index a95e7a4..55ac7ac 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/sh -xe
 #
 # HackPi
 #  by wismna
@@ -6,14 +6,16 @@
 #  14/01/2017
 #
 
+modprobe libcomposite
+
 cd /sys/kernel/config/usb_gadget/
 mkdir -p g1
 cd g1
 
-OS=MS # change this to anything else to skip M$ tweaks
 HOST="48:6f:73:74:50:43"
-SELF0="42:61:64:55:53:42"
-SELF1="42:61:64:55:53:43"
+RNDIS="42:61:64:55:53:42"
+RNDIS="" # disabled
+ECM="42:61:64:55:53:43"
 
 echo 0x04b3 > idVendor
 echo 0x4010 > idProduct
@@ -24,7 +26,7 @@ echo "badc0deddeadbeef" > strings/0x409/serialnumber
 echo "wismna" > strings/0x409/manufacturer
 echo "PiZero" > strings/0x409/product
 
-if [ "$OS" = "MS" ]; then
+if [ ! -z "$RNDIS" ]; then
        # Config 1: RNDIS
        mkdir -p configs/c.1/strings/0x409
        echo "0x80" > configs/c.1/bmAttributes
@@ -36,7 +38,7 @@ if [ "$OS" = "MS" ]; then
        echo "MSFT100" > os_desc/qw_sign
 
        mkdir -p functions/rndis.usb0
-       echo $SELF0 > functions/rndis.usb0/dev_addr
+       echo $RNDIS > functions/rndis.usb0/dev_addr
        echo $HOST > functions/rndis.usb0/host_addr
        echo "RNDIS" > functions/rndis.usb0/os_desc/interface.rndis/compatible_id
        echo "5162001" > functions/rndis.usb0/os_desc/interface.rndis/sub_compatible_id
@@ -50,13 +52,13 @@ echo 250 > configs/c.2/MaxPower
 mkdir -p functions/ecm.usb0
 # first byte of address must be even
 echo $HOST > functions/ecm.usb0/host_addr
-echo $SELF1 > functions/ecm.usb0/dev_addr
+echo $ECM > functions/ecm.usb0/dev_addr
 
 # Create the CDC ACM function
 mkdir -p functions/acm.gs0
 
 # Link everything and bind the USB device
-if [ "$OS" != "MacOs" ]; then
+if [ ! -z "$RNDIS" ]; then
        ln -s configs/c.1 os_desc
        ln -s functions/rndis.usb0 configs/c.1
 fi