From b7a327904e8011c1bf8b74fce47c3ddeea7a7739 Mon Sep 17 00:00:00 2001 From: Joe Foley Date: Mon, 29 Jun 2026 00:19:35 +0000 Subject: [PATCH] format and info on serial terminal --- gadget.md | 74 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 32 deletions(-) diff --git a/gadget.md b/gadget.md index 7fcdf04..b5d3ef8 100644 --- a/gadget.md +++ b/gadget.md @@ -9,16 +9,24 @@ USB-OTG method (Works on Zero, Zero W, and Compute Module) Based upon Adafruit guide: https://learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget/serial-gadget: # Raspberry Pi Connect -1. Make sure you have your USB cable plugged into the left port **USB** and not the right port marked **PWR**. +Make sure you have your USB cable plugged into the left port **USB** and not the right port marked **PWR**. 1. Open a connection to the device 1. Become root (the superuser) - `sudo su` -1. Enable the DWC USB peripheral device tree overlay by appending it to the end after the `[all]` category - `echo "dtoverlay=dwc2" >> /boot/firmware/config.txt` + ``` + 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` + ``` + echo "dwc2" >> /etc/modules + ``` 1. Check that we can load the libcomposite module - `modprobe libcomposite` + ``` + modprobe libcomposite + ``` 1. Put a copy of this repository in root's home directory using git ``` apt install -y git @@ -37,31 +45,33 @@ Based upon Adafruit guide: https://learn.adafruit.com/turning-your-raspberry-pi- ``` 1. Reboot and see if the serial port appears -## Additional hints +# Connecting to the serial terminal +You will need a serial terminal program (which used to be very very common) in order to communicate over your serial port -Look for the SD card reader on the VM under "Devices > USB" and click on it  Iff you get errors, you may have to shut down the VM and set the USB version to 2.0 or 3.0 -The Boot and Root partition should mount in Linux under /media/$USER/boot and /media/$USER/rootfs -Navigate to /media/$USER/boot and edit: -config.txt: add "dtoverlay=dwc2" at the end -cmdline.txt:  remove "init=/usr/lib/raspi-config/init_resize.sh" and add "modules-load=dwc2,g_serial" to the end.  Make sure everything is on one line! -Eject the card -Boot the pi with a keyboard and monitor attached -Login -sudo systemctl enable serial-getty@ttyGS0.service -sudo systemctl start serial-getty@ttyGS0.service +## Windows +- Putty: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html +- MobaXterm: https://mobaxterm.mobatek.net/ - - -# connecting to the serial terminal -If using a Linux VM, you will need to pass the Pi USB connection there.  This is similar to the procedure for accessing an Arduino. -Start the Linux VM if you haven't already -Menu:  Devices > USB -Look for "Silicon Labs CP210x USB to UART Bridge" and click on it.   -Run "ls -l /dev/ttyU*" to check if port /dev/ttyUSB0 is found.  The Pi will most often be accessible over this port. -The user must be in the dialout group to access it.  Use the Linux command: id  -to check if you are in the group.  If not in the dialout group, use: - sudo usermod -a -G dialout -You will use the screen app in Linux to access the Pi.   You can install it with: - sudo apt install screen -You should now gain access to the Pi with: - sudo screen /dev/ttyUSB0 115200 -Press enter and you will be prompted to log in to the Pi with default credentials. User: pi - PW: raspberry +## Linux +If using a Linux VM, you will need to pass the Pi USB connection there. +This is similar to the procedure for accessing an Arduino. +1. Start the Linux VM if you haven't already +1. Menu: Devices > USB +1. Look for "Silicon Labs CP210x USB to UART Bridge" and click on it. +1. check if port /dev/ttyUSB0 is found. The Pi will most often be accessible over this port. + ``` + ls -l /dev/ttyU* + ``` +1. The user must be in the dialout group to access it. Use the Linux command: `uid` -to check if you are in the group. If not in the dialout group, use: + ``` + sudo usermod -a -G dialout + ``` +1. You will use the GNU `screen` application in Linux to access the Pi. You can install it with: + ``` + sudo apt install screen + ``` +1. You should now gain access to the Pi with: + ``` + ` sudo screen /dev/ttyUSB0 115200 + ``` +1. Press enter and you will be prompted to log in to the Pi with default credentials. User: pi - PW: raspberry