Getting started
This is a quick guide for getting started with Darjeeling with Contiki-2.3 and the Cooja Simulator. It should explain everything from checking out the code
to compiling your first Darjeeling build.
Before you start
Before you can start developing with Darjeeling, there are some prerequisites.
Operating system
This short tutorial assumes that you're using Linux, in fact it's the weapon of choice for most of the
developers working on Darjeeling. We also provide some information about getting things to work on OSX.
Things haven't been tested with Windows or Windows/Cygwin, so you're pretty much on your own if you want
to use that. Feel free to ask questions on the forum though.
Java 1.6
Darjeeling requires Java 1.6. Ubuntu/Debian/Mint users installing the Sun JDK 1.6 is pretty straightforward, just
install the sun-java6-jdk package. Make sure you use the sun JDK, since we haven't tested with anything else.
For OSX users Java 1.6 should come pre-installed, but is not standard on older Pentium Macs. One workable option is
to install SoyLatte. This installs into /usr/local so it can
coexist with the standard MacOS java, you just need to set your path appropriately when you are building Darjeeling.
SoyLatte has a known issue where the @Override annotation will generate errors when used with a method that
implements an interface method. If you get weird errors conceSelect the application that should be builtrning @Override on mac/soylatte, this might be
your problem. We don't know of any workarounds, so it's probably best to just remove/comment out the offending
@Override tags from your Java code.
Ant
The build system uses Apache ANT. The Ubuntu package is simply called ant.
We're pretty sure it will work with 1.7.1.
GCC
You'll need to install GCC to build the Linux version of Darjeeling, and the appropriate ports for AVR and MSP430.
Ubuntu users will find both gcc-msp430 and avr-gcc in the standard repositories.
Obtaining the source
Check out the source from SVN:
svn co https://darjeeling.svn.sourceforge.net/svnroot/darjeeling/trunk darjeeling
Common requirements
set environment variables
Add DARJEELING to your path, so you can simply copy and past the commands from this guide.
export DARJEELING=<path to darjeeling>
Build the infuser
cd $DARJEELING/src/infuser
ant
Select the application that should be built
Edit build.xml and change the property "apps". Currently it is set to "testsuite", you can change it to "blink". The applications are located in $DARJEELING/src/apps. Note: you can also specify multiple applications, seperated by a comma. They will be run in sequence.
Contiki / Cooja
You can run your applications on top of contiki in the cooja simulator. However, for now it is a bit of a daunting task.
These steps need to be performed once, afterwards you can skip them
- Download and unpack contiki-2.3
- Set the CONTIKI environment variable
export CONTIKI=<path_to_contiki>
- Build the contiki for cooja library using one of the examples.
cd $CONTIKI/examples/rime
make example-abc TARGET=cooja
A gui starts, click Create then Compile and close the gui. This will create a file called mtype_aNumber.a in obj_cooja folder
- Copy the mtype_aNumber to darjeeling and rename it to contiki-cooja.a
cp obj_cooja/mtype.a $DARJEELING/src/platform/contiki/lib/contiki-cooja.a
- Remove the additional postfix from the automatically generated c file in contiki. Otherwise you will have to change compile commands in the further steps. So, please do it. Start by editing $CONTIKI/tools/cooja/java/se/sics/contikimote/ContikiMoteType.java at line 1104.
testID = ID_PREFIX + (new Random().nextInt(1000));
to
testID = ID_PREFIX;// + (new Random().nextInt(1000));
Build the application for contiki-cooja
Now we can build the application
cd $DARJEELING/src/config/contiki-cooja/
ant extra-clean
ant
You can change the application in build.xml (as discussed earlier). By default ctp, a tree routing protocol is built. Actually, the "ant extra-clean" is only needed when you've run the simulator and to want to rebuild the application or build another application.
Run the application in cooja
cd $CONTIKI/tools/cooja
ant
A gui appears. Create a simulation from file->new simulation and pass the wizard. Now add motes with your progam, motes types>create mote type >contiki mote type, the contiki process should point to $DARJEELING/src/config/contiki-cooja/c/main.c
Set the compile command to contain the following, but replace $(DARJEELING) and $(CONTIKI) with the actual paths
gcc -fPIC -shared -gdwarf-2 -g3 -Wall -std=c99 -c -DAUTOSTART_ENABLE -DCONTIKI_PLATFORM=native -I$(DARJEELING)/lib/ -I$(DARJEELING)/src/architecture/native/c -I$(DARJEELING)/src/platform/contiki/c -I$(DARJEELING)/src/config/contiki-cooja -I$(DARJEELING)/src/config/contiki-cooja/c -I$(DARJEELING)/src/vm/c -I$(DARJEELING)/src/config/contiki-cooja -I$(CONTIKI)/core -I$(CONTIKI)/platform/cooja -I$(CONTIKI)/cpu/native -I$(DARJEELING)/src/lib/base/build -I$(DARJEELING)/src/lib/radio/build -I$(DARJEELING)/src/lib/darjeeling/build $(DARJEELING)/src/config/contiki-cooja/c/darjeeling.c
gcc -fPIC -shared -gdwarf-2 -g3 -Wall -std=c99 -c -DAUTOSTART_ENABLE -DCONTIKI_PLATFORM=native -I$(DARJEELING)/lib/ -I$(DARJEELING)/src/architecture/native/c -I$(DARJEELING)/src/platform/contiki/c -I$(DARJEELING)/src/config/contiki-cooja -I$(DARJEELING)/src/config/contiki-cooja/c -I$(DARJEELING)/src/vm/c -I$(DARJEELING)/src/config/contiki-cooja -I$(CONTIKI)/core -I$(CONTIKI)/platform/cooja -I$(CONTIKI)/cpu/native -I$(DARJEELING)/src/lib/base/build -I$(DARJEELING)/src/lib/darjeeling/build $(DARJEELING)/src/config/contiki-cooja/c/main.c -o main.co
gcc -I$(JAVA_HOME)include -I$(CONTIKI)/platform/cooja/lib -I$(JAVA_HOME)include/linux -fno-builtin-printf -fPIC -Wall -g -I/usr/local/include -I. -I$(CONTIKI)/platform/cooja/. -I$(CONTIKI)/platform/cooja/dev -I$(CONTIKI)/platform/cooja/lib -I$(CONTIKI)/platform/cooja/sys -I$(CONTIKI)/platform/cooja/cfs -I$(CONTIKI)/platform/cooja/net -I$(CONTIKI)/core/dev -I$(CONTIKI)/core/lib -I$(CONTIKI)/core/net -I$(CONTIKI)/core/net/mac -I$(CONTIKI)/core/net/rime -I$(CONTIKI)/core/net/routing -I$(CONTIKI)/core/sys -I$(CONTIKI)/core/cfs -I$(CONTIKI)/core/ctk -I$(CONTIKI)/core/lib/ctk -I$(CONTIKI)/core/loader -I$(CONTIKI)/core/. -c obj_cooja/mtype.c -o obj_cooja/mtype.o
objcopy --redefine-sym printf=log_printf main.co
objcopy --redefine-sym printf=log_printf obj_cooja/mtype.o
objcopy --redefine-sym puts=log_puts main.co
objcopy --redefine-sym puts=log_puts obj_cooja/mtype.o
objcopy --redefine-sym putchar=log_putchar main.co
objcopy --redefine-sym putchar=log_putchar obj_cooja/mtype.o
gcc -I$(JAVA_HOME)include -I$(CONTIKI)/platform/cooja/lib -I$(JAVA_HOME)include/linux -shared -Wl,-Map=obj_cooja/mtype.map -o obj_cooja/mtype.cooja main.co obj_cooja/mtype.o $(DARJEELING)/src/platform/contiki/lib/contiki-cooja.a $(DARJEELING)/src/config/contiki-cooja/darjeeling.a
cp obj_cooja/mtype.cooja main.cooja
rm main.co
Click Compile, then click Create.
Now you can add motes and start the simulator. You should get something like this
.