diff --git a/README.md b/README.md index 1b83df8..14d5808 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,13 @@ Scripts and documentation for setting up a Raspberry Pi (Zero W 1 or 2) for use 1. [Raspberry Pi Imager procedure to setup ssh and Raspberry Pi Connect](imager.md) 1. Find out your Pi's ethernet addresss in case you need to find it on `iot-research` again. Type `ip addr show dev wlan0` and for something like `link/ether 01:23:45:67:89:ab`. Write this information (the 12 characters and colons) in your notebook. In T-411-MECH we want you to put this information in a spreadsheet links from the main page: this allows us connect Pi's to people in case of any issues. 1. [Solder the GPIO header pins](solder-gpio.md) -1. [Gadget Mode to setup a serial connection over USB](gadget.md) +1. Login to the pi using ssh or serial. (Pi Connect breaks wihle upgrading the Pi Connect program). Now update the packages on your pi: + ``` + sudo apt-get update + sudo apt-get -y upgrade + ``` + +1. [Gadget Mode to setup a network connection over USB](https://github.com/raspberrypi/rpi-usb-gadget) 1. [Setup the OLED screen to print the IP](oled-display/README.md) Based upon [Marcel's script on github to show the IP address on the OLED screen](https://github.com/mkyas/cpsy-display-ip) 1. Install Blinka by following the guide [CircuitPython Libraries on Linux and Raspberry Pi](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/installing-circuitpython-on-raspberry-pi)] diff --git a/Scripts/gadget.sh b/Scripts/gadget.sh index 490c1ef..de1e432 100755 --- a/Scripts/gadget.sh +++ b/Scripts/gadget.sh @@ -9,10 +9,19 @@ if [ $(id -u) -ne 0 ]; then exit 1 fi +if [ -f /boot/firmware/GADGET_MODE ]; then + systemd-cat -t gadget.sh -p info echo "/boot/firmware/GADGET_MODE exists: GADGET mode enabled" +else + systemd-cat -t gadget.sh -p warning echo "/boot/firmware/GADGET_MODE missing: GADGET mode disabled" + systemctl disable serial-getty@ttyGS0.service + exit 1 +fi # Is the dwc2 overlay installed? Nothing will work if it isn't. -if lsmod | grep -q "dwc2"; then - systemd-cat -t gadget.sh -p info echo "DWC2 module loaded, setting up OTG gadget serial and ethernet" +if [ -d /sys/class/udc ] && [ -n "$(ls -A /sys/class/udc)" ]; then + systemd-cat -t gadget.sh -p info echo "DWC2 precompiled, setting up OTG gadget serial and ethernet" +elif lsmod | grep -q "dwc2"; then + systemd-cat -t gadget.sh -p info echo "Pre 6.18.39 kernel. DWC2 module loaded, setting up OTG gadget serial and ethernet" else systemd-cat -t gadget.sh -p warning echo "DWC2 module missing. Aborting OTG setup." systemctl disable serial-getty@ttyGS0.service diff --git a/gadget.md b/gadget.md index 3510cff..e6f19c0 100644 --- a/gadget.md +++ b/gadget.md @@ -5,7 +5,9 @@ Based upon Adafruit guide: https://learn.adafruit.com/turning-your-raspberry-pi- The author discovered the guide was out of date, consulted the [2025 Raspberry Pi whitepaper on OTG](https://pip-assets.raspberrypi.com/categories/685-app-notes-guides-whitepapers/documents/RP-009276-WP/Using-OTG-mode-on-Raspberry-Pi-SBCs), found additional errors, and was finally able to correct them thanks to this blog https://www.isticktoit.net/?p=1383 ## Important : +- **We are still working out the kinks with the gadget mode switching on the Pi Zero W 2** - **Using the Gadget Mode will make the usb port unable to connect to a mouse or keyboard!!!** You will need to disable it make them work again. +- The blue USB cables included in the kit in 2026 are flakey. We recommend replacing them ASAP. - You will want to disable the serial console on RX/TX in `raspi-config` if you are trying to use that serial port for communicating with other devices. @@ -17,18 +19,18 @@ Make sure you have your USB cable plugged into the left port **USB** and not the ``` sudo su ``` -1. Enable the DWC version 2 USB peripheral device tree overlay by appending it to the end after the `[all]` category (which is at the end) -``` -echo "dtoverlay=dwc2" >> /boot/firmware/config.txt -``` -1. We add the required module `dwc2` for loading at startup -``` -echo "dwc2" >> /etc/modules -``` 1. Check that we can load the libcomposite module ``` modprobe libcomposite ``` +1. Reboot +``` +restart now +``` +1. Become root again +``` +sudo su +``` 1. Put a copy of this repository in root's home directory using git ``` cd /root @@ -85,7 +87,44 @@ This is similar to the procedure for accessing an Arduino. ``` 1. Press enter and you will be prompted to log in to the Pi with default credentials. User: pi - PW: raspberry -# Disabling the OTG mode to use a keyboard and mouse again +# Enabling/Disabling the OTG mode to use a keyboard and mouse again + +## Disable +1. Remove the SD card and access it on your computer +1. Delete the file called `GADGET_MODE` in the boot partition/drive usually called `bootfs`. +1. If the Pi is booted, you can `sudo rm /boot/firmware/GADGET_MODE` and reboot. + +## Enable +1. Remove the SD card and access it on your computer +1. Create a file called `GADGET_MODE` in the boot partition/drive called `bootfs`. +2. If the Pi is booted, you can `sudo touch /boot/firmware/GADGET_MODE` and reboot + +# Connecting over the USB ethernet to ssh into your Pi + +I have not tested this procedure because the serial console and normal network connection is sufficient for me --foley + +https://www.raspberrypi.com/news/usb-gadget-mode-in-raspberry-pi-os-ssh-over-usb/ + + +# Untested + Here are items that bear investigating but haven't been tested yet + + - [Modify Imager manifest to install otg](https://github.com/raspberrypi/rpi-imager/tree/main/doc/local_json) + +# Old DWC Instructions (for older versions) + +## Setting up +1. Enable the DWC version 2 USB peripheral device tree overlay by appending it to the end after the `[all]` category (which is at the end) +``` +echo "dtoverlay=dwc2" >> /boot/firmware/config.txt +``` +1. We add the required module `dwc2` for loading at startup +``` +echo "dwc2" >> /etc/modules +``` + + +## Disabling the OTG mode to use a keyboard and mouse again **WARNING: Untested** 1. Comment out the dwg2 line in `/boot/firmware/config.txt` using a `#` in front of the line @@ -105,16 +144,3 @@ This is similar to the procedure for accessing an Arduino. ``` systemctl disable serial-getty@ttyGS0.service ``` - -# Connecting over the USB ethernet to ssh into your Pi - -I have not tested this procedure because the serial console and normal network connection is sufficient for me --foley - -https://www.raspberrypi.com/news/usb-gadget-mode-in-raspberry-pi-os-ssh-over-usb/ - - -# Untested - Here are items that bear investigating but haven't been tested yet - - - [Modify Imager manifest to install otg](https://github.com/raspberrypi/rpi-imager/tree/main/doc/local_json) -