Tock Logo

Talking Tock

Talking Tock 32

More flexible relocation, STM32 & Teensy repos

This is the 32nd post in a series tracking the development of Tock, a safe multi-tasking operating system for microcontrollers.

  1. Moving process loading and relocation to userland
  2. STM32 & Teensy Development Underway
  3. Proposals
  4. Pull Requests
    1. Merged
    2. Older, but revigorated

Moving process loading and relocation to userland

Tock processes do not have a fixed location in flash and RAM—the bootloader or kernel might (and does) re-arrange processes to, for example, make room for a new process or add resources to an existing one. To deal with this, processes need to be compiled with a particular PIC strategy and, until recently, the kernel included a loader that with this by having a loader that copied appropriate sections to RAM and relocated sections such as the Global Offset Table and data relocation sections.

This resulted in a lot of dependency between the kernel and the particular toolchain used to compile and link a process. In turn, this makes it tricky to support userland processes that want/need to use different strategies. Finally, it adds a signficant amount of fairly brittle code that has to be trusted.

As of #714, the loading and relocation logic has been moved entirely to a userspace library. Incidentally, this also makes the kernel 100% compliant to the system call ABI we decided on for 1.0, since it no longer relies on a custom TBF header to manage relocation meta-data.

The biggest downside processes with the same loading scheme each have their own copy of the code in flash. Anecdotally, the code is ~240B, and the savings in the kernel (which requires more checks to ensure safety) make up for a few processes already.

STM32 & Teensy Development Underway

We’ve moved development of STM32-based ports of Tock to its own repo which already has support for the STM32F1, and pending support for the STM32F4.

We’ve also moved Teensy development into a similar shared repository. There is already fairly extensive support for the Teensy 3.6 (based on the mk66 microcontroller) as well as pending work on the Teensy 3.2.

Head on over if you’re able and interested in contributing to those ports, or if you just want to follow along or use them!


Pull Requests


Older, but revigorated