My Blög

Setting up my Raspberry pi

2012-12-05

Here’s my story on how to set up Raspberry pi to fit my needs. I will use it as a server that controls heating in my summer house and publish data from a weather station I have on the roof. When deployed it will replace a Mac mini that will find more Hollywood-esqe uses.

Update Dec 25 2012: In next version of Raspberry’s firmware, HIDRAW is enabled by default so there is no need to build the kernel yourself; just update the firmware. I’ve updated this little tutorial to reflect that. And fixed some typos.

I downloaded latest Raspbian Wheezy, copied it to an SD card popped it into the Raspberry, booted, ran the setup: expanded file system, set time zone, made sure ssh server is on.

And after a reboot and being an upgrade junkie fired off:

sudo aptitude update
sudo aptitude dist-upgrade
sudo apt-get update
sudo apt-get dist-upgrade

which takes a while so prepare yourself with a nice cup of something to sip on while the screen gets filled with charming ascii chars.

Essential services

I installed netatalk with sudo apt-get install netatalk and it just works. Makes nice integration with my mac.

Went on with Tight VNC Server with sudo apt-get install tightvncserver for those moments when you really need to run the GUI and have no monitor.

Then the lovely avahi-daemon (Bonjour server) with sudo apt-get install avahi-daemon. Assured that it starts on boot with sudo update-rc.d avahi-daemon defaults.

Then I made a Bonjour config file (sudo nano /etc/avahi/services/multiple.service) for SSH, VNC and AFP:

<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
        <name replace-wildcards="yes">%h</name>
        <service>
                <type>_device-info._tcp</type>
                <port>0</port>
                <txt-record>model=RackMac</txt-record>
        </service>
        <service>
                <type>_ssh._tcp</type>
                <port>22</port>
        </service>
        <service>
                <type>_afpovertcp._tcp</type>
    		        <port>548</port>
    	  </service>
        <service>
                <type>_rfb._tcp</type>
                <port>5901</port>
        </service>
</service-group>

Now it’s super easy for me to find the Raspberry and mount it on the Mac, or start a Screen sharing session with it. Or just have easy SSH access with ssh pi@raspberrypi.local. What IP did you say?

Note that OS X will pollute network shares with “.AppleDouble” folders, for reasons unknown. Read more here to find and get rid of them once and for all.

Wifi

I used the GUI to configure wifi, since the manual configuration only seem to work with WEP encryption. I used screen sharing and did remember to save the wifi config when I was done.

Programmers’ must-have

Git of course! sudo apt-get install git. Generate ssh key and let github know about it.

Node.js is a must! Want the fast lane to it? Here’s my precompiled package of v0.8.16 if you dare. Just download, expand, cd into it and sudo make install Build time should be around 10 seconds.

If you want to install node.js from scratch, do like this: wget http://nodejs.org/dist/v0.8.16/node-v0.8.16-tar.gz. Do the ./configure && make && sudo make install voodoo and wait 2 hours. Yes, 2 hours. So the precompiled one does have an edge.

For the Arch Linux ARM image, there’s a raspberry package here, build by @tootallnate who’s a core committer for node.

Other stuff

node-hid

node-hid is a node module for easy access to USB HID devices. It requires libudev-dev and libusb-1.0-0-dev so install it with sudo apt-get install libudev-dev libusb-1.0-0-dev first.

And then I added these USB permissions in a new file /etc/udev/rules.d/99-hid.rules to enable my particular USB thing:

SUBSYSTEM=="usb", ATTRS{idVendor}=="0fde", ATTRS{idProduct}=="ca01", \
    MODE:="666", GROUP="users"
KERNEL=="hidraw*", ATTRS{idVendor}=="0fde", ATTRS{idProduct}=="ca01", \
    MODE:="666", GROUP="users"

You also must update the firmware in your Raspberry to enable raw access to HID devices. Easiest way is to install rpi-update. Just follow the instructions to install it. I chose the very latest github commit on the “next” branch of the firmware. You should get the git hash of the commit you want to install. In my case: sudo rpi-update d0fe451d1e17c1780348d90daa2d45569b09efec and reboot when done.

You should now be able interact with your USB device. Voilá!

Oh by the way, make a backup of your SD card now.


Per Ejeklint in disguise

Writings by Per Ejeklint, living and working in Stockholm, Sweden. Follow me on Twitter!