ssh over serial with raspberry pi
Matthew Martinez
I am trying to use my raspberry pi over serial communication with my ubuntu laptop as in this tutorial.
I have ensured that:
- /boot/config.txt in my raspberry pi has a
enable_uart=1line at the bottom - The wiring is correct (TX cable in raspi's RX, and viceversa)
- Raspi is booting up and the green light is blinking
- I can access my pi with ssh over wifi
- I have screen and minicom installed on my laptop
On my laptop I tried looking for what usb ports are working (dmesg | grep tty) I get this return that led me to believe that my raspi is attached to /dev/ttyUSB0:
console [tty0] enabled ttyS4 at I/O 0x4060 (irq = 19, base_baud = 115200) is a 16550A pl2303 converter now attached to ttyUSB0 ttyS5 at MMIO 0x4010002000 (irq = 20, base_baud = 7500000) is a 16550A pl2303 converter now disconnected from ttyUSB0 pl2303 converter now attached to ttyUSB0
The problem:
When I open screen (sudo screen /dev/ttyUSB0 115200), a blank terminal screen appears and nothing changes. I tried pressing enter, and reconnecting the raspi.
I also tried with minicom, with the same results.
When trying cat /dev/ttyUSB0, I get a device or resource busy error
Also, I'm using the ubuntu 20.04 on my laptop and raspian on the raspberry pi
Does anyone have suggestions on how to deal with this issue? Working around the problem (i.e. using an ethernet cable or wifi) are not an option since I'm using a raspberry pi zero (and testing on a pi 4) and trying to go for a cabled connection via GPIO pins.
21 Answer
A decade ago, I used a similar serial login using a null-modem cable (which is different from a plain serial data cable). Here are my notes from that time on how to make a successful serial connection. Hope they help:
On the headless machine (Server), open the serial port, and leave it open.
# getty -L ttyS0 115200 vt100On the laptop with a serial port (Client), install the screen application, then use it as a terminal emulator to connect over the serial port.
# apt-get install screen
# screen /dev/ttyS0 115200 (Hit return once or twice)When finished with screen, quit using the command (CTRL+A , then Backslash)
You should be able to login to the Server from the Client.
If you have problems:
- Make sure you didn't start multiple screen sessions (they interfere)
- Make sure neither machine is running both getty and screen on the same port (they interfere). One machine should run getty, the other should run screen.
- Make sure both sides are using the same speed (115200). This modem setup does not auto-negotiate speeds!
- Try varying which service starts first. After each attempt, kill both the screen and getty services (but only the getty running on that port!)