SBC Serial Port Device Console Server

 

Introduction

Have you ever had to drag your laptop with a serial port and cable into an extremely loud, freezing cold (or boiling hot), data center to program a new network device such as a router or firewall? In the time it takes to find the right drivers and COM port for the USB Serial Port adaptor you can make a small network based serial port console server for around $100. This allows you to do the same work on up to 4 devices from anywhere with a network connection.

Don’t be like this guy when you could be working remote over a vpn!

cloud-dedicated-tools.jpg

This blog post shows how to use a Raspberry Pi 3 single board computer (SBC) as a network based serial port console server.  Connect the Raspberry Pi to an Ethernet or wireless network then use SSH or telnet to open a terminal window. Since the SBC runs a real 64 bit Linux operating system normal applications such as IPERF3, NMAP, and SCREEN work just fine.

Total project cost depends on what parts you already have and what you need to purchase. It takes around 2 hours to download the latest operating system image and copy it to the flash chip during which time you can build the kit and get everything ready.

Alternatives

There are many popular Network Serial Port Console servers available on eBay and Amazon for hundreds of dollars.  They have limited feature sets with closed operating systems and cannot be upgraded or expanded.

Bill of Materials

Here is the list of parts (BOM) needed to complete the build out of the project.

NOTE: a reliable power supply and Micro SD Flash Memory Card are important to the stability of this solution. Skimping on these two items could cause unplanned trips to the data center for troubleshooting this solution which is supposed to save you time, not make things worse.

  1. Raspberry Pi 3 ~$40

    product_2704
    Case available from Adafruit
  2. Case for Raspberry Pi 3 ~ $10 (Optional but recommended)
  3. Micro SD Card – 8GB or larger ~$20 (get an enterprise grade “type 10” flash chip with fast read write speeds)
  4. Micro SD to SD Card adapter for your computer ~$10 (used to transfer the OS image)
  5. USB to Serial Port adapter(s) ~$15 (up to 4 can be used simultaneously if needed)
  6. USB Power supply (or PoE option below)
    1. MicroUSB to USB type A power cable ~$5 (same type use by most android phones)
    2. 5-10 Watt USB Power Supply Adapter ~$5 (2.5 Amps recommended for fully loaded setup) https://www.adafruit.com/products/1995 or…
  7. IEEE 802.3af Micro USB Active PoE Splitter Power Over Ethernet 48V to 5V 2.4A ~$10
  8. An “admin” computer to use for testing and setup – Mac, Windows, Linux
  9. For initial setup you would also need the following:
    1. HDMI cable
    2. HDMI capable display monitor 1080p
    3. USB Keyboard

Setup Process

Follow these steps to build the solution:

  1. Obtain all the needed components in one place. You can assemble them later.
  2. Download the Operating System image to your admin computer.
    1. Open a web browser to: https://wiki.ubuntu.com/ARM/RaspberryPi
    2. Download this file: http://www.finnie.org/software/raspberrypi/ubuntu-rpi3/ubuntu-16.04-preinstalled-server-armhf+raspi3.img.xz
    3. Compressed download file size is: 216 MB
    4. Expand to: ubuntu-16.04-preinstalled-server-armhf+raspi3.img
  3. Insert the MicroSD card into the admin computer.
  4. Checking microSD Card performance and check whether is counterfeit:
    – H2testw 1.4 – Gold Standard In Detecting USB Counterfeit Drives
    – F3 – an alternative to h2testw
    This will help determine if the Micro SD Card is worth using.
  5. Copy the OS image to the MicroSD card.
    1. The image file size is over 4.3GB so depending on the write speed of the MicroSD card this can take an hour or so.
    2. Open a terminal command line interface on the admin computer.
    3. Here are the steps for Mac OS:
      diskutil list
      diskutil unmountDisk /dev/disk4
      sudo dd bs=1m if=~/Downloads/ubuntu-16.04-preinstalled-server-armhf+raspi3.img of=/dev/disk4

      Press Ctrl-t to monitor copy progress.

    4. Instructions for other Operating Systems and images can be found here: https://www.raspberrypi.org/documentation/installation/installing-images/README.md
  6. While the copy process takes place complete the following…
  7. Remove the Raspberry Pi 3 from the box and assemble with the case.
  8. Connect the Raspberry Pi 3 unit to the following:
    1. Local Area Ethernet Network
    2. HDMI display
    3. USB keyboard
  9. Turn on the display.
  10. When the copy process on the Admin computer completes you can remove the MicroSD card from the adapter.
  11. Insert the MicroSD card into the Raspberry Pi 3.
  12. Use the Micro USB cable to connect the Raspberry Pi 3 device to the power adapter.
  13. The Raspberry Pi 3 will boot up. You should see the login prompt on the display.
  14. Login with user and pass ubuntu/ubuntu.
  15. Run ifconfig to see the local assigned IP address. This assumes there is a DHCP server on the LAN. You can also assign a static IP address if needed.
  16. You can also use arp from your admin computer to find the Raspberry Pi 3 IP Address: https://www.raspberrypi.org/forums/viewtopic.php?t=74176
  17. Open a secure shell session from your admin PC to the IP Address of the Raspberry Pi 3.
  18. Update the Raspberry Pi 3 and install the tools you need:
    sudo apt-get –y update
    sudo apt-get –y upgrade
    sudo apt-get –y install iperf3 nmap sendemail
  19. Note the Ethernet MAC address and make a label to identify the Raspberry Pi 3 when it’s being used in the field. You may want to note the default password and other contact info on the label as well.
  20. Optionally: Here’s a script that can email you the IP Address when the Raspberry Pi 3 boots up. Edit /etc/rc.local and add a link to this file there.
    #/bin/sh
    now=$(date)
    IPADDRESS=$(/sbin/ifconfig eth0 | sed -n 's/.*inet addr:\([^ ]*\).*/\1/p')
    MACADDRESS=$(/sbin/ifconfig eth0 | sed -n 's/.*Link\([^ ]*\):*/\1/p')
    IPADDRESS="$IPADDRESS\n - $now \n -$MACADDRESS"
    echo "RaspberryPi3 IP address:\n - $IPADDRESS " | sendemail -o tls=yes username=iben.rodriguez@gmail.com password=qdfqraugzundgjzn -s smtp.gmail.com:587 -f iben.rodriguez@gmail.com -t raspberrypi3@ibenit.com -u "raspberrypi3 IP Address" -q

    Here is an example of what the email looks like:

        RaspberryPi3 IP address:
        - 192.168.123.456
        - Mon Nov  7 01:15:14 UTC 2016
        - encap:Ethernet  HWaddr b8:27:eb:12:34:56
  21. Once the setup steps are completed you can unplug everything and move the Raspberry Pi 3 device to its operational location in the field.

Operating Instructions

Once you have everything ready you can move the solution into place where the device with the serial port resides.  For example:  a data center with racks of network equipment that needs to have its initial networking configuration applied or changed.  The Raspberry Pi 3 has 4 USB ports that can each be used with a standard USB to RS-232 Serial Port adaptor.  With a USB hub you could connect even more serial port adapters if needed.

  1. Connect the serial ports to the serial port adaptors with the cables you’d normally use with your laptop.
  2. Connect the USB to RS-232 serial port adaptors to the Raspberry Pi 3.
  3. Make sure the Micro SD Card with the configured Operating System image is seated properly in the Raspberry Pi 3.
  4. Use the MicroSD USB cable to connect the Raspberry Pi 3 to the power supply adaptor.
  5. Based on the setup steps above you should know how to find the IP address using the MAC address and the DHCP server, ARP, or the email script.
  6. Using the IP address of the Raspberry Pi you can now establish an ssh secure shell session from your admin workstation.
    ssh ‪ubuntu@192.168.123.456
  7. Login with the user name and password established during the setup steps.
    ‪ubuntu@192.168.123.456's password: P@ss!23456789
  8. Find the device path to the USB Seral Port(s) with this command:
    ls -al /dev/ttyU*

    crw-rw---- 1 root dialout 188, 0 Nov  6 02:26 /dev/ttyUSB0

    With multiple USB to Serial adaptors you will see many tty entries. See this post for more details on this: http://raspberrypi.stackexchange.com/questions/12246/why-does-usb-port-enumeration-change

  9. Use the “screen” application to connect to the USB Serial Port
    screen /dev/ttyUSB0
  10. Press the enter key to wake up the console device and do your work.
  11. To quit the screen app, type CTRL-A, then \.
  12. You can also use the Raspberry Pi 3 as a remote linux administration workstation with commands such as iperf3 and nmap.

USB Device Power Usage

Run this command to see the maximum power utilization budget of the USB devices plugged into your Raspberry Pi 3.

ubuntu@ubuntu:~$ lsusb -v|egrep "^Bus|MaxPower"
Bus 001 Device 006: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
    MaxPower              100mA
Bus 001 Device 005: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
    MaxPower              100mA
Bus 001 Device 004: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
    MaxPower               44mA
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
    MaxPower                2mA

Obviously, the more USB devices you connect the more power you will need. Adjust the capacity of the USB power supply adapter accordingly.

Next Steps

On my wishlist of things to try next:

 

Raspberry Pi 3 Specifications

Raspberry Pi 3 Model B
Release date 29 February 2016
Introductory price US$35
Operating system Raspbian
Ubuntu MATE
Snappy Ubuntu Core
Windows 10 IoT Core[1]
RISC OS
Debian
Arch Linux ARM
System-on-chip used Broadcom BCM2837
CPU 1.2 GHz 64/32-bit quad-core ARM Cortex-A53
Memory GB LPDDR2 RAM at 900 MHz[2]
Storage MicroSDHC slot
Graphics Broadcom VideoCore IV at higher clock frequencies (300 MHz & 400 MHz) than previous that run at 250 MHz
Power 800 mA (4.0 W)
Website raspberrypi.org
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s