
RISC-V External Debug Support
Version 0.13.2
d5029366d59e8563c08b6b9435f82573b603e48e
Editors:
Tim Newsome <tim@sifive.com>, SiFive, Inc.
Megan Wachs <megan@sifive.com>, SiFive, Inc.
Fri Mar 22 09:06:04 2019 -0700

Contributors to all versions of the spec in alphabetical order (please contact editors to suggest cor-
rections): Bruce Ableidinger, Krste Asanovi´c, Allen Baum, Mark Beal, Alex Bradbury, Chuanhua
Chang, Zhong-Ho Chen, Monte Dalrymple, Vyacheslav Dyachenko, Peter Egold, Markus Goehrle,
Robert Golla, John Hauser, Richard Herveille, Yung-ching Hsiao, Po-wei Huang, Scott Johnson,
Jean-Luc Nagel, Aram Nahidipour, Rishiyur Nikhil, Gajinder Panesar, Deepak Panwar, Antony
Pavlov, Klaus Kruse Pedersen, Ken Pettit, Joe Rahmeh, Gavin Stark, Wesley Terpstra, Jan-Willem
van de Waerdt, Stefan Wallentowitz, Ray Van De Walker, Andrew Waterman, Andy Wright, and
Bryan Wyatt.

Contents
1 Introduction 1
1.1 Terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.1 Context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.2 Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 About This Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2.1 Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2.2 Register Definition Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2.2.1 Long Name (shortname, at 0x123) . . . . . . . . . . . . . . . . . . . 2
1.3 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.4 Supported Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 System Overview 5
3 Debug Module (DM) 7
3.1 Debug Module Interface (DMI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.2 Reset Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.3 Selecting Harts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.3.1 Selecting a Single Hart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.3.2 Selecting Multiple Harts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.4 Hart States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.5 Run Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.6 Abstract Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
i

ii RISC-V External Debug Support Version 0.13.2
3.6.1 Abstract Command Listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.6.1.1 Access Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.6.1.2 Quick Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.6.1.3 Access Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.7 Program Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.8 Overview of States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.9 System Bus Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.10 Minimally Intrusive Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.11 Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.12 Debug Module Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.12.1 Debug Module Status (dmstatus, at 0x11) . . . . . . . . . . . . . . . . . . . 20
3.12.2 Debug Module Control (dmcontrol, at 0x10) . . . . . . . . . . . . . . . . . . 22
3.12.3 Hart Info (hartinfo, at 0x12) . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.12.4 Hart Array Window Select (hawindowsel, at 0x14) . . . . . . . . . . . . . . . 26
3.12.5 Hart Array Window (hawindow, at 0x15) . . . . . . . . . . . . . . . . . . . . 26
3.12.6 Abstract Control and Status (abstractcs, at 0x16) . . . . . . . . . . . . . . 27
3.12.7 Abstract Command (command, at 0x17) . . . . . . . . . . . . . . . . . . . . . 28
3.12.8 Abstract Command Autoexec (abstractauto, at 0x18) . . . . . . . . . . . . 29
3.12.9 Configuration String Pointer 0 (confstrptr0, at 0x19) . . . . . . . . . . . . . 29
3.12.10 Next Debug Module (nextdm, at 0x1d) . . . . . . . . . . . . . . . . . . . . . . 30
3.12.11 Abstract Data 0 (data0, at 0x04) . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.12.12 Program Buffer 0 (progbuf0, at 0x20) . . . . . . . . . . . . . . . . . . . . . . 30
3.12.13 Authentication Data (authdata, at 0x30) . . . . . . . . . . . . . . . . . . . . 31
3.12.14 Halt Summary 0 (haltsum0, at 0x40) . . . . . . . . . . . . . . . . . . . . . . 31
3.12.15 Halt Summary 1 (haltsum1, at 0x13) . . . . . . . . . . . . . . . . . . . . . . 31
3.12.16 Halt Summary 2 (haltsum2, at 0x34) . . . . . . . . . . . . . . . . . . . . . . 32
3.12.17 Halt Summary 3 (haltsum3, at 0x35) . . . . . . . . . . . . . . . . . . . . . . 32
3.12.18 System Bus Access Control and Status (sbcs, at 0x38) . . . . . . . . . . . . 32

RISC-V External Debug Support Version 0.13.2 iii
3.12.19 System Bus Address 31:0 (sbaddress0, at 0x39) . . . . . . . . . . . . . . . . 34
3.12.20 System Bus Address 63:32 (sbaddress1, at 0x3a) . . . . . . . . . . . . . . . 35
3.12.21 System Bus Address 95:64 (sbaddress2, at 0x3b) . . . . . . . . . . . . . . . 35
3.12.22 System Bus Address 127:96 (sbaddress3, at 0x37) . . . . . . . . . . . . . . . 36
3.12.23 System Bus Data 31:0 (sbdata0, at 0x3c) . . . . . . . . . . . . . . . . . . . . 36
3.12.24 System Bus Data 63:32 (sbdata1, at 0x3d) . . . . . . . . . . . . . . . . . . . 37
3.12.25 System Bus Data 95:64 (sbdata2, at 0x3e) . . . . . . . . . . . . . . . . . . . 37
3.12.26 System Bus Data 127:96 (sbdata3, at 0x3f) . . . . . . . . . . . . . . . . . . . 38
4 RISC-V Debug 39
4.1 Debug Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
4.2 Load-Reserved/Store-Conditional Instructions . . . . . . . . . . . . . . . . . . . . . . 40
4.3 Wait for Interrupt Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
4.4 Single Step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
4.5 Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.6 dret Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.7 XLEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.8 Core Debug Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.8.1 Debug Control and Status (dcsr, at 0x7b0) . . . . . . . . . . . . . . . . . . . 42
4.8.2 Debug PC (dpc, at 0x7b1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
4.8.3 Debug Scratch Register 0 (dscratch0, at 0x7b2) . . . . . . . . . . . . . . . . 45
4.8.4 Debug Scratch Register 1 (dscratch1, at 0x7b3) . . . . . . . . . . . . . . . . 45
4.9 Virtual Debug Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
4.9.1 Privilege Level (priv, at virtual) . . . . . . . . . . . . . . . . . . . . . . . . . 45
5 Trigger Module 47
5.1 Native M-Mode Triggers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
5.2 Trigger Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
5.2.1 Trigger Select (tselect, at 0x7a0) . . . . . . . . . . . . . . . . . . . . . . . . 49
评论2