/~r/sysadmin/ Have you tried turning it on and off again?

Connect Raspbery Pi 3 Model B to C.H.I.P. via serial console

Here are the steps I took to connect my Raspberry Pi 3 Model B to my newly-arrived C.H.I.P.. I didn’t have a display capable of receiving component video input, so I used this method to bootstrap my C.H.I.P. with WiFi connectivity so I could SSH into it. In addition to the two computers, I used 3 male-to-female jumper wires.

Setting up the Raspberry Pi to act as a serial console client

First, I added enable_uart=1 to /boot/config.txt to enable the Raspberry Pi’s UART (universal asynchronous receiver/transmitter) controller. Once you reboot, you’ll be able to see the /dev/serial0 device, which corresponds to the UART serial console. The /dev/serial0 device is symlinked to /dev/ttyS0 on my Raspberry Pi (and should be on all other Raspberry Pi 3 Model B’s). Beware that /dev/ttyS1 refers to the Bluetooth controller and won’t work for this technique.

According to online sources, enabling UART is only necessary on the Raspberry Pi 3 Model B. Previous models of the Raspberry Pi can use the /dev/ttyAMA0 device instead of /dev/serial0 and do not need to add enable_uart=1 to their /boot/config.txt.

Next, I configured the Raspberry Pi to refrain from using the serial console for its own boot output and login prompt. This required 2 steps:

I modified the boot options in /boot/cmdline.txt so that console=serial0,115200 no longer appeared.

# Before
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

# After
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

Then, I stopped and disabled the serial-getty@ttyS0.service systemd service, which spawns the login prompt for the serial console. Stopping the service will only shut down the login prompt until the next reboot. Disabling the service will prevent the login prompt from appearing even after a reboot.

# View the current status of the login prompt service
sudo systemctl status serial-getty@ttyS0.service

# Stop the service
sudo systemctl stop serial-getty@ttyS0.service

# Disable the service
sudo systemctl disable serial-getty@ttyS0.service

Finally, I installed GNU screen on the Raspberry Pi with sudo apt update && sudo apt install screen.

Connecting the serial console pins

There are 3 connections to make between the Raspberry Pi and the C.H.I.P. They are:

  • Raspberry Pi GND (pin 6) to C.H.I.P. GND — Any ground pin will work, but on the Raspberry Pi, pin 6 is the closest
  • Raspberry Pi UART TXD (pin 8) to C.H.I.P. UART1-RX
  • Raspberry Pi UART RXD (pin 10) to C.H.I.P. UART1-TX

Opening the serial console session

On the Raspberry Pi, run:

screen /dev/serial0 115200

If you get a permissions error, make sure your user account is part of the dialout group, or just run this as root. I rebooted my C.H.I.P. after starting the screen session. To quit screen, you can press Ctrl+A then the \ key.

Once you see the login prompt from the C.H.I.P., you should be able to log in with username chip and password chip. Or, you can log in with username root and password chip. Make sure to change the default password (for both accounts) after logging in!

If your screen output looks garbled, check that your jumper cable connections are properly fitted.

Sources