Markdown test

Markdown files:

                      ZZZZZZ
                    ZZZZZZZZZZZZ
                  ZZZZZZZZZZZZZZZZ
                 ZZZZZZZ     ZZZZZZ
                ZZZZZZ        ZZZZZ
                ZZZZZ          ZZZZ
                ZZZZ           ZZZZZ
                ZZZZ           ZZZZ
                ZZZZ          ZZZZZ
                ZZZZ        ZZZZZZ
                ZZZZ     ZZZZZZZZ       777        7777       7777777777
          ZZ    ZZZZ   ZZZZZZZZ         777      77777777    77777777777
      ZZZZZZZ   ZZZZ  ZZZZZZZ           777     7777  7777       777
    ZZZZZZZZZ   ZZZZ    Z               777     777    777       777
   ZZZZZZ       ZZZZ                    777     777    777       777
  ZZZZZ         ZZZZ                    777     777    777       777
 ZZZZZ          ZZZZZ    ZZZZ           777     777    777       777
 ZZZZ           ZZZZZ    ZZZZZ          777     777    777       777
 ZZZZ           ZZZZZ     ZZZZZ         777     777    777       777
 ZZZZ           ZZZZ       ZZZZZ        777     777    777       777
 ZZZZZ         ZZZZZ        ZZZZZ       777     777    777       777
  ZZZZZZ     ZZZZZZ          ZZZZZ      777     7777777777       777
   ZZZZZZZZZZZZZZZ            ZZZZ      777      77777777        777
     ZZZZZZZZZZZ               Z
        ZZZZZ

The friendly Operating System for IoT!

FEATURES

RIOT OS is an operating system for Internet of Things (IoT) devices. It is based on a microkernel and designed for

  • energy efficiency
  • hardware independent development
  • a high degree of modularity

Its features comprise

  • a preemptive, tickless scheduler with priorities
  • flexible memory management
  • high resolution timers
  • virtual, long-term timers
  • the native port allows to run RIOT as-is on Linux, BSD, and MacOS. Multiple instances of RIOT running on a single machine can also be interconnected via a simple virtual Ethernet bridge
  • Wiselib support (C++ algorithm library, including routing, clustering, timesync, localization, security and more algorithms)
  • IPv6
  • UDP
  • 6LoWPAN
  • NHDP

GETTING STARTED

  • You want to start the RIOT? Just follow our Getting started documentation
  • The RIOT API itself can be built from the code using doxygen. The latest version is uploaded daily to http://riot-os.org/api.

USING THE NATIVE PORT WITH NETWORKING

If you compile RIOT for the native cpu and include the nativenet module, you can specify a network interface like this: PORT=tap0 make term

SETTING UP A TAP NETWORK

There is a shellscript in RIOT/dist/tools/tapsetup called tapsetup which you can use to create a network of tap interfaces.

USAGE To create a bridge and two (or count at your option) tap interfaces:

./dist/tools/tapsetup/tapsetup [-c [<count>]]

CONTRIBUTE

To contribute something to RIOT, please refer to the development procedures and read all notes for best practice.

MAILING LISTS

  • RIOT OS kernel developers list
  • devel@riot-os.org (http://lists.riot-os.org/mailman/listinfo/devel)
  • RIOT OS users list
  • users@riot-os.org (http://lists.riot-os.org/mailman/listinfo/users)
  • RIOT commits
  • commits@riot-os.org (http://lists.riot-os.org/mailman/listinfo/commits)
  • Github notifications
  • notifications@riot-os.org (http://lists.riot-os.org/mailman/listinfo/notifications)

LICENSE

  • All sources and binaries that have been developed at Freie Universität Berlin are licensed under the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation.
  • Some external sources, especially files developed by SICS are published under a separate license.

All code files contain licensing information.

For more information, see the RIOT website:

http://www.riot-os.org

CONTRIBUTE

This is a short version of the Development Procedures.

  1. Check if your code follows the coding conventions. If the code does not comply these style rules, your code will not be merged.
  2. The master branch should always be in a working state. The RIOT maintainers will create release tags based on this branch, whenever a milestone is completed.
  3. Comments on a pull request should be added to the request itself, and not to the commit.
  4. Keep commits to the point, e.g., don’t add whitespace/typo fixes to other code changes. If changes are layered, layer the patches.
  5. Describe the technical detail of the change(s) as specific as possible.
  6. Use Labels to help classify pull requests and issues.

Platform configurations for RIOT-OS

This directory contains existing configuration and initialization files for platforms supported by RIOT-OS.

Mulle OpenOCD configuration files

The configuration file in this directory has been tested with OpenOCD v0.7.0. The interface used is ftdi, OpenOCD must be built with –enable-ftdi

To start the OpenOCD GDB server:

openocd -f mulle.cfg

Zolertia Re-Mote platform

The Re-Mote platform is a IoT Hardware development platform based on TI’s CC2538 system on chip (SoC), featuring an ARM Cortex-M3 with 512KB flash, 32Kb RAM, double RF interface, and the following goodies:

  • ISM 2.4-GHz IEEE 802.15.4 & Zigbee compliant.
  • ISM 868-, 915-, 920-, 950-MHz ISM/SRD Band.
  • AES-128/256, SHA2 Hardware Encryption Engine.
  • ECC-128/256, RSA Hardware Acceleration Engine for Secure Key Exchange.
  • Power consumption down to 3uA using our shutdown mode.
  • Co-Processor to allow peripheral management, programming over BSL without requiring to press any button to enter bootloader mode.
  • Built-in battery charger (500mA), Energy Harvesting and Solar Panels to be connected to standards LiPo batteries.
  • Power input with wide range 2-26VDC.
  • Built-in TMP102 temperature sensor
  • Small form-factor (as the Z1 mote, half the size of an Arduino) 57x35 mm.

Port Features

In terms of hardware support, the following drivers have been implemented:

  • CC2538 System-on-Chip:
    • UART
    • Random number generator
    • Low Power Modes
    • General-Purpose Timers.
    • ADC
    • LEDs
    • Buttons
    • Internal/external 2.4GHz antenna switch controllable by SW.

And under work or pending at cc2538 base cpu:

* RF 2.4GHz built-in in CC2538 (PR #2198)
* SPI/I2C library
* Built-in core temperature and battery sensor.
* TMP102 temperature sensor driver.
* CC1120 sub-1GHz radio interface.
* Micro-SD external storage.
* USB (in CDC-ACM).
* uDMA Controller.

Requirements

  • Toolchain to compile RIOT for the CC2538
  • Drivers to enable your host to communicate with the platform
  • Built-in BSL programming over USB using cc2538-bsl (included)

Install a Toolchain

The toolchain used to build is arm-gcc, to check if it is currently installed run:

$ arm-none-eabi-gcc -v
Using built-in specs.
Target: arm-none-eabi
Configured with: /scratch/julian/lite-respin/eabi/src/gcc-4.3/configure
...
(skip)
...
Thread model: single
gcc version 4.3.2 (Sourcery G++ Lite 2008q3-66)

Else install from https://launchpad.net/gcc-arm-embedded

Drivers

The Re-Mote features a FTDI serial-to-USB module, the driver is commonly found in most OS, but if required it can be downloaded from http://www.ftdichip.com/Drivers/VCP.htm

For the CC2538EM (USB CDC-ACM)

The Re-Mote has built-in support for USB 2.0 USB, Vendor and Product IDs are the following:

  • VID 0x0451
  • PID 0x16C8

On Linux and OS X this is straightforward, on windows you need to install the following driver:

https://github.com/alignan/lufa/blob/remote-zongle/LUFA/CodeTemplates/WindowsINF/LUFA%20CDC-ACM.inf

And replace the IDs accordingly.

Device Enumerations

For the UART, serial line settings are 115200 8N1, no flow control.

Once all drivers have been installed correctly:

On windows, devices will appear as a virtual COM port.

On Linux and OS X, devices will appear under /dev/.

On OS X:

  • XDS backchannel: tty.usbserial-<serial number>
  • EM in CDC-ACM: tty.usbmodemf<X><ABC> (X a letter, ABC a number e.g. tty.usbmodemfd121)

On Linux:

  • Re-Mote over FTDI: ttyUSB1
  • Re-Mote over USB driver (in CDC-ACM): ttyACMn (n=0, 1, ....)

K60 tools

This directory contains tools for working with K60 CPUs.

Watchdog disable

wdog-disable.bin is a location-independent watchdog disable function with a breakpoint instruction at the end. Useful for disabling the watchdog directly from OpenOCD.

Usage:

openocd -c 'reset halt' \
  -c 'load_image wdog-disable.bin 0x20000000 bin' \
  -c 'resume 0x20000000' # watchdog is disabled and core halted

Valgrind Support

Rebuild your application using the all-valgrind target like this:

make -B clean all-valgrind

That way native will tell Valgrind about RIOT’s stacks and prevent Valgrind from reporting lots of false positives. The debug information flag -g is not strictly necessary, but passing it allows Valgrind to tell you precisely which code triggered the error.

To run your application run:

make term-valgrind

All this does is run your application under Valgrind. Now Valgrind will print some information whenever it detects an invalid memory access.

In order to debug the program when this occurs you can pass the –db-attach parameter to Valgrind. E.g:

valgrind --db-attach=yes ./bin/native/default.elf tap0

Now, you will be asked whether you would like to attach the running process to gdb whenever a problem occurs.

In order for this to work under Linux 3.4 or newer, you might need to disable the ptrace access restrictions: As root call:

echo 0 > /proc/sys/kernel/yama/ptrace_scope

Network Support

If you compile RIOT for the native cpu and include the native_net module, you need to specify a network interface like this:

make term PORT=tap0

Setting Up A Tap Network

There is a shellscript in RIOT/dist/tools/tapsetup called tapsetup which you can use to create a network of tap interfaces.

Usage: To create a bridge and two (or count at your option) tap interfaces:

../../dist/tools/tapsetup/tapsetup [-c [<count>]]

On OSX you need to start the RIOT instance at some point during the script’s execution. The script will instruct you when to do that.

To delete the bridge and all tap interfaces:

../../dist/tools/tapsetup/tapsetup -d

For OSX you have to run this after killing your RIOT instance and rerun ../../dist/tools/tapsetup [-c [<count>]] before restarting.

Daemonization

You can daemonize a riot process. This is useful for larger networks. Valgrind will fork along with the riot process and dump its output in the terminal.

Usage:

./bin/native/default.elf -d

Compile Time Options

Compile with

CFLAGS=-DNATIVE_AUTO_EXIT make

to exit the riot core after the last thread has exited.

RIOT integration into IoT-LAB

Check the Wiki to see how to build and run RIOT on FIT IoT-LAB: https://github.com/iot-lab/iot-lab/wiki/Riot-support

Control IoT-LAB via Make

Requirements

This feature requires to have a valid account for the FIT IoT-LAB (registration there is open for everyone) and the iot-lab/cli-tools to be installed.

Description

The folder dist/testbed-support/ contains a Makefile.iotlab that defines some targets to control RIOT experiments on IoT-LAB using the GNU Make build system. In order to use this, one has to include this Makefile at the end of the application’s Makefile, like this:

include $(RIOTBASE)/dist/testbed-support/Makefile.iotlab

Variables

This Makefile introduces some additional variables (default values in brackets):

  • IOTLAB_NODES (5)
  • IOTLAB_DURATION (30 minutes)
  • IOTLAB_SITE (grenoble.iot-lab.info)
  • IOTLAB_TYPE (m3:at86rf231)
  • IOTLAB_AUTH ($HOME/.iotlabrc)
  • IOTLAB_USER (taken from $IOTLAB_AUTH)
  • IOTLAB_EXP_ID (taken from first experiment in running state)
  • IOTLAB_EXP_NAME (RIOT_EXP)
  • IOTLAB_PHY_NODES
  • IOTLAB_EXCLUDE_NODES

Format of a Resource ID

Both variables IOTLAB_PHY_NODES and IOTLAB_EXCLUDE_NODES use the resource id string format as specified in the output of experiment-cli submit --help. An example would be: 1-3+7+10-13

Targets

It defines the following targets:

  • iotlab-exp
  • iotlab-flash
  • iotlab-reset
  • iotlab-term

Please note: All targets that require an already running experiment will use the first experiment of the user that has already entered state “Running” if IOTLAB_EXP_ID is not set.

iotlab-exp

This schedules a new experiment on the FIT IoT-LAB and waits until it enters “Running” state. It will request IOTLAB_NODES nodes of type IOTLAB_TYPE for IOTLAB_DURATION minutes at site IOTLAB_SITE. With IOTLAB_PHY_NODES it is possible to choose specific nodes for this experiment by using the resource id string format as described above. Note that the usage of IOTLAB_PHY_NODES ignores IOTLAB_NODES. It will also flash the binary of the current application to all registered nodes. The name of the experiment is set to “RIOT_EXP” or “RIOT_EXP_$(IOTLAB_EXP_NAME)” if IOTLAB_EXP_NAME is defined.

iotlab-flash

This target updates the application on all registered nodes of the given experiment to the current version of the application. Certain nodes can be excluded by listing them in the IOTLAB_EXCLUDE_NODES variable using the resource id string format as described above. If you do not use the default site, then you must specify the site with IOTLAB_SITE.

iotlab-reset

This target resets all registered nodes of the given experiment. Certain nodes can be excluded by listing them in the IOTLAB_EXCLUDE_NODES variable using the resource id string format as described above. If you do not use the default site, then you must specify the site with IOTLAB_SITE.

iotlab-term

Uses ssh to login the user on the IoT-LAB server of the specified site and start the serial_aggregator to communication with all registered nodes.

About

This is a cppcheck wrapper script with appropriate parameters for checking RIOT. It accepts a branch name as an argument which is used to limit the scope of the check. Other parameters will be passed to cppcheck, so you can further modify its behavior.

Example usage

Check all files changed in the current branch against the branch named ‘master’:

./dist/tools/cppcheck/check.sh master

Check all files but ignore warnings about unused struct members:

./dist/tools/cppcheck/check.sh --suppress=unassignedVariable

Check all files changed in the current branch against the branch named ‘master’, ignoring warnings about unassigned variables:

./dist/tools/cppcheck/check.sh master  --suppress=unassignedVariable

Default options

This script suppresses warnings of the type “unusedStructMember” by default. If you want to get warnings about “unusedStructMembers” run the script with the –show-unused-struct option: ./dist/tools/cppcheck/check.sh –show-unused-struct [BRANCH] [options to be passed]

What to do about the findings

You should read the code carefully. While cppcheck certainly produces valuable information, it can also warn about code that is actually OK. If this happens, you can add an “inline suppression” like this:

/* cppcheck-suppress passedByValue */
timex_t timex_add(const timex_t a, const timex_t b);

cmdline2xml.sh

Export all command line include paths and macro definitions to an XML file suitable for import in Eclipse CDT.

Instrucions

The Eclipse project must be located at “/RIOT” inside your Eclipse workspace, otherwise change cmdline2xml.sh accordingly (ECLIPSE_PROJECT_NAME=RIOT).

In the shell:

cd to application directory (e.g. examples/hello-world)
make eclipsesym

In Eclipse:

  1. Open the project properties, menu Project->Properties
  2. Select C/C++ General->Paths and Symbols
  3. (optional) Click Restore Defaults to delete any existing macros and include paths
  4. Click Import Settings...
  5. Select eclipsesym.xml in your application directory and press Finish
  6. Rebuild C/C++ index, menu Project->C/C++ Index->Rebuild

All conditional compilation and all include paths should now resolve properly for your application.

The file eclipsesym.xml is specific to the application being built and may differ depending on what modules are enabled and which platform is being built. Make sure that everything is set up properly in your shell and that regular make all works before running make eclipsesym

About

This script checks if a Pull Request needs squashing or if it is waiting for another Pull Request.

Usage

./pr_check.sh [<master branch>]

The optional <master branch> parameter refers to the branch the pull request’s branch branched from. The script will output all commits marked as squashable from HEAD to the merge-base with <master branch>. The default for <master branch> is master.

A commit is marked as squashable if it contains the keywords SQUASH or FIX (case insensitive) within the first five characters of it’s subject title.

RIOT Sniffer Application

About

This sniffer script can be used to sniff network traffic using RIOT based nodes. It is primarily designed for sniffing wireless data traffic, but can also well be used for wired network traffic, as long as the used network devices support promiscuous mode and output of raw data.

The sniffer is based on a RIOT node running the sniffer application application located in RIOTs application repository. This node outputs received network traffic via a serial port or a network socket in the Wireshark pcap format. This output is then parsed by the sniffer.py script included in this folder run on a host computer.

The sniffer.py script is a modified version of malvira’s script for the Redbee Ecotag (https://github.com/malvira/libmc1322x/wiki/wireshark).

Dependencies

The sniffer.py script needs pyserial.

Installing the dependencies:

Debuntu

apt-get install python-serial

PIP

pip install pyserial

Usage

General usage:

  1. Flash an applicable RIOT node with the sniffer application from (https://github.com/RIOT-OS/applications/tree/master/sniffer)
  2. Run the sniffer.py script For serial port:
$ ./sniffer.py serial <tty> <baudrate> <channel> [outfile]

For network socket:

$ ./sniffer.py socket <host> <port> <channel> [outfile]

The script has the following parameters:

  • connType: The type of connection to use. Either serial for serial ports or socket for network sockets.
  • host: The host if the socket connection type is in use.
  • port: The port of the host if the socket connection type is in use.
  • tty: The serial port the RIOT board is connected to. Under Linux, this is typically something like /dev/ttyUSB0 or /dev/ttyACM0. Under Windows, this is typically something like COM0 or COM1. This option is used for the serial connection type.
  • baudrate: The baudrate the serial port is configured to. The default in RIOT is 115200, though this is defined per board and some boards have some other value defined per default. NOTE: when sniffing networks where the on-air bitrate is > baudrate, it makes sense to increase the baudrate so no data is skipped when sniffing. This option is used for the serial connection type.
  • channel: The radio channel to use when sniffing. Possible values vary and depend on the link-layer that is sniffed. This parameter is ignored when sniffing wired networks.
  • [outfile]: When this parameter is specified, the sniffer output is saved into this file. See the examples below for alternatives to specifying this parameter. (optional)

Examples

The following examples are made when using the sniffer application together with an iotlab-m3 node that is connected to /dev/ttyUSB1 (or COM1) (serial connection type) and runs per default with a baudrate of 500000. For the socket connection type port 20000 is used.

Linux (serial)

Dump packets to a file:

$ ./sniffer.py serial /dev/ttyUSB1 500000 17 > foo.pcap

This .pcap can then be opened in wireshark.

Alternatively for live captures, you can pipe directly into wireshark with:

$ ./sniffer.py serial /dev/ttyUSB1 500000 17 | wireshark -k -i -
Windows (serial)

For windows you can use the optional third argument to output to a .pcap:

$ ./sniffer.py serial COM1 500000 17 foo.pcap
IoT-Lab Testbed (socket)

Start an experiment either via the website provided by the IoT-Lab testbed or by using the RIOT specific iotlab Makefile with 3 neighboring iotlab-m3 nodes, where one of them runs the sniffer application and the others run the gnrc_networking application.

Now you can bind the sniffer node to localhost: ssh -L 20000:node-id:20000 user@site.iot-lab.info

Then you can dump or observe the traffic generated by the other nodes running the gnrc_networking application via one of the following commands:

$ ./sniffer.py socket localhost 20000 26 > foo.pcap
$ ./sniffer.py socket localhost 20000 26 | wireshark -k -i -

Creating a SLIP network interface

The module gnrc_slip (Serial line IP) enables the RIOT network stack to communicate IP packets over the serial interface. This collection of tools originally from Contiki [1] enables Linux to interpret this data. Though there is a tool for such operations on Linux (slattach) it is only able to handle IPv4 packages and is unnessarily complicated.

Installation

Just install them using

make
sudo make install

By default they are installed to the /usr/local/bin directory, you can however change that by setting the PREFIX environment variable

export PREFIX=${HOME}/.local
make
sudo make install

Usage

tapslip6 allows you to open a TAP interface (includes link-layer data) for a serial interace handling IPv6 data, tunslip allows you to open a TUN interface (includes only network-layer data) for a serial interace handling IPv4 data, and tunslip6 allows you to open a TUN interface (includes only network-layer data) for a serial interace handling IPv6 data.

For more information use the help feature of the tools

tapslip -h
tunslip -h
tunslip6 -h

[1] https://github.com/contiki-os/contiki/tree/a4206273a5a491949f9e565e343f31908173c998/tools

USB to serial adapter tools

Tools for finding connected USB to serial adapter devices.

Usage

./list-ttys.sh

List all currently connected USB to serial adapters by searching through /sys/bus/usb/devices/.

./find-tty.sh [serial_regex1] [serial_regex2] ... [serial_regexZ]

Write to stdout the first tty connected to the chosen programmer. serial_regexN are extended regular expressions (as understood by egrep) containing a pattern matched against the USB device serial number. Each of the given expressions are tested, against each serial number until a match has been found.

In order to search for an exact match against the device serial, use ‘^serialnumber$’ as the pattern. If no pattern is given, find-tty.sh returns the first found USB tty (in an arbitrary order, this is not guaranteed to be the /dev/ttyUSBX with the lowest number).

Serial strings from all connected USB ttys can be found from the list generated by list-ttys.sh.

Exit codes

find-tty.sh returns 0 if a match is found, 1 otherwise.

Makefile example usage

The script find-tty.sh is designed for use from within a board Makefile.include. An example section is shown below (for an OpenOCD based solution):

# Add serial matching command
ifneq ($(PROGRAMMER_SERIAL),)
  OOCD_BOARD_FLAGS += -c 'ftdi_serial $(PROGRAMMER_SERIAL)'

  ifeq ($(PORT),)
    # try to find tty name by serial number, only works on Linux currently.
    ifeq ($(OS),Linux)
      PORT := $(shell $(RIOTBASE)/dist/tools/usb-serial/find-tty.sh "^$(PROGRAMMER_SERIAL)$$")
    endif
  endif
endif

# Fallback PORT if no serial was specified or if the specified serial was not found
ifeq ($(PORT),)
    ifeq ($(OS),Linux)
      PORT := $(shell $(RIOTBASE)/dist/tools/usb-serial/find-tty.sh)
    else ifeq ($(OS),Darwin)
      PORT := $(shell ls -1 /dev/tty.SLAB_USBtoUART* | head -n 1)
    endif
endif

# TODO: add support for windows as host platform
ifeq ($(PORT),)
  $(info CAUTION: No terminal port for your host system found!)
endif
export PORT

Limitations

Only tested on Linux, and probably only works on Linux.

Getting started {#getting-started}

[TOC]

Downloading RIOT code {#downloading-riot-code}

You can obtain the latest RIOT code from our Github repository either by downloading the latest tarball or by cloning the git repository.

In order to clone the RIOT repository, you need the Git revision control system and run the following command:

git clone git://github.com/RIOT-OS/RIOT.git

Compiling RIOT {#compiling-riot}

Setting up a toolchain {#setting-up-a-toolchain}

Depending on the hardware you want to use, you need to first install a corresponding toolchain. The Wiki on RIOT’s Github page contains a lot of information that can help you with your platform:

The build system {#the-build-system}

RIOT uses GNU make as build system. The simplest way to compile and link an application with RIOT, is to set up a Makefile providing at least the following variables:

  • APPLICATION: should contain the (unique) name of your application
  • BOARD: specifies the platform the application should be build for by default
  • RIOTBASE: specifies the path to your copy of the RIOT repository (note, that you may want to use $(CURDIR) here, to give a relative path)

Additionally it has to include the Makefile.include, located in RIOT’s root directory:

# a minimal application Makefile
APPLICATION = mini-makefile
BOARD ?= native
RIOTBASE ?= $(CURDIR)/../RIOT

include $(RIOTBASE)/Makefile.include

You can use Make’s ?= operator in order to allow overwriting variables from the command line. For example, you can easily specify the target platform, using the sample Makefile, by invoking make like this:

make BOARD=iotlab-m3

Besides typical targets like clean, all, or doc, RIOT provides the special targets flash and term to invoke the configured flashing and terminal tools for the specified platform. These targets use the variable PORT for the serial communication to the device. Neither this variable nor the targets flash and term are mandatory for the native port.

For the native port, PORT has a special meaning: it is used to identify the tap interface if the netdev2_tap module is used. The target debug can be used to invoke a debugger on some platforms. For the native port the additional targets such as all-valgrind and valgrind exist. Refer to cpu/native/README.md for additional information

Some RIOT directories contain special Makefiles like Makefile.base, Makefile.include or Makefile.dep. The first one can be included into other Makefiles to define some standard targets. The files called Makefile.include are used in boards and cpu to append target specific information to variables like INCLUDES, setting the include paths. Makefile.dep serves to define dependencies.

Unless specified otherwise, make will create an elf-file as well as an Intel hex file in the bin folder of your application directory.

Learn more about the build system in the Wiki

Building and executing an examples {#building-and-executing-and-example}

RIOT provides a number of examples in the examples/ directory. Every example has a README that documents its usage and its purpose. You can build them by typing

make BOARD=samr21-xpro

or

make all BOARD=samr21-xpro

into your shell.

To flash the application to a board just type

make flash BOARD=samr21-xpro

You can then access the board via the serial interface:

make term BOARD=samr21-xpro

If you are using multiple boards you can use the PORT macro to specify the serial interface:

make term BOARD=samr21-xpro PORT=/dev/ttyACM1

Note that the PORT macro has a slightly different semantic in native. Here it is used to provide the name of the TAP interface you want to use for the virtualized networking capabilities of RIOT.

We use pyterm as the default terminal application. It is shipped with RIOT in the dist/tools/pyterm/ directory. If you choose to use another terminal program you can set TERMPROG (and if need be the TERMFLAGS) macros:

make -C examples/gnrc_networking/ term \
    BOARD=samr21-xpro \
    TERMPROG=gtkterm \
    TERMFLAGS="-s 115200 -p /dev/ttyACM0 -e"

RIOT Documentation {#mainpage}

[TOC]

RIOT in a nutshell {#riot-in-a-nutshell}

RIOT is an open-source microkernel-based operating system, designed to match the requirements of Internet of Things (IoT) devices and other embedded devices. These requirements include a very low memory footprint (on the order of a few kilobytes), high energy efficiency, real-time capabilities, communication stacks for both wireless and wired networks, and support for a wide range of low-power hardware.

RIOT provides a microkernel, multiple network stacks, and utilities which include cryptographic libraries, data structures (bloom filters, hash tables, priority queues), a shell and more. RIOT supports a wide range of microcontroller architectures, radio drivers, sensors, and configurations for entire platforms, e.g. Atmel SAM R21 Xplained Pro, Zolertia Z1, STM32 Discovery Boards etc. (see the list of supported hardware. Across all supported hardware (32-bit, 16-bit, and 8-bit platforms). RIOT provides a consistent API and enables ANSI C and C++ application programming, with multithreading, IPC, system timers, mutexes etc.

Contribute to RIOT {#contribute-to-riot}

RIOT is developed by an open community that anyone is welcome to join:

  • Download and contribute your code on GitHub. You can read about how to contribute in our GitHub Wiki.
  • Subscribe to users@riot-os.org to ask for help using RIOT or writing an application for RIOT (or to just stay in the loop). A searchable archive of this list is available at the RIOT user Gmane newsgroup
  • [Subscribe]((http://lists.riot-os.org/mailman/listinfo/devel) to devel@riot-os.org to follow and discuss kernel and network stack developement, or hardware support. A searchable archive of this list is available at the RIOT devel Gmane newsgroup
  • Follow us on Twitter for news from the RIOT community.
  • Contact us on IRC for live support and discussions: irc.freenode.org #riot-os

The quickest start {#the-quickest-start}

You can run RIOT on most IoT devices, on open-access testbed hardware (e.g. IoT-lab), and also directly as a process on your Linux/FreeBSD/OSX machine (we call this the native port). Try it right now in your terminal window:

git clone git://github.com/RIOT-OS/RIOT.git # assumption: git is pre-installed
git checkout <LATEST_RELEASE>
cd RIOT
./dist/tools/tapsetup/tapsetup              # create virtual Ethernet
                                            # interfaces to connect to RIOT
cd examples/default/
make all
make term

... and you are in the RIOT shell! Type help to discover available commands. For further information see the README of the default example.

To use RIOT directly on your embedded platform, and for more hands-on details with RIOT, see @ref getting-started.

Before that, skimming through the next section is recommended (but not mandatory).

Structure {#structure}

This section walks you through RIOT’s structure. Once you understand this structure, you will easily find your way around in RIOT’s code base.

Overview

RIOT’s code base is structured into five groups.

  • The kernel (core)
  • Platform specific code (cpu; boards)
  • Device drivers (drivers)
  • Libraries and network code (sys; pkg)
  • Applications for demonstrating features and for testing (examples; tests)

In addition RIOT includes a collection of scripts for various tasks (dist) as well as a predefined environment for generating this documentation (doc).

The structural groups are projected onto the directory structure of RIOT, where each of these groups resides in one or two directories in the main RIOT directory.

The following list gives a more detailed description of each of RIOT’s top-level directories:

core

This directory contains the actual kernel. The kernel consists of the scheduler, inter-process-communication (messaging), threading, thread synchronization, and supporting data-structures and type definitions.

See @ref core for further information and API documentations.

boards

The platform dependent code is split into two logic elements: CPUs and boards, while maintaining a strict 1-to-n relationship, a board has exactly one CPU, while a CPU can be part of n boards. The CPU part contains all generic, CPU specific code (see below).

The board part contains the specific configuration for the CPU it contains. This configuration mainly includes the peripheral configuration and pin-mapping, the configuration of on-board devices, and the CPU’s clock configuration.

On top of the source and header files needed for each board, this directory additionally may include some script and configuration files needed for interfacing with the board. These are typically custom flash/debug scripts or e.g. OpenOCD configuration files. For most boards, these files are located in a dist sub-directory of the board.

See here @ref boards for further information.

cpu

For each supported CPU this directory contains a sub-directory with the name of the CPU. These directories then contain all CPU specific configurations, such as implementations of power management (LPM), interrupt handling and vectors, startup code, clock initialization code and thread handling (e.g. context switching) code. For most CPUs you will also find the linker scripts in the ldscripts sub-directory.

In the periph sub-directory of each CPU you can find the implementations of the CPU’s peripheral drivers like SPI, UART, GPIO, etc. See @ref drivers_periph for their API documentation.

Many CPUs share a certain amount of their code (e.g. all ARM Cortex-M based CPUs share the same code for task switching and interrupt handling). This shared code is put in its own directories, following a xxxxx_common naming scheme. Examples for this is code shared across architectures (e.g. cortexm_common, msp430_comon) or code shared among vendors (e.g. kinetis_common).

See @ref cpu for more detailed informtation.

drivers

This directory contains the drivers for external devices such as network interfaces, sensors and actuators. Each device driver is put into its own sub-directory with the name of that device.

All of RIOT’s device drivers are based on the peripheral driver API (e.g. SPI, GPIO, etc.) and other RIOT modules like the xtimer. This way the drivers are completely platform agnostic and they don’t have any dependencies into the CPU and board code.

See @ref drivers for more details.

sys

RIOT follows the micro-kernel design paradigm where everything is supposed to be a module. All of these modules that are not part of the hardware abstraction nor device drivers can be found in this directory. The libraries include data structures (e.g. bloom, color), crypto libraries (e.g. hashes, AES) , high-level APIs (e.g. Posix implementations), memory management (e.g. malloc), the RIOT shell and many more.

See @ref sys for a complete list of available libraries

sys/net

The sys/net sub-directory needs to be explicitly mentioned, as this is where all the networking code in RIOT resides. Here you can find the network stack implementations (e.g. the GNRC stack) as well as network stack agnostic code as header definitions or network types.

See @ref net for more details on networking code.

pkg

RIOT comes with support for a number of external libraries (e.g. OpenWSN, microcoap). The way they are included is that RIOT ships with a custom Makefile for each supported library that downloads the library and optionally applies a number of patches to make it work with RIOT. These Makefiles and patches can be found in the pkg directory.

See @ref pkg for a detailed description on how this works.

examples

Here you find a number of example applications that demonstrate certain features of RIOT. The default example found in this directory is a good starting point for anyone who is new to RIOT.

For more information best browse that directory and have a look at the README.md files that ship with each example.

tests

Many features/modules in RIOT come with their own test application, which are located in this directory. In contrary to the examples these tests are mostly focusing on a single aspect than on a set of features. Despite for testing, you might consider these tests also for insights on understanding RIOT.

dist & doc

All the tooling around RIOT can be found in these two folders.

doc contains the doxygen configuration and also contains the compiled doxygen output after running make doc.

Lastly, the dist directory contains tools to help you with RIOT. These include the serial terminal application pyterm, generic scripts for flashing, debugging, reseting (e.g. support for OpenOCD, Jlink), as well as code enabling easy integration to open testbeds such as the IoT-LAB. Furthermore you can find here scripts to do all kind of code and style checks.