-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
blocks 2.0 contain OTG modes, a fix to the run command block, and the new block loading system
- Loading branch information
1 parent
90d9670
commit 034d2c0
Showing
27 changed files
with
326 additions
and
4 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
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,29 @@ | ||
{ | ||
"categories": [ | ||
{ | ||
"name": "software", | ||
"display": "Programs", | ||
"colour": "120" | ||
}, | ||
{ | ||
"name": "network", | ||
"display": "Network", | ||
"colour": "260" | ||
}, | ||
{ | ||
"name": "setting", | ||
"display": "Settings", | ||
"colour": "210" | ||
}, | ||
{ | ||
"name": "otg", | ||
"display": "Pi Zero OTG", | ||
"colour": "80" | ||
}, | ||
{ | ||
"name": "other", | ||
"display": "Other", | ||
"colour": "290" | ||
} | ||
] | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
|
||
# Add the line to /boot/config.txt if it's not already there | ||
if ! grep -qxF "dtoverlay=dwc2" "/boot/config.txt" | ||
then | ||
echo "dtoverlay=dwc2" | tee -a /boot/config.txt | ||
fi | ||
|
||
# Add the line to /etc/modules if it's not already there | ||
if ! grep -qxF "dwc2" "/etc/modules" | ||
then | ||
echo "dwc2" | tee -a /etc/modules | ||
fi | ||
|
||
# Remove any modules currently in /etc/modules | ||
otg_modules=( "g_serial" "g_ether" "g_mass_storage" "g_midi" "g_audio" "g_hid" "g_acm_ms" "g_cdc" "g_multi" "g_webcam" "g_printer" "g_zero" ) | ||
for module in "${otg_modules[@]}" | ||
do | ||
if grep -qxF "$module" "/etc/modules" | ||
then | ||
grep -v "$module" "/etc/modules" > "/etc/modules2"; mv "/etc/modules2" "/etc/modules" | ||
fi | ||
done | ||
|
||
# Disable the g_mass_storage startup script if it exists | ||
if [ -f /etc/systemd/system/otgmassstorage.service ] | ||
then | ||
systemctl disable /etc/systemd/system/otgmassstorage.service | ||
fi | ||
|
||
# Add g_ether to /etc/modules | ||
echo "g_ether" | tee -a /etc/modules | ||
|
||
# Remove the static IP stuff from /etc/dhcpcd.conf if it exists | ||
startLine=$(grep -n "interface usb0 " /etc/dhcpcd.conf | cut -d : -f 1) | ||
if [ ! -z "$startLine" ] | ||
then | ||
matchLine=$((startLine+1)) | ||
grep -n "static " /etc/dhcpcd.conf | cut -d : -f 1 | while read line | ||
do | ||
if [ $line -eq $matchLine ] | ||
then | ||
endLine=$line | ||
sed -i "${startLine}d;${endLine}d" /etc/dhcpcd.conf | ||
fi | ||
done | ||
fi | ||
|
||
# Add the static IP to /etc/dhcpcd.conf | ||
echo -e "interface usb0 \nstatic ip_address=$1" | tee -a /etc/dhcpcd.conf |
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,18 @@ | ||
{ | ||
"name": "otgether", | ||
"text": "Set Pi Zero OTG Mode to Ethernet\\nWith Static IP: %1", | ||
"script": "otgEther.sh", | ||
"args": [ | ||
{ | ||
"type": "text", | ||
"default": "169.254.64.64", | ||
"maxLength":16 | ||
} | ||
], | ||
"network": false, | ||
"continue": true, | ||
"type": "network", | ||
"category":"otg", | ||
"shortDescription":"Set the Pi Zero to use Ethernet over OTG, with a static IP address.", | ||
"longDescription":"The Raspberry Pi Zero has the ability to support OTG gadget mode over it's DATA usb port. This block enables the Ethernet gadget, allowing your Raspberry Pi to be networked to a computer over USB. You need to specify an IP address for your Raspberr Pi, so that you'll be able to connect to it." | ||
} |
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,74 @@ | ||
#!/bin/bash | ||
|
||
#megabytes=$1 | ||
#kilobytes=$((megabytes * 1024)) | ||
#bytes=$((kilobytes * 1024)) | ||
|
||
# Add the line to /boot/config.txt if it's not already there | ||
if ! grep -qxF "dtoverlay=dwc2" "/boot/config.txt" | ||
then | ||
echo "dtoverlay=dwc2" | tee -a /boot/config.txt | ||
fi | ||
|
||
# Add the line to /etc/modules if it's not already there | ||
if ! grep -qxF "dwc2" "/etc/modules" | ||
then | ||
echo "dwc2" | tee -a /etc/modules | ||
fi | ||
|
||
# Remove any modules currently in /etc/modules | ||
otg_modules=( "g_serial" "g_ether" "g_mass_storage" "g_midi" "g_audio" "g_hid" "g_acm_ms" "g_cdc" "g_multi" "g_webcam" "g_printer" "g_zero" ) | ||
for module in "${otg_modules[@]}" | ||
do | ||
if grep -qxF "$module" "/etc/modules" | ||
then | ||
grep -v "$module" "/etc/modules" > "/etc/modules2"; mv "/etc/modules2" "/etc/modules" | ||
fi | ||
done | ||
|
||
# Add g_acm_ms to /etc/modules | ||
echo "g_mass_storage" | tee -a /etc/modules | ||
|
||
if [ ! -d /opt/otgmassstorage ] | ||
then | ||
mkdir /opt/otgmassstorage | ||
fi | ||
|
||
if [ ! -f /opt/otgmassstorage/filesystem.bin ] | ||
then | ||
dd if=/dev/zero of=/opt/otgmassstorage/filesystem.bin bs=512 count=2880 | ||
mkdosfs /opt/otgmassstorage/filesystem.bin | ||
fi | ||
|
||
if [ ! -f /etc/systemd/system/otgmassstorage.service ] | ||
then | ||
/bin/cat <<EOF >/etc/systemd/system/otgmassstorage.service | ||
[Unit] | ||
Description=Starts kernel modules for USB OTG | ||
After=systemd-remount-fs.service | ||
DefaultDependencies=false | ||
[Service] | ||
Type=simple | ||
ExecStart=/opt/otgmassstorage/start.sh | ||
WorkingDirectory=/opt/otgmassstorage/ | ||
[Install] | ||
WantedBy=local-fs.target | ||
EOF | ||
fi | ||
|
||
if [ ! -f /opt/otgmassstorage/start.sh ] | ||
then | ||
/bin/cat <<EOF >/opt/otgmassstorage/start.sh | ||
#!/bin/sh -e | ||
modprobe g_mass_storage file=/opt/otgmassstorage/filesystem.bin stall=0 | ||
exit 0 | ||
EOF | ||
fi | ||
|
||
chmod +x /etc/systemd/system/otgmassstorage.service | ||
chmod +x /opt/otgmassstorage/start.sh | ||
|
||
systemctl enable /etc/systemd/system/otgmassstorage.service |
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 @@ | ||
{ | ||
"name": "otgmassstorage", | ||
"text": "Set Pi Zero OTG Mode to Mass Storage", | ||
"script": "otgMassStorage.sh", | ||
"args": [], | ||
"network": false, | ||
"continue": true, | ||
"type": "setting", | ||
"category":"otg", | ||
"shortDescription":"Set the Pi Zero to use Mass Storage over OTG.", | ||
"longDescription":"The Raspberry Pi Zero has the ability to support OTG gadget mode over it's DATA usb port. This block enables the Mass Storage gadget, allowing your Raspberry Pi to appear as a USB flash drive to a connected computer. The files dropped onto this drive will be saved in the BIN file '/opt/otgmassstorage/filesystem.bin' allowing you to mount it, and retrieve the files you stored on it." | ||
} |
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,32 @@ | ||
#!/bin/bash | ||
|
||
# Add the line to /boot/config.txt if it's not already there | ||
if ! grep -qxF "dtoverlay=dwc2" "/boot/config.txt" | ||
then | ||
echo "dtoverlay=dwc2" | tee -a /boot/config.txt | ||
fi | ||
|
||
# Add the line to /etc/modules if it's not already there | ||
if ! grep -qxF "dwc2" "/etc/modules" | ||
then | ||
echo "dwc2" | tee -a /etc/modules | ||
fi | ||
|
||
# Remove any modules currently in /etc/modules | ||
otg_modules=( "g_serial" "g_ether" "g_mass_storage" "g_midi" "g_audio" "g_hid" "g_acm_ms" "g_cdc" "g_multi" "g_webcam" "g_printer" "g_zero" ) | ||
for module in "${otg_modules[@]}" | ||
do | ||
if grep -qxF "$module" "/etc/modules" | ||
then | ||
grep -v "$module" "/etc/modules" > "/etc/modules2"; mv "/etc/modules2" "/etc/modules" | ||
fi | ||
done | ||
|
||
# Disable the g_mass_storage startup script if it exists | ||
if [ -f /etc/systemd/system/otgmassstorage.service ] | ||
then | ||
systemctl disable /etc/systemd/system/otgmassstorage.service | ||
fi | ||
|
||
# Add g_midi to /etc/modules | ||
echo "g_midi" | tee -a /etc/modules |
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 @@ | ||
{ | ||
"name": "otgmidi", | ||
"text": "Set Pi Zero OTG Mode to MIDI", | ||
"script": "otgMidi.sh", | ||
"args": [], | ||
"network": false, | ||
"continue": true, | ||
"type": "setting", | ||
"category":"otg", | ||
"shortDescription":"Set the Pi Zero to use MIDI over OTG.", | ||
"longDescription":"The Raspberry Pi Zero has the ability to support OTG gadget mode over it's DATA usb port. This block enables the MIDI gadget, allowing your Raspberry Pi to appear as a MIDI input and output to a connected computer. Use any standard MIDI program on the connected computer or Raspberry Pi Zero to play music between the Pi and computer." | ||
} |
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,17 @@ | ||
#!/bin/bash | ||
|
||
# Remove any modules currently in /etc/modules | ||
otg_modules=( "g_serial" "g_ether" "g_mass_storage" "g_midi" "g_audio" "g_hid" "g_acm_ms" "g_cdc" "g_multi" "g_webcam" "g_printer" "g_zero" ) | ||
for module in "${otg_modules[@]}" | ||
do | ||
if grep -qxF "$module" "/etc/modules" | ||
then | ||
grep -v "$module" "/etc/modules" > "/etc/modules2"; mv "/etc/modules2" "/etc/modules" | ||
fi | ||
done | ||
|
||
# Disable the g_mass_storage startup script if it exists | ||
if [ -f /etc/systemd/system/otgmassstorage.service ] | ||
then | ||
systemctl disable /etc/systemd/system/otgmassstorage.service | ||
fi |
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 @@ | ||
{ | ||
"name": "otgremove", | ||
"text": "Disable Pi Zero OTG", | ||
"script": "otgRemove.sh", | ||
"args": [], | ||
"network": false, | ||
"continue": true, | ||
"type": "setting", | ||
"category":"otg", | ||
"shortDescription":"Disable the OTG mode on the Raspberry Pi Zero.", | ||
"longDescription":"The Raspberry Pi Zero has the ability to support OTG gadget mode over it's DATA usb port. If you've enabled this feature using one of the OTG blocks, you can use this block to return the Pi Zero back to it's default behaviour of not having any gadget enabled." | ||
} |
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,35 @@ | ||
#!/bin/bash | ||
|
||
# Add the line to /boot/config.txt if it's not already there | ||
if ! grep -qxF "dtoverlay=dwc2" "/boot/config.txt" | ||
then | ||
echo "dtoverlay=dwc2" | tee -a /boot/config.txt | ||
fi | ||
|
||
# Add the line to /etc/modules if it's not already there | ||
if ! grep -qxF "dwc2" "/etc/modules" | ||
then | ||
echo "dwc2" | tee -a /etc/modules | ||
fi | ||
|
||
# Remove any modules currently in /etc/modules | ||
otg_modules=( "g_serial" "g_ether" "g_mass_storage" "g_midi" "g_audio" "g_hid" "g_acm_ms" "g_cdc" "g_multi" "g_webcam" "g_printer" "g_zero" ) | ||
for module in "${otg_modules[@]}" | ||
do | ||
if grep -qxF "$module" "/etc/modules" | ||
then | ||
grep -v "$module" "/etc/modules" > "/etc/modules2"; mv "/etc/modules2" "/etc/modules" | ||
fi | ||
done | ||
|
||
# Disable the g_mass_storage startup script if it exists | ||
if [ -f /etc/systemd/system/otgmassstorage.service ] | ||
then | ||
systemctl disable /etc/systemd/system/otgmassstorage.service | ||
fi | ||
|
||
# Add g_serial to /etc/modules | ||
echo "g_serial" | tee -a /etc/modules | ||
|
||
# Forward a console over the serial | ||
systemctl enable getty@ttyGS0.service |
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 @@ | ||
{ | ||
"name": "otgserial", | ||
"text": "Set Pi Zero OTG Mode to Serial", | ||
"script": "otgSerial.sh", | ||
"args": [], | ||
"network": false, | ||
"continue": true, | ||
"type": "setting", | ||
"category":"otg", | ||
"shortDescription":"Set the Pi Zero to use Serial over OTG.", | ||
"longDescription":"The Raspberry Pi Zero has the ability to support OTG gadget mode over it's DATA usb port. This block enables the Serial gadget, allowing your Raspberry Pi to appear as a USB serial device to a connected computer. Using Putty on Windows, or Terminal on Mac and Linux, you'll be able to connect and log in to the command line of your Pi, over USB." | ||
} |
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
Oops, something went wrong.