Starting Riot

Hi friends, I am starting using RIOT (uC Nordic nRF51822, Board pca10000) but I have some issues I would like you could help me:

  1. I couldn’t figure out when the OS takes control of the uC, because in some examples the “main(void)” procedure never calls Riot.
  2. I couldn’t figure out how to make more than one independent task. Again in “main(void)” looks like a bare metal program.
  3. Solving the issue 2, when I put the priority on each task?
  4. Do you have some kind of manual or example telling the configuration of semaphores, mutex, events? There are some example with 2 or more simple tasks like a “blinking led” and “display writing” in same program?

Thank you,

Marcio Segura

Hello Friends,

I am using nrf51822 mcu on 2 projects. We are considering RIOT OS. But while looking at github commits, RIOT for nrf mcu is in very early stage.

By when can we expect BLE and other peripherals lib like I2C, ADC, SPI and UART to be available.

Fyi: Nordic just released s120 softdrive.

Thanks and regards, Satyan Raj

Hi Marcio, I’m not sure about Nodric uC but I think I can answer some of your questions.

  1. Actually, riot will call main instead. When uC start from a reset (power-on-reset or software/hardware reset), it will do some initialization (which can be found in cpu/nRF51822/startup.c, i think). Then, in a bare-metal program, it will call main but in RIOT, kernel_init will be called instead. kernel_init will then create 2 threads, idle_thread and main_thread with our main program.
  2. In main, we can create other threads using thread_create function. APIs can be found here [1]
  3. Thread priority will be assigned when we create thread. [1]
  4. Not sure there any better manuals yet but we can found the APIs in [2]. Infomation about mutex, scheduling, threads, etc. are in kernel module.

I think a small example like this should work in the way you want. We’ll have 2 tasks which print their names continuously.

#include <stdio.h>

#include "vtimer.h"
#include "thread.h"

const int16_t led_toggling_stack_size = 1024;
char led_toggling_stack[led_toggling_stack_size];
int16_t led_toggling_pid;

void *led_toggling(void *arg)
    while (1) {
        printf("We're in %s\n", thread_getname(thread_getpid()));
        vtimer_usleep(1000000); // you can adjust this value for your uC

    return NULL;

int main(void)
    int count;

    led_toggling_pid = thread_create(led_toggling_stack,
            PRIORITY_MAIN - 1,
            "Led toggling thread");
    if (led_toggling_pid < 0) {
        printf("Can't create thread\n");

    while (1) {
        printf("We're in %s\n", thread_getname(thread_getpid()));

        for (count = 0; count < 10000000; count++) { // you can adjust this value for your uC

    return 0;

Cheers, Nhat.

[1] [2]

Hi Satyan,

the support for the NRF chip is quite young indeed. Although the base support should be quite stable, there are two known issues I am currently working on: i) the interrupt driven UART is still buggy and ii) the vtimer seems to crash randomly.

For the UART there is an open PR [1], but it still needs to be fixed. For other peripherals there are branches in my github: I2C [2], SPI [3], ADC [4]. These are not well tested yet, but I expect them to be in a merge-able state by mid November.

Regarding Nordics soft-device: There is currently no plan on making it work with RIOT, as I plan to implement the lower BLE layers myself to customize them for the use with 6LoWPAN. But it shouldn’t be hard to use the Nordic stuff - feel free to do so and let us know of your progress!

Cheers, Hauke

[1] [2] [3] [4]