Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 39c0f158fe |
@@ -13,7 +13,6 @@ Scripts and documentation for setting up a Raspberry Pi (Zero W 1 or 2) for use
|
|||||||
- [Starting on Raspberry Pi Zero](https://reykjavik.instructure.com/courses/6589/pages/starting-on-raspberry-pi-zero-w)
|
- [Starting on Raspberry Pi Zero](https://reykjavik.instructure.com/courses/6589/pages/starting-on-raspberry-pi-zero-w)
|
||||||
|
|
||||||
## References and Links
|
## References and Links
|
||||||
- [Sparkfun GPIO pinout](https://cdn.sparkfun.com/assets/learn_tutorials/6/7/6/PiZero_1.pdf)
|
|
||||||
- [Guide to creating ssh keys](https://pimylifeup.com/raspberry-pi-ssh-keys/) Of note, this guide is a little dated as it suggests using RSA keys and many people are moving toward EDCSA keys.
|
- [Guide to creating ssh keys](https://pimylifeup.com/raspberry-pi-ssh-keys/) Of note, this guide is a little dated as it suggests using RSA keys and many people are moving toward EDCSA keys.
|
||||||
- [Raspberry Pi Connect](https://connect.raspberrypi.com)
|
- [Raspberry Pi Connect](https://connect.raspberrypi.com)
|
||||||
- [Setting up Raspberry Pi Connect](https://www.raspberrypi.com/documentation/services/connect.html)
|
- [Setting up Raspberry Pi Connect](https://www.raspberrypi.com/documentation/services/connect.html)
|
||||||
|
|||||||
+6
-4
@@ -12,17 +12,19 @@ fi
|
|||||||
|
|
||||||
# Is the dwc2 overlay installed? Nothing will work if it isn't.
|
# Is the dwc2 overlay installed? Nothing will work if it isn't.
|
||||||
if lsmod | grep -q "dwc2"; then
|
if lsmod | grep -q "dwc2"; then
|
||||||
systemd-cat -t gadget.sh -p info echo "DWC2 module loaded, setting up OTG gadget serial and ethernet"
|
echo "DWC2 module loaded, setting up OTG gadget serial and ethernet" | logger -t $0 -p info
|
||||||
|
echo "DWC2 module loaded"
|
||||||
else
|
else
|
||||||
systemd-cat -t gadget.sh -p warning echo "DWC2 module missing. Aborting OTG setup."
|
echo "DWC2 module missing. Aborting OTG setup." | logger -t $0 -p info
|
||||||
|
echo "DWC2 module missing"
|
||||||
systemctl disable serial-getty@ttyGS0.service
|
systemctl disable serial-getty@ttyGS0.service
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo modprobe libcomposite
|
modprobe libcomposite
|
||||||
cd /sys/kernel/config/usb_gadget
|
cd /sys/kernel/config/usb_gadget
|
||||||
if [ -d "MyGadget" ]; then
|
if [ -d "MyGadget" ]; then
|
||||||
systemd-cat -t gadget.sh -p warning echo "MyGadget already exists. Aborting OTG setup."
|
echo "MyGadget already exists. Aborting OTG setup." | logger -t $0 -p info
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
# From https://raspberry.tips/en/raspberrypi-tutorials/raspberry-pi-gpio-python
|
|
||||||
import lgpio
|
|
||||||
import time
|
|
||||||
|
|
||||||
# Open GPIO chip (0 = /dev/gpiochip0, on Pi 5 gpiochip4 also possible)
|
|
||||||
h = lgpio.gpiochip_open(0)
|
|
||||||
|
|
||||||
try:
|
|
||||||
lgpio.gpio_claim_output(h, 18) # GPIO18 (pin 12) as output (MOTA1)
|
|
||||||
|
|
||||||
for _ in range(5):
|
|
||||||
lgpio.gpio_write(h, 18, 1) # HIGH
|
|
||||||
time.sleep(0.5)
|
|
||||||
lgpio.gpio_write(h, 18, 0) # LOW
|
|
||||||
time.sleep(0.5)
|
|
||||||
|
|
||||||
finally:
|
|
||||||
lgpio.gpiochip_close(h) # Always close!
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
# From https://raspberry.tips/en/raspberrypi-tutorials/raspberry-pi-gpio-python
|
|
||||||
import lgpio
|
|
||||||
import time
|
|
||||||
|
|
||||||
# Open GPIO chip (0 = /dev/gpiochip0, on Pi 5 gpiochip4 also possible)
|
|
||||||
h = lgpio.gpiochip_open(0)
|
|
||||||
|
|
||||||
try:
|
|
||||||
lgpio.gpio_claim_output(h, 16) # GPIO16 as output (MOTA2)
|
|
||||||
lgpio.gpio_write(h, 16, 0) # LOW
|
|
||||||
|
|
||||||
# Hardware PWM on GPIO18 (pin 12) must be PWM-capable
|
|
||||||
# Frequency: 1000 Hz, duty cycle: 50%
|
|
||||||
lgpio.tx_pwm(h, 18, 1000, 50)
|
|
||||||
time.sleep(2)
|
|
||||||
|
|
||||||
# Reduce duty cycle to 20%
|
|
||||||
lgpio.tx_pwm(h, 18, 1000, 20)
|
|
||||||
time.sleep(2)
|
|
||||||
|
|
||||||
lgpio.tx_pwm(h, 18, 0, 0) # Stop PWM
|
|
||||||
|
|
||||||
finally:
|
|
||||||
lgpio.gpiochip_close(h) # Always close!
|
|
||||||
Reference in New Issue
Block a user