use all of the debugging capabilities of arm trustzonedevices · bandwidth limited to 10’s of...
TRANSCRIPT
1Copyright © 2019 Arm TechCon, All rights reserved.Copyright © 2019 Arm TechCon, All rights reserved.
#ArmTechCon
Aaron Bauch, Senior FAEIAR Systems SoftwarePresentation 1258
Use all of the DebuggingCapabilities of ARM TrustZone Devices
2Copyright © 2019 Arm TechCon, All rights reserved.
Agenda
• ARM TrustZone
• ARM CoreSight
• Visibility for Debugging• SWO debugging and demo
• ETM Trace debugging• Multicore challenges and Demo
• Questions
3Copyright © 2019 Arm TechCon, All rights reserved.
ARM TrustZone
Adds hardware basis for protected systemsSeparates trusted software componentsEnforces separation with hardware
4Copyright © 2019 Arm TechCon, All rights reserved.
Arm Coresight
• Optional logic macrocells• Provide ICE-like data gathering• C-SPY Debugger in IAR Embedded Workbench providesvisibility of this data
• Available resources vary by core type
5Copyright © 2019 Arm TechCon, All rights reserved.
Arm Coresight Arm Cortex-M4 as example
DWT Data Watchpointand Trace unit
CPU statistics
FPB Flash Patch andBreakpoint unit
6 breakpoints
DAP Debug Access Port
JTAG
Livecore access
Interrupt trace
SWD/SWO
ITMInstrumentationTrace Macrocell
ETM trigger
ETB instruction trace
ETB Embedded Trace Buffer
ETM Embedded TraceMacrocell
ETM instruction trace
Trace port
4 watchpoints
PC samplerITM
Software trace32 channels
Time stamping
I-jet
I-jet Trace
6Copyright © 2019 Arm TechCon, All rights reserved.
SWO or full ETM Trace?
Full ETM TraceHigh speed data bus enables capture of full instruction stream
• Bandwidth up to hundreds of Mbytes
Enables full code coverage• Profiling based on full code execution data• Progressive code coverage to find every
unexecuted instruction
Enables looking ”back in time”Requires trace probe able to collect high-speed trace data, like I-jet Trace
SWOUses Serial Wire Output signal
• One wire high speed serial async interface• Bandwidth limited to 10’s of Mbits
Can provide rich information• Interrupt entry and exit times• Data logging• Power logging and break points• Event tracking with minimal overhead• Even RTOS task switch activity in real time
Works with any probe, I-jet or I-jet Trace
7Copyright © 2019 Arm TechCon, All rights reserved.
Probes with different capabilities
I-jet Trace
I-jetPowerful, quick, and user-friendly
Download speed of up to 1MB/sec
High-resolution measurements of target power consumption
Supports Embedded Trace Macrocell (ETM)
Large trace memory capacities
High-speed communication via SuperSpeed USB 3.0
8Copyright © 2019 Arm TechCon, All rights reserved.
Debug overview
9Copyright © 2019 Arm TechCon, All rights reserved.
What is debugging?
Wikipedia definition:“Debugging is a methodical process offinding and reducing the number of bugs,or defects, in a computer program or apiece of electronic hardware, thus makingit behave as expected.”
10Copyright © 2019 Arm TechCon, All rights reserved.
Comprehensive debugger
RTOS awareness
Timeline window
Integrated debugger for source and disassembly debugging
Edit source files without leaving the debug session
Dockable windows and tab groups
Performance analysis
Power vizualization
11Copyright © 2019 Arm TechCon, All rights reserved.
Considerations in complex
applications
12Copyright © 2019 Arm TechCon, All rights reserved.
RTOS Debugging challenges
Standard debugging tools only give information on the codethat is running
• No understanding that this code may be part of one of several threads.
• No understanding of the objects used to communicate between tasks
• No understanding of the concept of a Task Stack
Difficult to debug problems like:• Memory corruption
• Semaphore deadlock
• Stack overflow
13Copyright © 2019 Arm TechCon, All rights reserved.
Linker stack usage analysis
Linker can provide stack usage in .map file.
Task will be seen as Uncalled function.
Use Stack Usage Control file to identify asTask.
14Copyright © 2019 Arm TechCon, All rights reserved.
Additional debug features
Stack Analysis
• Runtime stack monitoring
Attach to running target
• Connect to the target anytime without resetting the application
15Copyright © 2019 Arm TechCon, All rights reserved.
• RTOS Aware plugins give you a high level of control and visibilityover an application built on top of a real-time operating system.
• They can display RTOS-specific items like task lists, queues,semaphores, mailboxes and various RTOS system objects.
• Task-specific breakpoints and task-specific stepping make iteasier to debug tasks as well.
RTOS-specific debugging tools
16Copyright © 2019 Arm TechCon, All rights reserved.
RTOS-aware debuggers
Stack start and end adress is not always known to user.Using an RTOS awareness plugin with the debugger can often display memoryusage of each thread’s stack.
17Copyright © 2019 Arm TechCon, All rights reserved.
Plugins
RTOS Awareness Plugin• Get instant information from your
RTOS
18Copyright © 2019 Arm TechCon, All rights reserved.
Timeline view of RTOS Task Switch
The Timeline can display task switch activity in real time
Alongside of Interrupt, power and data trace
19Copyright © 2019 Arm TechCon, All rights reserved.
Multicorechallenges
20Copyright © 2019 Arm TechCon, All rights reserved.
Debugging multicore processors
• Visibility of all cores• Start and stop cores simultaneously or individually• Step 1 core while others are running or stopped• Multicore breakpoints, e.g.• BP on 1 core stops execution on all cores• BP on core A with condition on core B
• Multicore Trace• Very challenging for Heterogeneous MCPs with different Trace capabilities, e.g.• Cortex-A9 has PTM (Program Trace)• Cortex-M3 or Cortex-A5/A8 has ETM• Some have even data trace
21Copyright © 2019 Arm TechCon, All rights reserved.
IAR Embedded Workbench SMP Support• Single debugger instance for all cores• Cores can be stopped/run individually or together
22Copyright © 2019 Arm TechCon, All rights reserved.
IAR Embedded Workbench AMP Support
Master (Cortex-A) Slave (Cortex-M4)
Start/stop core0/core1 Start/stop all cores
23Copyright © 2019 Arm TechCon, All rights reserved.
Arm CoreSight and ETM Trace
24Copyright © 2019 Arm TechCon, All rights reserved.
ETM Trace
Time
Bug happens Break
Without trace
Without trace: Not every instruction captured
With traceTrace information~103.. ~106 instructions
With trace: Possible to go back in time and evaluate the behavior
25Copyright © 2019 Arm TechCon, All rights reserved.
Integrated profiling toolsFunction profiling • Based on simulator, sampled trace
or full trace• Execution time per function• Select time interval
Timeline window shows the application’s profileInterrupt log, Data log, Event log, Call stack
Code coverage analysisWhich code has been executed?
Stack analysiscalculates maximum stack usage, helps find the optimal stack size, and checks stack integrity at runtime to detect overflow
26Copyright © 2019 Arm TechCon, All rights reserved.
Arm CoreSight and SWO
27Copyright © 2019 Arm TechCon, All rights reserved.
Debugging using SWD/SWO
ITM Events
Interrupt logging
Power logging
Data logging
28Copyright © 2019 Arm TechCon, All rights reserved.
Minimizing power• Work fast, sleep a lot
• Optimization• Efficient code
Integrated measuring of power consumption correlated to the source code
Detailed power logsPower breakpoints Function-level power
profiling
• Power Debugging
• Tune the application to minimize power-consuming use of hardware resources
• Enabled by I-jet or other hardware with power debugging support
29Copyright © 2019 Arm TechCon, All rights reserved.
Target hardware
NXP LPC55S69
Dual-core M33• TrustZone on Core 0
I-jet debugging probe
I-scope current sense
30Copyright © 2019 Arm TechCon, All rights reserved.
SWO Demo
31Copyright © 2019 Arm TechCon, All rights reserved.
Multicore Debug Demo
32Copyright © 2019 Arm TechCon, All rights reserved.
Summary
• By using the right techniques, you can keep full control and make sure your application behaves as expected.
• In this session we covered:• The Arm CoreSight architecture and its capabilities• How to debug and view program execution taking advantage of ARM CoreSight logic• How to visualize program objects with the Timeline
• Interrupts, Data Logs, Power and RTOS tasks• The more information you use to debug, the faster you will find those bugs
• Quicker debug means faster time-to-market• More information means more robust code
33Copyright © 2019 Arm TechCon, All rights reserved.
Questions?
34Copyright © 2019 Arm TechCon, All rights reserved.
Thank you for your attention!www.iar.com
Further questions? [email protected]