swo vs. etm trace - iar systems · • etm trace is a high-speed trace: – can select between...

26
Become highly efficient with big trace data Shawn A. Prestridge, Senior FAE

Upload: others

Post on 21-Aug-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

Become highly efficient with big trace data

Shawn A. Prestridge, Senior FAE

Page 2: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

Agenda • SWO vs. ETM trace • Constraining trace data • Profiling code • Code coverage • ETM vs. Function trace • Navigating trace data

Page 3: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

SWO vs. ETM Trace

Page 4: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

• When someone says “trace”, they generally mean ETM

• SWO Trace is a low-speed trace option for Arm Cortex cores:

– Not guaranteed to get every instruction – Buffers are on-chip and generally very small (~2kB) – Almost all Arm Cortex M3/M4/M7 MCUs can do SWO

trace

• ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full

MCU execution – Buffers are generally on the hardware debug probe

(up to 256Mbyte of trace memory on I-jet Trace) – Not all MCUs have the optional ETM module

SWO Trace vs. ETM Trace

Page 5: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

Constraining trace data

Page 6: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

Needle in a haystack • Trace can give you every single instruction

– Non-intrusive trace – Richer trace mode

• Can get hundreds of millions of instructions every second

• How do you find what’s really important?

Page 7: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

Constraining trace data • Trace start/stop breakpoints help you

look at only important data – Ignore idle tasks in an RTOS – Focus on only specific functions under test

• Selected instrumentation can help you determine program flow

Page 8: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

Profiling code

Page 9: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

Reasons to profile your code

• Identifies “hot spots” in code – Can help you identify bottlenecks – Shows where optimization efforts should be

focused • Can help you identify excessive contexts

switches in tasks/interrupts

Page 10: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

Other reasons • Data/stimuli are not being processed quickly enough

to meet application goals

• Interrupt servicing seems to take an inordinate amount of time

• Excessive battery drain/power usage

• Identifying potential spots for code refactoring

• Identify usage-based test cases

• Better understand cyclomatic complexity of application (more on this later)

Page 11: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

Profiling source data • Two different ways to profile:

– SWO (sampled) trace – ETM trace

• ETM has a larger data set and gives you a more accurate picture

Page 12: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

ETM Profiling • Two different ways:

– Flat trace data – Calls trace data

• Flat trace is good for identifying bottlenecks • Calls trace is good for finding excessive

context switches

Page 13: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

Code coverage

Page 14: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

Why do I need code coverage?

• Shows that you have executed every line of code – Verifies your test matrix – Required for most certifications – Can identify dead code

• Helps you do path analysis through code

Page 15: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

Cyclomatic complexity • Software metric used to measure the

“complexity” of an application

• Looks at the number of linearly independent paths through the code

• Helps you identify when code is too interdependent

Page 16: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

Why do I care about complexity? • Excessively complex code means that you

cannot easily change/fix code – Interdependency means code has lots

of tentacles – Makes regression testing harder

• Code coverage can help you understand your code’s complexity

Page 17: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

ETM vs. Function Trace

Page 18: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

Definitions • Both use the same ETM trace data • ETM Trace lets you see each individual instruction

– Interspersed with C source – Like looking at individual trees

• Function trace lets you see how function calls progress and return – Cycle counts show how long you’re in the function – Like looking at the whole forest

Page 19: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

What can they help me do? • ETM trace is good for:

– Finding cause of faults/exceptions – Diagnosing nested interrupt issues

• Function trace helps you: – Identify timing issues – Performance monitoring of code

Page 20: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

Navigating trace data

Page 21: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

Millions and millions • ETM trace generates copious quantities of

data – Difficult to find the section of code in which you

are interested – Navigation tools in trace window help you

• When combined with techniques mentioned previously, can help you quickly isolate issues

Page 22: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

Integrated profiling tools

Function profiling Based on simulator, sampled trace or full trace Execution time per function Select time interval

Timeline window shows the application’s profile Interrupt log, Data log, Event log, Call stack

Code coverage analysis Which code has been executed?

Trace analysis shows instruction path through your application

Page 23: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

• SuperSpeed USB 3.0 interface (5 Gbps) • Fully compatible with USB 2.0 (480 Mbps) • No power supply required, powered entirely by the USB port • Target power of up to 600mA can be supplied from I-jet Trace

with overload protection • Automatic core recognition • JTAG, SWD, target power consumption measuring

I-jet Trace for ARM Cortex-A/R/M

Trace features • Trace memory size up to 256 Mbyte • Up to 16-bit wide trace data collection • Up to 350MHz ETM trace clock • 64-bit timestamp with CPU cycle accuracy for timing analysis • Automatic alignment of parallel trace data skew on individual bits to compensate for PCB layout

and signal integrity problems • Automatic trace data and clock voltage threshold adjustments to get the most reliable capture with

noisy or un-terminated target boards • Support for trace logic levels from 1.2 V to 5V

Page 24: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

Demonstration

Page 25: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

Summary • Trace does generate abundant data,

but you can narrow down the scope

• Big data helps you to do code coverage and profiling, as well as understanding overall flow

• Trace data can be quickly navigated

Page 26: SWO vs. ETM Trace - IAR Systems · • ETM Trace is a high-speed trace: – Can select between stalling on trace FIFO full or full MCU execution – Buffers are generally on the hardware

• Get scanned to have this presentation emailed to you.

• Visit IAR Demo Space to get a demo of our technology.

Want to learn more?

Thank you for your attention!