Pigweed is in early development and is not suitable for production use at this time.
Getting Started with Pigweed
As of today, the source is available for everyone at pigweed.googlesource.com under an Apache 2.0 license. Instructions on getting up and running can be found in the README.
See Pigweed in action
Pigweed offers modules that address a wide range of embedded developer needs. These highlight how Pigweed can accelerate embedded development across the entire lifecycle:
- Setup: Get started faster with simplified setup via a virtual environment with all required tools
- Development: Accelerated edit-compile-flash-test cycles with watchers and distributed testing
- Code Submission: Pre-configured code formatting and integrated presubmit checks
SETUPA classic challenge in the embedded space is reducing the time from running git clone to having a binary executing on a device. Oftentimes, an entire suite of tools is needed for non-trivial production embedded projects. For example, your project likely needs:
- A C++ compiler for your target device, and also for your host
- A build system (or three); for example, GN, Ninja, CMake, Bazel
- A code formatting program like clang-format
- A debugger like OpenOCD to flash and debug your embedded device
- A known Python version with known modules installed for scripting
- … and so on
DEVELOPMENTIn typical embedded development, adding even a small change involves the following additional manual steps:
- Re-building the image
- Flashing the image to a device
- Ensuring that the change works as expected
- Verifying that existing tests continue to pass
Pigweed’s pw_watch module solves this inefficiency directly, providing a watcher that automatically invokes a build when a file is saved, and also runs the specific tests affected by the code changes. This drastically reduces the edit-compile-flash-test cycle for changes.
In the demo above, the pw_watch module (on the right) does the following:
- Detects source file changes
- Builds the affected libraries, tests, and binaries
- Flashes the tests to the device (in this case a STM32F429i Discovery board)
- Runs the specific unit tests
CODE SUBMISSIONWhen developing code as a part of a team, consistent code is an important part of a healthy codebase. However, setting up linters, configuring code formatting, and adding automated presubmit checks is work that often gets delayed indefinitely.
Pigweed’s pw_presubmit module provides an off-the-shelf integrated suite of linters, based on tools that you’ve probably already used, that are pre-configured for immediate use for microcontroller developers. This means that your project can have linting and automatic formatting presubmit checks from its inception.
And a bunch of other modulesThere are many modules in addition to the ones highlighted above...
- pw_tokenizer – A module that converts strings to binary tokens at compile time. This enables logging with dramatically less overhead in flash, RAM, and CPU usage.
- pw_string – Provides the flexibility, ease-of-use, and safety of C++-style string manipulation, but with no dynamic memory allocation and a much smaller binary size impact. Using pw_string in place of the standard C functions eliminates issues related to buffer overflow or missing null terminators.
- pw_bloat – A module to generate memory reports for output binaries empowering developers with information regarding the memory impact of any change.
- pw_unit_test – Unit testing is important and Pigweed offers a portable library that’s broadly compatible with Google Test. Unlike Google Test, pw_unit_test is built on top of embedded friendly primitives; for example, it does not use dynamic memory allocation. Additionally, it is 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 levelling. This is a lightweight alternative to a file system for embedded devices.
- pw_cpu_exception_armv7m – Robust low level hardware fault handler for ARM Cortex-M; the handler even has unit tests written in assembly to verify nested-hardware-fault handling!
- pw_protobuf – An early preview of our wire-format-oriented protocol buffer implementation. This protobuf compiler makes a different set of implementation tradeoffs than the most popular protocol buffer library in this space, nanopb.
Why name the project Pigweed?Pigweed, also known as amaranth, is a nutritious grain and leafy salad green that is also a rapidly growing weed. When developing the project that eventually became Pigweed, we wanted to find a name that was fun, playful, and reflective of how we 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.
So far, so good 😁
What’s next?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.
By Keir Mierle and Mohammed Habibulla, on behalf of the Pigweed team