Raspberry Pi: attach a serial console

For a Raspberry Pi with GPIO pins (B, B+, 2, 3):

  1. Connect as follows:
  2. Append this line at the end of /boot/config.txt:
    enable_uart=1
  3. Access the console from your workstation like this:
    sudo screen /dev/ttyUSB0 115200

Sources:

For Raspberry Pi without pins (Pi Zero, Pi Zero W):

  1. Add the following line at the end of /boot/config.txt:
    dtoverlay=dwc2
  2. Insert the following between ‘rootwait‘ and ‘quiet‘ in /boot/cmdline.txt:
    modules-load=dwc2,g_serial
  3. Mount the linux part of the Pi SD card and add the following lines at the end of /etc/rc.local, before ‘exit 0’:
    usbconsole="[email protected]"
    if [ ! $(systemctl is-enabled "${usbconsole}") ]
    then
    echo "Enabling and starting ttyGS0 console..."
    systemctl enable "${usbconsole}"
    systemctl start "${usbconsole}"
    fi
  4. Connect a micro usb cable into the socket market ‘USB‘ on the Pi, not the one marked ‘PWR’.
  5. On your workstation, console can be accessed as:
    sudo screen /dev/ttyACM0 115200

Sources:

Leave a Reply

Your email address will not be published. Required fields are marked *