Bering-uClibc 6.x - User Guide - Advanced Topics - Setting Up a Raspberry PI as a net to serial gateway

From bering-uClibc
Revision as of 00:58, 29 August 2018 by Jeanrocco (Talk | contribs)

Jump to: navigation, search

This is a work in progress


This setup describes how to make any device serial communication port accessible through an SSH network session. The motivation was to make the serial port of a distant APU2c2 accessible over distances longer than 200 feets. Knowing that RS-232C communication distances are short, why not use a wired network instead that can reach a lot farther.

This setup shows how to adapt the LEAF tarball distribution for the raspberry PI and make it act as an interface between your network and any device serial communication port. The Raspberry PI will run an ssh server and will accept an ssh session where one can access the serial port using minicom or picocom communication programs. There is a USB to RS-232C cable, that connects the raspberry PI to the serial port.

Using the Raspberry PI with the LEAF distribution transforms it into a very stable and dependable platform, since everything runs in rams. It is a well known fact that, it is only a matter of time for the Raspberry PI to corrupt it's SD card and make it fail to boot or run. This is mainly caused by random power fails occuring when the PI is writing to the SD card (further readings:

You will need

  1. - one raspberry pi 1 and power supply, (or PI2 or PI3 but it will be overkill...)
  2. - rs232c to USB cable
  3. - one db9 null modem
  4. - LEAF tarball distribution for PI1, at
  5. - One SD card, 4 gig. is plenty
  6. - a pc running a modern Linux distribution
  7. - an SD card programmer

Setting up the SD

  1. - Download the tarball and unpack it in a suitably named directory
  2. - Put the SD card in the programmer, and make a single Fat32 partition, format it to Fat32
  3. - Copy all the files from the tarball to the SD
  4. - Looking at the SD contain:
1- find the package dropbear.lrp
2- rename it to dropbear.tgz
3- doubleclick it
4- add -B in /etc/network/interfaces DB_OPTIONS=" -B "
5- save files and update archive dropbear.tgz
6- rename dropbear.tgz back to dropbear.lrp

Starting the Raspberry PI

  1. - Put the SD card in the Raspberry PI, and power it up
  2. - After ~ 30 seconds, find out the PI's Ip address, and ssh in it
  3. - Set the new passwords for the OS and webmin
  4. - Open webmin from a browser http://raspberry_pi_IP_address
  5. - Edit LEAF.CFG to your liking: add ....local... remove ...shorewall and dnsmasq...

Correcting some bugs...

  • - fix xterm go to /etc/terminfo/x and "cp xterm xterm-256color"
  • - fix reboot: simple reboot by connecting GPIO4 to the PI reset connector P6 pin 1 (the square one)
script /root/
# reset avec gpio4 connecte sur reset du PI, P6 pin 1 square.
echo "4" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio4/direction
cd /sbin
mv reboot old_reboot
ln -s /root/ reboot
  • - set local.local:
lrcfg > 3) local > 1) list of files that should be saved > 
lrcfg > s) save configuration

Using the gateway

  1. - Open an ssh session to the PI
  2. - start picocom: picocom -b115200 /dev/ttyUSB0
  3. - hit return:... you should have the prompt to login in your router !
  4. - exit picocom with Cntl-a Cntl-x, help is Cntl-a Cntl-h

Have fun