This post explains steps to setup Contiki development environment and flash an example to SensorTag platform.

Contiki development environment

  • Download ContikiInstant 3.0 from this link
  • Download VMware player
  • Setup a shared folder between the host and guest machines
  • Add the ContikiInstant image to VMware player
  • In the Linux virtual machine, delete the Swedish keyboard (default keyboard)

Prepare Contiki repo

The contiki folder in the ContikiInstant image may be out of date. If it is the cased, delete this folder and then clone the Contiki repo

$ rm -Rf contiki
$ git clone --recursive https://github.com/contiki-os/contiki.git

Simulation with Cooja

On the guest machine, open Terminal

$ cd contiki
$ git submodule sync
$ git submodule update --init
$ cd tools/cooja
$ ant run

Build and flash the first example to SensorTag

After installation, it is now ready to flash firmware to the chip. In the contiki folder, change to the example folder

$ cd /example/cc26xx
$ make BOARD=sensortag/cc2650 cc26xx-demo

Check the target in the Makefile.target file and make sure it is srf06-cc26xx

TARGET = srf06-cc26xx

and BOARD points to the subdirectory under this platform in Contiki.

Using BOARD=sensortag or sensortag/cc2650 depends on the structure of the Contiki platform folder. The default contiki folder in the ContikiInstant image puts the sensortag platform in the srf06-cc26xx folder, therefore, BOARD=sensortag. From Contiki 3.0 , e.g. obtained with clone command, the new sensortag platform is in srf06-cc26xx/sensortag/cc2650, so BOARD=sensortag/cc2650. Use $make clean when switching between boards.

After that, flash the cc26xx-demo.bin to SensorTag using Flash Programmer 2.

Define the BOARD_CONF_DEBUGGER_DEVPACK directive to enable using uart in Devpack-Debugger. However, if the default contiki folder in the ContikiInstant image is used, I had to modify contiki/platform/srf06-cc26xx/sensortag/board.h in order to receive UART data through CC-DEVPACK-DEBUGGER. For the latest source code, define a directive project-conf.h to use Devpack-Debugger.

Below is the output on COM4, 115200, 8N1 of the Devpack-Debugger with the SensorTag running the demo code

Bat: Temp=25 C
Bat: Volt=3292 mV
HDC: Temp=28.14 C
HDC: Humidity=56.45 %RH
MPU Gyro: X=1.12 deg/sec
MPU Gyro: Y=0.33 deg/sec
MPU Gyro: Z=1.64 deg/sec
MPU Acc: X=0.03 G
MPU Acc: Y=0.14 G
MPU Acc: Z=0.95 G
OPT: Light=46.96 lux

Issues

Using CC-DEVPACK-DEBUGGER v1.2 to receive uart data

By default, after flashing the cc26xx-demo firmware to SensorTag, a Terminal running on the host machine couldn’t receive data transmitted by the SensorTag through its uart. The issue was confirmed on Contiki forum.

That was because in contiki/platform/srf06-cc26xx/sensortag/board.h, the port mapping for the uart was as follows

#define BOARD_IOID_UART_TX IOID_16

Meanwhile, on the SensorTag schematic, TX is IOID_29. Therefore, section UART IOID mapping, i.e. line 103, needs to be as followings

#define BOARD_IOID_DP4_UARTRX IOID_28
#define BOARD_IOID_DP5_UARTTX IOID_29
#define BOARD_IOID_UART_RX BOARD_IOID_DP4_UARTRX
//#define BOARD_IOID_UART_TX IOID_16
#define BOARD_IOID_UART_TX BOARD_IOID_DP5_UARTTX
#define BOARD_IOID_UART_CTS IOID_UNUSED
#define BOARD_IOID_UART_RTS IOID_UNUSED
#define BOARD_UART_RX (1 << BOARD_IOID_UART_RX)
#define BOARD_UART_TX (1 << BOARD_IOID_UART_TX)
#define BOARD_UART_CTS (1 << BOARD_IOID_UART_CTS)
#define BOARD_UART_RTS (1 << BOARD_IOID_UART_RTS)

Note that I have Devpack-Debugger v1.2

UPDATE 09/01/2016 The issue was resolved in the latest Contiki repo by using the BOARD_CONF_DEBUGGER_DEVPACK directive, see contiki/platform/srf06-cc26xx/sensortag/board.h. Set this directive to 1 in project-conf.h will use the correct uart pins. Using the latest repo requires BOARD=sensortag/cc2560 in make.

References

  1. Contiki Getting Started
  2. Setup SW Contiki
  3. Contiki CC-DEVPACK-DEBUGGER UART Issue