Armv8 M Processor Debug 100734 0100 0100 en
Armv8 M Processor Debug 100734 0100 0100 en
Armv8 M Processor Debug 100734 0100 0100 en
Version 1.0
Document History
Your access to the information in this document is conditional upon your acceptance that you will not use or permit others to use
the information for the purposes of determining whether implementations infringe any third party patents.
THIS DOCUMENT IS PROVIDED “AS IS”. ARM PROVIDES NO REPRESENTATIONS AND NO WARRANTIES,
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTABILITY, SATISFACTORY QUALITY, NON-INFRINGEMENT OR FITNESS FOR A PARTICULAR PURPOSE
WITH RESPECT TO THE DOCUMENT. For the avoidance of doubt, ARM makes no representation with respect to, and has
undertaken no analysis to identify or understand the scope and content of, third party patents, copyrights, trade secrets, or other
rights.
TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL ARM BE LIABLE FOR ANY DAMAGES,
INCLUDING WITHOUT LIMITATION ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE, OR
CONSEQUENTIAL DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING
OUT OF ANY USE OF THIS DOCUMENT, EVEN IF ARM HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
This document consists solely of commercial items. You shall be responsible for ensuring that any use, duplication or disclosure of
this document complies fully with any relevant export laws and regulations to assure that this document or any portion thereof is
not exported, directly or indirectly, in violation of such export laws. Use of the word “partner” in reference to ARM’s customers is
not intended to create or refer to any partnership relationship with any other company. ARM may make changes to this document at
any time and without notice.
If any of the provisions contained in these terms conflict with any of the provisions of any signed written agreement covering this
document with ARM, then the signed written agreement prevails over and supersedes the conflicting provisions of these terms.
This document may be translated into other languages for convenience, and you agree that if there is any conflict between the
English version of this document and any translation, the terms of the English version of the Agreement shall prevail.
Words and logos marked with ® or ™ are registered trademarks or trademarks of ARM Limited or its affiliates in the EU and/or
elsewhere. All rights reserved. Other brands and names mentioned in this document may be the trademarks of their respective
owners. Please follow ARM’s trademark usage guidelines at http://www.arm.com/about/trademark-usage-guidelines.php
LES-PRE-20349
Confidentiality Status
This document is Non-Confidential. The right to use, copy and disclose this document may be subject to license restrictions in
accordance with the terms of the agreement entered into by ARM and the party that ARM delivered this document to.
ARM 100734_0100_0100_en Copyright © 2016 ARM Limited or its affiliates. All rights reserved. 2
Non-Confidential
ARM®v8-M Processor Debug
Product Status
The information in this document is Final, that is for a developed product.
Web Address
http://www.arm.com
ARM 100734_0100_0100_en Copyright © 2016 ARM Limited or its affiliates. All rights reserved. 3
Non-Confidential
Contents
ARM®v8-M Processor Debug
Preface
About this book ...................................................... ...................................................... 6
Feedback ...................................................................................................................... 8
ARM 100734_0100_0100_en Copyright © 2016 ARM Limited or its affiliates. All rights reserved. 4
Non-Confidential
Preface
ARM 100734_0100_0100_en Copyright © 2016 ARM Limited or its affiliates. All rights reserved. 5
Non-Confidential
Preface
About this book
Intended audience
Glossary
The ARM Glossary is a list of terms used in ARM documentation, together with definitions for those
terms. The ARM Glossary does not contain terms that are industry standard unless the ARM meaning
differs from the generally accepted meaning.
See the ARM Glossary for more information.
Typographic conventions
italic
Introduces special terminology, denotes cross-references, and citations.
bold
Highlights interface elements, such as menu names. Denotes signal names. Also used for terms
in descriptive lists, where appropriate.
monospace
Denotes text that you can enter at the keyboard, such as commands, file and program names,
and source code.
monospace
Denotes a permitted abbreviation for a command or option. You can enter the underlined text
instead of the full command or option name.
monospace italic
Denotes arguments to monospace text where the argument is to be replaced by a specific value.
monospace bold
Denotes language keywords when used outside example code.
<and>
Encloses replaceable terms for assembler syntax where they appear in code or code fragments.
For example:
MRC p15, 0, <Rd>, <CRn>, <CRm>, <Opcode_2>
SMALL CAPITALS
Used in body text for a few terms that have specific technical meanings, that are defined in the
ARM glossary. For example, IMPLEMENTATION DEFINED, IMPLEMENTATION SPECIFIC, UNKNOWN, and
UNPREDICTABLE.
ARM 100734_0100_0100_en Copyright © 2016 ARM Limited or its affiliates. All rights reserved. 6
Non-Confidential
Preface
About this book
Timing diagrams
The following figure explains the components used in timing diagrams. Variations, when they occur,
have clear labels. You must not assume any timing information that is not explicit in the diagrams.
Shaded bus and signal areas are undefined, so the bus or signal can assume any value within the shaded
area at that time. The actual level is unimportant and does not affect normal operation.
Clock
HIGH to LOW
Transient
HIGH/LOW to HIGH
Bus stable
Bus change
Signals
The signal conventions are:
Signal level
The level of an asserted signal depends on whether the signal is active-HIGH or active-LOW.
Asserted means:
• HIGH for active-HIGH signals.
• LOW for active-LOW signals.
Lowercase n
At the start or end of a signal name denotes an active-LOW signal.
ARM 100734_0100_0100_en Copyright © 2016 ARM Limited or its affiliates. All rights reserved. 7
Non-Confidential
Preface
Feedback
Feedback
Feedback on content
If you have comments on content then send an e-mail to [email protected]. Give:
• The title ARM®v8-M Processor Debug .
• The number ARM 100734_0100_0100_en.
• If applicable, the page number(s) to which your comments refer.
• A concise explanation of your comments.
ARM also welcomes general suggestions for additions and improvements.
Note
ARM tests the PDF only in Adobe Acrobat and Acrobat Reader, and cannot guarantee the quality of the
represented document when used with any other PDF reader.
ARM 100734_0100_0100_en Copyright © 2016 ARM Limited or its affiliates. All rights reserved. 8
Non-Confidential
Chapter 1
Debug for ARM®v8-M
Debugging is a key part of software development and is often considered to be the most time-consuming
part of the process. It enables software developers to halt program execution and determine the cause of
any problems. Developers often add breakpoint instructions into software, and data or hardware
watchpoints to examine the values of program variables or the contents of registers. Debug facilities that
are provided by a system are a vital consideration for any developer.
It contains the following sections:
• 1.1 Debug tools on page 1-10.
• 1.2 Types of debug on page 1-11.
• 1.3 Accessing debug features on page 1-13.
• 1.4 Debug support on page 1-14.
• 1.5 Debug authentication on page 1-15.
• 1.6 Debug registers on page 1-16.
• 1.7 Memory accesses on page 1-18.
• 1.8 Other debug functionality on page 1-19.
ARM 100734_0100_0100_en Copyright © 2016 ARM Limited or its affiliates. All rights reserved. 1-9
Non-Confidential
1 Debug for ARM®v8-M
1.1 Debug tools
ARM 100734_0100_0100_en Copyright © 2016 ARM Limited or its affiliates. All rights reserved. 1-10
Non-Confidential
1 Debug for ARM®v8-M
1.2 Types of debug
Halting debug
In halting debug, the debug event causes the core to enter debug state. In debug state, the core is halted,
meaning that it no longer fetches instructions. Instead, the core executes instructions under the direction
of a debugger running on a different host that is connected through an external interface.
Monitor debug
In Monitor debug, the debug event causes a debug exception to be raised. The exception must be handled
by dedicated debug monitor software running on the same core. Monitor debug assumes that there is
software support.
Profiling
Profiling is a technique that lets you identify sections of code that consume large proportions of the total
execution time. A profiler identifies which parts of the code are frequently executed and which occupy
the most core cycles. A profiler can also help you identify bottlenecks, situations where the performance
of the system is constrained by a few functions. This data is collected using instrumentation, an
execution trace, or sampling.
Profiling can be considered as a form of dynamic code analysis.
There are two basic approaches to gathering information: time-based sampling, and event-based
sampling.
Time-based sampling
The state of the system is sampled at a periodic interval. The size of the sampling interval can
affect the results. For example, a smaller sampling interval can increase execution time but
produce more detailed data.
ARM 100734_0100_0100_en Copyright © 2016 ARM Limited or its affiliates. All rights reserved. 1-11
Non-Confidential
1 Debug for ARM®v8-M
1.2 Types of debug
Event-based sampling
Sampling is driven by occurrences of an event, which means that the time between sampling
intervals is variable. Events can often be hardware-related, for example, cache misses.
ARM 100734_0100_0100_en Copyright © 2016 ARM Limited or its affiliates. All rights reserved. 1-12
Non-Confidential
1 Debug for ARM®v8-M
1.3 Accessing debug features
ARM 100734_0100_0100_en Copyright © 2016 ARM Limited or its affiliates. All rights reserved. 1-13
Non-Confidential
1 Debug for ARM®v8-M
1.4 Debug support
To see which are available for a particular ARMv8-M processor, see the relevant Technical Reference
Manual (TRM) for that processor.
ARM 100734_0100_0100_en Copyright © 2016 ARM Limited or its affiliates. All rights reserved. 1-14
Non-Confidential
1 Debug for ARM®v8-M
1.5 Debug authentication
The ARMv8-M architecture with Security Extension supports the same external debug control signals as
the ARMv8-M architecture with Main Extension with the same rules for enabling invasive, and non-
invasive debug being applied. Unlike the ARMv8-M architecture with Main Extension specification, the
baseline specification states that it is IMPLEMENTATION DEFINED whether many of the debug registers are
accessible from software running on the processor. Unless otherwise stated, the Security Extensions do
not change this behavior.
The following table shows how the various debug event sources are handled when invasive debug is
either disabled or not permitted in the current state.
Debug event source Types of behavior based on the invasive debug settings
Disabled Enabled but prohibited Enabled and allowed
by security level
BKPT instruction HardFault HardFault Debug event generated
C_HALT. Internal halt request. Writes to DHCSR.C_HALT are See note Pended
not possible when debug is disabled
VC_CORERESET Ignore
All other Vector catch Ignore
FPB breakpoint. The processor cannot ignore an FPB
Breakpoint and it will escalate to HardFault.
EDBGRQ. External halt request. When EDBGRQ is ignored by
the processor, the event remains pending in the system because
the signal remains asserted.
DWT watchpoint
ARM 100734_0100_0100_en Copyright © 2016 ARM Limited or its affiliates. All rights reserved. 1-15
Non-Confidential
1 Debug for ARM®v8-M
1.6 Debug registers
1.6.1 DCRSR
Secure registers are only accessible when DHCSR.S_SDE is 1. When a register is not accessible, it
behaves as RAZ/WI when accessed by a debugger.
The existing REGSEL field is extended to provide direct debugger access to:
• The SP_main, SP_process, CONTROL, FAULTMASK, BASEPRI, and PRIMASK registers for each
of:
— The current state view.
— Non-secure banked register.
— Secure banked register, if DHCSR.S_SDE == 1.
• The Secure stack limit registers, if DHCSR.S_SDE == 1.
If the floating-point extension is implemented, then because the FPSCR and S0-S31 registers can contain
data belonging to a different state from the one the processor is in. These registers are only accessible to
the debugger if invasive debug is enabled for the security state that is associated with the register state
(as indicated by the FPCCR register).
1.6.2 DSCSR
Debug security control and status register, address 0xE000EE08, controls the banking of memory-mapped
registers when accessed by the debugger, and allows the debugger to read and modify the current
security state of the processor.
Note
This method of bank selection means that the register aliasing is not used for accesses from the debugger.
Accesses to the aliased addresses from the debugger have the same behavior as reserved addresses.
1.6.3 DHCSR
A new status bit, DHCSR.S_SDE, is added. This bit indicates whether Secure invasive debug is enabled.
It is RES0 if Security Extensions are not implemented.
It normally reflects the state of the external authentication interface, but is frozen while the processor is
in Debug state.
Writes to DHCSR.C_SNAPSTALL are ignored if DHCSR.S_SDE == 0.
Interrupts that target Secure state are not masked by DHCSR.C_MASKINTS when DHCSR.S_SDE is 0.
1.6.4 DAUTHCTRL
Debug authentication control, address 0xE000EE04, resets to 0x0 allows the external Secure Debug
Enable authentication interface signals (SPIDEN and SPNIDEN) to be overridden from software.
This register can only be accessed by software running in the Secure privileged state, unprivileged
accesses generate a BusFault, and privileged Non-secure accesses behave as RAZ/WI. This register is
not accessible from the debugger.
1.6.5 DAUTHSTATUS
Debug authentication status, address 0b0xE000EFB8, indicates which debug features are present, and
status of these features. This register is compatible with the CoreSight™ AUTHSTATUS register.
ARM 100734_0100_0100_en Copyright © 2016 ARM Limited or its affiliates. All rights reserved. 1-16
Non-Confidential
1 Debug for ARM®v8-M
1.6 Debug registers
This register can only be accessed by the debugger or software running in a privileged mode, accesses
from the other states generates a BusFault.
To aid detection of what debug features are enabled or present this register is present in all ARMv8-M
processors, even if they do not implement the Security Extensions. However since processors without
Security Extensions only implement the Non-secure state, the Secure debug features are reported as not
implemented and disabled.
ARM 100734_0100_0100_en Copyright © 2016 ARM Limited or its affiliates. All rights reserved. 1-17
Non-Confidential
1 Debug for ARM®v8-M
1.7 Memory accesses
ARM 100734_0100_0100_en Copyright © 2016 ARM Limited or its affiliates. All rights reserved. 1-18
Non-Confidential
1 Debug for ARM®v8-M
1.8 Other debug functionality
1.8.1 FPB
Where a debugger can create unlimited soft breakpoints if code is in RAM, by simply swapping out a
breakpointed instruction and replacing it with a BKPT instruction, the Flash Patch and Breakpoint (FPB)
unit mimics this for non-volatile memory by returning a BKPT code for the comparator address.
Typically FPB implements hardware breakpoints, and patches code and data from Code space to System
space. Flash Patch allows a breakpoint to be set in ROM code which causes a branch to another address.
It can be used to replace instructions in ROM after it is masked.
The Flash Patch functionality is not implemented if the Security Extension is implemented.
The debug event that is associated with breakpoints defined by the FPB can be blocked if invasive debug
is not enabled for the mode the processor was in when the breakpoint became active.
Trace
For many real-time systems, it is not possible to use invasive debug methods. Consider, for example, an
engine management system. While you can stop the core at a particular point, the engine will keep
moving and you will not be able to do useful debug.
Any trace data that is generated is only logged if non-invasive debug is enabled for the security and
privilege state that the processor was in when the data was generated. For trace information related to
exceptions, the trace data must only be logged if non-invasive debug is enabled for the security state that
the exception is taken to.
1.8.3 DWT
The Data Watchpoint and Trace (DWT) unit is a debug unit that provides watchpoints and system
profiling for the processor. Data tracing is also available if the processor has been implemented with
DWT and ITM trace. It provides a series of counters which are triggered by processor events.
The DWT unit contains several counters that can count:
• Clock cycles.
• Folded instructions (If-Then and some NOPs).
• LSU operations.
• Sleep cycles.
• Interrupt overhead.
• Cycles Per Instruction (CPI).
The DWT unit also contains a Program Count Sample Register (PCSR). The PCSR can be used by a
debugger for crude profiling as it contains the instruction address of recently executed instructions.
The DWT unit interfaces to the core, ETM, and ITM.
When non-invasive debug is not enabled for the mode the processor is in, the DWT behaves as follows:
ARM 100734_0100_0100_en Copyright © 2016 ARM Limited or its affiliates. All rights reserved. 1-19
Non-Confidential
1 Debug for ARM®v8-M
1.8 Other debug functionality
DWT_CTRL
A control bit, DWT_CTRL.CYCDISS, is added to stop the cycle counter from incrementing when
executing Secure code. DWT_CTRL resets to 0.
ARM 100734_0100_0100_en Copyright © 2016 ARM Limited or its affiliates. All rights reserved. 1-20
Non-Confidential