Microcontrollers in Micro-increments : A Test-driven C++ Workflow for Embedded Systems
Baby steps are safe steps. Making small moves in code, driven by tests, and continuously refactoring helps to keep embedded development on the right track. With test-driven development we can move more quickly, cleanly, and safely. With increased device capability comes increased expectations, and to meet these expectations we find that real-time operating systems, vendor-supplied drivers and third-party libraries are becoming the new normal for embedded projects. Debugging this complex embedded firmware directly on the target hardware, though, is a slow and painful process, and often with an uncertain outcome. In this talk I’ll demonstrate on a realistic hardware design how different test-driven idioms for C++ on embedded can help us to both build the code right, and build the right code. I’ll show how continuous integration builds, sanitizers and other tools can leverage this investment in tests, give us a high level of confidence in our code changes, and reduce the amount of time spent on debug-on-hardware activity. We’ll look at patterns of implementation in C++ that help to build testable embedded systems, as well as the trade-offs and compromises to a “pure” design ideal that we often have to make on these highly constrained devices.