Skip to content

Instantly share code, notes, and snippets.

@jjmcdn
Last active August 12, 2017 21:18
Show Gist options
  • Save jjmcdn/9c090252f9758046c17ff9d28cd21167 to your computer and use it in GitHub Desktop.
Save jjmcdn/9c090252f9758046c17ff9d28cd21167 to your computer and use it in GitHub Desktop.
Attempts at using 6LowPAN with TI devices

Objective

I have two objectives with this project.

  • Reproduce the setup (I think I see) here with a single BeagleBone Black using a CC2531EMK and able to ping a CC2650 SensorTag using 6lowPAN over 802.15.4.

  • Connect two devices (eg. two BeagleBone Blacks), both running Linux, via 6lowPAN over 802.15.4 with only one connected to a larger network (wired ethernet or wifi) and be able to ping between the two devices and reach the wider network from the device only connected over 6lowPAN.

Since I'm not able to achieve the first objective yet, I'm not even trying the second.

The Story So Far

I've put links below in the References section, but I'm going to collect everything in one place now so it's all clear what the current state of the world is.

Hardware

My setup includes (links below showing specifically the parts I've purchased in case there's any doubt):

  • A Rev. C BeagleBone Black (and, for what it's worth, I'm using one of these to bring out my console)

  • A CC2531EMK with different software loads (detailed below) (x2, since I want to use the same hardware for each side of the second objective)

  • A CC Debugger for loading alternate firmware on the CC2531EMK

  • A CC2650 Multi-Standard SensorTag

  • A SimpleLink SensorTag Debugger DevPack for loading alternate firmrware on the CC2650

  • A Boundary Devices SabreLite (only relevant for the second objective, I frankly don't care what the second piece of hardware is, it could be a Raspberry Pi, a netbook, anything).

BeagleBone Black

I started out using the latest stable Debian Jessie image for the BBB but currently I'm using the latest (at the time of this writing) Jessie console image with some tweaks.

I've modified the filesystem to add support for swap:

root@beaglebone:~# fdisk -l /dev/mmcblk0

Disk /dev/mmcblk0: 3.7 GiB, 3980394496 bytes, 7774208 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xcd75e7c4

Device         Boot   Start     End Sectors  Size Id Type
/dev/mmcblk0p1 *       2048 3481599 3479552  1.7G 83 Linux
/dev/mmcblk0p2      3481600 7774207 4292608    2G 82 Linux swap / Solaris

This is because I've been doing some builds directly on the BBB and was periodically running into OOM conditions. There's obviously no reason to need a 2GB swap on this device, but since the default size of the console image took 1.7GB of the card and I didn't want to mess around with resizing the partitions and filesystems, I just took the rest of the card for my swap. Good thing I wasn't using a 16GB card or something, I guess.

I modified my /etc/sysctl.conf to turn on some options that seem to be required all the time:

root@beaglebone:~# tail -10 /etc/sysctl.conf 
#net.ipv6.conf.all.accept_source_route = 0
#
# Log Martian Packets
#net.ipv4.conf.all.log_martians = 1
#
net.ipv6.conf.all.accept_ra = 1
net.ipv6.conf.all.accept_ra_rt_info_max_plen = 64
net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding = 1
net.ipv6.conf.all.accept_ra = 2

I've also added a lot of Debian packages to support building stuff like 6lbr, wpan-tools and so on. Otherwise it is a stock Debian Jessie console image.

CC2531EMK

Since my hardware is the CC2531, I'm following the instructions here for the 2.4GHz option. I downloaded the cc2531-slip-radio_contikimac.zip firmware for the CC2531EMK and loaded it with the CC-Debugger using the SmartRF Flash Programmer v2 software from TI. To all appearances the load was successful and when I plug the CC2531EMK into a USB port I get the succession of LEDs lighting up and going out as described on the page and the dongle does appear as /dev/ttyACM0:

root@beaglebone:~# dmesg
[ 6766.097564] usb 1-1: new full-speed USB device number 3 using musb-hdrc
[ 6766.461133] usb 1-1: New USB device found, idVendor=0451, idProduct=16a8
[ 6766.461155] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 6766.461166] usb 1-1: Product: CC2531 USB Dongle
[ 6766.461175] usb 1-1: Manufacturer: Texas Instruments
[ 6766.461184] usb 1-1: SerialNumber: 00124B000768D237
[ 6766.472626] cdc_acm 1-1:1.0: ttyACM0: USB ACM device
root@beaglebone:~# lsusb -v | grep -A20 0451:16a8
Bus 001 Device 003: ID 0451:16a8 Texas Instruments, Inc. 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            2 Communications
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x0451 Texas Instruments, Inc.
  idProduct          0x16a8 
  bcdDevice            0.00
  iManufacturer           1 Texas Instruments
  iProduct                2 CC2531 USB Dongle
  iSerial                 3 00124B000768D237
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           67
    bNumInterfaces          2
root@beaglebone:~# 

So that much seems good.

6lbr

After spending a bit of time spinning my wheels on the 6lbr side of things I think I now have this working (detailed in #149 in the 6lbr issue tracker). This is my current configuration:

root@beaglebone:~# cat /etc/6lbr/6lbr.conf
MODE=ROUTER

RAW_ETH=0
BRIDGE=1
DEV_BRIDGE=br0
DEV_TAP=tap0
DEV_ETH=eth0
RAW_ETH_FCS=1

DEV_RADIO=/dev/ttyACM0
BAUDRATE=115200

#Enable this line if radio device is not detected
#SCAN_DEVICE=/usr/lib/6lbr/bb-scan-usb.sh

LOG_LEVEL=3 #INFO and above only

and as I mentioned in the issue, since we needed to change the sysctl options for br0 when it comes up, I've made this change to 50bridge:

root@beaglebone:~# grep jjm -n -C3 /etc/6lbr/ifup.d/50bridge 
37-             fi
38-             ip addr flush dev $DEV
39-             brctl addif $DEV_BRIDGE $DEV
40:             # jjm
41-             sysctl -w net.ipv6.conf.br0.accept_ra=1
42-             sysctl -w net.ipv6.conf.br0.accept_ra_rt_info_max_plen=64
43:             # /jjm
44-             ;;
45-
46-     Darwin)

I've tweaked my interfaces file a bit since I last updated issue #149:

root@beaglebone:~# cat /etc/6lbr/6lbr.conf
MODE=ROUTER

RAW_ETH=0
BRIDGE=1
DEV_BRIDGE=br0
DEV_TAP=tap0
DEV_ETH=eth0
RAW_ETH_FCS=1

DEV_RADIO=/dev/ttyACM0
BAUDRATE=115200

#Enable this line if radio device is not detected
#SCAN_DEVICE=/usr/lib/6lbr/bb-scan-usb.sh

LOG_LEVEL=3 #INFO and above only

It appears 6lbr starts up okay:

root@beaglebone:~# service 6lbr start
root@beaglebone:~# service 6lbr status
● 6lbr.service - LSB: 6LoWPAN Border Router
   Loaded: loaded (/etc/init.d/6lbr)
   Active: active (running) since Fri 2016-04-15 14:52:48 UTC; 11s ago
  Process: 518 ExecStart=/etc/init.d/6lbr start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/6lbr.service
           ├─523 /bin/sh /usr/lib/6lbr/6lbr /etc/6lbr/6lbr.conf
           ├─528 /usr/lib/6lbr/bin/cetic_6lbr_router -c /etc/6lbr/nvm.dat -o /etc/6lbr/nvm.conf -...
           ├─529 /bin/sh /usr/lib/6lbr/6lbr-watchdog 528 60 3 /var/log/6lbr.timestamp
           └─627 sleep 1

Apr 15 14:52:48 beaglebone 6lbr[518]: Starting 6LoWPAN Border Router:.
root@beaglebone:~# ifconfig
br0       Link encap:Ethernet  HWaddr 78:a5:04:bc:d0:04  
          inet addr:134.86.9.49  Bcast:134.86.9.127  Mask:255.255.255.128
          inet6 addr: 2001:db8:2:0:7aa5:4ff:febc:d004/64 Scope:Global
          inet6 addr: fe80::7aa5:4ff:febc:d004/64 Scope:Link
          inet6 addr: bbbb::7aa5:4ff:febc:d004/64 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1173 errors:0 dropped:0 overruns:0 frame:0
          TX packets:40 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:97257 (94.9 KiB)  TX bytes:5046 (4.9 KiB)

eth0      Link encap:Ethernet  HWaddr 78:a5:04:bc:d0:04  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1168 errors:0 dropped:2 overruns:0 frame:0
          TX packets:43 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:113293 (110.6 KiB)  TX bytes:5156 (5.0 KiB)
          Interrupt:175 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  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)

tap0      Link encap:Ethernet  HWaddr 02:0a:0b:0c:0d:0e  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7 errors:0 dropped:0 overruns:0 frame:0
          TX packets:952 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500 
          RX bytes:714 (714.0 B)  TX bytes:90105 (87.9 KiB)

root@beaglebone:~# route -6 -n
Kernel IPv6 routing table
Destination                    Next Hop                   Flag Met Ref Use If
::1/128                        ::                         U    256 0     0 lo
2001:db8:2::/64                ::                         UAe  256 1     0 br0
aaaa::/64                      fe80::7ff:ff68:d237        UGAe 1024 0     0 br0
bbbb::/64                      ::                         UAe  256 0     0 br0
fe80::/64                      ::                         U    256 0     0 br0
::/0                           ::                         !n   -1  1    37 lo
::1/128                        ::                         Un   0   1     1 lo
2001:db8:2::/128               ::                         Un   0   1     0 lo
2001:db8:2:0:7aa5:4ff:febc:d004/128 ::                         Un   0   1     2 lo
bbbb::/128                     ::                         Un   0   1     0 lo
bbbb::7aa5:4ff:febc:d004/128   ::                         Un   0   1     0 lo
fe80::/128                     ::                         Un   0   1     0 lo
fe80::7aa5:4ff:febc:d004/128   ::                         Un   0   1     3 lo
ff00::/8                       ::                         U    256 5     1 br0
ff00::/8                       ::                         U    256 0     0 tap0
::/0                           ::                         !n   -1  1    37 lo

but I'm never able to discover my CC2650STK:

root@beaglebone:~# ping6 -c2 -I br0 ff02::1
PING ff02::1(ff02::1) from fe80::7aa5:4ff:febc:d004 br0: 56 data bytes
64 bytes from fe80::7aa5:4ff:febc:d004: icmp_seq=1 ttl=64 time=0.237 ms
64 bytes from fe80::7ff:ff68:d237: icmp_seq=1 ttl=64 time=1.08 ms (DUP!)
64 bytes from fe80::7aa5:4ff:febc:d004: icmp_seq=2 ttl=64 time=0.190 ms

--- ff02::1 ping statistics ---
2 packets transmitted, 2 received, +1 duplicates, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.190/0.502/1.080/0.409 ms
root@beaglebone:~# ip -6 neigh show
2001:db8:2:0:70d1:d811:a52a:c495 dev br0 lladdr f0:1f:af:58:3f:4a STALE
fe80::85e4:615e:5482:ded1 dev br0 lladdr 00:26:b9:a7:da:8b REACHABLE
2001:db8:2:0:388c:fc12:9a74:5610 dev br0 lladdr 00:26:b9:a7:da:8b REACHABLE
fe80::7ce5:6c6f:cae3:5d70 dev br0 lladdr f0:1f:af:35:76:04 STALE
fe80::7aa5:4ff:febc:d004 dev br0 lladdr 02:0a:0b:0c:0d:0e router STALE
fe80::58d9:9d5f:b2cf:e06d dev br0 lladdr d0:67:e5:39:cf:ab REACHABLE
2001:db8:2:0:85da:c573:410b:630c dev br0 lladdr f0:1f:af:35:76:04 STALE
fe80::7ff:ff68:d237 dev br0 lladdr 02:00:07:68:d2:37 router REACHABLE
fe80::3035:689f:137d:3d55 dev br0 lladdr 34:e6:d7:28:59:34 STALE
2001:db8:2:0:6459:a21f:d0ef:b7db dev br0 lladdr 34:e6:d7:28:59:34 STALE
2001:db8:2:0:3cd8:6ce6:6fe0:62e dev br0 lladdr d0:67:e5:39:cf:ab REACHABLE
fe80::45ee:fe95:8af3:33d2 dev br0 lladdr f0:1f:af:58:3f:4a REACHABLE

So that leads me to what's on my CC2650STK.

CC2650STK

Originally I started trying to build the slip-radio images for both the CC2531EMK and the CC2650STK (from the 6lbr and Contiki repos respectively) natively, but that proved to be a bad idea. So I'm working from a Instant Contiki 3 image now. My CC2531EMK isn't running the firmware I built, either, it's using the one I downloaded off the TI Wiki, but the option is there for me to build now if I need to.

Working from the instructions here I cloned the contiki repo:

user@instant-contiki:~$ git clone --recursive https://github.com/contiki-os/contiki
[...]
user@instant-contiki:~$ cd contiki
user@instant-contiki:~/contiki$ git pull ; git submodule sync ; git submodule update --init

web-demo

Next I built the cc26xx-web-demo image, hoping that would produce the most straightforward success so I could begin building upon that. Continuing from the above example:

user@instant-contiki:~/contiki$ cd contiki/examples/cc26xx/cc26xx-web-demo/
user@instant-contiki:~/contiki/examples/cc26xx/cc26xx-web-demo$ make TARGET=srf06-cc26xx BOARD=sensortag/cc2650 cc26xx-web-demo.bin CPU_FAMILY=cc26xx
user@instant-contiki:~/contiki/examples/cc26xx/cc26xx-web-demo$ scp cc26xx-web-demo.bin jjm@burninator:./

Then I moved that into a shared location where I could burn the firmware on to my CC2650STK using the Debugger DevPack. Using the same SmartRF Flash Programmer install I used to flash my CC2531EMK, I flashed cc26xx-web-demo onto my CC2650STK. I selected All unprotected pages from Erase, Entire source file from Program and Readback from the Verify tab. The report was that the write was successful and the blinking LEDs during the write/verify phase seemed to indiate something was happening.

I removed the DevPack from the SensorTag and the LED on the front of the tag began flashing rapidly. It didn't seem to do anything else, though, and no matter how long I wait I never see the LEDs on my CC2531EMK indicating any traffic. Further, when I connect to http://[bbbb::100]/ on my BeagleBone Black I never see the SensorTag appear in the list. And, as above, when I ping all of the local addresses I can't find any IPv6 neighbour that would correspond to the SensorTag. Pushing the button on the left side of the board (the one that isn't indicated as 'power' on the red sleeve) doesn't seem to have any effect. Pressing the power button on the side will alternatively turn off the green LED and turn on the red one or turn off the board entirely, depending on whether I prese it once or twice in quick succession.

So then I decided I would try a more complete stack.

slip-radio

Currently I'm trying to use the slip-radio demo from:

user@instant-contiki:~/contiki/examples/ipv6/slip-radio$ make TARGET=srf06-cc26xx BOARD=sensortag/cc2650 slip-radio.bin CPU_FAMILY=cc26xx
user@instant-contiki:~/contiki/examples/ipv6/slip-radio$ scp slip-radio.bin  jjm@burninator.deserted.net:./

Repeating the above steps for flashing the device results in something less successful, I think. The green LED gradually goes from dim to off right after I detach the DevPack and I never see any signs of life from the SensorTag at all.

Unfortunately I don't have a serial console on the CC2650STK, which would probably make things easier, but given that I'm not having any success with any of the demos I've tried, I'm thinking I must have a more fundamental problem that I need to correct first.

Additional notes

It's probably worth noting at this point that since I'm configuring my Beaglebone black via dhcp I'm not yet running wrapsix (as suggested at the end of the Cc26xx_sw_examples page), I hope that's not my only problem here. I intend to update wrapsix myself to support a non-hard-coded IP address. That's important for my longer-term goal, if it turns out I need wrapsix at all to achieve my goals.

At this point I'm going to reach out to the TI community forums.

References

@puddletowntom
Copy link

Hi,

I attempted the TI wiki tutorial for the cc26xx also. I too have run into the same problem of having the sensortags appear on the 6lbr router page. The LEDs of the cc2650 were lit the same way as you describe. Have you had any more luck with it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment