Seeing the error message “Could not stop Cortex-M device!” when trying to debug or program a Cortex-M chip over JTAG is a common issue that can often be resolved by checking the physical JTAG connections. There are a few key things to check:
1. Check the JTAG cable
The most likely culprit is a problem with the physical JTAG cable connecting the debugger to the target board. Here are some things to try:
- Inspect the cable for any obvious damage like cuts or crimps in the wiring.
- Wiggle and flex the cable while connected to see if the error comes and goes. This can reveal intermittent breaks in the wiring.
- Try swapping the cable out for a known good one if available.
- Test the cable continuity with a multimeter to verify there are no opens.
If wiggling the cable makes the error appear/disappear or if cable continuity fails, you likely need a new cable.
2. Check target power supply
Insufficient power to the target board can also cause JTAG communication issues. Verify:
- The board has a stable 3.3V or 5V power source connected.
- Power is being properly regulated with capacitors close to the JTAG pins.
- JTAG pin voltages are at expected levels.
Erratic target power can intermittently disrupt JTAG causing errors. Adding capacitors, checking regs, or fixing power issues may resolve it.
3. Check target board JTAG pin connections
It’s also important to closely inspect the physical JTAG connections between the cable and target board:
- Verify JTAG pinout and connections match documentation.
- Check for shorts or incorrect connections, especially around the TCK/TMS pins.
- Reseat JTAG connectors and reflow solder joints if needed.
- Inspect pins under a magnifying glass for cracked solder joints or other damage.
With high-speed JTAG signals, even small shorts/disconnects between pins can prevent stable communication.
4. Try lower JTAG clock speeds
Higher JTAG clock speeds can sometimes exceed cable/board capabilities leading to errors. Try lowering debugger JTAG clock speed settings incrementally until communication succeeds. Common speeds to try are 1 MHz, 500 kHz, or lower. If very slow speeds are required it can indicate cabling issues.
5. Update debugger firmware/software
Old or buggy debugger firmware and host software can also be a factor. Ensure you have the latest firmware and software installed. Interface chips like FTDI adapters in particular may require the latest drivers.
6. Disable other interfaces sharing pins
On some boards JTAG pins are shared with other interfaces like SWD, GPIO, SPI, etc. Make sure JTAG has exclusive access to the pins by disabling any other interfaces in firmware or hardware.
7. Try external JTAG isolators
For tricky issues, external JTAG isolators can help by cleaning up signal integrity issues between the debugger and target. They buffer the JTAG signals providing robust communication.
8. Verify target JTAG enable/disable settings
The target Cortex-M device JTAG interface may need to be explicitly enabled in firmware or unlocked. Consult documentation and ensure any required steps to enable JTAG are performed before trying to communicate over it.
9. Check target reset line
The JTAG communication relies on the target being in a stable reset/powered state. Verify the reset line is being held low and not pulsing erratically which could disrupt sync. A pull-down may be needed on reset.
10. Try JTAG chain re-enumeration
For complex JTAG chains with multiple chips, manually initiating a JTAG re-enumeration after connecting can help synchronize communication. The debugger may be getting confused about how many/which devices are in the chain.
Debugging JTAG communication issues takes patience but methodically checking connections, signal integrity, power, and settings will eventually uncover the root cause. Don’t forget to also reach out to the debugger hardware/software vendors for assistance – they may have additional advice for troubleshooting their tools.
With a bit of care to the hardware and configuration, JTAG can be a very reliable debug/programming interface for Cortex-M devices. Taking the time to properly diagnose tricky issues will pay off with a robust JTAG link for future development work.