Weekly driver 4: ENC28J60, Ethernet for your microcontroller

March 13, 2018

It’s week number 11 and the weekly driver #4 is out! Last time, I did drivers 1 and 2 so you may be wondering where’s driver 3? Driver #3, the MCP3008, was covered by @pcein in their blog. Also, as of now there are at least 14 (!) drivers being worked on by the community. This week I’m releasing a driver for the ENC28J60, an Ethernet controller with SPI interface. ... Read more

Weekly driver 1 & 2: L3GD20, LSM303DLHC and Madgwick

February 19, 2018

Oh, time flies. It’s already week 8 and we have zero weekly driver posts out there – don’t worry though because there’s plenty of drivers and embedded-hal implementations in the works. To play catch up in this post I’ll cover two embedded-hal drivers: the l3gd20 and the lsm303dlhc. The L3GD20 is an IC that contains a gyroscope and exposes I2C and SPI interfaces; the LSM303DLHC is an IC that contains an accelerometer and a magnetometer, and exposes an I2C interface. ... Read more

Zero cost stack overflow protection for ARM Cortex-M devices

February 17, 2018

One of the core features of Rust is memory safety. Whenever possible the compiler enforces memory safety at compile. One example of this is the borrow checker which prevents data races, iterator invalidation, pointer invalidation and other issues at compile time. Other memory problems like buffer overflows can’t be prevented at compile time. In those cases the compiler inserts runtime checks, bounds checks in this case, to enforce memory safety at runtime. ... Read more

Memory safe DMA transfers

February 9, 2018

UPDATE Given the comments I’ve received so far I think I should more explicitly mention that the context here are systems that lack a MMU and where a memory allocator may or may not be available or desirable, e.g. Cortex-M microcontrollers. In this post I’ll describe an approach to building memory safe DMA based APIs. DMA? DMA stands for Direct Memory Access and it’s a peripheral used for transferring data between two memory locations in parallel to the operation of the core processor. ... Read more

RTFM v0.3.0: safe `&'static mut T` and less locks

January 22, 2018

RTFM (Real Time For the Masses) v0.3.0 is out! This blog post will cover the goodies of this new release. The minor (breaking) release was mainly to become compatible with the new IO model presented in my previous blog post, but a new feature also shipped with this release: safe creation of &'static mut references. First, let’s look at one feature that landed in v0.2.1 but that didn’t get documented in this blog, yet it was essential to adapt RTFM to the new IO model: ... Read more

Embedded Rust in 2018

January 21, 2018

This is my #Rust2018 blog post. These are some things I think the Rust team needs to address this year to make Rust a (more) viable alternative to C/C++ in the area of bare metal (i.e. no_std) embedded applications. Stability Here’s a list of breakage / regressions I encountered (i.e. that I had to work around / fix) during 2017: Changes in target specification files broke compilation of no_std projects that use custom targets. ... Read more

Brave new I/O

January 18, 2018

Hey there! It’s been a while. I’ve been working on some cool stuff for you. Now that’s in more or less good shape I can blog about it! This blog post introduces our new approach to I/O in embedded contexts. Overview: The register model First some background information In microcontrollers all external I/O requires interacting with peripherals. Peripherals are additional pieces of electronics that sit in the same chip / package as the core processor. ... Read more

RTFM v2: simpler, less overhead and more device support

July 29, 2017

Hiya folks! It’s been a while. Today I’m pleased to present the next version of the Real Time For the Masses framework: cortex-m-rtfm v0.2.0 or just v2, which is how I like to call it. Here’s the executive summary of the changes: v2 is simpler. v1 used a bunch of tokens – ceiling tokens, priority tokens, preemption threshold tokens and task tokens – for memory safety; this made the API rather boilerplatery. ... Read more

A CPU usage monitor for the RTFM framework

June 4, 2017

We have used the RTFM framework in the previous posts but put most of the application logic in tasks, and always sent the processor to sleep in the idle function. In this post we’ll put the idle function to better use and build a CPU usage monitor there. Idle The main logic of the CPU usage monitor will be in the idle function. Let’s see how it works: // RESOURCES peripherals! ... Read more

The ITM and the quest for faster logging

May 31, 2017

In this post we’ll explore the different alternatives one has to log data from a microcontroller to some host machine. Be it for printf style debugging or for logging sensor data. The Blue Pill This time I’ll use a different development board: the Blue Pill. On the center the Blue Pill development board. On the left side a UART to USB adapter based on the CH340G. On the right side an SWD programmer: a Chinese clone of the ST-LINK. ... Read more

Creative Commons License
Jorge Aparicio