Debugging
How to tell if the bug is hardware or firmware
A method to isolate hardware versus firmware without a blame loop: reproduce, change one variable, measure, and record what the evidence actually supports.
Hardware teams and firmware teams can both be right about the symptom and wrong about the cause. A reset looks like a watchdog bug until the rail is scoped. A dead bus looks like a driver bug until the pull-up is measured. The useful move is not a louder opinion. It is a smaller experiment.
Why the blame loop happens
Embedded products fail at boundaries: power, reset, clocks, pinmux, buses, and timing between a peripheral and the code that talks to it. Each layer can generate the same user-visible symptom. Once two people have a plausible story, meetings replace measurements.
The loop also happens because tools lie in both directions. A debugger that cannot attach is often treated as a toolchain problem. Vendor hardware notes treat power, reset, boot pins, and debug wiring as conditions for the CPU to exist at all (ST AN2586; family equivalents such as AN4488). Conversely, a board that “works with the old hex” is not proof the new firmware is innocent if the old hex never stressed the failing path.
Reproduce before you theorize
Write down the smallest sequence that fails: board revision, firmware hash, temperature, power source, cables, and whether a debugger is attached. Then reproduce it twice. If it cannot be reproduced, you do not yet have a bug. You have an anecdote.
Change one variable per experiment. Swapping the board, the image, the cable, and the power supply in the same afternoon makes every result unreadable. Known-good inputs matter: a known-good board with the failing image, and the failing board with a known-good image, is the cheapest split when both exist.
Hardware-first checks
These checks are fast and they falsify a large class of “firmware” reports:
- Power. Measure the rails the MCU and analog domain actually use, at the pins, under the load that fails. Include analog supplies (VDDA and similar). A digital rail that looks fine at the connector can still be missing at the package.
- Reset. Confirm the reset pin is in the idle state the datasheet requires, and that a debugger can control it if you need connect-under-reset. Read the reset-cause register before firmware clears it. Brown-out, pin reset, and watchdog are different stories (Silicon Labs AN0018.2 on supply monitoring and reset cause).
- Clock. If the design depends on an external crystal or oscillator, verify it starts. If the design claims an internal oscillator, confirm the option bytes or configuration match that claim.
- Debug channel. SWD/JTAG is a physical interface (ARM CoreSight / SWD). No target found is a hardware or configuration problem until power, reset, and pin states are measured. It is not evidence that application C is wrong.
- Interface pins. For I2C, UART, SPI, USB: levels, pull-ups, idle state, and whether both ends agree on voltage. A logic analyzer beat a printf.
CHECK
If the debugger cannot attach, stop arguing about application code. Prove the CPU is powered, out of reset, and that the debug pins are still debug pins.
Minimal firmware as a test instrument
Full application firmware is a poor first instrument. It enables many peripherals, services interrupts, and hides timing. A few-kilobyte image that toggles one GPIO, loops one UART, or polls one bus tells you whether the silicon and the net can do that one thing.
If the minimal image fails the same way, the burden shifts toward hardware (or toward a configuration that is still hardware-adjacent: option bytes, boot pins, clock tree). If the minimal image works and the application fails, the burden shifts toward software, integration, or a hardware path the application uniquely stresses (high current, RF transmit, USB enumerate, external memory).
Keep the experiment honest: same board revision, same power, same temperature. Log the image hash.
When the bug is the interface
Some failures are not “the PCB” or “the C file.” They are the contract between them: pinmux, DMA versus cache, setup/hold on a bus, analog reference shared with a switching rail, or a radio that pulls the supply during TX. Those need simultaneous hardware and firmware evidence — a scope shot next to a register dump.
Race and configuration bugs should be claimed only when you can show two timings or two configs. “It feels racy” is not a diagnosis.
Evidence you should be able to show
- Board revision and firmware hash for every experiment
- A reproduction sequence another engineer can follow
- At least one measurement (voltage, logic capture, current, reset cause) that survives the meeting
- What was held constant when one variable changed
- Which hypothesis the last experiment ruled out
EVIDENCE
A cause is best-supported, not proven for all time. Record PASS, FAIL, or PEND against a stated check. Do not upgrade a guess because it is socially convenient.
Common wrong diagnosis
Replace the MCU first. Sometimes it is the MCU. Often it is orientation, solder, missing analog supply, or a rail that never came up. Measure before you unsolder.
Add delays until it “works.” A delay can mask a reset, a clock that is not ready, or a bus that needs a proper state machine. The symptom moved. The cause did not.
Trust printf as a scope. Logging changes timing and can hide or create the failure. Use it as a clue, then confirm on the wire.
Call it hardware because the previous firmware worked. Previous firmware may never have used the failing peripheral, current, or temperature.
When to escalate to Rescue
Escalate when reproduction exists, the cheap splits are done, and the team is still arguing from two unmeasured stories. Escalation is not “someone else will magically know.” It is another pair of hands running the same isolation method with lab instruments and a written best-supported cause.
This note is not a board bring-up service page. It does not claim a fix. It describes how to stop guessing.
NEXT GATE
Board still stuck after bring-up? Embedded Hardware Rescue isolates hardware and firmware with evidence, then names the next step.
Sources
- STMicroelectronics, AN2586, Getting started with STM32F10xxx hardware development (power, reset, boot, SWD/JTAG). st.com. Accessed 3 September 2026.
- STMicroelectronics, AN4488, Getting started with STM32F4xxxx MCU hardware development. st.com. Accessed 3 September 2026.
- Silicon Labs, AN0018.2, Supply Voltage Monitoring (brown-out / reset-cause use). silabs.com. Accessed 3 September 2026.
- Arm, ARM Debug Interface Architecture Specification (ADIv5 / CoreSight SWD-JTAG). developer.arm.com. Accessed 3 September 2026.