dcsimg
Skip to end of metadata
Go to start of metadata

Introduction

This page will show you step-by-step how to interface a NimbeLink cape to the BeagleBone Black/Green.

Hardware Requirements

BeagleBone Black at Digi-Key
BeagleBone Green at Digi-Key
NimbeLink Beaglebone Black IOT cape:
NL-AB-BBBC at Digi-Key
 
XBee XB24CZ7WIT-004 at Digi-Key

Software Requirements

 

Install latest console image to eMMC

Today the latest version is: 2016-01-03 (these are just weekly snapshots, so always check for the latest)

Flasher: (console) (BeagleBone Black/Green eMMC)
wget https://rcn-ee.com/rootfs/bb.org/testing/2016-01-03/console/BBB-eMMC-flasher-debian-8.2-console-armhf-2016-01-03-2gb.img.xz
sha256sum: ecd682d199d98abbff46e187cd1ccb51e9776645a5aa28f35d0d5e9c92127ec4

Insert microSD into pc adapter and check device node name (in our case /dev/sdd):

voodoo@hades:~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 465.8G  0 disk 
└─sda1   8:1    0 465.8G  0 part /
sdd      8:48   1   7.4G  0 disk 
└─sdd1   8:49   1   7.4G  0 part 

Download the *.img.xz and matching *.bmap file, and write to microSD card via bmaptools:

voodoo@hades:~$ wget https://rcn-ee.com/rootfs/bb.org/testing/2016-01-03/console/BBB-eMMC-flasher-debian-8.2-console-armhf-2016-01-03-2gb.img.xz
voodoo@hades:~$ wget https://rcn-ee.com/rootfs/bb.org/testing/2016-01-03/console/BBB-eMMC-flasher-debian-8.2-console-armhf-2016-01-03-2gb.bmap
 
voodoo@hades:~$ sudo bmaptool copy --bmap BBB-eMMC-flasher-debian-8.2-console-armhf-2016-01-03-2gb.bmap  BBB-eMMC-flasher-debian-8.2-console-armhf-2016-01-03-2gb.img.xz /dev/sdd
[sudo] password for voodoo: 
bmaptool: info: block map format version 2.0
bmaptool: info: 435200 blocks of size 4096 (1.7 GiB), mapped 79584 blocks (310.9 MiB or 18.3%)
bmaptool: info: copying image 'BBB-eMMC-flasher-debian-8.2-console-armhf-2016-01-03-2gb.img.xz' to block device '/dev/sdd' using bmap file 'BBB-eMMC-flasher-debian-8.2-console-armhf-2016-01-03-2gb.bmap'
bmaptool: info: 100% copied
bmaptool: info: synchronizing '/dev/sdd'
bmaptool: info: copying time: 1m 20.9s, copying speed 3.8 MiB/sec

Insert microSD into the first BeagleBone Black/Green and wait for flashing procedure to finish. (device should shutdown)

Enable g_serial on usb mini connector

Since we will be using an NimbeLink cape, we will be losing access to the J1 serial debug header on the baseboard.  So let's enable "g_serial" over the usb mini by default.  We can have current am335x_evm boot script to this for us, by removing "udhcpd"

https://github.com/RobertCNelson/boot-scripts/blob/master/boot/am335x_evm.sh#L145

#If image file is found, use it for g_multi
if [ -f ${usb_image_file} ] ; then
	modprobe g_multi file=${usb_image_file} cdrom=0 ro=0 stall=0 removable=1 nofua=1 ${g_network} || true
#In a single partition setup, dont load g_multi, as we could trash the linux file system...
elif [ "x${root_drive}" = "x/dev/mmcblk0p1" ] || [ "x${root_drive}" = "x/dev/mmcblk1p1" ] ; then
	if [ -f /usr/sbin/udhcpd ] || [ -f /usr/sbin/dnsmasq ] ; then
		#Make sure (# CONFIG_USB_ETH_EEM is not set), otherwise this shows up as "usb0" instead of ethX on host pc..
		modprobe g_ether ${g_network} || true
	else
		#serial:
		modprobe g_serial || true
	fi
else
	boot_drive="${root_drive%?}1"
	modprobe g_multi file=${boot_drive} cdrom=0 ro=0 stall=0 removable=1 nofua=1 ${g_network} || true
fi

Let's remove udhcpd

debian@beaglebone:~$ sudo apt-get remove udhcpd --purge
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  udhcpd*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 88.1 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 12104 files and directories currently installed.)
Removing udhcpd (1:1.22.0-9+deb8u1) ...
Purging configuration files for udhcpd (1:1.22.0-9+deb8u1) ...

On the next reboot:

[13188.095975] usb 5-1.4: new high-speed USB device number 5 using xhci_hcd
[13188.186421] usb 5-1.4: New USB device found, idVendor=0525, idProduct=a4a7
[13188.186426] usb 5-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[13188.186428] usb 5-1.4: Product: Gadget Serial v2.4
[13188.186430] usb 5-1.4: Manufacturer: Linux 4.1.13-ti-r34 with musb-hdrc
[13188.200414] cdc_acm 5-1.4:2.0: ttyACM0: USB ACM device
[13188.200922] usbcore: registered new interface driver cdc_acm
[13188.200925] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

Using gtkterm we can get access via:

gtkterm -p /dev/ttyACM0 -s 115200 &

Install common tools

For this project we are going to use just a few tools on top of the base console image.

sudo apt-get update ; sudo apt-get install bc git-core i2c-tools picocom ppp python-dev python-setuptools usbutils

Update /boot/uEnv.txt to use the correct dtb for NimbeLink and eMMC usage

sudo sed -i 's/#dtb=$/dtb=am335x-boneblack-emmc-overlay.dtb/' /boot/uEnv.txt

Install device tree overlays for NimbeLink cape

git clone https://github.com/beagleboard/bb.org-overlays --depth=1
cd ./bb.org-overlays
./dtc-overlay.sh
./install.sh
cd ~/

Update Kernel (the 2016-01-03 default kernel lacks the driver for the iio based temp sensor we are using in this example.)

cd /opt/scripts/tools/
git pull
sudo ./update_kernel.sh --ti-rt-channel --lts-4_1
cd ~/

Install Exoline

git clone https://github.com/exosite/exoline --depth=1
cd ./exoline
sudo python setup.py install
cd ~/

Disable eth0

sudo sed -i 's/auto eth0$/#auto eth0/' /etc/network/interfaces
sudo sed -i 's/iface eth0 inet dhcp$/#iface eth0 inet dhcp/' /etc/network/interfaces

Cleanup and Shutdown system via:

sudo apt-get clean ; sudo systemctl poweroff

Install NimbeLink and powerup BeagleBone Black/Green and verify cape is installed, since j1 debug is hidden use the usb port:

gtkterm -p /dev/ttyACM0 -s 115200 &
debian@beaglebone:~$ dmesg | grep bone
[    3.976746] bone_capemgr bone_capemgr: Baseboard: 'A335BNLT,,BBG115091797'
[    3.976783] bone_capemgr bone_capemgr: compatible-baseboard=ti,beaglebone-black - #slots=4
[    4.032343] bone_capemgr bone_capemgr: slot #0: No cape found
[    4.092306] bone_capemgr bone_capemgr: slot #1: No cape found
[    4.152301] bone_capemgr bone_capemgr: slot #2: No cape found
[    4.182329] bone_capemgr bone_capemgr: slot #3: 'Skywire Beaglebone Cape,00D0,Nimbelink,NL-AB-BBBC'
[    4.182849] bone_capemgr bone_capemgr: initialized OK.
[    4.211219] bone_capemgr bone_capemgr: slot #3: dtbo 'NL-AB-BBBC-00D0.dtbo' loaded; overlay id #0

debian@beaglebone:~$ cat /sys/devices/platform/bone_capemgr/slots 
 0: PF----  -1 
 1: PF----  -1 
 2: PF----  -1 
 3: P---L-   0 Skywire Beaglebone Cape,00D0,Nimbelink,NL-AB-BBBC

 

Clone eMMC

Insert a microSD into BeagleBone Black/Green that we will use to clone the eMMC to the additional device.

debian@beaglebone:~$ lsblk
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk0boot0 179:8    0    2M  1 disk 
mmcblk0boot1 179:16   0    2M  1 disk 
mmcblk0      179:0    0  3.6G  0 disk 
`-mmcblk0p1  179:1    0  3.6G  0 part /
mmcblk1      179:24   0  3.7G  0 disk <<< Inserted microSD >>>
`-mmcblk1p1  179:25   0  1.7G  0 part 

Run "beaglebone-black-make-microSD-flasher-from-eMMC.sh" script

cd /opt/scripts/tools/eMMC
sudo ./beaglebone-black-make-microSD-flasher-from-eMMC.sh

Progress:

-----------------------------
Version: [1.20151007: gpt partitions with raw boot...]
-----------------------------
copying: [/dev/mmcblk0] -> [/dev/mmcblk1]
lsblk:
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
mmcblk0boot0 179:8    0    2M  1 disk 
mmcblk0boot1 179:16   0    2M  1 disk 
mmcblk0      179:0    0  3.6G  0 disk 
`-mmcblk0p1  179:1    0  3.6G  0 part /
mmcblk1      179:24   0  3.7G  0 disk 
`-mmcblk1p1  179:25   0  1.7G  0 part 
-----------------------------
df -h | grep rootfs:
-----------------------------
update-initramfs: Generating /boot/initrd.img-4.1.13-ti-rt-r39
<<< RUNNING >>>

Shutdown system via:

sudo systemctl poweroff

Remove "microSD" and flash other BeagleBone Black/Green devices.

XBee Setup

Download and install XCTU: http://www.digi.com/products/xbee-rf-solutions/xctu-software/xctu

Gateway Xbee: (13A200 40F536D8)
PAN ID: 4113
Coordinator Enable: Enabled [1]
 
Sensor Xbee: (13A200 40E5F1AD)
PAN ID: 4113
Destination Address High: 13A200
Destination Address Low: 40F536D8

Test, with both Xbee's installed in their ownNimbeLink cape:

echo "test" > /dev/ttyS2

Temperature Sensor

Add device:

sudo sh -c "echo si7005 0x40 > /sys/bus/i2c/devices/i2c-2/new_device"
 
debian@beaglebone:~$ dmesg | grep i2c-2
[  228.452700] i2c i2c-2: new_device: Instantiated device si7005 at 0x40

Look at the device:

debian@beaglebone:~$ ls /sys/bus/iio/devices/iio\:device0/in_temp*
/sys/bus/iio/devices/iio:device0/in_temp_offset
/sys/bus/iio/devices/iio:device0/in_temp_raw
/sys/bus/iio/devices/iio:device0/in_temp_scale
 
debian@beaglebone:~$ cat /sys/bus/iio/devices/iio:device0/in_temp*     
-6400
9704
7.812500

Conversion:

T = ((in_temp0_raw + in_temp0_offset) * in_temp0_scale) / 1000
T = ((9704 + -6400) * 7.812500) / 1000
T = (3304 * 7.812500) / 1000
T = 25812.5 / 1000
T = 25.8125	(C) 78.4625 (F)

Script the conversion using bc:

#!/bin/bash -e

in_temp_raw=$(cat /sys/bus/iio/devices/iio:device0/in_temp_raw || true)
in_temp_offset=$(cat /sys/bus/iio/devices/iio:device0/in_temp_offset || true)
in_temp_scale=$(cat /sys/bus/iio/devices/iio:device0/in_temp_scale || true)
 
if [ ! "x${in_temp_raw}" = "x" ] && [ ! "x${in_temp_offset}" = "x" ] && [ ! "x${in_temp_scale}" = "x" ] ; then
	temp=$(echo "${in_temp_raw} + ${in_temp_offset}" | bc)
	temp=$(echo "scale=5; ${temp} * ${in_temp_scale}" | bc)
	temp=$(echo "scale=5; ${temp} / 1000" | bc)
	echo "${temp}"
fi

Now send that data padded with a cksum over the serial port:

#!/bin/bash -e

port="/dev/ttyS2"

send_data () {
        date_cksum=$(echo ${data} | cksum | awk '{print $1}')
        echo "\$${data}*${date_cksum}#"
        echo -e "\$${data}*${date_cksum}#\n" > ${port}
}

stty -F ${port} raw speed 9600 &> /dev/null

in_temp_raw=$(cat /sys/bus/iio/devices/iio:device0/in_temp_raw || true)
in_temp_offset=$(cat /sys/bus/iio/devices/iio:device0/in_temp_offset || true)
in_temp_scale=$(cat /sys/bus/iio/devices/iio:device0/in_temp_scale || true)
 
if [ ! "x${in_temp_raw}" = "x" ] && [ ! "x${in_temp_offset}" = "x" ] && [ ! "x${in_temp_scale}" = "x" ] ; then
	temp=$(echo "${in_temp_raw} + ${in_temp_offset}" | bc)
	temp=$(echo "scale=5; ${temp} * ${in_temp_scale}" | bc)
	temp=$(echo "scale=5; ${temp} / 1000" | bc)
	data="TEXT,TEMP0,${temp},"
    send_data
fi

and load the iio driver if not loaded (assumes root)

#!/bin/bash -e

port="/dev/ttyS2"

send_data () {
        date_cksum=$(echo ${data} | cksum | awk '{print $1}')
        echo "\$${data}*${date_cksum}#"
        echo -e "\$${data}*${date_cksum}#\n" > ${port}
}

stty -F ${port} raw speed 9600 &> /dev/null

if [ ! -f /sys/bus/iio/devices/iio:device0/in_temp_raw ] ; then
	echo si7005 0x40 > /sys/bus/i2c/devices/i2c-2/new_device
fi

in_temp_raw=$(cat /sys/bus/iio/devices/iio:device0/in_temp_raw || true)
in_temp_offset=$(cat /sys/bus/iio/devices/iio:device0/in_temp_offset || true)
in_temp_scale=$(cat /sys/bus/iio/devices/iio:device0/in_temp_scale || true)
 
if [ ! "x${in_temp_raw}" = "x" ] && [ ! "x${in_temp_offset}" = "x" ] && [ ! "x${in_temp_scale}" = "x" ] ; then
	temp=$(echo "${in_temp_raw} + ${in_temp_offset}" | bc)
	temp=$(echo "scale=5; ${temp} * ${in_temp_scale}" | bc)
	temp=$(echo "scale=5; ${temp} / 1000" | bc)
	data="TEXT,TEMP0,${temp},"
    send_data
fi

tie into cron

/etc/crontab
# m h dom mon dow user	command
17 *	* * *	root    cd / && run-parts --report /etc/cron.hourly
25 6	* * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6	* * 7	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6	1 * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
*  *    * * *   root    /bin/bash /home/debian/tx_temp.sh &> /dev/null &
#

Receiver

We need P9.30 for SPIDEV1, which is the enter key on the LCD7, so disable P9.30 in BB-BONE-LCD7-01-00A3.dts