By ‘embedded software’ do you mean a project that involves some sort of kernel e.g. ChibiOS or linux? By ‘firmware hardware and drivers’ do you mean bare metal?
I’ve read recent Memfault posts that use Renode to test. Would you use unit test frameworks like CMocka for ‘embedded software’ and Renode’s Robot framework for ‘firmware and hardware drivers’?
It’s a good question, and is one that is generally a gray area. I’ll do my best to answer.
ChibiOS and Linux would be very hard items to test themselves, as they are built upon event loops, interrupts, likely close hardware interaction, and when you include a single source file of ChibiOS, you likely need to pull in the entire project.
What I typically mean by embedded software, is the layers on top of the hardware and OS.
- This is your higher level flash driver that dispatches larges reads and writes to multiple individual flash sector (or subsector) reads and writes (where the flash chip itself is faked out).
- Filesystem, and then any module built upon the filesystem (ideally with the filesystem faked out)
- Graphics stack and Bluetooth communication protocols (what responses are expected given a certain request)
These modules that your unit testing should also have small number of dependencies. They should take in inputs and spit out outputs, and that is what is tested.
By firmware hardware, and drivers, yes, I typically mean bare metal in these situations. I have found this type of code very difficult to test in unit tests, and it’s usually more work than it’s worth. I’d probably even push for flashing specific firmware for on-device validation tests (simple ones though).
With Renode, it does open up the possibility to test lower level bits of your stack! I would still say it’s probably not worth it. Once an OS, driver, or hardware interaction module works, it works. It doesn’t contain more bugs, and the bugs that do remain always seem to be timing bugs and/or undocumented “features” from the manufacturer, which Renode or QEMU might not even help out much with.
With Renode or QEMU, I’d focus more towards integration tests, which pull in almost the entire firmware and run that as a whole with a few of the lower-level modules mocked/faked out (like the communication stack. Make it work over USB).
CMocka for ‘embedded software’ and Renode’s Robot framework for ‘firmware and hardware drivers’?
Yes, that sounds right.