SoC
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
  • Arm Cortex M3
  • Contact
Reading: Fail to add JTAG/swd debug into Cortex-M0
SUBSCRIBE
SoCSoC
Font ResizerAa
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Search
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Have an existing account? Sign In
Follow US
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
© S-O-C.ORG, All Rights Reserved.
Arm

Fail to add JTAG/swd debug into Cortex-M0

Ryan Ryan
Last updated: October 5, 2023 9:58 am
Ryan Ryan 7 Min Read
Share
SHARE

Adding JTAG/SWD debug capability to a Cortex-M0 microcontroller can sometimes be tricky and fail unexpectedly. This is often due to subtle differences between MCU models as well as complexities in properly configuring the debug interface. With some diligence and methodical troubleshooting, the root cause can usually be identified and resolved.

Contents
Common Reasons JTAG/SWD Fails on Cortex-M0Incorrect JTAG/SWD Pin ConnectionsInvalid or Missing JTAG/SWD ConfigurationSecurity Locks or Memory ProtectionFaulty External Debug HardwareNoise or Signal Integrity IssuesStep-by-Step Debugging Process for Cortex-M0 JTAG/SWD1. Verify Debug Module is Enabled2. Check JTAG/SWD Pin Connections3. Initialize DAP and Debug Interface4. Confirm No Security Locks are Enabled5. Test with Known-Good Probe and Target6. Check Target Power Supplies and Decoupling7. Analyze JTAG/SWD Physical Signals8. Modify PCB Traces for Signal Integrity9. Update MCU or Debug Probe Firmware10. Consult Manufacturer Application NotesBypassing JTAG/SWD for Alternate Debug MethodsEmbedded Trace Macrocell (ETM)Serial Wire Output (SWO)Debug UART with BreakpointsOn-Chip Logic AnalyzerIn-Circuit Emulators (ICE)Conclusion

Common Reasons JTAG/SWD Fails on Cortex-M0

Incorrect JTAG/SWD Pin Connections

The first thing to check is that the JTAG/SWD pins on the MCU are properly connected to the debug probe. The pinout and layout for these signals can vary between MCU models so consulting the datasheet is essential. Some common issues are mismatched pin assignments, failure to tie pull-up/pull-down resistors, or lack of connectivity due to broken PCB traces.

Invalid or Missing JTAG/SWD Configuration

The Cortex-M0 debug module requires correct initialization and configuration via the Debug Access Port (DAP). This includes enabling debug mode, configuring the DAP, and selecting the appropriate debug interface (JTAG vs SWD). Debug probes have onboard ROM which handles this initialization, but it must be compatible with the specific MCU model.

Security Locks or Memory Protection

Many Cortex-M0 MCUs include security features like flash lock bits or memory protection units. If these are not properly handled, they can override debug access even if the interface is working physically. Make sure to unlock debug and avoid setting protections on memory regions needed for debugging.

Faulty External Debug Hardware

Issues with the debug probe itself, its drivers, or the USB connection to the host computer can manifest as JTAG/SWD failures. Try a known-good probe on the target to rule this out. Loose probe connections, poor probe power regulation, and buggy probe firmware can all prevent proper debug access.

Noise or Signal Integrity Issues

Electrical noise coupled onto the JTAG/SWD lines or trace impedances that distort the signals can cause intermittent glitches or total failure. Careful PCB layout, adequate decoupling, and bypass capacitors on the target system can help mitigate these issues.

Step-by-Step Debugging Process for Cortex-M0 JTAG/SWD

1. Verify Debug Module is Enabled

Consult the MCU datasheet and reference manual to locate the debug enable bit in the Debug Access Port (DAP). This bit controls whether the debug module communicates over the JTAG/SWD pins. Make sure it is set to 1 to enable debug access.

2. Check JTAG/SWD Pin Connections

Use a multimeter to test connectivity between MCU pins and debug probe. Verify 5V, GND, SWDIO, and SWCLK (plus /TRST if using JTAG) are properly wired based on your schematic and pinout diagram.

3. Initialize DAP and Debug Interface

Verify the debug probe is properly initializing the DAP port on your MCU. This requires a ROM table compatible with the chip. You may need to select different firmware or upgrade the probe.

4. Confirm No Security Locks are Enabled

Check for any flash security lock bits or MPU settings that could block debug access. Make sure to unlock the chip and avoid memory protection on regions like flash, SRAM, and debug module registers.

5. Test with Known-Good Probe and Target

Try substituting a proven debug probe and simple test board to identify any issues with target system or existing probe hardware/firmware.

6. Check Target Power Supplies and Decoupling

Inspect power supply voltages under operation and measure ripple. Add filtering capacitors if noise is excessive. The debug interface is sensitive to power issues.

7. Analyze JTAG/SWD Physical Signals

Use an oscilloscope or logic analyzer to verify JTAG/SWD connections are clean, without distortion or reflections. Add series resistors if necessary to dampen reflections.

8. Modify PCB Traces for Signal Integrity

Tune trace width and spacing to achieve proper 90Ω differential impedance for SWDIO/SWCLK. Minimize stubs, vias, and length mismatches. Route signals away from noise sources.

9. Update MCU or Debug Probe Firmware

Check chip and probe vendor websites for firmware patches that address any silicon bugs or debug initialization issues impacting your hardware version.

10. Consult Manufacturer Application Notes

Chip vendors often release detailed application notes on optimally configuring debug. Also check errata for your MCU revision.

Bypassing JTAG/SWD for Alternate Debug Methods

Embedded Trace Macrocell (ETM)

Some Cortex-M0 MCUs integrate an ETM module for instruction trace capture without needing SWD connectivity. This provides insight into code execution without halt-mode debugging.

Serial Wire Output (SWO)

The SWO pin can output debugging and instrumentation data from the Cortex-M0 real-time in normal operation. This provides trace visibility without halting execution.

Debug UART with Breakpoints

Instrumenting code with debug printouts over UART combined with software breakpoints can enable basic debugging without JTAG/SWD and with target running.

On-Chip Logic Analyzer

Some MCUs contain integrated logic analyzers to capture digital signals in real-time without debug probes. This is helpful for monitoring peripherals and I/O.

In-Circuit Emulators (ICE)

Full in-circuit emulators act as drop-in target replacements for more sophisticated and transparent debugging compared to JTAG/SWD probes.

Conclusion

While troubleshooting JTAG/SWD connectivity on Cortex-M0 can be frustrating, methodically verifying key debug requirements and addressing common issues will ultimately allow successful access. For non-critical debugging, alternate techniques like debug UART output or on-chip trace tools may suffice. With the right approach, most JTAG/SWD problems can be resolved and full unobtrusive debug achieved.

Newsletter Form (#3)

More ARM insights right in your inbox

 


Share This Article
Facebook Twitter Email Copy Link Print
Previous Article Fixing “unknown compiler option ‘-lint’” error when compiling Cortex-M0 in ModelSim
Next Article Will The Arm Architecture Replace The X86/X64 Architecture?
Leave a comment Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

2k Followers Like
3k Followers Follow
10.1k Followers Pin
- Sponsored-
Ad image

You Might Also Like

Does ARM Cortex-M3 have cache?

The short answer is no, the ARM Cortex-M3 processor does…

8 Min Read

ARM Application Binary Interface

The ARM application binary interface (ABI) defines the low-level interface…

7 Min Read

What is the TrustZone in the Arm Cortex?

The TrustZone is a security extension in the Arm Cortex…

6 Min Read

Configuration and optimization of threads and stacks for Keil RTX and Cortex-M0+

Configuring and optimizing threads and stacks for the Keil RTX…

5 Min Read
SoCSoC
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
Welcome Back!

Sign in to your account