Revision as of 02:23, 4 January 2014 by Craig Peacock (Talk | contribs)

Using the Microchip IEEE 802.15.4 Radio on the BeagleBone Black

Beagle Bone Black with a Sure Electronics GP-GC500:
BeagleBoneBlack_MRF24J40.png

Custom made cape:
BeagleBoneBlack_MRF24J40_IEEE802154_6LOWPAN_CAPE.jpg

To load support for the Microchip MRF24J40 execute the following:

#echo BB-BONE-MRF24J40 > /sys/devices/bone_capemgr.8/slots

This should result in following kernel debug messages:

[  883.483409] bone-capemgr bone_capemgr.8: part_number 'BB-BONE-MRF24J40', version 'N/A'
[  883.483585] bone-capemgr bone_capemgr.8: slot #6: specific override
[  883.483660] bone-capemgr bone_capemgr.8: bone: Using override eeprom data at slot 6
[  883.483716] bone-capemgr bone_capemgr.8: slot #6: 'Bone-MRF24J40,00A0,Signal 11 Softwa,BB-BONE-MRF24J40'
[  883.484028] bone-capemgr bone_capemgr.8: slot #6: Requesting firmware 'cape-bone-mrf24j40-00A0.dtbo' for board-name 'Bone-MRF24J40', version '00A0'
[  883.484113] bone-capemgr bone_capemgr.8: slot #6: dtbo 'cape-bone-mrf24j40-00A0.dtbo' loaded; converting to live tree
[  883.484629] bone-capemgr bone_capemgr.8: slot #6: #2 overlays
[  883.594180] edma-dma-engine edma-dma-engine.0: allocated channel for 0:43
[  883.594350] edma-dma-engine edma-dma-engine.0: allocated channel for 0:42
[  883.595019] mrf24j40: probe(). IRQ: 205
[  883.599630] bone-capemgr bone_capemgr.8: slot #6: Applied #2 overlays.

Kernel Patch Typo - Incompatible with baseboard

The current kernel patches has a typo in the /kernel/firmware/capes/cape-bone-mrf24j40-00A0.dts that may cause the cape manager to report it is incompatible with the baseboard. i.e.:

[  417.682368] bone-capemgr bone_capemgr.8: slot #8: Requesting firmware 'cape-bone-mrf24j40-00A0.dtbo' for board-name 'Bone-MRF24J40', version '00A0'
[  417.682392] bone-capemgr bone_capemgr.8: slot #8: dtbo 'cape-bone-mrf24j40-00A0.dtbo' loaded; converting to live tree
[  417.682595] bone-capemgr bone_capemgr.8: slot #8: Incompatible with baseboard for 'BB-BONE-MRF24J40'
[  417.692228] bone-capemgr bone_capemgr.8: slot #8: Failed verification 

If this is the case, change the following line

compatible = "ti,beaglebone", "ti-beaglebone-black";

to

compatible = "ti,beaglebone", "ti,beaglebone-black"; 

and rebuild.

Unable to get IRQ

Device Tree support is gradually getting more mature. Changes were made after version 3.8 of the kernel that may result with the MRF24J40 driver being unable to get an IRQ, similar to that below:

[   46.261282] edma-dma-engine edma-dma-engine.0: allocated channel for 0:43
[   46.261342] edma-dma-engine edma-dma-engine.0: allocated channel for 0:42
[   46.261755] mrf24j40: probe(). IRQ: 0
[   46.266992] mrf24j40 spi1.0: Unable to get IRQ
[   46.277735] mrf24j40: probe of spi1.0 failed with error -22
[   46.280241] bone-capemgr bone_capemgr.6: slot #7: Applied #2 overlays.

If this is the case change the following lines in /kernel/firmware/capes/cape-bone-mrf24j40-00A0.dts from

interrupt-parent = <&gpio2>;
interrupts = <29>;

to

#interrupt-cells = <2>;
interrupt-parent = <&gpio1>;
interrupts = <29 0x8>;

Rebuild and then copy the .dtbo to the /lib/firmware path on your root filesystem.

dtc -O dtb -o BB-BONE-MRF24J40-00A0.dtbo -b o -@ cape-bone-mrf24j40-00A0.dts

I/O Conflict with HDMI

The MRF24J40 shares I/O (P9.31) with the HDMI Interface. If you don't disable the HDMI interface on boot (or unload it - glup), the following error may result:

[   23.701229] bone-capemgr bone_capemgr.8: slot #7: Requesting firmware 'cape-bone-mrf24j40-00A0.dtbo' for board-name 'Bone-MRF24J40', version '00A0'
[   23.715092] bone-capemgr bone_capemgr.8: slot #7: dtbo 'cape-bone-mrf24j40-00A0.dtbo' loaded; converting to live tree
[   23.726858] bone-capemgr bone_capemgr.8: slot #7: BB-BONE-MRF24J40 conflict P9.31 (#5:BB-BONELT-HDMI)
[   23.736629] bone-capemgr bone_capemgr.8: slot #7: Failed verification

To disable the HDMI interface, see the example at the bottom of this page.

Testing your MRF24J40 Hardware

The easiest way of testing your MRF24J40 interface hardware is using izchat to send simple text messages between two 802.15.4 interfaces. Izchat is part of the Linux Zigbee User Space Tools

Device 1:

# echo BB-BONE-MRF24J40 > /sys/devices/bone_capemgr.9/slots
# iz add wpan-phy0
Registered new device ('wpan0') on phy wpan-phy0
# iz set wpan0 777 8001 11
# ifconfig wpan0 up
# izchat 777 8001 8002
> hello
how are you?

Device 2:

# echo BB-BONE-MRF24J40 > /sys/devices/bone_capemgr.9/slots
# iz add wpan-phy0
Registered new device ('wpan0') on phy wpan-phy0
# iz set wpan0 777 8002 11
# ifconfig wpan0 up
# izchat 777 8002 8001
hello
> how are you?

6LoWPAN

Once your hardware has been verified, you can set up 6LoWPAN (IPv6 over Low power Wireless Personal Area Networks).

On Device 1 run:

iz add wpan-phy0
ip link set wpan0 address a0:0:0:0:0:0:0:1
iz set wpan0 777 8001 11
ifconfig wpan0 up
ip link add link  wpan0 name lowpan0 type lowpan
ip link set lowpan0 address a0:0:0:0:0:0:0:1
ifconfig lowpan0 up

Device 2:

iz add wpan-phy0
ip link set wpan0 address a0:0:0:0:0:0:0:2
iz set wpan0 777 8002 11
ifconfig wpan0 up
ip link add link wpan0 name lowpan0 type lowpan
ip link set lowpan0 address a0:0:0:0:0:0:0:2
ifconfig lowpan0 up

Once stacks are set up on both hosts, you can ping each other. From Device 1:

root@beaglebone:~# ping6 fe80::a200:0:0:2%lowpan0
PING fe80::a200:0:0:2%lowpan0 (fe80::a200:0:0:2%lowpan0): 56 data bytes
64 bytes from fe80::a200:0:0:2: seq=0 ttl=64 time=21.200 ms
64 bytes from fe80::a200:0:0:2: seq=1 ttl=64 time=10.748 ms
64 bytes from fe80::a200:0:0:2: seq=2 ttl=64 time=9.459 ms
64 bytes from fe80::a200:0:0:2: seq=3 ttl=64 time=11.259 ms
64 bytes from fe80::a200:0:0:2: seq=4 ttl=64 time=17.628 ms
64 bytes from fe80::a200:0:0:2: seq=5 ttl=64 time=10.599 ms
64 bytes from fe80::a200:0:0:2: seq=6 ttl=64 time=13.174 ms
64 bytes from fe80::a200:0:0:2: seq=7 ttl=64 time=12.962 ms
64 bytes from fe80::a200:0:0:2: seq=8 ttl=64 time=9.473 ms
64 bytes from fe80::a200:0:0:2: seq=9 ttl=64 time=10.595 ms