use all of the debugging capabilities of arm trustzonedevices · bandwidth limited to 10’s of...

34
Copyright © 2019 Arm TechCon, All rights reserved. #ArmTechCon Aaron Bauch, Senior FAE IAR Systems Software Presentation 1258 Use all of the Debugging Capabilities of ARM TrustZone Devices

Upload: others

Post on 25-Jun-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

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

Page 2: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

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

Page 3: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

3Copyright © 2019 Arm TechCon, All rights reserved.

ARM TrustZone

Adds hardware basis for protected systemsSeparates trusted software componentsEnforces separation with hardware

Page 4: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

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

Page 5: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

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

Page 6: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

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

Page 7: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

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

Page 8: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

8Copyright © 2019 Arm TechCon, All rights reserved.

Debug overview

Page 9: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

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.”

Page 10: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

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

Page 11: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

11Copyright © 2019 Arm TechCon, All rights reserved.

Considerations in complex

applications

Page 12: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

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

Page 13: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

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.

Page 14: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

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

Page 15: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

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

Page 16: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

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.

Page 17: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

17Copyright © 2019 Arm TechCon, All rights reserved.

Plugins

RTOS Awareness Plugin• Get instant information from your

RTOS

Page 18: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

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

Page 19: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

19Copyright © 2019 Arm TechCon, All rights reserved.

Multicorechallenges

Page 20: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

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

Page 21: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

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

Page 22: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

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

Page 23: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

23Copyright © 2019 Arm TechCon, All rights reserved.

Arm CoreSight and ETM Trace

Page 24: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

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

Page 25: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

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

Page 26: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

26Copyright © 2019 Arm TechCon, All rights reserved.

Arm CoreSight and SWO

Page 27: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

27Copyright © 2019 Arm TechCon, All rights reserved.

Debugging using SWD/SWO

ITM Events

Interrupt logging

Power logging

Data logging

Page 28: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

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

Page 29: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

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

Page 30: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

30Copyright © 2019 Arm TechCon, All rights reserved.

SWO Demo

Page 31: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

31Copyright © 2019 Arm TechCon, All rights reserved.

Multicore Debug Demo

Page 32: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

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

Page 33: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

33Copyright © 2019 Arm TechCon, All rights reserved.

Questions?

Page 34: Use all of the Debugging Capabilities of ARM TrustZoneDevices · Bandwidth limited to 10’s of Mbits. ... calculates maximum stack usage, helps find the optimal stack size, and

34Copyright © 2019 Arm TechCon, All rights reserved.

Thank you for your attention!www.iar.com

Further questions? [email protected]