Tock Logo

Talking Tock

nRF51 support

This post is about initial support in Tock for the nRF51 series of chips that combine a Bluetooth Low Energy (BLE) radio with a Cortex-M0 core. Support is for the nRF51 DK (development kit) platform, also known as the PCA10028. Currently there is support for GPIO, timers, and a single process. UART support will be coming soon. The next step will be a driver/system call interface to the BLE transciever which will allow a open source BLE stack to run as a process.

History and Background

The Firestorm and Imix platforms both have an nRF51 on them, to provide BLE connectivity. Currently, the nRF51 processors run C code implemented on top of Nordic Semiconductor’s software libraries. This C code provides an interface over a serial port to the platform’s main processor, the SAM4L. Within Tock, a driver (ble_serialization.rs) provides a system call interface to the nRF; a C process can send commands through these calls to advertise, notify, and handle connections.

The major blocking item on running Tock directly on the nRF51 has been a Bluetooth Low Energy stack. Nordic’s stack is closed source, and controls key hardware resources like the memory protection unit and timers. Writing an entire stack from scratch is a huge undertaking (tens of thousands of lines of code). Because many embedded sensing network, IoT, and HCI applications (including many of the applications we are building or have built) need to use just an nRF51, rather than a full Firestorm or Imix, we decided to make nRF51 support a priority.

@lizardo started bringing up Tock on the nRF51, getting the system to boot and run a process. He also found that the Apache mynewt project has a complete open source BLE stack for the nRF51. Because this stack is in C, our plan is to borrow this code and run it as a process in Tock, providing system calls to the hardware abstraction layer while keeping all of the rest of the stack in C. The long-term goal is to have a full open source BLE stack running in Tock on the nRF, such that one can build nRF51-based platforms and we can explore how Tock should operate in multicore/distributed settings such as the Imix and Firestorm, where two different Cortex M microcontrollers run the OS.

Current Status

@phil-levis has been building on @lizardo’s work, and has a pull request for an initial nRF51 port. This pull request supports a single process, GPIO, and timers. UART (i.e. printf) support will be added soon.

There is support for one platform, the nRF51 development kit (DK), the PCA10028. This platform has ARM mbed support, which means that it appears as a storage device over USB and you reprogram it by copying a file to the device. It also has out-of-the-box JTAG support over USB.

There are several to do items in the short term: