At the risk of a flame war, I'm going to state the obvious. firmware code often has quality issues because it is often written by Electrical Engineers.
EE's often have little software engineering taught as mandatory subjects in college, and often only get to learn good SW engineering practices on the job, or via milspec/aerospace certification, if ever.
No disrespect is intended, it's just my experience after working with a lot of otherwise very talented EEs.
I've written production firmware (computer engineering background). In my experience EE's don't usually write production firmware, but are responsible for writing non-production verification loops and code.
Usually a computer engineer or software person works with the EE who developed the board level hardware + ASIC engineers.
Of course, there exist EEs who are talented at writing software, but I wonder how often EEs are tasked with writing production code.
I was an embedded contractor for 8 years. It was a huge majority of EEs writing the production code at every company I worked with. I probably worked closely with about 300 engineers in that time, and fewer than 20 of them had Computer Science backgrounds. This was especially true in aerospace/defense, where I very well might have been the only CS guy in the (large) building.
And, no, most weren't "EEs who are talented at writing software" :)
I am an EE, and I wrote several thousand lines of production code for an airborne radar system. It wasn't even firmware; it was signal processing application code running in RTLinux on commercial server hardware. Our firmware was all written by EEs, though I ended up having to help the EE tasked with the C code quite a bit.
For example, if the firmware is controlling a device that does not typically include higher-level computer systems. For example, an ECU originally designed for a non-hybrid vehicle, there will likely be no CE/CS people involved.
EE's often have little software engineering taught as mandatory subjects in college, and often only get to learn good SW engineering practices on the job, or via milspec/aerospace certification, if ever.
No disrespect is intended, it's just my experience after working with a lot of otherwise very talented EEs.