#kernel #teensy #no-std #teensy-4

nightly no-std teensycore

A kernel for the teensy4.0 microcontroller

14 releases

0.0.14 Jun 9, 2023
0.0.13 Mar 17, 2023
0.0.11 Aug 7, 2022
0.0.8 May 15, 2022
0.0.6 Jan 18, 2022

#210 in Embedded development

43 downloads per month

MIT license



Teensycore is a kernel written in rust for the Teensy-4.0 microcontroller.


To properly build teensycore and any subsequent project, you'll need the following:

# Install build tools
sudo apt-get install build-essential gcc-arm-none-eabi jq

# Configure rust
rustup default nightly
rustup target add thumbv7em-none-eabihf


You must first configure your project as a library. Your Cargo.toml should look something like this:

name = "my_project"
version = "0.1.0"
edition = "2021"

crate-type = ["staticlib"]
path = "src/lib.rs"

teensycore = "^0.0.14"

Teensycore exports a convenient macro that helps to configure the entrypoint of your application. It takes care of the default panic handler, initializing system clocks, setting up irq, enabling debug UART, and much more. In this way, you can just focus on what your project needs to get going. Replace your src/lib.rs with something like this:

#![crate_type = "staticlib"]

    /* Application code here */

You are now ready to start writing some baremetal rust!


In order for your project to build correctly, you'll need the following:

  • Configure your project as a library
  • Put your entrypoint code in src/lib.rs
  • Download the build template bash script
  • Execute build-template.sh in lieu of cargo build.

The build script will generate a .hex file and place it in a folder called out. This hex file is compatible with the teensy 4.0 and can be flashed with the teensy-loader utility.

CAUTION: Do not build this in release mode. It optimizes a lot of stuff away, and can cause problems.


Here is a very basic blinky example. To see more examples, check out the /examples folder.

#![crate_type = "staticlib"]

use teensycore::*;
use teensycore::phys::pins::*;

    pin_mode(13, Mode::Output);

    loop {
        pin_out(13, Power::High);
        wait_ns(1 * S_TO_NANO);
        pin_out(13, Power::Low);
        wait_ns(1 * S_TO_NANO);


This project is a work-in-progress and will be undergoing significant development over the coming months as I make it suitable for my own needs. Contributions are welcome.



No runtime deps