in Beginner, C, C++, Electronics, General, Guide, Internet, Programming, Ubuntu, Wireless Sensor Networks

TI CC2530DK – Contiki OS – Internet of Things

This blog post is an effort to create a one stop information for starting off your Contiki project with cc2530DK.

There is enough information already available on Github wiki. This post is more than an extension to have all information under one place and as usual my way of documenting my projects!

[toc]

Getting started

Installation – Ubuntu

I am assuming that you already have a system installed with Ubuntu. My suggestion would be to do it on a Virtual machine. I am using VirtualBox

Installing Contiki

The easiest way is to use [viraldownloader id=211 text=’InstantContiki 2.7′]. The longer description of how to install on your existing virtual machine (vm) is also available at the bottom.

Steps for firing up your instant contiki 2.7

  1. Install vmware since the guest operating system is in VMDK and Vmx files [viraldownloader id=212 text=’vmplayer’]
  2. Start the VM instance and Contiki comes already installed.

Steps for installation

  • Install the following packages:
    Copy paste the following in your terminal. You need root access to perform this.
sudo apt-get install build-essential binutils-msp430 gcc-msp430 msp430-libc binutils-avr gcc-avr gdb-avr avr-libc avrdude openjdk-7-jdk openjdk-7-jre ant libncurses5-dev doxygen git gtkterm

This will allow you to cross-compile for MSP430- and AVR-platforms.

  • Clone the Contiki sources from Github:
git clone git://github.com/contiki-os/contiki.git contiki

This is all about installing contiki. There is one more step where you will install SDCC to compile for 8051 devices.

Installing SDCC to compile for cc2530/1 devices

  • As always, first step is to install the pre-requisites. Copy paste the following in your terminal.
sudo apt-get install gcc flex bison libboost-graph-dev srecord python subversion
  • Now download the SDCC compiler from SVN. Try with root if it doesn’t work.  Copy paste the following in your terminal.
cd ~/ && svn co -r 8737 svn://svn.code.sf.net/p/sdcc/code/trunk/sdcc && cd sdcc
Edit files in SDCC before install
  • You should be already in the sdcc folder. There is something to be done to get the libraries correct for our hardware.
    • Edit device/lib/incl.mk. We need model-huge and model-large libraries. To instruct the build system to build model-huge libraries, find this line:
MODELS = small medium large
    • Add huge. You may remove small and medium if you only use SDCC for contiki, but make sure you keep large. So your new line may end up looking like this
MODELS = small large huge
  • Edit device/lib/Makefile.in. Find this line:
 TARGETS += models small-mcs51-stack-auto

Replace it with this

 TARGETS += models model-mcs51-stack-auto
  • Run this:
 ./configure --disable-gbz80-port --disable-z80-port --disable-ds390-port --disable-ds400-port --disable-pic14-port --disable-pic16-port --disable-hc08-port --disable-r2k-port --disable-z180-port --disable-sdcdb --disable-ucsim
Install commands for SDCC
  • Now its the final step for installation. Copy paste the following command in the terminal
cd ~/sdcc && make && sudo make install

This is the end of preparing your system for developing with Contiki and CC2530DK

Source:

  1. https://github.com/contiki-os/contiki/wiki/Setup-contiki-toolchain-in-ubuntu-13.04
  2. https://github.com/contiki-os/contiki/wiki/8051-Requirements#build-your-toolchain-sdcc

Verifying your Contiki Installation

  1. You can test your setup by compiling and running the hello-world-example as follows:
 cd contiki-2.7/examples/hello-world
 make TARGET=native hello-world
 ./hello-world.native

2. The last command should result in an output like this:

Contiki-2.6-584-g807293a started
 Rime started with address 2.1
 MAC nullmac RDC nullrdc NETWORK Rime
 Hello, world

Yay, pass this and your contiki works.

Verifying your Compiler installation

  • Goto into the directory where cc2530DK example files are available.  Try to compile any of the example programs without errors
cd ~/contiki-2.7/examples/cc2530dk/ && make

If you pass this step with out any errors that you are in the right track. If there was no errors type the following command and see if the file exists.

ls
/* See if you can see these following files.
hello-world.hex
blink-hello.hex
timer-test.hex

Flashing your Hello-World example

  • Use the hello-world.hex file

Virtual Machine configurations

  • If your host machine for the Guest os Ubuntu is Windows: install [viraldownloader id=217 text=’SmartRF Flash Programmer’]
    • If its not windows like in my case, install windows on another VM machine.
      • Add the CC2531 to be mounted by default to your Ubuntu Machine
      • your SmartRF Evaluation Board to be mounted on the windows machine
    • Do the following to get better at sharing the files between VMs
      • Host-only adapter to share files between your VMs
        • [viraldownloader id=224 text=’VM Network setup’]
      • NAT adapter to get internet to your adapter
        • [viraldownloader id=226 text=’VM Network setup – for internet’]

Verifying your Hello-world example

Write a Comment

Comment

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.