Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

16.2 External debug and CoreSight

External debug means an agent outside the PE controls it: a JTAG probe, a Trace32 or DS-5 session, or a validation script driving the DAP. Debug events halt the PE in Debug state rather than raising an exception. The Arm ARM defines the PE side, meaning the external debug registers, Debug state and the authentication rules. The CoreSight architecture and ADIv5/ADIv6 define the fabric that gets the probe to those registers. A bring-up engineer needs both, because “the debugger can’t connect” is usually a fabric, power or authentication problem rather than a core problem.

Topology: probe to register

 probe ──JTAG/SWD──> DP (JTAG-DP / SW-DP / SWJ-DP)
                      │  DP CTRL/STAT: CDBGPWRUPREQ/ACK, CSYSPWRUPREQ/ACK
                      ├── APB-AP ──> debug APB ──> ROM table
                      │                           ├─ core0: debug | CTI | PMU | ETE/ETM  (4KB frames)
                      │                           ├─ core1: ...
                      │                           └─ CTM, funnels, TMC/ETR, STM ...
                      └── AXI-AP / AHB-AP (MEM-AP) ──> system interconnect ──> DRAM, peripherals
  • The DP (Debug Port) terminates the wire protocol. Before anything behind it responds, the debugger sets CDBGPWRUPREQ (debug power domain) and CSYSPWRUPREQ (system power) in DP CTRL/STAT and waits for the matching ACK bits. A board that never returns CDBGPWRUPACK has a power-controller or reset-sequencing problem, not a core problem.
  • APs (Access Ports) are bus masters. A MEM-AP issues memory transactions, with attributes taken from its CSW register. The APB-AP masters the debug APB. In ADIv6, APs are themselves found through ROM tables and can sit behind other APs.
  • The ROM table lists components by offset. Every CoreSight component has 4KB of registers with CIDR/PIDR identification at the top and DEVARCH/DEVTYPE describing it. For an A-profile PE, the Arm ARM fixes the layout of the debug frame (EDSCR at 0x088, EDITR at 0x084, DBGBCR<n>_EL1 at 0x408 + 16n, OSLAR_EL1 at 0x300, and so on), and separately the PMU, CTI and trace frames.
  • Software-lock registers (EDLAR, CTILAR, key 0xC5ACCE55) apply only to accesses from the system side (that is, from software on a core). Accesses through the APB-AP are external and bypass them. The software lock is optional and Arm deprecates it, so many current implementations leave it out.

Bring-up note: on a multi-chiplet SoC, each chiplet usually has its own DP or a nested AP/ROM-table subtree, and the die-to-die link must be up and its debug bridge configured before the remote ROM table is visible. Ask the SoC team for the actual ROM-table walk, with base addresses, before blaming the probe. A useful first test is to read each core’s EDDEVARCH (offset 0xFBC) and EDPRSR.

Halting debug state

EDSCR is the external view of debug status and control:

FieldMeaning
STATUS[5:0]0b000010 Non-debug, 0b000001 restarting, 0b010011 external debug request, 0b000111 breakpoint, 0b101011 watchpoint, 0b011011 halting step, 0b101111 HLT, 0b100111 Reset Catch, 0b100011 OS Unlock Catch, 0b110111 Exception Catch
HDEhalting debug enable: breakpoints, watchpoints and HLT halt instead of taking exceptions
ITEthe instruction written to EDITR has completed
ERRcumulative error flag, cleared by writing EDRCR.CSE
MAmemory access mode (below)
TXfull/RXfullDebug Communications Channel (DCC) handshake
EL, NS, NSE, RWthe Exception level, Security state and register width while halted

Halting events are: External Debug Request (a CTI output, below), breakpoints and watchpoints with HDE == 1, HLT #imm, halting step (EDECR.SS), and the catch events EDECR.RCE (Reset Catch) and EDECR.OSUCE (OS Unlock Catch). EDESR records pending ones. Reset Catch is the bring-up workhorse: it halts the core on the first instruction after reset, before any firmware runs.

In Debug state the PE does not fetch. The debugger writes A64 instructions to EDITR, which the PE executes one at a time, and moves data through DBGDTRRX_EL0/DBGDTRTX_EL0. Reading a system register looks like this:

EDITR <- MRS X0, VBAR_EL3        // only if halted at EL3, or after DCPS3
EDITR <- MSR DBGDTR_EL0, X0      // X0 -> DTR (both halves)
read DBGDTRTX (low word), DBGDTRRX (high word)

DCPS1/2/3 change EL while halted (DCPS3 subject to authentication), and DRPS lowers the EL as an ERET would (from SPSR_ELx) but does not branch. The PSTATE saved on entry to Debug state is in DSPSR_EL0, with the resume address in DLR_EL0, and both are restored on exit. Leaving Debug state is only possible through a CTI restart trigger (below). No register write exits it directly.

EDPRSR is the first register to read on any core you cannot talk to, because it is designed to stay readable while the core is powered down. It reports PU (core powered up), SPD (sticky power-down: the core lost power since the last read, so debug register state was lost), R/SR (in reset / sticky reset), HALTED, OSLK (OS Lock, which 16.1 says blocks most debug-frame accesses), DLK (double lock), and the RME and Debugv8p4 “access disabled” status bits (EDAD, SDAD, EPMAD, SPMAD, …).

CTI and CTM: halting everything at once

Each PE has a CTI (Cross-Trigger Interface). Trigger inputs come from PE events and trigger outputs drive PE actions. The CTIs exchange events over a small number of broadcast channels on the CTM (Cross-Trigger Matrix). The architected PE connections are:

CTI triggerDirectionMeaning
input 0PE → CTIcross-halt trigger: the PE entered Debug state
input 1PE → CTIPMU overflow
inputs 4–7trace → CTItrace unit external outputs (when present)
output 0CTI → PEDebug request: the halting event
output 1CTI → PERestart request: exit Debug state
output 2CTI → GICgeneric CTI interrupt
outputs 4–7CTI → tracetrace unit external inputs

A cross-halt setup, done on every core’s CTI:

CTICONTROL.GLBEN = 1
CTIINEN0  = 1<<0      // input trigger 0 (I halted) -> channel 0
CTIOUTEN0 = 1<<0      // channel 0 -> output trigger 0 (debug request)
CTIOUTEN1 = 1<<1      // channel 1 -> output trigger 1 (restart)
CTIGATE   = 0b11      // let channels 0,1 propagate to/from the CTM

To halt everything, write CTIAPPPULSE = 1<<0 on any CTI, or let any core hit a breakpoint. Its cross-halt input fires channel 0, and every core receives a debug request. To restart:

  1. On each core, write CTIINTACK = 1<<0. The debug request output is latched until acknowledged. If you restart without acking, the core halts again at once.
  2. Poll CTITRIGOUTSTATUS bit 0 until it reads 0.
  3. Write CTIAPPPULSE = 1<<1 (channel 1). Every core leaves Debug state, and EDSCR.STATUS passes through 0b000001 to 0b000010.

Cross-halting is not simultaneous. The CTM is usually asynchronous across clock domains, so cores stop at different times, with an implementation-dependent spread that can be many cycles. Do not treat a cross-halt snapshot as a coherent point in time for memory-ordering analysis (7.1).

Authentication: who may halt what

The authentication interface consists of signals driven by the SoC (fuses, life-cycle state, a security controller), and the PE evaluates them through ASL functions:

SignalASL predicatePermits
DBGENExternalInvasiveDebugEnabled()halting and invasive access in Non-secure state
SPIDEN (with DBGEN)ExternalSecureInvasiveDebugEnabled()the same in Secure state
NIDEN, SPNIDENExternal[Secure]NoninvasiveDebugEnabled()trace and PMU counting, before FEAT_Debugv8p4
RLPIDEN (RME)ExternalRealmInvasiveDebugEnabled()Realm state
RTPIDEN (RME)ExternalRootInvasiveDebugEnabled()Root state (EL3 under RME)

With FEAT_Debugv8p4, the separate non-invasive signals are gone in effect: Non-secure non-invasive debug is always permitted (DBGAUTHSTATUS_EL1.NSNID can only read “enabled”), and Secure non-invasive debug follows Secure invasive debug (SNID == SID). DBGAUTHSTATUS_EL1 reports the evaluated result per state (NSID, SID, RLID, RTID, …). It is the register to read when a debugger “can see the core but cannot halt it”. For how the RME signals combine with DBGEN and SPIDEN, see the ASL definitions of these predicates rather than relying on the signal names.

A halting event that is not allowed in the current state does not halt and is not lost if it is a level-held request. External Debug Request stays asserted until acknowledged, so a core running EL3 code with SPIDEN = 0 halts at the first instruction after it enters a state where halting is allowed. Breakpoints, watchpoints and HLT that are not allowed behave as if HDE == 0.

EL3 software has additional controls over register access by an external debugger: MDCR_EL3.EDAD/EDADE (breakpoint, watchpoint and OSLAR_EL1 access per Security state), MDCR_EL3.EPMAD/EPMADE (PMU frame), and ETAD/ETADE (trace). The E...E “extended” bits exist with RME to add Realm to the set. These do not stop halting. They stop a debugger from reprogramming hardware the Secure or Realm world depends on.

Security note: debug authentication is the gate that turns a production device into a development device. For review, the questions are: which life-cycle states drive DBGEN/SPIDEN/RTPIDEN high; whether the signals can change at runtime (an authenticated debug unlock, and what the CPU sees during the transition); whether MEM-APs into Secure or Root memory are gated by the same policy, since an AXI-AP that can issue Secure transactions bypasses the PE’s authentication entirely; and whether MDCR_EL3.EDAD/EPMAD are set when SPIDEN is low.

Debugging across power-down

Pre-DoPD Armv8 splits the external debug registers between a Debug power domain (kept on while debugging, holding for example EDPRSR, EDPRCR.COREPURQ, the EDECR Reset Catch and OS Unlock Catch controls, and the ID registers. The per-field domain is given in each register description) and the Core power domain (everything else, lost on power-down). Using the debug-domain registers:

  • EDPRCR.CORENPDRQ (also visible as DBGPRCR_EL1.CORENPDRQ) asks the power controller to emulate power-down: the core goes through CPU_SUSPEND/CPU_OFF, but its registers survive.
  • EDPRCR.COREPURQ asks for Core power-up so that the debugger can reach a core that is off.
  • EDPRSR.SPD and SR tell the debugger that state was lost and that breakpoints must be reprogrammed.

With FEAT_DoPD, all external debug registers live in the Core power domain. Accesses to a powered-down core return an error, COREPURQ is gone, and power-up requests go through an IMPLEMENTATION DEFINED mechanism, typically a CoreSight Granular Power Requester or the system power controller. CORENPDRQ remains. The OS Double Lock is not permitted with DoPD (16.1).

Touching memory and system registers without side effects

There are two paths, with opposite trade-offs:

  1. Through the halted PE. Use EDITR loads and stores, or memory access mode (EDSCR.MA = 1), where each read of DBGDTRTX executes an implicit LDR W1, [X0], #4 and each write of DBGDTRRX executes an implicit STR. Accesses use the PE’s current translation regime, attributes and caches, so they are coherent with what software sees. They can also allocate cache lines, fill TLBs and move PMU event counts. Breakpoints and watchpoints do not fire, because debug events are not generated in Debug state. They can fault: EDSCR.ERR is set and the fault syndrome appears in the halted context’s ESR/FAR.
  2. Through a MEM-AP. This does not disturb the PE at all. What it sees depends on where the AP sits and on CSW attributes. A non-coherent AXI-AP reading DRAM sees stale data for lines that are dirty in a core’s cache. A debug master on an I/O-coherent (ACE-Lite or CHI RN-I) port that issues cacheable shareable reads snoops the caches and sees current data. Writes through a non-coherent AP can also be overwritten later by a dirty-line eviction (8.7).

Practical rule: for software-visible truth, read through the PE, or clean to PoC first by issuing DC CVAC through EDITR. To inspect memory without changing cache or TLB state, use a coherent MEM-AP. To inspect the caches themselves, use the IMPLEMENTATION DEFINED RAM-index system instructions that many Arm cores provide in Debug state (see the core TRM). These are core-specific, not architectural.

Validation note: test cross-halt and authentication as properties, not as demos.

  • (1) With all CTIs programmed, pulse channel 0 and check that EDPRSR.HALTED == 1 and EDSCR.STATUS == 0b010011 on every core. Measure the spread using timestamps from each core’s trace, or from CNTVCT_EL0 read in Debug state.
  • (2) Restart without CTIINTACK and expect an immediate re-halt. That proves the latch behaviour.
  • (3) With SPIDEN = 0, assert a debug request while a core spins in Secure EL1. It must not halt until it returns to Non-secure, and DBGAUTHSTATUS_EL1.SID must read 0b10.
  • (4) Power a core down with CORENPDRQ = 0 and confirm that EDPRSR.PU = 0 and SPD = 1, and that core-domain accesses return errors rather than hanging the DAP.

Checkpoint

Q16.2.1 A debugger halts all cores through the CTI, then pulses the restart channel. Every core leaves Debug state and immediately halts again with EDSCR.STATUS == 0b010011. What was missed?

  • A. EDRCR.CSE was not written, so the sticky error flag forced a re-halt
  • B. The debug request trigger output was not acknowledged with CTIINTACK, so it was still asserted
  • C. EDSCR.HDE must be cleared before restarting
  • D. Restart must be requested through EDPRCR, not the CTI
Answer

B. CTI output trigger 0 (debug request) stays asserted until it is acknowledged through CTIINTACK. Restarting with it still high is an External Debug Request again, which is exactly STATUS 0b010011. EDRCR.CSE clears EDSCR.ERR, and a sticky error causes no halt, which rules out A. Exit from Debug state is architecturally only through the CTI restart trigger, so D is backwards.

Read more: Arm ARM (DDI0487), “Cross-triggers” chapter, CTIINTACK, EDSCR

Q16.2.2 On a halted core, a debugger reads a buffer through a non-coherent AXI-AP and through the PE in memory access mode, and gets different data. Software on the core had just written the buffer through a Write-Back mapping. Which statement is correct?

  • A. The AP is correct. Memory access mode reads through a separate debug cache
  • B. The difference shows a coherency bug in the interconnect
  • C. The PE path is software-visible truth. The AP read DRAM while the new data was still dirty in the core’s cache
  • D. Both are UNKNOWN until the core is restarted
Answer

C. Memory access mode executes ordinary loads in the PE’s translation regime, so it hits the dirty lines. A non-coherent AP issues transactions that do not snoop the CPU caches, so it sees memory below the cache. That is expected behaviour, not a bug: the AP is not part of the coherent domain, which rules out B. Issue DC CVAC through EDITR first if you need the AP view to agree.

Read more: Arm ARM (DDI0487), “Memory access mode”, EDSCR.MA. ADIv6, “MEM-AP” CSW

Q16.2.3 On a production-fused part, DBGEN = 1 and SPIDEN = 0. A core executing BL31 at EL3 receives an External Debug Request. What happens?

  • A. The request stays pending. The core halts once it is executing in a state where halting is allowed, for example after ERET to Non-secure EL1 or EL2
  • B. The core halts at EL3, but EDITR instructions are ignored
  • C. The request is dropped and the debugger must re-issue it
  • D. The core takes a Debug exception to EL3 instead
Answer

A. Halting is not allowed in Secure state (EL3 without RME) when ExternalSecureInvasiveDebugEnabled() is FALSE. External Debug Request is a level held by the CTI output until it is acknowledged, so it takes effect at the first point where halting is allowed. It is not dropped, which rules out C. Halting events never turn into exceptions, which rules out D.

Read more: Arm ARM (DDI0487), “Halting allowed and halting prohibited”, DBGAUTHSTATUS_EL1