nRF51 IoT SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Setting up Raspberry Pi as router

To allow fast startup with 6LoWPAN over Bluetooth low energy, you can set up a Raspberry Pi as Linux boarder router. With this setup, you can test all delivered examples.

The Raspberry Pi must run a version of Raspbian OS that supports 6LoWPAN, the required modules must be installed, and a Bluetooth dongle with Bluetooth low energy support must be connected to the Raspberry Pi.

This user guide explains how to set up Raspbian OS on the Raspberry Pi and add 6LoWPAN support and router capabilities, so that you can use the Raspberry Pi as router.

Prerequisites

Note: Save the above downloaded files to the same directory. The kernel must be unzipped prior to transferring them to the raspberry. You should have in total 6 .deb files after unzipping. Let’s call this path /path/to/downloaded/dependencies

Note
In order to prepare your SD-card on OS X/Linux/Windows,

Ways of interfacing:

  • Interfacing with HDMI capable display and keyboard
  • Interfacing headless (without display and keyboard)

If you are not familiar with the raspberry pi, generic information about the board is available on this site: http://elinux.org/RPi_Hub

Before you start setting up Raspbian OS, ensure that you have an SSH terminal client and the SCP file transfer program installed.

Download the following files:

Connecting and obtaining dependencies for your Raspberry Pi

To be able to communicate with your raspberry pi, it’s essential that it’s connected to your network, and that you know the IP address of it. Finding the ip-address of the Raspberry Pi can be done by calling “hostname –I” in the terminal of your Raspberry Pi. If you have issues finding the IP address of your device, please see this page: http://www.raspberrypi.org/documentation/troubleshooting/hardware/networking/ip-address.md

Setting up Raspbian OS

Copy the standard image of Raspbian OS to an SD card. See http://www.raspberrypi.org/documentation/installation/installing-images/ for detailed instructions on how to install the image.

Note
Before copying the image, it might be necessary to format the SD card with the FAT file system.

The following commands demonstrate how to create the SD card on a Linux operating system. These commands assume that the SD card is the /dev/sdb device. See the Raspberry Pi documentation for information about how to create the SD card on other operating systems, or to troubleshoot problems.

Warning
Make sure that you understand the documentation about how to create the SD card. If you choose a wrong device (for example, /dev/sda instead of /dev/sdb), you might overwrite your current file system!
# Insert SD card.
# Check all mounted drives.
df -h
# Detach drive.
umount /dev/sdb1
# Copy image into /dev/sdb drive.
dd bs=4M if=2014-09-09-wheezy-raspbian.img of=/dev/sdb

Directly accessing the Raspberry Pi

To be able to access the Raspberry Pi without an internet connection and without a router, and without attaching a screen, it must be assigned a static network address. You can then access the Raspberry Pi through this IP address. However, this IP will be used only to get easy access to the dynamic IP address.

To assign a static network address to the Raspberry Pi, edit the network interface configuration file on the system partion. The file is located at /etc/network/interfaces on the Raspian OS SD card. With the SD card mounted on your computer, open the file /media/<path-to-raspbian-system-partition>/etc/network/interfaces in an editor (you need root permissions to edit the file) and add a static network. For example:

auto eth0:1
iface eth0:1 inet static
address 192.168.111.111
netmask 255.255.255.0

Next, couple the Raspberry Pi and the host directly with a network cable and configure your host machine to use the same static network. For example, assign the host the IP 192.168.111.112 with the same netmask that you used for the Raspberry Pi.

If the host is running on a Linux system, issue the following command, for example:

sudo ifconfig eth0 192.168.111.112 netmask 255.255.255.0

Adding 6LoWPAN support and router capabilities to Raspbian OS

Currently, Raspbian OS does not support 6LoWPAN. You must upgrade the kernel to add 6LoWPAN support. In addition, you need to install several modules that provide Bluetooth low energy and router capabilities

Upgrading the kernel to 3.17 (with 6LoWPAN support)

The current Raspbian OS uses the 3.12 Linux kernel, which does not support 6LoWPAN. Therefore you must upgrade the kernel to version 3.17.

Complete the following steps to upgrade the kernel:

  1. Insert the SD card into the Raspberry Pi and power it on.
  2. Use SCP to copy the new kernel and the other downloaded packages from the host computer to the Raspberry Pi. For example:
    scp *.deb pi:raspberry@192.168.111.111:~
  3. When all files are copied, use SSH to connect to the Raspberry Pi. To do so, use the IP for eth0:1 that you added in the network interface file. For example:
    ssh pi:raspberry@192.168.111.111
  4. In the SSH window, log in as root user on the Raspbery Pi:
    # Log in as root user.
    sudo su
  5. Install the packages on the Raspbery Pi:
    # Install the new kernel packages.
    dpkg -i linux-headers-*.deb linux-image-*.deb
    # Install radvd.
    dpkg -i radvd_1.8.5-1_armhf.deb
    # Install bluez.
    dpkg -i libcap-ng0_0.6.6-2_armhf.deb
    dpkg -i bluez_4.99-2_armhf.deb
    Alternatively, you can install the addional modules with apt-get if the Raspberry Pi is connected to the internet. The kernel, however, must always be upgraded manually.
    Note
    When installing the new kernel, some error messages like "Hmm. There is a symbolic link ..." might appear. You can ignore those messages.
  6. Before rebooting the device, you must activate the new kernel:
    1. List the files in the /boot folder, locate the new kernel image, and open /boot/config.txt for editing. For example:
      # List files in /boot
      pi@raspberrypi ~ $ ls /boot/ | grep vmlinuz
      vmlinuz-3.17.4-release+
      # Open config.txt for edit.
      nano /boot/config.txt
    2. In /boot/config.txt, add the following content or replace the kernel option with a line like this:
      ...
      # Assuming the vmlinuz-3.17.4-release+ is the kernel we want to activate.
      kernel=vmlinuz-3.17.4-release+
    3. Save /boot/config.txt and exit the editor.
  7. Reboot the Raspberry Pi with the new kernel activated:
    # Reboot the device.
    reboot

Adding BLE and router capabilities

To add Bluetooth low energy functionality to Linux, you must install BlueZ - Bluetooth Stack. This module also provides tools like hcitool, hciconfig, and so on.

If you followed the procedure described above, BlueZ is already installed. Otherwise, log in as root user and issue the following command to install it:

# Install BlueZ module.
apt-get install bluez

Having IPv6 connectivity requires distributing the global IPv6 prefix to Bluetooth devices. On Linux, you can use the Router Advertisement Daemon for this purpose. RADVD can periodically or on solicitation send Router Advertisement message.

See RADVD for Linux for more information about RADVD and how to configure and run it.

Additional configuration

By default, the debugfs file system is not mounted to a specific location in Raspbian OS. To be aligned with most Linux distributions, you should configure Raspbian OS to use /sys/kernel/debug as debugfs location.

The following commands can be used to mount debugfs:

# Log in as root user.
sudo su
# Proceed with caution.
# Mount debugfs file system.
mount -t debugfs none /sys/kernel/debug
# Check the contents of the folder.
ls /sys/kernel/debug

To make this change persistent, mount debugfs permanently by adding it to the /etc/fstab file.