Knurling Tools

So far, the knurling-rs project has released the following tools:

probe-run

probe-run is a cargo runner to flash and run embedded applications just like you would native applications and provides you with stack backtraces that mimic native panicking behavior so you can see where things went wrong. It seamlessly integrates into your Cargo workflow and reduces the gap when moving from native Rust to embedded.

probe-run even lets you seamlessly use Rust-analyzers ▶Run button in your embedded projects!

For more details, check out our blog post introducing probe-run.

View probe-run on GitHub

defmt

defmt is a highly efficient logging framework that targets resource-constrained devices, like microcontrollers. defmt stands for "deferred formatting":

Rather than performing formatting input like 255u8 into "255" on the embedded device that's logging data, this is deferred to the host that will outputs logs. This way, only the single-byte binary data needs to be sent to the host instead of the entire format string, and the formatting happens there.

At compile time, defmt builds a table of string literals, like "Hello, world" or "The answer is {:?}". At runtime, the logging device sends the index of the table entry to the host instead of the complete string.

Run-time values needed to fill in the format strings are compressed additionally, for example by compressing several booleans into one byte.

This means that defmt reduces

Apart from its efficiency benefits, defmt is also an improvement in terms of usability. For example, the location information included in the log messages is understood by VS Code and can be clicked to navigate to the log statement:

For more details on how it works, check out the defmt book.

View defmt on GitHub

flip-link adds zero-cost stack overflow protection for your embedded programs– no MPU or stack probe support needed!

It does this by flipping the standard memory layout of ARM Cortex-M programs.

With this inverted memory layout, the stack hits the boundary of the RAM region when it "overflows" instead of corrupting memory. This boundary collision raises a hardware exception (usually the "hard fault" exception), which by default halts the program.

For more details, check out our blog post introducing flip-link.

app-template

We've also created a Cargo project template called app-template so you can hit the ground running with probe-run, defmt and flip-link. Using the knurling app-template, and cargo-generate, you can start your embedded project just by running

$ cargo generate \
    --git https://github.com/knurling-rs/app-template \
    --branch main \
    --name my-app

and specifying your desired HAL and compilation target.

For full setup instructions, see the app-template repository.

View app-template on GitHub

defmt-test

defmt-test is an embedded test harness that lets you write and run unit tests as if you were using the built-in #[test] attribute, but they'll run on your embedded target.

Of course, defmt-test also gives you an #[init] attribute for initialization functions needed to set up your peripherals etc.

For more details, check out our blog post introducing defmt-test. Also check our blog post series on testing embedded Rust code.

View defmt-test on GitHub

Want more? Sponsor us ♥️

Knurling-rs is funded through GitHub sponsors. Sponsors get early access to new tools we are building and allow us to dedicate more time towards Knurling.

Thank you to all of the people already sponsoring our work through the Knurling project!