SlideShare a Scribd company logo
LCU14-101: Coresight Overview 
Mathieu Poirier, LCU14 
LCU14 BURLINGAME
About this Presentation 
● What is CoreSight 
● Why Use CoreSight? 
● Coresight Components and HW tracing 
● Presentation of the Coresight Framework 
● Minimal steps to enable tracing 
● Upstreaming Strategy and Current Status 
● What is Coming Next 
● Question and Comments
Coresight in One Image 
Source: ARM Ltd.
What is CoreSight 
● A set of IP blocks added to ARM SoCs at synthesis time 
● IP blocks provide HW assisted system tracing using an out of band 
bus (ATB), i.e non-intrusive debug capabilities 
● Very useful for system profiling and debugging without costly 
external tools 
● CoreSight blocks are enabled/disabled at will 
● Synchronisation of many CoreSight sources allow for debugging of 
very complex scenarios. 
**Also includes JTAG specification, not covered in this 
presentation
Why Using CoreSight? 
● Enhanced tracing capabilities over common solutions: 
● Decoupling of CPU power state and tracing engine 
● Tuning and configuration of scenarios simply impossible to achieve with a JTAG 
● Synchronisation of traces from different source → multi-dimensional debugging 
● Two different trace format for enhance granularity (STM vs ETM) 
● Some debugging scenarios can’t afford to stop the target for 
debugging when a condition occurs: 
● Assembly chain in production 
● A vehicle in motion 
● Some Systems don’t have a JTAG port or the port is not 
accessible 
● Server with 256 processors 
● A probe in an oil well, somewhere in the field
Enhanced Tracing Capabilities 
● JTAGs require to have a connection with a core, making it difficult 
to trace power management intensive scenarios. 
● Enhance tuning and capabilities: 
● Address range comparators 
● Single address comparator 
● Context ID and Virtual ID tracing 
● Start and Stop address matching 
● Security states ex, secure, non-secure or both 
● External input for global system awareness 
● Three-state sequencer and counters 
● Tunables can be mixed to make very complex cases: 
● Start tracing only if in “secure mode”, between addresses 0xABC and 0xDEX, when 
the ID of the running process is 456.
Two Different Trace Format 
● STM: transform SW writes into STPv2 
● ETM/PTM: represent program flows using PFT 
CPU 
kernel 
user 
space 
DSP 
ETB 
TPIU 
STM 
SW writes 
PFTv1.1 
STPv2
Coresight Components 
● Coresight IP blocks are divided in 4 categories: 
● Source, link, sink and “global” (not official term) 
● Source: 
● Generate trace data (PFTv1.x and STPv2) 
● ETM (Embedded Trace Macrocell), PTM (Program Trace Macrocell) 
● STM (System Trace Macrocell) 
● Links: 
● Replicators - duplicate trace data, usually in 2 streams 
● Funnel - aggregate trace data, usually 8 to 1 
● Global: 
● CTI - Cross Trigger Interface, for communication between entities 
** The above list is not exclusive, there are other components **
A Typical Coresight System 
Source: ARM Ltd
ETM/PTM Trace Output 
● Trace output from ETM/PTMs are compressed to reduce the 
amount of space taken in the trace buffer (ETB). 
● The format is called Program Flow Trace (PFT) 
● Only waypoints are recorded: 
● A waypoint is a point where instruction execution by the processor might involve a 
change in the program flow 
● Can be an instruction (ex. indirect branches) or an event (ex. all exceptions) 
● Each waypoint means that instructions between the current 
waypoint address and the previous one have been executed. 
● Using waypoints and the original program image, the program 
flow can be reconstructed. 
● Atoms are used to indicate waypoint instruction execution.
ETM/PTM Trace Output Decoding 
● Decoding trace output is not to be taken lightly. 
● Program Linaro has experimented with: 
● ptm2human [1]: 
● Not bad for an experimental exercise 
● List received packet, i.e, sync, atoms, timestamps 
● Does not interpret the content of the packet, so no waypoint decoding 
● completely free, thumbs up to “hwangcc23” 
● ARM DS-5: 
● Yields very detailed traces 
● Program execution can be reconstructed perfectly - see [2] for more information 
● Other trace decoding programs: 
● Texas Instrument’s Code Composer Studio 
● Lauderbach Trace32 
● Trace decoding is currently a big problem. 
● Linaro is weighing options on how to proceed in this area.
STM Trace Decoding 
● STM produces a trace stream conformant to the MIPI’s STPv2. 
● For more information see: 
● http://mipi.org/specifications/debug 
● Tools to decode STM traces: 
● ARM’s DS-5 
● ST-Microelectronic’s STM-Probe 
● Liewenthal Electronic’s Fido box
Linaro CoreSight Framework 
● Linaro Started working on CoreSight in March after LCA2014 
● Started from the initial framework submitted by Pratik Patel [3] 
● The framework provides support for: 
● source: ETMv3.3 to ETMv3.5 along with PTMv1.0 and PTMv1.1 
● link: 8 port funnel and non-configurable replicator 
● sink: ETBv1.0, TPIU and TMC (Trace Memory Controller) 
● Support for STM and CTI will be submitted when the base 
framework is accepted upstream. 
● With the framework it is possible to aggregate, configure and 
collect trace data seamlessly on a platform.
Where to get the code 
● Coresight branch on git.linaro.og: 
● https://git.linaro.org/kernel/coresight.git/ 
● Always look at the “master” branch for the latest code 
● The code is rebased on the latest release 
● The Coresight framework and drivers are under drivers/coresight/ 
● Menuconfig options can be found under “Kernel Hacking/Coresight Tracing Support” 
● Earlier submission and initial RFC are also present. 
● Upstream submission if you want to see what we’ve done: 
● V1: http://thread.gmane.org/gmane.linux.kernel/1714785 
● V2: http://thread.gmane.org/gmane.linux.kernel/1734361 
● V3: https://lkml.org/lkml/2014/8/7/439 
● V4: https://lkml.org/lkml/2014/8/20/618
CoreSight Framework Highlights 
● Provides an easy integration via DT for any platforms with generic 
coreSight components 
● Plenty of flexibility for addition of, new non-generic devices 
● A front-end/back-end configuration for common and architecture specific parts are very 
likely to happen. 
● Device specific method to access DT configuration can also be done easily 
● Access via debugfs of all ETM/PTM configuration registers 
● Processor state (hibernation) not coupled with ETM/PTM 
configuration 
● Multiple configuration of source and sink is supported. 
● Provides interface for reporting the status of various components 
and the gathering of meta data.
CoreSight Framework 
● When the framework boots coresight devices are discovered 
● The individual drivers will then register each newly found device 
with the framework: 
coresight-tpiu 20030000.tpiu: TPIU initialized 
coresight-etb10 20010000.etb: ETB initialized 
coresight-funnel 20040000.funnel: FUNNEL initialized 
coresight-replicator replicator: REPLICATOR initialized ← non-configurable replicator don’t have an address map 
coresight-etm3x 2201c000.ptm: ETM initialized 
coresight-etm3x 2201d000.ptm: ETM initialized 
coresight-etm3x 2203c000.etm: ETM initialized 
coresight-etm3x 2203d000.etm: ETM initialized 
coresight-etm3x 2203e000.etm: ETM initialized
CoreSight Framework 
● When the kernel has booted, coresight devices and attributes are 
found under /sys/kerne/debug/coresight: 
root@linaro-developer:~# cd /sys/kernel/debug/coresight/ 
root@linaro-developer:/sys/kernel/debug/coresight# ls 
00000000.replicator 20030000.tpiu 2201c000.ptm 2203c000.etm 2203e000.etm 
20010000.etb 20040000.funnel 2201d000.ptm 2203d000.etm 
root@linaro-developer:/sys/kernel/debug/coresight# ls 20010000.etb/ 
enable status trigger_cntr 
root@linaro-developer:/sys/kernel/debug/coresight# ls 2201c000.ptm/ 
addr_acctype cntr_idx enable nr_ctxid_cmp seq_32_event 
addr_idx cntr_rld_event enable_event reset seq_curr_state 
addr_range cntr_rld_val etmsr seq_12_event status 
addr_single cntr_val fifofull_level seq_13_event sync_freq 
addr_start ctxid_idx mode seq_21_event timestamp_event 
addr_stop ctxid_mask nr_addr_cmp seq_23_event traceid 
cntr_event ctxid_val nr_cntr seq_31_event trigger_event 
root@linaro-developer:/sys/kernel/debug/coresight#
CoreSight Framework 
● By default the first address comparator is configured with “_stext” 
and “_etext” → good health check of coresight implementation 
root@linaro-developer:/sys/kernel/debug/coresight# ls 
00000000.replicator 20030000.tpiu 2201c000.ptm 2203c000.etm 2203e000.etm 
20010000.etb 20040000.funnel 2201d000.ptm 2203d000.etm 
root@linaro-developer:/sys/kernel/debug/coresight# ls 20010000.etb 
enable status trigger_cntr 
root@linaro-developer:/sys/kernel/debug/coresight# cat 2201c000.ptm/addr_range 
0x80008280 0x805d34d8 ← Addresses match with _stext and _etext in “System.map” 
root@linaro-developer:/sys/kernel/debug/coresight# ls 20010000.etb/ 
enable status trigger_cntr 
root@linaro-developer:/sys/kernel/debug/coresight# echo 1 > 20010000.etb/enable ← Enable at least one source 
root@linaro-developer:/sys/kernel/debug/coresight# echo 1 > 2201c000.ptm/enable ← System already configure, simply enable 
tracing 
root@linaro-developer:/sys/kernel/debug/coresight# cat 20010000.etb/status 
Depth: 0x2000 
Status: 0x1 
RAM read ptr: 0x0 
RAM wrt ptr: 0x1aeb ← RAM write pointer is incrementing, i.e, traces are being collected 
Trigger cnt: 0x0 
Control: 0x1 
Flush status: 0x0 
Flush ctrl: 0x2001 
root@linaro-developer:/sys/kernel/debug/coresight#
Enabling a “Path” using the Framework 
Source: ARM Ltd
CoreSight Framework 
● When satisfied with trace collection, simply harvest the content of 
the ETB buffer: 
root@linaro-developer:/sys/kernel/debug/coresight# echo 0 > 2201c000.ptm/enable 
root@linaro-developer:/sys/kernel/debug/coresight# ls /dev/ 
Display all 166 possibilities? (y or n) 
.initramfs/ snd/ tty55 
.udev/ stderr tty56 
20010000.etb stdin tty57 
audio stdout tty58 
block/ tty tty59 
bus/ tty0 tty6 
char/ tty1 tty60 
root@linaro-developer:/sys/kernel/debug/coresight# dd if=/dev/20010000.etb of=~/cstrace.bin 
64+0 records in 
64+0 records out 
32768 bytes (33 kB) copied, 0.00233771 s, 14.0 MB/s 
root@linaro-developer:/sys/kernel/debug/coresight# 
root@linaro-developer:/sys/kernel/debug/coresight# ll ~/cstrace.bin 
-rw-r--r-- 1 root root 32768 Aug 22 16:00 /root/cstrace.bin ← File with the trace data, in PFT format 
root@linaro-developer:/sys/kernel/debug/coresight#
Upstreaming Stargegy and Status 
● CodeAurora’s submission created a lot of talk on STM and CTI 
implementation 
● Linaro’s goal was to establish a foundation without being impaired 
by STM and CTI debates 
● Concentrating on basic tracing would concentrate efforts and 
discussions on the framework implementation 
● STM and CTI will be coming as soon as the framework gets 
accepted upstream. 
● At this time we have been through 4 submission, each round 
yielding very fruitful comments and ideas
What is next 
● Currently supported platforms: 
● ARM Vexpress-TC2 
● TI beagle/beagleXM 
● Huawei’s D01 board (upstreaming currently under way) 
● New platforms we are currently working on: 
● Qualcomm APQ8074 
● TI UEVM5432 (OMAP5) 
● Support for STM/STM500 
● Need to find a way to manage channel allocation between user and kernel space 
● How to model external input in a flexible and generic way? 
● Userspace tool and libraries… 
● CTI (Cross Trigger Interface) 
● John Hunter (formely?) at TI published a good driver on github 
● codeAurora also has one, need to look at both
What is Next (Cont’d) 
● Support for ARMv8 
● The framework has been developed on ARMv7, need to see how it will work on V8 
● Devices, like STM500 ant ETMv4, are tailored for V8 
● STM500 may turn out to be like STM 
● ETMv4 is a very different implementation than ETMv3.x 
● How to support the tracing of application code? 
● Integration with other kernel subsystem, i.e Perf and Ftrace 
● Follow what other architectures are doing and not re-invent the 
wheel: 
● Intel’s PT architecture [6][7] 
● MIPS ?
Challenges (Preview of the Next Session) 
● How data is represented in the trace stream depends on how the 
trace source has been configure (cycle accurate, timestamp) 
● Unlike ftrace, trace streams can’t simply be exported off platform and decoded 
● There has to be knowledge about the configuration and the image in memory 
● Commonly called the “metadata” problem 
● Identification of trace stream decoder that is open and free 
● ptm2human is a very good start. 
● etm-objdump[4]]5] also did a very promising decoder 
● Both need to be improved (and maintained) 
● How do we control traces from the kernel? 
● ftrace has the capability to start and stop traces using a kernel API 
● Do we need the same mechanism for coresight? 
● STM channel allocation and management
Question and Comment 
[1]. https://github.com/hwangcc23/ptm2human 
[2]. https://wiki.linaro.org/WorklingGroups/Kernel/Coresight/traceDecodingWithDS5 
[3]. http://lists.infradead.org/pipermail/linux-arm-kernel/2012-December/138646.html 
[4]. http://lists.linaro.org/pipermail/linaro-dev/2012-November/014439.html 
[5]. http://lists.linaro.org/pipermail/linaro-dev/2012-November/014476.html 
[6]. http://thread.gmane.org/gmane.linux.kernel/1771197 
[7]. https://software.intel.com/en-us/blogs/2013/09/18/processor-tracing
More about Linaro Connect: connect.linaro.org 
Linaro members: www.linaro.org/members 
More about Linaro: www.linaro.org/about/

More Related Content

PDF
LAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSD
PPTX
SATA Protocol
PPTX
DDR SDRAMs
PDF
Uvm dac2011 final_color
PDF
LCU14 500 ARM Trusted Firmware
PPTX
Bootloaders (U-Boot)
PPTX
Embedded System Programming on ARM Cortex M3 and M4 Course
PPTX
Slideshare - PCIe
LAS16-210: Hardware Assisted Tracing on ARM with CoreSight and OpenCSD
SATA Protocol
DDR SDRAMs
Uvm dac2011 final_color
LCU14 500 ARM Trusted Firmware
Bootloaders (U-Boot)
Embedded System Programming on ARM Cortex M3 and M4 Course
Slideshare - PCIe

What's hot (20)

PDF
U-Boot - An universal bootloader
PDF
System On Chip
PDF
Pcie basic
PPT
Double data rate (ddr)
PDF
Soc architecture and design
PDF
ARM CORTEX M3 PPT
PPT
U boot porting guide for SoC
PPTX
Advance Peripheral Bus
PPTX
I2c protocol - Inter–Integrated Circuit Communication Protocol
PPTX
Arm cortex-m3 by-joe_bungo_arm
PPT
Process and Threads in Linux - PPT
PDF
G Streamer Apps Development Manual
PDF
System-on-Chip
PPTX
dual-port RAM (DPRAM)
PPTX
Cache Memory- JMD.pptx
ODP
Pc ie tl_layer (3)
PDF
Ral by pushpa
PPT
Uart
PDF
System verilog important
U-Boot - An universal bootloader
System On Chip
Pcie basic
Double data rate (ddr)
Soc architecture and design
ARM CORTEX M3 PPT
U boot porting guide for SoC
Advance Peripheral Bus
I2c protocol - Inter–Integrated Circuit Communication Protocol
Arm cortex-m3 by-joe_bungo_arm
Process and Threads in Linux - PPT
G Streamer Apps Development Manual
System-on-Chip
dual-port RAM (DPRAM)
Cache Memory- JMD.pptx
Pc ie tl_layer (3)
Ral by pushpa
Uart
System verilog important
Ad

Viewers also liked (10)

PDF
Lca14 14-501- glibc-eglibc
PDF
Bridging the gap between hardware and software tracing
PDF
LCA14: LCA14-415: ACPI Power Management
PDF
LCU14 114- Upstreaming 201
PDF
LAS16-310: Introducing the first 96Boards TV Platform: Poplar by Hisilicon
PDF
LCU14-410: How to build an Energy Model for your SoC
PDF
LCU13: An Introduction to ARM Trusted Firmware
PPTX
AMBA 2.0 PPT
PDF
Amba bus
PDF
BUD17-TR01: Philosophy of Open Source
Lca14 14-501- glibc-eglibc
Bridging the gap between hardware and software tracing
LCA14: LCA14-415: ACPI Power Management
LCU14 114- Upstreaming 201
LAS16-310: Introducing the first 96Boards TV Platform: Poplar by Hisilicon
LCU14-410: How to build an Energy Model for your SoC
LCU13: An Introduction to ARM Trusted Firmware
AMBA 2.0 PPT
Amba bus
BUD17-TR01: Philosophy of Open Source
Ad

Similar to Lcu14 101- coresight overview (20)

PPTX
chipset debuging FTF-DES-F1321-QorIQ-Debug.pptx
PPTX
PDF
Embedded systems development Defcon 19
PDF
AAME ARM Techcon2013 004v02 Debug and Optimization
PDF
BPF Hardware Offload Deep Dive
PPTX
Defense_Presentation
PDF
Geep networking stack-linuxkernel
PPTX
Gl embedded starterkit_ethernet
PDF
1-AVR Introduction to Atmega32 good .pdf
PDF
BKK16-103 OpenCSD - Open for Business!
PDF
Phytium 64 core cpu preview
PDF
Tos tutorial
PDF
Install FD.IO VPP On Intel(r) Architecture & Test with Trex*
PDF
Asymmetric Multiprocessing - Kynetics ELC 2018 portland
PDF
AMP Kynetics - ELC 2018 Portland
PDF
HKG18-TR14 - Postmortem Debugging with Coresight
PDF
Freertos based environmental data acquisition using arm cortex m4 f core
PDF
ate_full_paper
PPT
No[1][1]
chipset debuging FTF-DES-F1321-QorIQ-Debug.pptx
Embedded systems development Defcon 19
AAME ARM Techcon2013 004v02 Debug and Optimization
BPF Hardware Offload Deep Dive
Defense_Presentation
Geep networking stack-linuxkernel
Gl embedded starterkit_ethernet
1-AVR Introduction to Atmega32 good .pdf
BKK16-103 OpenCSD - Open for Business!
Phytium 64 core cpu preview
Tos tutorial
Install FD.IO VPP On Intel(r) Architecture & Test with Trex*
Asymmetric Multiprocessing - Kynetics ELC 2018 portland
AMP Kynetics - ELC 2018 Portland
HKG18-TR14 - Postmortem Debugging with Coresight
Freertos based environmental data acquisition using arm cortex m4 f core
ate_full_paper
No[1][1]

More from Linaro (20)

PDF
Deep Learning Neural Network Acceleration at the Edge - Andrea Gallo
PDF
Arm Architecture HPC Workshop Santa Clara 2018 - Kanta Vekaria
PDF
Huawei’s requirements for the ARM based HPC solution readiness - Joshua Mora
PDF
Bud17 113: distribution ci using qemu and open qa
PDF
OpenHPC Automation with Ansible - Renato Golin - Linaro Arm HPC Workshop 2018
PDF
HPC network stack on ARM - Linaro HPC Workshop 2018
PDF
It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
PDF
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
PDF
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
PDF
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
PDF
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
PDF
HKG18-100K1 - George Grey: Opening Keynote
PDF
HKG18-318 - OpenAMP Workshop
PDF
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
PDF
HKG18-315 - Why the ecosystem is a wonderful thing, warts and all
PDF
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
PDF
HKG18-TR08 - Upstreaming SVE in QEMU
PDF
HKG18-113- Secure Data Path work with i.MX8M
PPTX
HKG18-120 - Devicetree Schema Documentation and Validation
PPTX
HKG18-223 - Trusted FirmwareM: Trusted boot
Deep Learning Neural Network Acceleration at the Edge - Andrea Gallo
Arm Architecture HPC Workshop Santa Clara 2018 - Kanta Vekaria
Huawei’s requirements for the ARM based HPC solution readiness - Joshua Mora
Bud17 113: distribution ci using qemu and open qa
OpenHPC Automation with Ansible - Renato Golin - Linaro Arm HPC Workshop 2018
HPC network stack on ARM - Linaro HPC Workshop 2018
It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-100K1 - George Grey: Opening Keynote
HKG18-318 - OpenAMP Workshop
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-315 - Why the ecosystem is a wonderful thing, warts and all
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18-TR08 - Upstreaming SVE in QEMU
HKG18-113- Secure Data Path work with i.MX8M
HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-223 - Trusted FirmwareM: Trusted boot

Recently uploaded (20)

PDF
Encapsulation theory and applications.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Empathic Computing: Creating Shared Understanding
PDF
Review of recent advances in non-invasive hemoglobin estimation
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Cloud computing and distributed systems.
PDF
KodekX | Application Modernization Development
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
cuic standard and advanced reporting.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Modernizing your data center with Dell and AMD
Encapsulation theory and applications.pdf
Electronic commerce courselecture one. Pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Understanding_Digital_Forensics_Presentation.pptx
Machine learning based COVID-19 study performance prediction
Empathic Computing: Creating Shared Understanding
Review of recent advances in non-invasive hemoglobin estimation
The AUB Centre for AI in Media Proposal.docx
Cloud computing and distributed systems.
KodekX | Application Modernization Development
Per capita expenditure prediction using model stacking based on satellite ima...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Spectral efficient network and resource selection model in 5G networks
20250228 LYD VKU AI Blended-Learning.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
NewMind AI Weekly Chronicles - August'25 Week I
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
cuic standard and advanced reporting.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Modernizing your data center with Dell and AMD

Lcu14 101- coresight overview

  • 1. LCU14-101: Coresight Overview Mathieu Poirier, LCU14 LCU14 BURLINGAME
  • 2. About this Presentation ● What is CoreSight ● Why Use CoreSight? ● Coresight Components and HW tracing ● Presentation of the Coresight Framework ● Minimal steps to enable tracing ● Upstreaming Strategy and Current Status ● What is Coming Next ● Question and Comments
  • 3. Coresight in One Image Source: ARM Ltd.
  • 4. What is CoreSight ● A set of IP blocks added to ARM SoCs at synthesis time ● IP blocks provide HW assisted system tracing using an out of band bus (ATB), i.e non-intrusive debug capabilities ● Very useful for system profiling and debugging without costly external tools ● CoreSight blocks are enabled/disabled at will ● Synchronisation of many CoreSight sources allow for debugging of very complex scenarios. **Also includes JTAG specification, not covered in this presentation
  • 5. Why Using CoreSight? ● Enhanced tracing capabilities over common solutions: ● Decoupling of CPU power state and tracing engine ● Tuning and configuration of scenarios simply impossible to achieve with a JTAG ● Synchronisation of traces from different source → multi-dimensional debugging ● Two different trace format for enhance granularity (STM vs ETM) ● Some debugging scenarios can’t afford to stop the target for debugging when a condition occurs: ● Assembly chain in production ● A vehicle in motion ● Some Systems don’t have a JTAG port or the port is not accessible ● Server with 256 processors ● A probe in an oil well, somewhere in the field
  • 6. Enhanced Tracing Capabilities ● JTAGs require to have a connection with a core, making it difficult to trace power management intensive scenarios. ● Enhance tuning and capabilities: ● Address range comparators ● Single address comparator ● Context ID and Virtual ID tracing ● Start and Stop address matching ● Security states ex, secure, non-secure or both ● External input for global system awareness ● Three-state sequencer and counters ● Tunables can be mixed to make very complex cases: ● Start tracing only if in “secure mode”, between addresses 0xABC and 0xDEX, when the ID of the running process is 456.
  • 7. Two Different Trace Format ● STM: transform SW writes into STPv2 ● ETM/PTM: represent program flows using PFT CPU kernel user space DSP ETB TPIU STM SW writes PFTv1.1 STPv2
  • 8. Coresight Components ● Coresight IP blocks are divided in 4 categories: ● Source, link, sink and “global” (not official term) ● Source: ● Generate trace data (PFTv1.x and STPv2) ● ETM (Embedded Trace Macrocell), PTM (Program Trace Macrocell) ● STM (System Trace Macrocell) ● Links: ● Replicators - duplicate trace data, usually in 2 streams ● Funnel - aggregate trace data, usually 8 to 1 ● Global: ● CTI - Cross Trigger Interface, for communication between entities ** The above list is not exclusive, there are other components **
  • 9. A Typical Coresight System Source: ARM Ltd
  • 10. ETM/PTM Trace Output ● Trace output from ETM/PTMs are compressed to reduce the amount of space taken in the trace buffer (ETB). ● The format is called Program Flow Trace (PFT) ● Only waypoints are recorded: ● A waypoint is a point where instruction execution by the processor might involve a change in the program flow ● Can be an instruction (ex. indirect branches) or an event (ex. all exceptions) ● Each waypoint means that instructions between the current waypoint address and the previous one have been executed. ● Using waypoints and the original program image, the program flow can be reconstructed. ● Atoms are used to indicate waypoint instruction execution.
  • 11. ETM/PTM Trace Output Decoding ● Decoding trace output is not to be taken lightly. ● Program Linaro has experimented with: ● ptm2human [1]: ● Not bad for an experimental exercise ● List received packet, i.e, sync, atoms, timestamps ● Does not interpret the content of the packet, so no waypoint decoding ● completely free, thumbs up to “hwangcc23” ● ARM DS-5: ● Yields very detailed traces ● Program execution can be reconstructed perfectly - see [2] for more information ● Other trace decoding programs: ● Texas Instrument’s Code Composer Studio ● Lauderbach Trace32 ● Trace decoding is currently a big problem. ● Linaro is weighing options on how to proceed in this area.
  • 12. STM Trace Decoding ● STM produces a trace stream conformant to the MIPI’s STPv2. ● For more information see: ● http://mipi.org/specifications/debug ● Tools to decode STM traces: ● ARM’s DS-5 ● ST-Microelectronic’s STM-Probe ● Liewenthal Electronic’s Fido box
  • 13. Linaro CoreSight Framework ● Linaro Started working on CoreSight in March after LCA2014 ● Started from the initial framework submitted by Pratik Patel [3] ● The framework provides support for: ● source: ETMv3.3 to ETMv3.5 along with PTMv1.0 and PTMv1.1 ● link: 8 port funnel and non-configurable replicator ● sink: ETBv1.0, TPIU and TMC (Trace Memory Controller) ● Support for STM and CTI will be submitted when the base framework is accepted upstream. ● With the framework it is possible to aggregate, configure and collect trace data seamlessly on a platform.
  • 14. Where to get the code ● Coresight branch on git.linaro.og: ● https://git.linaro.org/kernel/coresight.git/ ● Always look at the “master” branch for the latest code ● The code is rebased on the latest release ● The Coresight framework and drivers are under drivers/coresight/ ● Menuconfig options can be found under “Kernel Hacking/Coresight Tracing Support” ● Earlier submission and initial RFC are also present. ● Upstream submission if you want to see what we’ve done: ● V1: http://thread.gmane.org/gmane.linux.kernel/1714785 ● V2: http://thread.gmane.org/gmane.linux.kernel/1734361 ● V3: https://lkml.org/lkml/2014/8/7/439 ● V4: https://lkml.org/lkml/2014/8/20/618
  • 15. CoreSight Framework Highlights ● Provides an easy integration via DT for any platforms with generic coreSight components ● Plenty of flexibility for addition of, new non-generic devices ● A front-end/back-end configuration for common and architecture specific parts are very likely to happen. ● Device specific method to access DT configuration can also be done easily ● Access via debugfs of all ETM/PTM configuration registers ● Processor state (hibernation) not coupled with ETM/PTM configuration ● Multiple configuration of source and sink is supported. ● Provides interface for reporting the status of various components and the gathering of meta data.
  • 16. CoreSight Framework ● When the framework boots coresight devices are discovered ● The individual drivers will then register each newly found device with the framework: coresight-tpiu 20030000.tpiu: TPIU initialized coresight-etb10 20010000.etb: ETB initialized coresight-funnel 20040000.funnel: FUNNEL initialized coresight-replicator replicator: REPLICATOR initialized ← non-configurable replicator don’t have an address map coresight-etm3x 2201c000.ptm: ETM initialized coresight-etm3x 2201d000.ptm: ETM initialized coresight-etm3x 2203c000.etm: ETM initialized coresight-etm3x 2203d000.etm: ETM initialized coresight-etm3x 2203e000.etm: ETM initialized
  • 17. CoreSight Framework ● When the kernel has booted, coresight devices and attributes are found under /sys/kerne/debug/coresight: root@linaro-developer:~# cd /sys/kernel/debug/coresight/ root@linaro-developer:/sys/kernel/debug/coresight# ls 00000000.replicator 20030000.tpiu 2201c000.ptm 2203c000.etm 2203e000.etm 20010000.etb 20040000.funnel 2201d000.ptm 2203d000.etm root@linaro-developer:/sys/kernel/debug/coresight# ls 20010000.etb/ enable status trigger_cntr root@linaro-developer:/sys/kernel/debug/coresight# ls 2201c000.ptm/ addr_acctype cntr_idx enable nr_ctxid_cmp seq_32_event addr_idx cntr_rld_event enable_event reset seq_curr_state addr_range cntr_rld_val etmsr seq_12_event status addr_single cntr_val fifofull_level seq_13_event sync_freq addr_start ctxid_idx mode seq_21_event timestamp_event addr_stop ctxid_mask nr_addr_cmp seq_23_event traceid cntr_event ctxid_val nr_cntr seq_31_event trigger_event root@linaro-developer:/sys/kernel/debug/coresight#
  • 18. CoreSight Framework ● By default the first address comparator is configured with “_stext” and “_etext” → good health check of coresight implementation root@linaro-developer:/sys/kernel/debug/coresight# ls 00000000.replicator 20030000.tpiu 2201c000.ptm 2203c000.etm 2203e000.etm 20010000.etb 20040000.funnel 2201d000.ptm 2203d000.etm root@linaro-developer:/sys/kernel/debug/coresight# ls 20010000.etb enable status trigger_cntr root@linaro-developer:/sys/kernel/debug/coresight# cat 2201c000.ptm/addr_range 0x80008280 0x805d34d8 ← Addresses match with _stext and _etext in “System.map” root@linaro-developer:/sys/kernel/debug/coresight# ls 20010000.etb/ enable status trigger_cntr root@linaro-developer:/sys/kernel/debug/coresight# echo 1 > 20010000.etb/enable ← Enable at least one source root@linaro-developer:/sys/kernel/debug/coresight# echo 1 > 2201c000.ptm/enable ← System already configure, simply enable tracing root@linaro-developer:/sys/kernel/debug/coresight# cat 20010000.etb/status Depth: 0x2000 Status: 0x1 RAM read ptr: 0x0 RAM wrt ptr: 0x1aeb ← RAM write pointer is incrementing, i.e, traces are being collected Trigger cnt: 0x0 Control: 0x1 Flush status: 0x0 Flush ctrl: 0x2001 root@linaro-developer:/sys/kernel/debug/coresight#
  • 19. Enabling a “Path” using the Framework Source: ARM Ltd
  • 20. CoreSight Framework ● When satisfied with trace collection, simply harvest the content of the ETB buffer: root@linaro-developer:/sys/kernel/debug/coresight# echo 0 > 2201c000.ptm/enable root@linaro-developer:/sys/kernel/debug/coresight# ls /dev/ Display all 166 possibilities? (y or n) .initramfs/ snd/ tty55 .udev/ stderr tty56 20010000.etb stdin tty57 audio stdout tty58 block/ tty tty59 bus/ tty0 tty6 char/ tty1 tty60 root@linaro-developer:/sys/kernel/debug/coresight# dd if=/dev/20010000.etb of=~/cstrace.bin 64+0 records in 64+0 records out 32768 bytes (33 kB) copied, 0.00233771 s, 14.0 MB/s root@linaro-developer:/sys/kernel/debug/coresight# root@linaro-developer:/sys/kernel/debug/coresight# ll ~/cstrace.bin -rw-r--r-- 1 root root 32768 Aug 22 16:00 /root/cstrace.bin ← File with the trace data, in PFT format root@linaro-developer:/sys/kernel/debug/coresight#
  • 21. Upstreaming Stargegy and Status ● CodeAurora’s submission created a lot of talk on STM and CTI implementation ● Linaro’s goal was to establish a foundation without being impaired by STM and CTI debates ● Concentrating on basic tracing would concentrate efforts and discussions on the framework implementation ● STM and CTI will be coming as soon as the framework gets accepted upstream. ● At this time we have been through 4 submission, each round yielding very fruitful comments and ideas
  • 22. What is next ● Currently supported platforms: ● ARM Vexpress-TC2 ● TI beagle/beagleXM ● Huawei’s D01 board (upstreaming currently under way) ● New platforms we are currently working on: ● Qualcomm APQ8074 ● TI UEVM5432 (OMAP5) ● Support for STM/STM500 ● Need to find a way to manage channel allocation between user and kernel space ● How to model external input in a flexible and generic way? ● Userspace tool and libraries… ● CTI (Cross Trigger Interface) ● John Hunter (formely?) at TI published a good driver on github ● codeAurora also has one, need to look at both
  • 23. What is Next (Cont’d) ● Support for ARMv8 ● The framework has been developed on ARMv7, need to see how it will work on V8 ● Devices, like STM500 ant ETMv4, are tailored for V8 ● STM500 may turn out to be like STM ● ETMv4 is a very different implementation than ETMv3.x ● How to support the tracing of application code? ● Integration with other kernel subsystem, i.e Perf and Ftrace ● Follow what other architectures are doing and not re-invent the wheel: ● Intel’s PT architecture [6][7] ● MIPS ?
  • 24. Challenges (Preview of the Next Session) ● How data is represented in the trace stream depends on how the trace source has been configure (cycle accurate, timestamp) ● Unlike ftrace, trace streams can’t simply be exported off platform and decoded ● There has to be knowledge about the configuration and the image in memory ● Commonly called the “metadata” problem ● Identification of trace stream decoder that is open and free ● ptm2human is a very good start. ● etm-objdump[4]]5] also did a very promising decoder ● Both need to be improved (and maintained) ● How do we control traces from the kernel? ● ftrace has the capability to start and stop traces using a kernel API ● Do we need the same mechanism for coresight? ● STM channel allocation and management
  • 25. Question and Comment [1]. https://github.com/hwangcc23/ptm2human [2]. https://wiki.linaro.org/WorklingGroups/Kernel/Coresight/traceDecodingWithDS5 [3]. http://lists.infradead.org/pipermail/linux-arm-kernel/2012-December/138646.html [4]. http://lists.linaro.org/pipermail/linaro-dev/2012-November/014439.html [5]. http://lists.linaro.org/pipermail/linaro-dev/2012-November/014476.html [6]. http://thread.gmane.org/gmane.linux.kernel/1771197 [7]. https://software.intel.com/en-us/blogs/2013/09/18/processor-tracing
  • 26. More about Linaro Connect: connect.linaro.org Linaro members: www.linaro.org/members More about Linaro: www.linaro.org/about/