wiki:RaspberryPi
Last modified 5 years ago Last modified on 04/02/14 00:10:46

Setting up a Raspberry Pi for Fawkes

This document describes how to get a Raspberry Pi (raspi) board up and running for use with Fawkes. We will use Pidora 18, as we use Fedora on the other robot and desktop machines for development. We recommend to use an 8GB or larger SD card.

Raspberry Pi Installation - Laptop

We chose to go with the easy route through the graphical installer Fedora ARM Installer, but you can choose any installation method, for example the ones described on the Fedora Raspberry Pi wiki page. The catch with the graphical installer is that it must be run with the English locale. If you use a different default locale, for example German, run the installer with (on your laptop/desktop):

LANG=C LC_NUMERIC=C fedora-arm-installer

Update the list of images, choose the SD card device (unmount the drive if it was automatically mounted on insertion, not via the graphical tools, because they will also remove the device files, but through the command line), and start the writing process.

Raspberry Pi Installation - On the raspi

The following installation instructions are meant to be executed on the raspi. After writing the image to the SD card plug the card into the raspi and connect it to Ethernet and power. The raspi will automatically get an IP address via DHCP if such service is provided. All the following instructions assume that you have found a way to know the IP (query the router/DHCP server or guess) and logged in as root using ssh root@the-ip-you-found. The initial password is raspberrypi.

First Boot Setup

If you plug a screen, keyboard, and mouse, or if you connect using VNC to the first boot screen you can do several of the steps mentioned later over the graphical first time setup guide, i.e. resizing the root file system, setting up the time zone, or configuring the graphical output. Confer the setting up VNC below to use the VNC method. If you choose to use the graphical setup you can skip the following manual steps.

Installing a VNC Server

There are two methods to setup the VNC server. First, you can run a VNC server manually each time you want to use it. This method is required to connect to the first boot screen. The second method adds a module loaded by the X server so that VNC is enabled each time the graphical screen starts.

For either method first install the required packages using

yum install tigervnc-server tigervnc-server-module

Manual VNC Server

Login as root. Check which display the X server is using by issuing

ps ax | grep Xorg

You will get a line where the commands starts with something like /usr/bin/Xorg :0. The ":0" shows you the display number. For first boot it will most likely be ":9". Then create a password and run the VNC server with

# vncpasswd /etc/vnc-passwd
Password: ...
Verify: ...
# DISPLAY=:0 x0vncserver -PasswordFile /etc/vnc-passwd

As you can see the display number must be adjusted as needed.

Automatic VNC Server integrated in X Server

First setup the password file as described above in the manual section. Then create the file /etc/X11/xorg.conf.d/30-vncserver.conf with the following content.

Section "Screen"
    Identifier "VNC"
    Option "SecurityTypes" "VncAuth"
    Option "UserPasswdVerifier" "VncAuth"
    Option "PasswordFile" "/etc/vnc-passwd"
EndSection

Section "Module"
    Load "vnc"
EndSection

The VNC server will be active after the next restart of the X server. In doubt just reboot. Do this only after first boot has been completed initially.

Resizing the Root Partition

The default image comes for a 2GB SD card, while you typically will want to use a larger disk. Hence the root partition must be resized. For this we will need to erase the partition and create a new one that starts exactly at the same position, but spans the free space. Afterwards need to reboot and to (on-line) resize the file system. Now step by step:

  1. Login as root on the raspi using SSH.
  2. Run fdisk and resize the partition by deleting and recreating.
    [root@raspi ~]# LANG=C fdisk /dev/mmcblk0
    Welcome to fdisk (util-linux 2.21.2).
    
    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command.
    
    
    Command (m for help): p
    
    Disk /dev/mmcblk0: 7948 MB, 7948206080 bytes
    4 heads, 16 sectors/track, 242560 cylinders, total 15523840 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0xfdddd43b
    
            Device Boot      Start         End      Blocks   Id  System
    /dev/mmcblk0p1   *        2048      106495       52224    c  W95 FAT32 (LBA)
    /dev/mmcblk0p2          106496    15523839     7708672   83  Linux
    
    Command (m for help): d
    Partition number (1-4): 2
    Partition 2 is deleted
    
    Command (m for help): n
    Partition type:
       p   primary (1 primary, 0 extended, 3 free)
       e   extended
    Select (default p): p
    Partition number (1-4, default 2): 2
    First sector (106496-15523839, default 106496): 106496
    Last sector, +sectors or +size{K,M,G} (106496-15523839, default 15523839): 
    Using default value 15523839
    Partition 2 of type Linux and of size 7.4 GiB is set
    
    Command (m for help): w
    

Now you need to reboot the raspi using reboot.

  1. Resize the file system. This can be done online. Just login as root again and execute:
    resize2fs /dev/mmcblk0p2
    

After a few seconds to minutes you will be able to make use of the full space.

Set Timezone

The time zone is set to EST by default. To switch it copy the appropriate zoneinfo file (see the available files with rpm -ql tzdata). For example for Europe/Berlin? do:

cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime

Enable Avahi mDNS-SD Service Discovery

Service discovery and host name announcement is extremely convenient and heavily used by Fawkes. You can enable it issuing the following commands:

systemctl unmask avahi-daemon.service
systemctl unmask avahi-daemon.socket
systemctl enable avahi-daemon.service
systemctl start avahi-daemon.service

Setting up the Firewall

The firewall should be enabled to prevent ports from leaking to the outside. The following configuration allows SSH, mDNS-SD service discovery (Avahi), and access to Fawkes (1910, 2208, and 8088). Pidora 18 uses firewalld, which was problematic for us because it did not find any zones after a yum upgrade. Therefore we disable it an use the iptables scripts. First, add the following to the iptables configurations:

# IPv4 /etc/sysconfig/iptables
 *filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 1910 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 2208 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8088 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
# IPv6 /etc/sysconfig/ip6tables
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p ipv6-icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 546 -d fe80::/64 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 5353 -d ff02::fb -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 1910 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 2208 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8088 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp6-adm-prohibited
-A FORWARD -j REJECT --reject-with icmp6-adm-prohibited
COMMIT

Then disable firewalld and enable the iptables scripts:

systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl enable iptables.service
systemctl start iptables.service
systemctl enable ip6tables.service
systemctl start ip6tables.service

Getting and Compiling Fawkes

First you need to install the required software development tools and libraries.

yum groupinstall --skip-broken "Development Tools"
yum install sqlite-devel openssl-devel libxml++-devel avahi-devel yaml-cpp-devel \
  lua-devel libjpeg-devel libpng-devel opencv-devel SDL-devel libmicrohttpd-devel \
  flite-devel asciidoc doxygen graphviz graphviz-devel rrdtool-devel bullet-devel \
  eigen3-devel bluez-libs-devel libudev-devel urg-devel readline-devel file-devel \
  clipsmm-devel xmlrpc-c-devel clipsmm-devel protobuf-devel libdaemon-devel

On ARM tolua++ is currently broken and hence should not be installed.

Finally, you can get and compile Fawkes using the following:

git clone git://git.fawkesrobotics.org/fawkes.git
cd fawkes
make

Afterwards, you may want to read on in the GettingStartedGuide on running Fawkes and the DeveloperGettingStartedGuide.