BeagleBoneBlack IoT cape IEEE802.15.4 cape with Microchip MRF24J40MD component NGS IoT Bone (rev. MRF-1) Code : NGS_IoT_Bone_rev_MRF_1
Page intentionally left blank New Generation Sensors S.r.l. 2/16
Warranty, Warnings and Disclaimers This evaluation board/kit is intended for use for ENGINEERING DEVELOPMENT, DEMONSTRATION, OR EVALUATION PURPOSES ONLY and is not considered by New Generation Sensors S.r.l. to be a finished end product fit for general consumer use. Persons handling the product(s) must have electronics training and observe good engineering practice standards. As such, the goods being provided are not intended to be complete in terms of required design-, marketing-, and/or manufacturing-related protective considerations, including product safety and environmental measures typically found in end products that incorporate such semiconductor components or circuit boards. This evaluation board/kit does not fall within the scope of the European Union directives regarding electromagnetic compatibility, restricted substances (RoHS), and therefore may not meet the technical requirements of these directives or other related directives. Please read the User Manual and, specifically, the Warnings and Restrictions notice in the Systems Reference Manual of the BeagleBone Black you are using, prior to handling the product. This notice contains important safety information about temperatures and voltages. No license is granted under any patent right or other intellectual property right of Supplier covering or relating to any machine, process, or combination in which such Supplier products or services might be or are used. The Supplier currently deals with a variety of customers for products, and therefore our arrangement with the user is not exclusive. The Supplier assumes no liability for applications assistance, customer product design, software performance, or infringement of patents or services described herein. The NGS IoT Bone (rev. MRF-1) as purchased is warranted against defects in materials and workmanship for a period of 90 days from purchase. This warranty does not cover any problems occurring as a result of improper use, modifications, exposure to water, excessive voltages, abuse, or accidents. All boards will be returned via standard mail if an issue is found. If no issue is found or express return is needed, the customer will pay all shipping costs. New Generation Sensors S.r.l. 3/16
Page intentionally left blank New Generation Sensors S.r.l. 4/16
Revision History Version Changes Date 1.0 First version of the document 14/04/2016 New Generation Sensors S.r.l. 5/16
Page intentionally left blank New Generation Sensors S.r.l. 6/16
Table of Contents 1. Introduction...8 Scope... 8 Acronyms and abbreviations... 8 2. BBB pin description...9 3. Device setup... 11 Setup in kernel 3.8.13 with BBB Cape Manager and Device Tree overlay... 11 Setup in kernel 4.1.21 with Device Tree... 13 4. Communication setup...15 WPAN interface configuration... 15 6LoWPAN interface configuration... 16 New Generation Sensors S.r.l. 7/16
1. Introduction The NGS IoT Bone (rev. MRF-1) cape described in this document provides the IEEE802.15.4 interface capabilities for Ad-Hoc Internet of Things deployments. The cape embeds the Microchip MRF24J40MD module as standard 2.4 GHz RF transceiver. This solution creates a low-cost, low-data rate (up to 250kbps) Wireless Personal Area Network (WPAN). Scope This document describes the cape s behaviors and features, and also how to interact with it. Acronyms and abbreviations 6LoWPAN BBB DTB DTS I/O Acronym NGS IoT Bone (rev. MRF-1) SPI WPAN Table 1 - List of acronyms Description IPv6 over Low power Wireless Personal Area Networks Beagle Bone Black Device Tree Blob Device Tree Source Input / Output The BBB IoT Cape based on the IEEE802.15.4 described in this document Serial Periferal Interface (the MRF24J40 control interface) Wireless Personal Area Network New Generation Sensors S.r.l. 8/16
2. BBB pin description This cape has been developed to be fully compatible the Beagle Bone Black version. The pin map assignment based on the BBB (I/O) perspective is the following: Table 2 - P9 Header pin usage PIN Name on BBB Direction Description P9.23 GPIO1_17 O MRF24J40 reset P9.27 GPIO3_19 I MRF24J40 Interrupt P9.25 GPIO3_21 O MRF24J40 Wake P9.28 SPI1_CSO O SPI Chip Select P9.30 SPI1_D1 O SPI Serial Data Out P9.29 SPI1_D0 I SPI Serial Data In P9.31 SPI1_SCLK O SPI Clock Table 3 P2 Header pin usage PIN Name on BBB Direction Description P2.1 - Power 3.3V P2.2 - Power GND P2.3 I2C2_SCL O I2C SCL P2.4 I2C2_SDA I/O I2C SDA P2.5 UART1_TX O UART TX P2.6 UART1_RX I UART RX P2.7 SYS_5V Power 5 V P2.8 GND Power GND New Generation Sensors S.r.l. 9/16
P8 P9 P2 New Generation Sensors S.r.l. 10/16
3. Device setup In order to have the NGS IoT Bone (rev. MRF-1) fully working in the Linux environment some steps must be followed as a function of the Linux Kernel version used in the reference distribution. Setup in kernel 3.8.13 with BBB Cape Manager and Device Tree overlay The first step to have the device working with kernel 3.8.13 is to load the cape definition. Such a definition can be loaded through the command: echo BBB-MRF24J40 > /sys/devices/bone_capemgr*/slots To enable the device the file BBB-MRF24J40.dtbo must be copied in /lib/firmware. Such a dtbo file can be created with the following command: dtc O dtb o BBB-MRF24J40.dtb b 0 -@ BBB-MRF24J40.dts The BBB-MRF24J40.dts is reported in the following: /dts-v1/; /plugin/; / { compatible = "ti,beaglebone", "ti,beaglebone-black"; /* Identification */ part-number = "BBB-MRF24J40"; version = "00A0"; /* state the resources this cape uses */ exclusive-use = /* the pin header uses */ P9.23 /*gpio1_17*/ P9.25 /*gpio3_21*/ P9.27 /*gpio3_19*/ "P9.31", /* spi1_sclk */ "P9.29", /* spi1_d0 */ "P9.30", /* spi1_d1 */ "P9.28", /* spi1_cs0 */ /* the hardware IP uses */ "gpio1_17", "gpio3_21", "gpio3_19", New Generation Sensors S.r.l. 11/16
"spi1"; fragment@0 { target = <&am33xx_pinmux>; overlay { mrf24j40_cape_pins: pinmux_mrf24j40_cape_pins { pinctrl-single,pins = < 0x1a4 0x2f /* IRQ: mcasp0_fsr.gpio3_19 */ 0x1ac 0x2f /* SLP_TR: mcasp0_ahclkx.gpio3_21 */ 0x044 0x37 /* RESET: gpmc_a1.gpio1_17 */ >; bone_mrf24j40_spi1_pins: pinmux_bone_mrf24j40_spi1_pins { pinctrl-single,pins = < 0x190 0x33 /* mcasp0_aclkx.spi1_sclk, RX_ENABLED PULLUP MODE3 */ 0x194 0x33 /* mcasp0_fsx.spi1_d0, RX_ENABLED PULLUP MODE3 */ 0x198 0x33 /* mcasp0_axr0.spi1_d1, RX_ENABLED PULLUP MODE3 */ 0x19c 0x33 /* mcasp0_ahclkr.spi1_cs0, RX_ENABLED PULLUP MODE3 */ >; fragment@1 { target = <&spi1>; overlay { #address-cells = <1>; #size-cells = <0>; status = "okay"; pinctrl-names = "default"; pinctrl-0 = <&bone_mrf24j40_spi1_pins>; mrf24j40@0 { compatible = "mrf24j40mc"; reg = <0>; /* CHIPSEL */ spi-max-frequency = <6000000>; mode = <0>; pinctrl-names = "default"; pinctrl-0 = <&mrf24j40_cape_pins>; interrupt-parent = <&gpio2>; interrupts = <29>; New Generation Sensors S.r.l. 12/16
To check whether the cape has been loaded the following command must be executed: cat /sys/devices/bone_capemgr.*/slots Setup in kernel 4.1.21 with Device Tree To have the cape working with kernel 4.1.21 the right definition must be inserted in the BeagleBone Black Device Tree, then the reference dts file must be compiled. The cape definition to be inserted at the end of the kernel file /arch/arm/boot/dts/am335x-boneblack.dts is reported in the following: &am33xx_pinmux { spi1_pins: pinmux_spi1_pins { pinctrl-single,pins = < 0x190 (PIN_INPUT_PULLDOWN MUX_MODE3) /*sclk */ 0x194 (PIN_INPUT MUX_MODE3) /* d0 */ 0x198 (PIN_OUTPUT_PULLDOWN MUX_MODE3) /* d1 */ 0x19c (PIN_OUTPUT_PULLUP MUX_MODE3) /* cs0 */ 0x1a4 (PIN_INPUT MUX_MODE7) /* gpio3_19 */ 0x1ac (PIN_OUTPUT_PULLDOWN MUX_MODE7) /* gpio3_21 */ 0x044 (PIN_OUTPUT_PULLUP MUX_MODE7) /* gpio1_17 */ >; &spi1 { status = "okay"; pinctrl-names = "default"; pinctrl-0 = <&spi1_pins>; mrf24j40@0 { compatible = "mrf24j40mc"; spi-max-frequency = <6000000>; reg = <0>; /* CHIPSEL */ interrupts = <19 4>; interrupt-parent = <&gpio3>; mrf24j40-wake = <&gpio3 21 1>; mrf24j40-reset = <&gpio1 17 1>; To check whether the cape has been loaded the dmesg command can be used after the boot, and the following output must be shown whether everything is correct: New Generation Sensors S.r.l. 13/16
[ 15.683169] mrf24j40 spi2.0: probe(). IRQ: 141 Moreover, by using the iwconfig command a wpan0 interface appears, which can be enabled through the ifconfig wpan0 up command. As result the following output can be seen by simply running ifconfig : wpan0 Link encap:unspec HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 UP BROADCAST RUNNING NOARP MTU:127 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:300 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) An already compiled dts file supporting the NGS IoT Bone (rev. MRF-1) can be downloaded from ngssensors.it/en/. New Generation Sensors S.r.l. 14/16
4. Communication setup To have a fully working WPAN network the network interface must be properly configured. In the following the main configuration steps are reported, as well as how to set up a 6LoWPAN interface. Because of the lack of a 6LoWPAN support in the Linux kernel 3.8.13 the whole reported procedure refers to Linux kernel 4.1.21 only. WPAN interface configuration The wpan0 interface can be easily configured through wpan-tools, a userspace tools for Linux IEEE 802.15.4 stack. Wpan-tools can be downloaded at the link https://github.com/linux-wpan/wpan-tools. The following set of commands, which refers to version 0.6, can be used to change the transmission channel, the device MAC address, and the PAN-ID: iwpan dev wpan0 del iwpan phy phy0 set channel 0 23 iwpan phy phy0 interface add wpan0 type node 11:22:33:44:55:66:77:88 iwpan dev wpan0 set pan_id 0xabcd As a result the WPAN interface will have the following configuration parameters: iwpan phy wpan_phy phy0 supported channels: page 0: 11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26 current_page: 0 current_channel: 23, 2465 MHz cca_mode: Unknown CCA mode (0) tx_power: 0 iwpan dev phy#0 Interface wpan0 ifindex 8 wpan_dev 0x5 extended_addr 0x1122334455667788 short_addr 0x0002 pan_id 0xabcd type node max_frame_retries -1 min_be 3 max_be 5 max_csma_backoffs 4 lbt 0 ifconfig wpan0 Link encap:unspec HWaddr 11-22-33-44-55-66-77-88-00-00-00-00-00-00-00-00 New Generation Sensors S.r.l. 15/16
UP BROADCAST RUNNING NOARP MTU:127 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:300 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) 6LoWPAN interface configuration Once the wpan interface has been configured the 6lowpan interface can be created through the following commands: ip link add link wpan0 name lowpan0 type lowpan ip link set lowpan0 up To check whether a lowpan interface is running use the ifconfig command: ifconfig lowpan0 Link encap:unspec HWaddr 11-22-33-44-55-66-77-88-00-00-00-00-00-00-00-00 inet6 addr: fe80::1322:3344:5566:7788/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1280 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) wpan0 Link encap:unspec HWaddr 11-22-33-44-55-66-77-88-00-00-00-00-00-00-00-00 UP BROADCAST RUNNING NOARP MTU:127 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:34 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:300 RX bytes:0 (0.0 B) TX bytes:3066 (3.0 KB) New Generation Sensors S.r.l. 16/16