-
Notifications
You must be signed in to change notification settings - Fork 0
How to install 6LoWPAN Linux Kernel on Raspberry Pi
Install a fairly new (next) Linux kernel on a raspberry pi, which is able to run IEEE802.15.4 devices (i.e. the Atmel AT86RF233) and 6LoWPAN.
NOTE There is much room for improvement here, so follow the steps with caution :-)
http://elinux.org/RPi_Low-level_peripherals
git clone git@github.com:raspberrypi/linux.git linux-rpi
cd linux rpi
git checkout rpi-4.0.y
git clone git@github.com:raspberrypi/firmware.git firmware
cd firmware
git checkout next
http://openlabs.co/blog/archives/1-6LoWPAN-kernel-on-a-Raspberry-Pi Don't forget the lib dir
Follow these sections:
- cross-compiling
- building the Linux kernel
- patching the device tree
Boot options -> Use appended device tree blob to zImage
-- is this needed? --
http://elinux.org/Raspberry_Pi_Kernel_Compilation
http://elinux.org/Raspberry_Pi_Kernel_Compilation
http://elinux.org/Raspberry_Pi_Kernel_Compilation
https://github.com/raspberrypi/linux/wiki/How-to-boot-using-device-tree
(but remove the option init_emmc_clock
)
sudo apt-get install libnl-3-dev libnl-genl-3-dev
####get them from here:
https://github.com/linux-wpan/wpan-tools
The current master seems to fail while configuring...
cd wpan-tools
./autogen.sh
./configure
http://wpan.cakelab.org/releases/wpan-tools-0.4.tar.gz
tar xfvz wpan-tools-0.4.tar.gz
cd wpan-tools-0.4.tar.gz
./configure
make
sudo make install
For testing, follow some of the instructions at http://wpan.cakelab.org/#_how_to_8217_s
This how-to will guide you to:
- configure the Raspberry Pi Kernel for 802.15.4 and 6LoWPAN
- patch in support for the openlabs Raspberry-Pi-802.15.4-radio device
- compile a recent Linux kernel (rpi-4.0.y) for the Raspberry Pi
- and use the new built Kernel on your Raspberry Pi
To start off, we obtain the latest Raspbian image and flash it on our SDCard.
- We download the official image from the Raspbian download site (scroll down a bit there),
- and follow their provided guides to flash the downloaded Raspbian image to our SDCard.
- Then we Plug the SDCard and boot our Raspberry Pi.
- Note, if you login the first time, the username is
pi
and the password israspberry
- Additional note, watch out if you have a german keyboard layout, the keys
y
andz
are switched. - In the first run of our Raspberry, we set the filesystem to be expanded and set additional options for the system using the
raspi-config
tool. Then we let the Raspberry Pi reboot to finish the installation. - After the reboot we login and update the system by entering
sudo apt-get update
followed bysudo apt-get upgrade
.
We focus on cross compilation here, since we don't want to spend a night watching the build process ;).
To start, we need an appropriate and recent cross compiler (GCC for ARM) to build a new Raspbian kernel.
The Raspberry Pi requires a GCC for cortex a7
processors with hard fp (arm-gnueabihf
) support.
So, our choice for a suiting GCC here is the Linaro GCC 4.9, which fulfills the requirements.
Note, you can use any other suiting GCC for the build process.
We download the appropriate tar.xz
file and decompress it, e.g. directly in directory where we downloaded the file to.
To make the cross GCC ready to build things, we open a terminal and export the PATH
to the newly decompressed GCC bin directory.
We enter:
export PATH=$PATH:/home/<myusername>/Downloads/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf/bin
Doing so we tell the environment (of the current terminal) the location of the cross GCC executables.
(Please note, this may differ for your system).
To test if the export succeeded, we type arm-linux-gnueabihf-gcc --version
, which should provides us with the version information of our cross GCC.
If not, the path export seems to be failed. You can check the export by entering $PATH
in the terminal, which shows the content of the exported variable.
Please note, if you use a 64 bit Linux you may also need to install multilib support, i.e. i386 support.
Now we download the latest Raspberry Pi kernel sources from their Git repository.
We enter:
git clone https://github.com/raspberrypi/linux.git linux-rpi
cd linux rpi
git checkout rpi-4.0.y
cd ..
Additionally we also obtain the latest firmware files.
We enter:
git clone https://github.com/raspberrypi/firmware.git firmware
cd firmware
git checkout next
cd ..
Now we have everything prepared to start configuring and building our new kernel.
First we configure the sources with an appropriate configuration for the Raspberry Pi.
We switch in the kernel source folder, by entering cd linux-rpi
followed by:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2835_defconfig
This provides us with an initial and basically complete configuration for the new kernel. In addition, we need to enable 802.15.4, 6LoWPAN and our specific transmission devices in the kernel, since its not provided in the default configuration.
We basically follow the openlabs guide, which instructs to setup an appropriate configuration for 802.15.4 and 6LoWPAN using an AT86RF233 SPI transceiver for a net-next kernel on a Raspberry Pi.
Contrary to the guide, we first patch the device tree, to enable support for the AT86RF233 SPI transceiver.
We load the arch/arm/boot/dts/bcm2835-rpi-b.dts
file in our favorite editor and append the following part at the end:
&spi0 {
status="okay";
spidev@0{
status = "disabled";
};
spidev@1{
status = "disabled";
};
at86rf233@0 {
compatible = "atmel,at86rf233";
reg = <0>;
interrupts = <23 1>;
interrupt-parent = <&gpio>;
reset-gpio = <&gpio 24 1>;
sleep-tpio = <&gpio 25 1>;
spi-max-frequency = <500000>;
};
};
This enables SPI on the Raspberry Pi and tells the kernel that our AT86RF233 SPI transceiver may be plugged over SPI (Pins 15-26) to it.
Now that we set-up the SPI connection for our AT86RF233 transceiver, we move on to configure our kernel for providing 802.15.4, 6LoWPAN and the transceiver device drivers.
We enter:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
which provides us with the kernel configuration menu to configure/enable the above named features.
- First we enable 802.15.4 and 6LoWPAN support in our kernel.
We traverse the menu to:
Networking support
--> Networking options
--> IEEE Std 802.15.4 Low-Rate Wireless Personal Area Networks support
enable the item if not already enabled, and enter the sub-menu of this item.
There we set all options either to be loaded as module <M>
or as direct part of the kernel <*>
.
We < Exit >
back to Networking options
and set 6LoWPAN Support
if not already set.
Then traverse back to root menu.
- Now we enable the drivers for our 802.15.4 devices (e.g. our AT86RF233 SPI transceiver).
We traverse to:
Device Drivers
--> Network device support
--> IEEE 802.15.4 drivers
enable it if not already enabled, and enter the sub-menu.
There we set our driver(s) either to be loaded as module <M>
or as direct part of the kernel <*>
,
e.g. <M> AT86RF230/231/233/212 transceiver driver
.
Then we traverse back to root menu.
- Finally we put in some default Boot options We traverse to:
Boot options
--> () Default kernel command string
hit the enter key and type
console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait
in the "popped-up" input field.
Then we hit < Ok >
and got back to the root menu.
There we hit < Save >
and store the configuration in the proposed file (.config
) followed by
< Exit >
to leave the kernel configuration menu.
After we finished our configuration, we fire the build process of our new kernel.
We enter:
CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm make zImage modules dtbs -j8
and have break.
When all is finished, we collect all built modules together in a .mods
folder.
We enter:
CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm INSTALL_MOD_PATH=.mods make modules_install
which copies all *.ko
files to the provided directory, i.e. .mods
.
Now that we built a recent kernel we need to copy with the modules and the firmware to our SDCard.
First the kernel:
sudo cp arch/arm/boot/dts/*.dtb /media/<myusername>/boot/
sudo cp arch/arm/boot/dts/overlays/*.dtb* /media/<myusername>/boot/overlays
sudo scripts/mkknlimg arch/arm/boot/zImage /media/<myusername>/boot/kernel.img
After this, we copy the modules:
sudo cp -r .mods/lib/* /media/<myusername>/<SDCardpatitionname>/lib
and the prebuilt firmware files for hard fp:
cd ..
cd firmware
sudo rm -rf /media/<myusername>/<SDCardpatitionname>/opt/vc
sudo cp -r hardfp/opt/* /media/<myusername>/<SDCardpatitionname>/opt
As last step we need to tell the bootloader which device configuration it should use, i.e. bcm2835-rpi-b.dtb
.
We fire our favorite editor open the /media/<myusername>/boot/config.txt
file, append
device_tree=bcm2835-rpi-b.dtb
device_tree_address=0x100
at the end and save it.
That's it :D our SDCard is prepared to run the new kernel.
So, we unmount the SDCard, plug it in the Raspberry Pi and let it boot. If everything went fine, we should see the usual boot process. If you see a colored screen permanently (in case you plugged a monitor to your Raspberry Pi) something went wrong.
After logging in, we need the WPAN tools to setup and use one of our 802.15.14 devices.
First we need to install the dh-autoreconf
package to be able to build the recent WPAN tools.
We type
sudo apt-get install dh-autoreconf
Then we clone the latest wpan-tools sources
git clone https://github.com/linux-wpan/wpan-tools
cd wpan-tools
build them
./autogen.sh
./configure CFLAGS='-g -O0' --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib
make
and finally install them
sudo make install
For testing, follow some of the instructions at http://wpan.cakelab.org/#_how_to_8217_s
RIOT - The friendly Operating System for the Internet of Things
Homepage | [GitHub] (https://github.com/RIOT-OS/) | Developers Mailing List | Users Mailing List | Twitter @RIOT_OS
- Family: ARM
- Board: Airfy Beacon
- Board: Arduino Due
- Board: CC2538DK
- Board: HikoB Fox
- Board: IoT LAB M3
- Board: LimiFrog-v1
- Board: mbed_lpc1768
- Board: MSB-IoT
- Board: MSBA2
- Board: Nucleo-L1
- Board: Nucleo-F334
- Board: Nucleo-F303
- Board: Nucleo-F091
- Board: Mulle
- Board: OpenMote
- Board: PCA1000x (nRF51822 Development Kit)
- Board: Phytec phyWAVE-KW22
- Board: RFduino
- Board: Samr21 xpro
- Board: Spark Core
- Board: STM32F0discovery
- Board: STM32F3discovery
- Board: STM32F4discovery
- Board: UDOO
- Board: yunjia-nrf51822
- Family: ATmega
- Board: Arduino Mega2560
- Family: MSP430
- Board: MSB-430H
- Board: TelosB
- Board: WSN430
- Board: Zolertia Z1
- Board: eZ430-Chronos
- Family: native
- Board: native
- Family: x86
- Board: Intel Galileo