34
How to develop smaller, faster, smarter code using IAR Embedded Workbench

How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

How to develop smaller, faster, smarter code using IAR Embedded Workbench

Page 2: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Agenda

• Optimizations• Code quality• Advanced debugging and Trace

Page 3: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Optimizations

Page 4: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

IoT design considerations

• Small• Cheap• Time to market• Performance and power efficiency

Page 5: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

What options do we have?

Size vs Speed

• Room for more features• Use a cheaper device• Use a device with less

memory

• Better response time• Faster execution

• Saving power • Enhance battery time

Power

Page 6: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Structuring the application

To be efficient: • Isolate device-dependent code• Use tuned code where needed• Optimize the rest for size

Optimize speedOptimize size

Hardware

Device Driver Files

Generic Program

Files

Tuned Program

Files

Page 7: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

1. Project2. File group3. File4. Function

#pragma optimize=speedvoid matrix_mul_matrix(MATDAT *A, MATDAT *B){...

}

Different levels of optimizations

Page 8: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Speed, size or both?

OptimizationCommon sub-expressions Speed ↑ Size →Loop unrolling Speed ↑ Size ↑Function inlining Speed ↑ Size ?Code motion Speed ↑ Size →Dead code elimination Speed → Size ↓Static clustering Speed ↑ Size ↓Instruction scheduling Speed ↑ Size →

Effect

Page 9: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Advanced debugging and Trace

Page 10: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Breakpoints

• Toggle breakpoints on any C or assembly line• Define complex breakpoint conditions.

– Run until the next time the condition is met. – Run until number of times the condition occurs.

Page 11: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Other breakpoints

• Data breakpointsHalt the target at access of a specific memory location/range set in memory window, optional with a certain pattern match (dependent on driver)

• Log breakpoints

• Trace start/stop breakpointsTriggered by ETM trace data

• Immediate breakpointsSimulator only, association with C-SPY macros

Page 12: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Debugging via SWD/SWO

ITM eventsInterrupt loggingData logging Power logging

Page 13: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Power debugging

Work fast, sleep a lot!• Optimizations• Efficient code

Detailed power logsPower breakpoints

Function-level power profiling

• Integrated measuring of power consumption correlated to the source code

• Tune the application to minimize power-consuming use of hardware resources

• Enabled by I-jet or other hardware with power debugging support

Page 14: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Additional debug features• Stack analysis

• Attach to running target– Connect to the target anytime without resetting the application

Page 15: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

RTOS Awareness PluginGet instant information from your RTOS!

Page 16: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

• Debugger awareness for integrated RTOSes and other software components, such as TCP/IP stacks

• Project templates and quick access to RTOS-specific help

• RTOS-specific syntax highlighting enabled for use by plugins

Integrated software solutions

Page 17: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Trace

• Follow the program flow

• Learn where the application has been and how you got there

• Go back in time and evaluate execution backwards

Page 18: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Why use trace?

Time

Bug occurs Break

Without trace

Without trace: Usually only a little information availableWith trace: Go back in time and evaluate the behavior

With trace Trace information~103.. ~106 instructions

Page 19: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Instruction Trace

Each executed instruction is recorded, usually by sending info to dedicated pins on the device• Requires special HW, a trace probe, to recieve the data• Large amounts of data and limited memory...

ETM (Embedded Trace Macrocell)

ETM

Instructiontrace

Trace port

Page 20: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Navigating trace data

Page 21: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Millions and millions

• ETM trace generates copious quantities of data– Hard to find the right section of code

• Navigation tools in the trace window are available– Combined with previously mentioned

techniques, helps you quickly isolate bugs

Page 22: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Trace filtering and navigation

Navigate forwards or backwards on…… loops… functions… interrupts… statement boundaries

Page 23: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Code coverage• Verify whether all parts have been executed• Using trace data• Possible to require that all code is really tested, i.e.

executed in a test session

Page 24: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Integrated profiling tools

Function profiling • Based on simulator,

sampled trace or full trace• Execution time per function• Select time interval

Stack analysis• Calculates maximum stack usage• Helps find the optimal stack size• Checks stack integrity at runtime to

detect overflow

Page 25: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Debugging multicore processors

• Visibility of all cores• Start and stop cores simultaneously or individually• Step one 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 e.g. different trace capabilities

• Cortex-A9 has PTM (Program Trace)• Cortex-M3 or Cortex-A5/A8 has ETM • Some have even data trace

Page 26: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

IAR Embedded Workbench SMP Support

• One project and debugger instance for all cores• Cores can be stopped/run individually or together

Page 27: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

IAR Embedded Workbench AMP Support

Master (Cortex-A) Slave (Cortex-M4)

Start/stop core0/core1 Start/stop all cores

Page 28: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Migrate to our tools

Page 29: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Reasons to migrate to IAR Embedded Workbench Best in class code optimization Access to first-class technical support Code analysis tools Safety certified build tools State-of-the-art debugger

Works with externally built ELF files Even better with IAR Systems built executables

Page 30: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Migrate to IAR build tools

• Linker supports AEABI compliant ELF object files

• Support for 17 GCC attributes• Syntax: __attribute__ ((attribute-list))

Page 31: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Take advantage of the IAR project converter

Page 32: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Project converter

• Included in IAR Embedded Workbench• Project converters for:

– TI Code Composer Studio for Arm + MSP430– Keil uVision5 for Arm– Renesas HEW and e2Studio for RX– ST Atollic

Page 33: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Optimization goals have varied over time but modern tools offer several options

Modern debugging tools offer tons of possibilities to evaluate the code

Full control of your appliciaton on a Multi-core platform is essential

Smart Trace capabilities will help you to quickly identify the million dollar bug

Improve yout products and development processes with IAR Systems

Summary

Page 34: How to develop smaller, faster, smarter code using IAR ...€¦ · Advanced debugging and Trace. Breakpoints ... – Renesas HEW and e2Studio for RX – ST Atollic Optimization goals

Thank you for your attention!

www.iar.com