Pigweed Labday

March 16, 2021

Pigweed is a mix of libraries and build system for embedded development. The thing that initially sold me on wanting to try it was automatically running tests on embedded devices. The current target list is pretty small and it’s primarily targeted at the STM32F429I-DISC1, but does have support for stuff like the teensy line through teensyduino.

If you’re interested in playing with it, I recommend going through the remoticon workshop. It has an accompanying video.

It will walk you through the setup, using the tokenized logger, running tests, the RPC module, the KVS module, and an example of semi-automated testing.

One thing I inordinately appreciate is the ascii art:

In the end my entire day was fighting with the workshop, before finally learning the reason I couldn’t get tests on the device to work was that the device was printing everything before the test runner could connect to serial. There isn’t a great way to solve this, but I ended up getting around it by following the recommendation of a dev on discord and just blocking till serial for all code. Apply this patch to `third_party/pigweed`:

patch
diff --git a/pw_sys_io_arduino/sys_io_arduino.cc b/pw_sys_io_arduino/sys_io_arduino.cc
index 4709ad5a..a6625e42 100644
--- a/pw_sys_io_arduino/sys_io_arduino.cc
+++ b/pw_sys_io_arduino/sys_io_arduino.cc
@@ -20,7 +20,11 @@
 #include "pw_preprocessor/compiler.h"
 #include "pw_sys_io/sys_io.h"

-extern "C" void pw_sys_io_Init() { Serial.begin(115200); }
+extern "C" void pw_sys_io_Init() {
+  while (!Serial && millis() < 3000) {}
+  Serial.begin(115200);
+}

 namespace pw::sys_io {