Installation

It All Starts With Raspbian

As all of my Raspberry Pi projects, Dave is built upon a default Raspbian installation. I have removed a lot of ballast from the system, mainly GUI stuff, which I'm sure I'm never going to use. But doing this is not really necessary. It only frees up a reasonable amount of disk space.

But hey, if you like using the GUI of your Raspbian installation, feel free to keep it. In my case I can't reach the HDMI output anymore, I don't need it anyway. But if you design your hardware carefully you must still be able to use the GUI.
It's not even a problem that you can't use the video output though. You can still use the GUI programs using X forwarding over an ssh connection.

That brings us to the first thing we definitely do want to switch on in Dave, the ssh server. This can simply be done using the raspi-config script, which auto-starts on a fresh installation of Raspbian.

Fixed IP Address

I usually prefer my servers to have a fixed IP address in my network. This also makes forwarding external traffic to Dave a bit easier. Setting a fixed IP address is quite simple. Execute the command sudo nano /etc/network/interfaces and copy/paste the next information into this file. Yes you may overwrite every existing text, as I have included everything you need in this example. Of course you will have to adapt the IP addresses to match your private network and choose a free host address for Dave, which falls outside the DHCP scope.

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
allow-hotplug eth0
iface lo inet loopback

iface eth0 inet static
address 192.168.123.10
netmask 255.255.255.0
gateway 192.168.123.1
dns-nameservers 8.8.8.8

LAMP

Indeed Dave is going to be used to turn my lights on and off. But this LAMP I'm referring to is a Linux + Apache + Mysql + PHP installation. One of Dave's tasks it to serve up my landing page. And in the near future I hope to make it the server base for my mobile phone apps, with which I can control the lights in my house using my mobile phone.

Installing the LAMP stack is simply a matter of executing the next command: sudo apt-get install apache2 php5 php5-mysql mysql-client mysql-server.

You may want to tweak the web server settings a bit, but none of them are absolutely necessary. It all should basically work out of the box, which you can test by pointing your web browser to Dave's IP address.

Well, there may be at least one thing you might want to change in the Apache settings. Enter the command sudo nano /etc/apache2/sites-available/default . Then find the line which contains the word "Indexes" in the /var/www options list and remove the entire line. Finally restart apache2 to make the changes effective.
This little tweak prevents people listing your web directories in search for files they'd better not see.

One more litte tweak, execute sudo nano /etc/apache2/apache2.conf and add the line ServerName localhost at the end of the file to avoid the warning that Apache can't find the name of the server whenever it restarts.

Mail System

It would be helpful if Dave could mail you if there is anything up his mind he wishes to inform you about. I have written a special mail setup page for that. I advise you to use the Exim4 setup, as that allows you to use aliases.

Setting Up Git

As I'm going to do some programming on Dave, and because my web sites are prepared there as well, I have started using Git as my versioning system. I advise you to learn how to work with Git too. It is not absolutely necessary, if you are a loner like me, but it certainly expands your horizon. And you will only learn to appreciate the advantages of a versioning system once you are using one.

Git is already installed per default in Raspbian nowadays. You only need to set it up before you start using it. Here's what I usually do on fresh systems:

git config --global user.name "Your Name"
git config --global user.email "Your email address"
git config --global color.ui false
git config --global push.default current

Extra Directories

This one is completely up to you. But I usually install 3 extra directories on a fresh system. The ~/bin directory, which is going to hold all your private scripts and programs. Creating the ~/bin directory will automatically add this directory to the $PATH variable the next time you log in.
The ~/src directory is used to write programs in. Normally it is empty, but when I'm working on something I clone the particular git repository here and work on it. When I'm done I simply push the project back to the git server, whichever you chose to use.
Finally the ~/tmp directory, which is used to hold all sorts of temporary stuff. You may even write a script which keeps this directory empty by deleting files which are older than a week for instance.

Enable One-Wire Thermometers

In case you need them, enter the command sudo nano /etc/modules , and add the following lines:

w1-gpio
w1-therm

And while you're at it and you do have a network with native IPv6 support, add a line containing ipv6 to enable that too.

Since kernel 3.18 we also need to configure the Device Tree for the 1-wire interface. So enter the command sudo nano /boot/config.txt and add the following lines at the end of the file:

# device tree config
dtparam=spi=on
dtoverlay=w1-gpio,gpiopin=4

By the way, this also enables the SPI bus for the AVRdude programmer, if you haven't enabled it using raspi-config yet.

Installing AVRdude

This is only necessary if you have included an AVR processor in the hardware and want to program it by Dave himself. AVRdude is a commonly used tool to program the Flash memory of AVR processors. It can use dozens of programmers, one of those is the SPI interface of our Raspberry Pi.

For your convenience I have created a download package with a copy of AVRdude in it. Installing is simply a matter of unpacking the ZIP file to your Raspberry Dave, for instance to the ~/tmp directory. Then go to this ~/tmp directory and execute the command ./install.sh.
Two little text files are included explaining how to connect the AVR to your Raspberry Pi, and it shows you an example command on how to start avrdude.

avrdude -p atmega88 -c gpio -U flash:w:test.hex

Let's break down this command. The parameter -p atmega88 tells avrdude what target processor it is to use. This will tell avrdude how to program the processor and what memory size it has, among other things.
The parameter -c gpio tells avrdude to use the GPIO pins as a programming device for the AVR processor. That's what you need if you want to use the Raspberry Pi as programming computer.
Finally the -U parameter tells avrdude to program flash memory, write to it, and the file it has to write to Flash memory.
So basically the only thing yo need to change in the command above is the processor type, if you are using something else than the ATMega88, and the name of the file you want to write.

Download avrdude Here you can download a copy of AVRdude Version 5.10.

SB-Assembler

You have a couple of options when it comes to the programming language you want to use for the AVR processor. C is a commonly used option. If you know your Arduino, you are probably already familiar with the C programming language.

But if you're like me, and want to program in assembly, I highly recommend you try my SB-Assembler. Examples on this page will very likely be written using my SB-Assembler, which can run on Linux and therefore will also run on the Raspberry Pi.