Jun 27, 2016 0 Comments in IEEE 802.15.4, Learning, Peripheral, SPI by
Using 6LoWPAN on Cosino

The wireless transceiver can be bought at our shop as:

Connecting the device

In order to get access to the device you should consider the table below.

Mega 2560 extension

Signal J21
SCK 15
CS 10
GND 33

For further informations about the chip you can read the mrf24j40 datasheet.

Accessing the device

The kernel needs the correct DTS configuration and modules to recognize the device and load the driver.

Note: The kernel you’re running on Cosino must be at least the 4.1 version! If you have not upgraded the kernel yet, you can follow our guide at Cosino’s Linux Kernel.

DTS configuration

The SPI settings to put into the DTS file arch/arm/boot/dts/at91-cosino_mega2560.dts are reported in the patch below:

This patch is related to Cosino Mega 2560 but you can easily adapt it according to your hardware.

Kernel modules

The Linux Kernel needs the 6LoWPAN modules and the driver for mrf24j40 enabled as shown below in the make menuconfig output:

After all settings are in place just install the new kernel and reboot the system. If everything works well you should read the following kernel messages during the boot:

Also you can check the /proc/interrupt file as shown below:

Note: you can have a different settings in case you’re using different settings as above!

Setting up the Wpan-tools

Now you have to download and install the wpan-tools in order to configure the device but before you needs some prerequisite packages:

Then let’s download the wpan-tools using git:

Then enter into the new directory wpan-tools, compile and install the package as shown below:

Now we can set up the interface with channel 11 (2405 MHz) and PAN ID to 0x23.

If everything is correct, the right ifconfig output should be as below:

Do ping between two Cosino boards

To test your new 6lowpan network you have to set up another Cosino board as above but with a different extended address.
So follow the previous steps but remember to change the MAC address as below:

Now you can try to ping the other board at the inet6 address shown by the ifconfig command below:

Now from the other board you can do the following command and the ping should work as below: