-
Notifications
You must be signed in to change notification settings - Fork 285
Add USB Ethernet Gadget toggle #933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
paulober
wants to merge
12
commits into
raspberrypi:qml
Choose a base branch
from
paulober:add-usb-ether-gadget-toggle
base: qml
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3ac37d7
Add USB Ethernet Gadget toggle
paulober a2223c1
Implemented requested changes and switched to auto g_ether
paulober 38ee103
Added CLI support for enable usb ether gadget mode config + CLI versi…
paulober bd69720
Fix typos and duplicate code
paulober 2c0da0d
Support/requirement for new supportedFeatures property for devices an…
paulober ede04fb
Switch json supportedFeatures to capabilities + added usb ether gadge…
paulober 879e874
Fix capabilities for subitems
paulober 04e6378
Update ether gadget toggle script
paulober 879d4e5
Update signature of andCapabilities method
paulober d99a508
Fix usb ether toggle script
paulober cb733d3
Merge branch 'qml' into add-usb-ether-gadget-toggle
paulober 092e59e
Merge branch 'qml' into add-usb-ether-gadget-toggle
paulober File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
File renamed without changes.
This file contains hidden or 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 hidden or 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 hidden or 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 @@ | ||
<RCC> | ||
<qresource prefix="/"> | ||
<file>extraFiles/10-usb.network</file> | ||
<file>extraFiles/g_ether.conf</file> | ||
<file>extraFiles/usb-ether-gadget.conf</file> | ||
<file>extraFiles/rpi-usb-ether-gadget.sh</file> | ||
paulober marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</qresource> | ||
</RCC> |
This file contains hidden or 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,33 @@ | ||
[Match] | ||
Name=usb* | ||
|
||
[Link] | ||
RequiredForOnline=no | ||
|
||
[Network] | ||
# Configure Subnet for USB Ethernet Gadget | ||
# - IP Range: 10.12.194.1 to 10.12.194.14 | ||
# - Total IPs: 16 | ||
# - Usable IPs: 14 | ||
# - Network Address: 10.12.194.0 | ||
# - Broadcast Address: 10.12.194.15 | ||
# - Subnet Mask: 255.255.255.240 (/28) | ||
# | 10 - private | ||
# | 12 - 2012 founding of Raspberry Pi Ltd. | ||
# | 194 - address of Raspberry Pi Ltd. in the Science Park, Cambridge | ||
# | 1 - first device | ||
# TODO: maybe only static hostname to not conflict when multiple devices are connected | ||
# to the same computer | ||
Address=10.12.194.1/28 | ||
DHCPServer=yes | ||
|
||
[DHCPServer] | ||
# Configure DHCP settings | ||
PoolSize=16 # Number of IP addresses available for lease | ||
DefaultLeaseTimeSec=60 # Default lease time for DHCP clients | ||
MaxLeaseTimeSec=60 # Maximum lease time for DHCP clients | ||
|
||
# Network isolation settings (no internet) | ||
EmitDNS=no # Do not provide DNS information | ||
EmitNTP=no # Do not provide NTP information | ||
EmitRouter=no # Do not provide router information |
This file contains hidden or 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 @@ | ||
options g_ether idVendor=0x04b3 idProduct=0x4010 iManufacturer="Raspberry Pi" bcdDevice=0x0100 iProduct="USB Ethernet Gadget" iSerialNumber=<serial> | ||
paulober marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,48 @@ | ||
#!/bin/bash | ||
|
||
# check if the script is run as root | ||
if [ "$EUID" -ne 0 ]; then | ||
echo -e "\e[31mPlease run this script as root\e[0m" | ||
exit | ||
fi | ||
|
||
# check if the script is run on a Raspberry Pi | ||
if ! grep -q "Raspberry Pi" /proc/device-tree/model; then | ||
echo -e "\e[31mThis script is for Raspberry Pi devices only\e[0m" | ||
exit | ||
fi | ||
|
||
TURN_ON=true | ||
if [ "$1" == "on" ]; then | ||
TURN_ON=true | ||
elif [ "$1" == "off" ]; then | ||
TURN_ON=false | ||
elif [ "$1" == "toggle" ]; then | ||
if [ -f /etc/modules-load.d/usb-ether-gadget.conf ]; then | ||
TURN_ON=false | ||
fi | ||
elif [ "$1" == "status" ]; then | ||
if [ -f /etc/modules-load.d/usb-ether-gadget.conf ]; then | ||
echo -e "\e[33mUSB Ethernet Gadget is on\e[0m" | ||
else | ||
echo -e "\e[33mUSB Ethernet Gadget is off\e[0m" | ||
fi | ||
exit | ||
else | ||
echo "Usage: rpi-usb-ether-gadget [on|off|toggle|status|help]" | ||
exit | ||
fi | ||
|
||
#rm /etc/modprobe.d/g_ether.conf | ||
|
||
if [ "$TURN_ON" = false ]; then | ||
echo -e "Turning \e[31moff\e[0m USB Ethernet Gadget mode" | ||
rm -f /etc/modules-load.d/usb-ether-gadget.conf | ||
sed -i '/dtoverlay=dwc2,dr_mode=peripheral/d' /boot/firmware/config.txt | ||
else | ||
echo -e "Turning \e[32mon\e[0m USB Ethernet Gadget mode" | ||
echo -e "dwc2\ng_ether\n" > /etc/modules-load.d/usb-ether-gadget.conf | ||
echo -e "\ndtoverlay=dwc2,dr_mode=peripheral\n" >> /boot/firmware/config.txt | ||
fi | ||
|
||
echo "Reboot to apply changes" |
This file contains hidden or 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,2 @@ | ||
dwc2 | ||
g_ether |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.