Every rewrite starts with someone saying the old code is unmaintainable. That's rarely the real question — the real question is whether the cost of continuing to patch it exceeds the cost and risk of starting over.
We look at three signals before recommending a rewrite: how often changes cause regressions in unrelated features, whether the original toolchain is still supported, and whether the team can even build the existing firmware reliably.
If two of those three are failing, a staged rewrite usually pays for itself within a year. If only one is failing, we almost always recommend refactoring in place instead.