Hands-On RIOT OS and 6LowPAN

5 Apr

The quite new RIOT OS is getting bigger and feature richer every day. It was finally time to test it on my two CC2538DK boards and try everything out.


The needed prerequisites can of course vary based on your goals. A minimal setup would be in this case:

  • ARM GNU GCC Toolchain
  • UART/COM Port

Building an image

… is quite easy as you only need to e.g. select an appropiate example you want to compile and add the build target to the make command. In this case I want to test the 6LowPAN capabilities and will use the gnrc_networking example:

git clone https://github.com/RIOT-OS/RIOT.git
cd RIOT/examples/gnrc_networking
make BOARD=cc2538dk
   text       data        bss        dec        hex    filename
  80380        196      20876     101452      18c4c    RIOT/examples/gnrc_networking/bin/cc2538dk/gnrc_networking.elf

This will build the image and create the .elf and .bin files in a new sub directory bin/cc2538dk. Copy those images and flash them to two targets.

Having a closer look

To check if everything is running the UART console and a sniffer device should be used. When you check the UART console you will see something like:

> main(): This is RIOT! (Version: 2017.04-devel-611-g3af13-debian)
RIOT network stack example application
All up, running the shell now

All the shell commands available can be listed by executing `help`:

> help
Command              Description
udp                  send data over UDP and listen on UDP ports
reboot               Reboot the node
ps                   Prints information about running threads.
ping6                Ping via ICMPv6
random_init          initializes the PRNG
random_get           returns 32 bit of pseudo randomness
ifconfig             Configure network interfaces
fibroute             Manipulate the FIB (info: 'fibroute [add|del]')
ncache               manage neighbor cache by hand
routers              IPv6 default router list
rpl                  rpl configuration tool ('rpl help' for more information)

In this example I want to run a simple ping from one board to another to check the networking functionalities. To check the IP address:

> ifconfig
Iface  7   HWaddr: 9c:00  Channel: 26  Page: 0  NID: 0x23
           Long HWaddr: 00:12:4b:00:06:15:a8:6b
           TX-Power: 0dBm  State: IDLE
           AUTOACK  MTU:1280  HL:64  6LO  RTR  IPHC
           Source address length: 8
           Link type: wireless
           inet6 addr: ff02::1/128  scope: local [multicast]
           inet6 addr: fe80::212:4b00:615:a86b/64  scope: local
           inet6 addr: ff02::1:ff15:a86b/128  scope: local [multicast]
           inet6 addr: ff02::1a/128  scope: local [multicast]

           Statistics for Layer 2
            RX packets 8  bytes 344
            TX packets 16 (Multicast: 16)  bytes 674
            TX succeeded 0 errors 0
           Statistics for IPv6
            RX packets 8  bytes 512
            TX packets 16 (Multicast: 16)  bytes 1010
            TX succeeded 16 errors 0

and do the ping from another board:

> ping6 fe80::212:4b00:615:a904
12 bytes from fe80::212:4b00:615:a904: id=83 seq=1 hop limit=64 time = 6.327 ms
12 bytes from fe80::212:4b00:615:a904: id=83 seq=2 hop limit=64 time = 6.304 ms
12 bytes from fe80::212:4b00:615:a904: id=83 seq=3 hop limit=64 time = 6.304 ms
--- fe80::212:4b00:615:a904 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2.0637904 s
rtt min/avg/max = 6.304/6.311/6.327 ms

If you check Wireshark you should be able to see the ICMP Pings as well:
The next post describes how to use one of the boards as a slip radio to enable a linux host to access the 6LowPAN network.