mmap-rs provides a cross-platform and safe Rust API that abstracts mmap on Unix systems and VirtuaAlloc and CreateFileMapping on Microsoft Windows to create and manage memory mappings in the virtual address space of the calling process. This crate can be used to create both file and anonymous mappings and supports additional features such as huge pages and locking physical memory on platforms where these features are available. Finally, this crate also allows you to enumerate the existing memory mappings of a given process.

View code

U-Boot SPI Driver for Allwinner SoCs

While the Allwinner SoCs have support for booting from SPI NOR flash, one of the limitations was that there was simply no U-Boot SPI driver. While working at Whitebox Systems, we needed support for booting from SPI NOR flash for one of our projects. Back then we found that everything else was already in place, except for the SPI driver itself.

To implement the SPI driver, we mostly based our code on the existing implementation in the Linux source code, as well as a manual describing the register mapping used for the various SPI interfaces on the various SoCs. We then wrote and prototyped a SPI driver for U-Boot. Once we confirmed that we could read, write and erase the SPI NOR flash attached, we set up U-Boot SPL and applied some soldering hacks to boot U-Boot and eventually the Linux kernel directly from SPI NOR flash.

We then made sure the driver had full support for other SoCs as well by testing it on the H2+ Orange Pi Zero, the A20 OLinuXino LIME 2, the A64 Pine64+ and the A64 OLinuXino. The driver ended up in U-Boot mainline, and also led to new OLinuXino boards that now ship with SPI NOR flash.

View commit