-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
283 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/bin/bash | ||
|
||
#Parts of code used are from https://gist.github.com/Gadgetoid/c52ee2e04f1cd1c0854c3e77360011e2 | ||
#Props to Gadgetoid for getting rndis working on windows with multiple composited usb devices. | ||
|
||
if [ ! -d /sys/kernel/config/usb_gadget ]; then | ||
modprobe libcomposite | ||
fi | ||
|
||
if [ -d /sys/kernel/config/usb_gadget/g1 ]; then | ||
exit 0 | ||
fi | ||
|
||
ID_VENDOR="0x1d6b" | ||
ID_PRODUCT="0x0104" | ||
|
||
SERIAL="$(grep Serial /proc/cpuinfo | sed 's/Serial\s*: 0000\(\w*\)/\1/')" | ||
MAC="$(echo ${SERIAL} | sed 's/\(\w\w\)/:\1/g' | cut -b 2-)" | ||
MAC_HOST="12$(echo ${MAC} | cut -b 3-)" | ||
MAC_DEV="02$(echo ${MAC} | cut -b 3-)" | ||
|
||
cd /sys/kernel/config/usb_gadget/ | ||
|
||
mkdir g1 | ||
cd g1 | ||
|
||
echo "0x0200" > bcdUSB | ||
echo "0x02" > bDeviceClass | ||
echo "0x00" > bDeviceSubClass | ||
echo "0x0001" > bcdDevice | ||
echo $ID_VENDOR > idVendor | ||
echo $ID_PRODUCT > idProduct | ||
|
||
# Windows extensions to force config | ||
|
||
echo "1" > os_desc/use | ||
echo "0xcd" > os_desc/b_vendor_code | ||
echo "MSFT100" > os_desc/qw_sign | ||
|
||
mkdir strings/0x409 | ||
echo "$SERIAL" > strings/0x409/serialnumber | ||
echo "Pimoroni Ltd." > strings/0x409/manufacturer | ||
echo "PiNav Network" > strings/0x409/product | ||
|
||
# Config #1 for OSX / Linux | ||
|
||
mkdir configs/c.1 | ||
mkdir configs/c.1/strings/0x409 | ||
echo "CDC RNDIS" > configs/c.1/strings/0x409/configuration | ||
|
||
mkdir functions/rndis.usb0 # Flippin' Windows | ||
|
||
#network | ||
echo "RNDIS" > functions/rndis.usb0/os_desc/interface.rndis/compatible_id | ||
echo "5162001" > functions/rndis.usb0/os_desc/interface.rndis/sub_compatible_id | ||
|
||
echo $MAC_HOST > functions/rndis.usb0/host_addr | ||
echo $MAC_DEV > functions/rndis.usb0/dev_addr | ||
|
||
# Set up the rndis device only first | ||
|
||
ln -s functions/rndis.usb0 configs/c.1 #network | ||
|
||
# Tell Windows to use config #2 | ||
|
||
ln -s configs/c.1 os_desc | ||
|
||
# Show Windows the RNDIS device with | ||
# bDeviceClass 0x02 | ||
# bDeviceSubClass 0x02 | ||
|
||
ls /sys/class/udc > UDC | ||
|
||
# Give it time to install | ||
|
||
sleep 5 | ||
|
||
# Yank it back | ||
|
||
echo "" > UDC | ||
|
||
# Reset bDeviceClass to 0x00 | ||
# This is essential to make it work in Windows 10 | ||
# Basically forces it to use device information | ||
# in the descriptors versus assuming a particular class. | ||
|
||
echo "0x00" > bDeviceClass | ||
|
||
# Re-attach the gadget | ||
|
||
ls /sys/class/udc > UDC | ||
|
||
# BOOM! | ||
|
||
ifconfig usb0 up 10.0.99.1 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# libusbgx.la - a libtool library file | ||
# Generated by libtool (GNU libtool) 2.4.6 Debian-2.4.6-2 | ||
# | ||
# Please DO NOT delete this file! | ||
# It is necessary for linking the library. | ||
|
||
# The name that we can dlopen(3). | ||
dlname='libusbgx.so.2' | ||
|
||
# Names of this library. | ||
library_names='libusbgx.so.2.0.0 libusbgx.so.2 libusbgx.so' | ||
|
||
# The name of the static archive. | ||
old_library='libusbgx.a' | ||
|
||
# Linker flags that cannot go in dependency_libs. | ||
inherited_linker_flags='' | ||
|
||
# Libraries that this one depends upon. | ||
dependency_libs=' -lconfig' | ||
|
||
# Names of additional weak libraries provided by this library | ||
weak_library_names='' | ||
|
||
# Version information for libusbgx. | ||
current=2 | ||
age=0 | ||
revision=0 | ||
|
||
# Is this an already installed library? | ||
installed=no | ||
|
||
# Should we warn about portability when linking against -modules? | ||
shouldnotlink=no | ||
|
||
# Files to dlopen/dlpreopen | ||
dlopen='' | ||
dlpreopen='' | ||
|
||
# Directory that this library needs to be installed in: | ||
libdir='/usr/local/lib' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# libusbgx.la - a libtool library file | ||
# Generated by libtool (GNU libtool) 2.4.6 Debian-2.4.6-2 | ||
# | ||
# Please DO NOT delete this file! | ||
# It is necessary for linking the library. | ||
|
||
# The name that we can dlopen(3). | ||
dlname='libusbgx.so.2' | ||
|
||
# Names of this library. | ||
library_names='libusbgx.so.2.0.0 libusbgx.so.2 libusbgx.so' | ||
|
||
# The name of the static archive. | ||
old_library='libusbgx.a' | ||
|
||
# Linker flags that cannot go in dependency_libs. | ||
inherited_linker_flags='' | ||
|
||
# Libraries that this one depends upon. | ||
dependency_libs=' -lconfig' | ||
|
||
# Names of additional weak libraries provided by this library | ||
weak_library_names='' | ||
|
||
# Version information for libusbgx. | ||
current=2 | ||
age=0 | ||
revision=0 | ||
|
||
# Is this an already installed library? | ||
installed=yes | ||
|
||
# Should we warn about portability when linking against -modules? | ||
shouldnotlink=no | ||
|
||
# Files to dlopen/dlpreopen | ||
dlopen='' | ||
dlpreopen='' | ||
|
||
# Directory that this library needs to be installed in: | ||
libdir='/usr/local/lib' |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
KERNEL=="js[0-9]*", SUBSYSTEM=="input", ACTION=="add", PROGRAM="/bin/systemd-escape -p --template=pinav_bridge_daemon@.service $env{DEVNAME}", TAG+="systemd", ENV{SYSTEMD_WANTS}+="%c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[pinav] | ||
numControllers=2 | ||
|
||
[pinav.net] | ||
enabled=false | ||
|
||
[pinav.serial] | ||
enabled=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[Unit] | ||
Description=PiNav Bridge Daemon on %I | ||
BindTo=%i.device | ||
After=%i.device | ||
|
||
[Service] | ||
Type=forking | ||
User=root | ||
ExecStart=/usr/bin/pinav_bridge_daemon %I | ||
|
||
[Install] | ||
WantedBy=%i.device |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[Unit] | ||
Description=PiNav USB Gadget | ||
|
||
[Service] | ||
Type=simple | ||
User=root | ||
WorkingDirectory=/usr/bin | ||
ExecStart=/usr/bin/pinav_usb | ||
RemainAfterExit=true | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters