I just started at a small company and there is a hot-needle-built software for micro controllers written in C which we are now starting to clean up to make it maintainable again.
Of course this goes in parallel to normal production and since our final product testing is quite extensive, the software in general works quite well.
However, there are a few things that bother me like things that only work with -Os
and break with any other optimisation level in that the watchdog (counting up a certain sequence, which looks good before it resets) resets the MCU kind of randomly. So I thought about using a sanitizer like the UBSan from the LLVM project to inspect things further. But I find myself unable to find a tool that might help here.
Am I missing something or is it just in the nature of embedded systems that runtime-checker like UBSan cannot be used?
What I tried so far was stepping through instruction by instruction to see where it breaks ... but well, the part where the watchdog reset acurs, jumps around, meaning it happens in any corner of the code.
I also enabled many warning switches of the compiler and ran cppcheck and in the process fixed over a hundred warnings about possibly undefined variables and dead code but the watchdog issue remains.
Are there other ways to inspect random resets more effectively?