FAQ

From ContikiWiki

Jump to: navigation, search

Contents

[edit] General

[edit] What is Contiki and what is it good for?

The Contiki operating system allows tiny devices such as small wireless sensors to communicate with each other and the outside world using very little power. One of the main innovations in Contiki is the ability to communicate using the Internet protocols (IPv4 and IPv6) even in very resource-constrained systems.

The typical technical specifications for a device running Contiki is that it has a small microcontroller with a few tens of kilobytes of memory (MSP430, AVR Atmega, ARM Cortex M3, etc), a wireless low-power communications device such as an IEEE 802.15.4 CC2420 chip, a set of sensors, and a battery.

[edit] What are the alternatives to Contiki?

There are several alternatives to Contiki. From the sensor network community, there are a number of open source research projects that are similar to Contiki, such as TinyOS, LiteOS, and SOS. From the embedded systems community, there are several real-time operating systems (RTOSes) that run on the same devices as Contiki does. Examples include FreeRTOS and uC/OS. For devices with more resources in terms of power, memory, and size, versions of Linux are also an alternative.

[edit] What makes Contiki different from the alternatives?

[edit] What source code license does Contiki have?

Contiki has a 3-clause BSD license.

[edit] Who uses Contiki OS?

Contiki is used by a wide range of commercial and academic users throughout the world.

[edit] Software

[edit] How do I install Contiki OS?

The easiest way to access Contiki OS is by using the Instant Contiki virtual machine image, which provides all the necessary tools, compilers and files that you need to dive right into developing Contiki OS apps. Installation tutorials can be found in the Getting Started section of the Contiki Wiki.

[edit] What programming language does Contiki use?

Contiki is written in the C programming language. Most parts of the source code is C99-compliant, but there are also a few uses of compiler extensions to access certain hardware. This code is limited to the cpu/ and platform/ subdirectories.

[edit] What programming libraries are available for Contiki?

When programming software in C for Contiki, there can be certain restrictions as to what libraries you can use. This all depends on the target platform and the compiler. Common restrictions for resource-constrained embedded systems is that the C library is highly limited to a few of the most common C functions. Furthermore, even if the functions are available, there may be restrictions on arguments that are accepted; e.g., limited format strings in printf(). In addition to the libraries provided by the compiler, Contiki contains a programming library that is useful for a lot of embedded software. This library contains abstractions that encapsulate common programming patterns for resource-constrained system, and is designed to be sparing with the memory and code size.

[edit] What are Protothreads?

Protothreads is a lightweight thread abstraction, which is used in Contiki primarily to implement processes. Both the Contiki kernel and Contiki software use Protothreads extensively to achieve cooperative multitasking. Protothreads can be implemented in standard C, and are thus highly portable. The only state required for each protothread is an abstract pointer to the instruction after the thread's last yield point. This pointer can be implemented portably using C's switch statements, but also by using compiler extensions such as address labels, and requires only 2 bytes in 16-bit hardware.

Protothreads programmers need to be aware of a few differences with typical thread libraries. When switching thread context, the local stack is not restored. Thus, stack variables should not be used inside a protothread, unless the value written is only read back before the next context switch and thereafter not needed anymore. Furthermore, protothreads are not preempted by the Contiki kernel. To ensure a smooth operation of systems running different threads, a protothread should divide its work into smaller work units and voluntarily yield control to the Contiki kernel after completing a work unit.

For further information, see the Protothreads homepage.

[edit] What software does Contiki OS require to be installed natively?

To run Contiki as a user process on your computer, you can build it using the native platform. This required the GNU GCC toolchain and a host operating system that supports the POSIX API.

Otherwise, each hardware platform has its own requirements regarding toolchain and installation tools. Most of these tools are installed in [Instant Contiki].

[edit] Hardware

[edit] What hardware does Contiki OS support?

Contiki supports many different hardware platforms, including AVR Raven, MicaZ, Scatterweb MSB-430, Redbee Econotag, Wismote, and Zolertia Z1.

In addition, there are multiple external ports of Contiki to a vast array of platforms. These are often announced on the contiki-developers mailing list and located in external code repositories.

[edit] How easy is it to port Contiki OS to a new hardware platform?

It depends on the complexity of the platform, and the availability of drivers for the different components. Given a simple platform for which all the hardware drivers are already available, the porting should take less than a day for an experienced programmer. If hardware drivers are needed, this can entail a significant extension of the time needed to port Contiki. To get an idea of the work needed, have a look at the source code, configuration, and make files in different Contiki platform directories. If the CPU used by the platform is not yet supported in Contiki, certain CPU-specific functionality will need to be implemented in a new subdirectory to cpu/.

[edit] Organisation

[edit] IPv6

[edit] How do I obtain the link-local IPv6 address of a node?

The IPv6 address registered for the link-local interface is obtained by calling the uip_ds6_get_link_local(-1) function.

Example: print out the IPv6 address of the first interface:

 #include "net/uip.h"
 #include "net/uip-debug.h"
 {
   uip_ds6_addr_t *addr;
   addr = uip_ds6_get_link_local(-1);
   if(addr != NULL) {
     uip_debug_ipaddr_print(&addr->ipaddr);
   }
 }

[edit] Code size issues

Q: What do the following error messages indicate?

msp430-ld: region text is full (example-shell.sky section .text)
msp430-ld: address 0x45e9 of example-shell.sky section .bss is not within region data
msp430-ld: section .text [00004000 -> 0001734f] overlaps section .bss [00001604 -> 000045e8]
msp430-ld: section .vectors [0000ffe0 -> 0000ffff] overlaps section .text [00004000 -> 0001734f]
msp430-ld: example-shell.sky: section .vectors lma 0xffe0 overlaps previous sections
make: *** [example-shell.sky] Error 1

A: This means that your code uses too much RAM and ROM to fit your hardware.


Q: How do I see how much RAM and ROM my code needs?

A: Most compilers have a command size that lists section sizes and total sizes for compiled files. For example msp430-gcc:

 > msp430-size test-button.sky
    text    data     bss     dec     hex filename
   22580     170    4916   27666    6c12 test-button.sky

text is the code size, data is the size of initialized memory, and bss is the size of uninitialized memory.

The objdump tool gives a quick overview of the variable allocation in RAM:

> objdump -t --section=.bss ravenusbstick.elf
> avr-objdump -t --section=.data webserver6.elf


Q: How do I see how much memory is available for the stack?

A: Using the size command described above. The maximal stack size is the total available memory on the hardware minus data minus bss.

[edit] Cooja

[edit] Cooja visualization attributes

Q: What does the color of an arrow represent in Cooja? How is it updated?

A: The colors can be used to illustrate different types of relationships between nodes in a network topology. The RPL simulations can use colored lines to differentiate between upward and downward links. Notice that you usually need to set the DEBUG flag to DEBUG_ANNOTATE or DEBUG_FULL in the relevant source code files to see such visualization attributes.

The Contiki program on the node from which the line points executes the line

printf("#L %d 1\n", node_id_of_line_end); 

to show the arrow and

printf("#L %d 0\n", node_id_of_line_end); 

to remove it.

Personal tools