Installing The Pi-Bus Driver

My Pi-Bus Driver runs on Raspbian, which is most likely the most favourite OS for the Raspberry Pi. I have stripped Raspbian down to a text based only version because I have no need for a graphical user interface. Not only can't I reach the HDMI output anymore when the Pi-Bus Driver is boxed in, I have plenty of other Linux systems which I can use in a GUI environment anyway.

Being an SB-Bus Driver isn't a very hard job for the Raspberry Pi. It can run on a Raspberry Pi which has plenty of other jobs to do without any problems. Since my Pi-Bus Driver runs 24/7 it is given quite some side jobs like allowing remote access, doing some daily backups and monitoring other systems, just to name but a few. Lately it is also a TOR router, which creates a completely isolated LAN, especially for virus infected guest computers.
An other Raspberry Pi runs a web server and database in my network, which has to be on 24/7 too. Otherwise my Pi-Bus Driver would have have had those jobs assigned to it as well.

Anyway, in order to create a Pi-Bus Driver you should start installing Raspbian, with or without a graphical user interface. The rest of this page will describe what else you need in order to make it complete.

I'm assuming that your main system user is called pi, which is the default case in Raspbian. You may name your main system user anything you like though. You may even have multiple users set up on your Raspberry Pi. It goes without saying that you'll have to replace any reference to the user pi to the actual user name on your system.

Preparing The Serial Port

Per default the main serial port for the Raspberry Pi is used as system console. This is nice if you want to control your Raspberry Pi over the serial interface. But this console is undesirable if we want to communicate to other devices over it. Therefore you'll need to free the serial port /dev/ttyAMA0 from its console duties.
And there is also an issue with the default rights of non root users who want to access the serial port. So let's prepare everything for the Pi-Bus Driver now.

Take Ownership

First of all we have to make sure that we are allowed to access the serial port, without having to become root. It's not practical to have to become root every time we run a program which uses the serial port.
Taking ownership of the serial port is as easy as adding the group "dialout" to your login id. You do that with the following command:

sudo usermod -a -G dialout pi

In the line above pi is the user you want to add a group to.
You may have to add the dialout group to other, maybe less obvious, accounts too, depending on the intended use of the system. For instance if you want your web server to control the serial port you may have to add the dialout group the the www-data user too.

Disable Serial Console

Next we have to disable the Serial Console, to free the serial port for our own communication. For that you'll have to execute the next command sudo nano /etc/inittab . Then find the line below and place a # sign in front of it, to make it a comment so it will be ignored the next time the system starts. B.T.W. this is usually the last line in the file.

T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

The next time you start your Raspberry Pi the console port will be disabled. But we're not home yet. Upon boot the entire boot log is output on the serial port, which might confuse your connected SB-Bus devices.
Enter the next command sudo nano /boot/cmdline.txt and delete two fields from the text you see in your editor. The fields to delete are:

console=ttyAMA0,115200
kgdboc=ttyAMA0,115200

Be careful to leave all the remaining text on one single line! Now it's time to reboot your Raspberry Pi.

Installing Minicom

We're going to need a serial terminal emulation program. My choice is minicom.. Installing minicom is as simple as entering the command line sudo apt-get install minicom. Nothing to it. After installing minicom you'll have to set it up. This is also pretty easy. Use the command nano ~/.minirc.dfl and copy/paste the next information into this file:

pu port             /dev/ttyAMA0
pu baudrate         9600
pu updir            /home/pi
pu downdir          /home/pi
pu rtscts           No
pu xonxoff          Yes
pu macenab          No
pu askdndir         Yes
pu logfname
pu localecho        Yes
pu addlinefeed      Yes

That's all there is to it. Don't worry if you don't know how minicom works. On the next page you'll find a crash course on minicom.