Low Power Wireless: 6LoWPAN, IEEE802.15.4 and the Raspberry Pi

In the linux-rpi2 directory, set up a configuration file for the RPi 2B with:


make bcm2709_defconfig

Then run menuconfig to do two things:

1) Install the device driver as a module from the menu entry:


Device Drivers
--> Network device support
  --> IEEE 802.15.4 drivers

2) Install 6LoWPAN support as a module from the menu entry:


Networking support
--> Networking options
  --> IEEE Std 802.15.4 Low-Rate Wireless Personal Area
      Networks support

Build the kernel and associated files with:


make zImage modules dtbs -j4

Five hours later, install the modules and dtbs files:


sudo make modules_install dtbs_install

The safest way to install the kernel is to copy it to an appropriate location. When I run make kernelversion in the source tree, it tells me I have built 4.7.2. So I use that number in copying the kernel:


sudo cp arch/arm/boot/zImage /boot/kernel.4.7.2.img

That way I don't destroy any existing images, so I have a safe fallback to the previous system.

Finally, you need to tell the RPi to boot into the new kernel. As root, edit /boot/config.txt and add these lines at the end:


kernel=kernel.4.7.2.img
device_tree=bcm2709-rpi-2-b.dtb
dtoverlay=at86rf233

What does that do? First, it tells the RPi to use the new boot image kernel.4.7.2.img. Second—and this is currently ARM-specific—it tells the RPi to pick up hardware default values using the device tree system from bcm2709-rpi-2-b.dtb. And third—and this is RPi-specific—it says to add in the at86rf233 device in an additional file to the device tree file.

Finally...reboot. If all went well, you should have the new kernel running. Check this with:


uname -a

It should show something like this:


Linux raspberrypi 4.7.2-v7+ #1 SMP Fri Aug 26 15:45:29 UTC 2016
 ↪armv7l GNU/Linux

If it didn't boot or showed the wrong kernel, take your SD card back to somewhere else so you can comment out the lines you added to /boot/config.txt. Back on the RPi, reboot back into the default kernel, and try to figure out which step went wrong. I skipped some steps from Sebastian's guide because I didn't need them, but if your system isn't working, pay very close attention to his guide. He seems to be pretty diligent about updating it.

Setting Up 6LoWPAN

Are you there yet? Sorry, no. You've built and installed an upstream kernel with 6LoWPAN support. You're more than half-way there though. To configure the 6LoWPAN stack, you need another tool, wpan-tools. Get this from GitHub:


git clone --depth 1 https://github.com/linux-wpan/wpan-tools.git
 ↪wpan-tools

Before you can build this though, you need autoreconf:


sudo apt-get install dh-autoreconf

Then in the wpan-tools directory, you can run:


./autogen.sh
./configure CFLAGS='-g -O0' --prefix=/usr --sysconfdir=/etc
 ↪--libdir=/usr/lib
make
sudo make install

______________________

Jan Newmarch has written many books and papers about software engineering, network programming, user interfaces and artificial intelligence, and he is currently digging into the IoT.