how to develop smaller, faster, smarter code using iar ...€¦ · advanced debugging and trace....
TRANSCRIPT
![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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/1.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/2.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/3.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/4.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/5.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/6.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/7.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/8.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/9.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/10.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/11.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/12.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/13.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/14.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/15.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/16.jpg)
• 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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/17.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/18.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/19.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/20.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/21.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/22.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/23.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/24.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/25.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/26.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/27.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/28.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/29.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/30.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/31.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/32.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/33.jpg)
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](https://reader035.vdocuments.net/reader035/viewer/2022062506/5f1f96e3bf8ab064bd6ec5cf/html5/thumbnails/34.jpg)
Thank you for your attention!
www.iar.com