Google today open-sourced Pigweed, a collection of microcontroller modules designed for developers using 32-bit devices. They’re intended to enable faster and more reliable development on microcontrollers — i.e., the small computers embedded within single circuit chips. Assuming it works as advertised, Pigweed could accelerate the development of hardware in a range of industries, from smart home and manufacturing to robotics, automotive, and even telecommunications.
Google filed a trademark for Pigweed with the U.S. Patent and Trademark Office in late January, and the documents suggested that the project would involve a “computer operating software.” Some took this to mean a new operating system akin to Google’s Fuchsia, but in a blog post this morning, Google made it clear that Pigweed is simply a collection of microcontroller libraries.
Pigweed ships with tools that offer a simplified setup via a virtual environment. The bootstrap script in Pigweed’s pw_env_setup module sets up the current shell to have access to a standardized set of utilities — including Python 3.8, clang-format, and an ARM compiler — all without modifying the system’s default environment.
Pigweed supports distributed testing, as well as pre-configured code formatting and integrated pre-submit checks. From the code editor, the pw_watch module provides a watcher that automatically invokes a build when a file is saved, and that runs the tests affected by the code changes to reduce the edit-compile-flash-test cycle for changes. For instance, pw_watch can detect file changes before building the affected libraries and binaries, flashing the tests to the target device, and running the specific unit tests.
Pigweed’s pw_target_runner module runs tests in parallel across multiple devices, while its pw_pressubmit module provides an off-the-shelf integrated suite of linters (tools that analyze source code to flag errors and bugs) based on tools that are pre-configured for use for microcontroller developers. Pw_tokenizer converts strings to binary tokens at compile time, enabling logging with less overhead in flash, RAM, and CPU usage. And pw_bloat generates memory reports for output binaries to empower developers with information regarding the memory impact of changes.
Here’s a list of other modules included in the initial Pigweed release:
- Pw_string: A module that provides the flexibility and safety of C++-style string manipulation, but with no dynamic memory allocation and a much smaller binary size impact.
- Pw_unit_test: A module built on top of embedded friendly primitives that doesn’t use dynamic memory allocation. It can be used to port to new target platforms by implementing the test event handler interface.
- Pw_kvs: A key-value-store implementation for flash-backed persistent storage with integrated wear leveling; a lightweight alternative to a file system for embedded devices.
- Pw_cpu_exception_armv7m: A low-level hardware fault handler for ARM Cortex-M; the handler has unit tests written in assembly to verify nested-hardware-fault handling.
- Pw_protobuf: An early preview of a wire-format-oriented protocol buffer implementation.
As of today, the Pigweed source is available under an Apache 2.0 license. Google cautions that it’s still in early development and is not recommended for production at this time.
So, what about the origin of the name “Pigweed”? Google notes that it’s a nutritious grain and leafy salad green that’s also a rapidly growing weed. When developing the project that eventually became Pigweed, the tech giant wanted to find a name that was “fun, playful, and reflective” of how it saw Pigweed growing. “Teams would start out using one module that catches their eye, and after that goes well, they’d quickly start using more,” wrote Google. “We’re continuing to evolve the collection and add new modules. It’s our hope that others in the embedded community find these modules helpful for their projects.”