Sunday 4 November 2012

Contiki for the cc2531 USB Stick: At long last...

As of a couple of days ago, the Contiki embedded Operating System for the Internet of Things will now run on TI's excellent cc2531 USB dongles (and by 'run' I mean 'properly, with USB support'). Currently, we can put the USB dongle in CDC-ACM mode but, with the backbone of the driver in place, I am hoping that support for other device classes will start appearing soon (I've already heard people mentioning HID and ECM).

I successfully ran a 6LoWPAN border router on one of these little things and it's bloody fast, compared to standard UART-based approaches (e.g. a Sensinode n601 or a cc2530 EM on a SmartRF). Extremely unscientific tests show an average 30% RTT reduction when communicating (IPv6 ping) between the linux host and the USB stick. I'm sure I've saved those benchmarks somewhere...

I also successfully ran a .15.4 sniffer on a USB stick. More on that in a future blog post, stay tuned!

The USB code is largely based on a USB framework for ARM CPUs which pre-existed in the contiki source tree. Philippe R├ętornaz (EPFL) made a bunch of adjustments to it so that it would play nicely with the cc2531. He also wrote the low level USB driver. I took all that and did a series of contikifications.

The framework, driver etc are hosted in branch master of contiki's official github repo. If you are interested in further gory details, have a look at pull request #18 or commits 0e55eb0947..79cffa030f. As ever, in order to get proper 6LoWPAN functionality on those things without a gazillion crashes, you will need to use the cc-ports branch on contiki-sensinode.

Some more information can be found on the contiki wiki, in the 8051-related pages (which I've only recently moved to the GitHub wiki over from the old location)

As ever, feedback is invited and would be extremely appreciated.