Changes

Jump to: navigation, search
History
{{AppliesTo MITO 8M AN}}
{{InfoBoxBottom}}
{{WarningMessage|text=This technical note Application Note was validated against specific versions of hardware and software. What is described here may not work with other versions.}}
[[Category:MISC-AN-TN]]
[[Category:MISC-AN]]
|June 2021
|First public release
|-
|1.0.1
|June 2021
|Added webinar recording
|}
==Introduction==
This Application Note (AN) is associated with [https://www.dave.eu/en/news-and-media/news/multicore-debug-and-trace-su-nxp-imx8 this webinar] organized by [https://www.lauterbach.com www.lauterbach.it Lauterbach Italy], [https://www.dave.eu DAVE Embedded Systems], and [https://www.nxp.com NXP ] in May 2021. The webinar showed advanced techniques used to debug, trace, and energy profile the code executed by the NXP i.MX8M SoC powering the [[MITO_8M_SOM|Mito8M system-on-module (SoM)]] with the aid of Lauterbach tools.  Specifically, this article deals with JTAG debugging, which is a stop-mode technique. Unlike run/mode debuggers such as GDB, this means that the debugger stops the processor, for example, to execute the code step-by-step or when it hits a breakpoint. Another fundamental characteristic of this mode is that the processor cooperates with the debugger for controlling the execution of the code and for accessing internal resources (CPU registers, RAM/flash memories, on-chip peripheral registers, etc.). For more details on JTAG debugging, please refer to [https://www2.lauterbach.com/pdf/training_jtag.pdf this document]. Tracing is an extremely powerful technique that comes to help not only to "enhance" the debugging. It is also an outstanding troubleshooting weapon and allows advanced measurements, profiling, and specific software-related testing like code coverage. You can think about it as a sort of "movie" that is shot in real-time and in a non-intrusive fashion while the processor is running. Later on, it allows engineers to scrutinize all the processor's activity around specific events that occurred in the past. For instance, this is astonishingly useful for analyzing errors, bugs, or other situations that do not allow to stop the processor. With respect to tracing, three different strategies are here illustrated:* Onchip trace* Offchip trace via Trace Port Interface Unit (TPIU)* Offchip trace via PCIe.In this AN, tracing will be also used to show how to carry out energy profiling in order to correlate the power consumption with the execution of the code. The hardware platforms used for this demonstration basically consists of the [[MITO_8M_SOM/MITO_8M_Evaluation_Kit|MITO 8M Evaluation Kit]]. This kit comprises three different boards:* The SoM* The [[:Category:SBC-AXEL|SBCX carrier board]]* An adapter board.It is also worth remembering that Mito8M SoM '''is electrically and mechanically compatible with i.MX6-based [[AXEL_Lite_SOM|AxelLite SoM]]'''. Therefore, '''Mito8M can be mated with the SBCX carrier board directly'''. Nevertheless, to fully leverage all the functionalities it provides, an adapter board is required. Namely, the adapter board allows to access physical interfaces that are used for the purposes here discussed.
==Regarding the software configuration, a typical Linux SMP debugging and trace==The following sections describe how to configure setup was used. Specifically, the Lauterbach TRACE32® debugger to support debug and trace of Linux running on the quad-core ikernel 4.14.MX 8M Application Processor by NXP Semiconductors98 was utilized in tandem with a root file system built with Yocto Sumo.
==The debugging/tracing/energy profiling tools==
This chapter details the Lauterbach tools used for this demonstration.
=== Prerequisites ===
* <u>Optional:</u> LA-7844X Debug Cortex-M (ARMv6/7/8 32-bit) Ext.
* <u>Optional:</u> LA-7949 Analog Probe for PI/PT-II/CP/MicroTrace
  [[File:Lauterbach offchip trace via PCIe.png|center|framelessthumb|783x783px]]''|TRACE32 PowerDebug PRO, PowerTrace Serial, PTSERIAL-PCIe x1 Slot-Card-Converter, MITO 8M board'']] 
For a general introduction to debug features provided by TRACE32 tools, please refer to https://www.lauterbach.com/manual.html:
* Debugger Basics – Training manual (training_debugger.pdf)
* Training HLL Debugging manual (training_hll.pdf)
 
==Debugging and tracing==
The following sections describe how to configure the Lauterbach TRACE32® debugger to support debug and trace of Linux running on the quad-core i.MX 8M Application Processor by NXP Semiconductors.
 
=== TRACE32 configuration ===
* Information common for all cores, which is displayed on a white background. Typical common information are: memory contents, values of variables, breakpoint setting.
A selector is available to switch the core-specific information to a selected core.
 
 
[[File:TRACE32 selector.png|center|frame]]
 
On an SMP system the program execution on all cores is started with Go and stopped with Break. The same onchip breakpoints are programmed by the debugger at the same time to all cores. If a breakpoint is hit, TRACE32 selects the core on which the breakpoint occurred.
=== Startup scripts ===
Reference scripts for startup and for configuring the Analog Probe are available for download: please refer to [[#Resources|''Resources'']] section below.
For more details about the PRACTICE batch language, please refer to https://www.lauterbach.com/manual.html:
* Training PRACTICE manual (training_practice.pdf)
While configuring the TRACE32 kernel awareness for Linux, a specific menu file for Linux can be loaded which includes many useful menu items developed for the TRACE32 GUI to ease Linux debugging.
 
 
[[File:TRACE32 Linux menu.png|center|frame]]
To provide full debugging possibilities, the debugger has to know how virtual addresses are translated to physical addresses. If an OS that runs several processes at the same logical addresses (e.g. Linux) is used, the hardware MMU in the CPU only holds translation tables that allow the debugger memory accesses to the code/data of the kernel and the currently running process. The OS itself maintains the translation tables for all processes, because the OS is responsible for the reprogramming of the hardware MMU on a process switch. The debugger can access code/data from a not currently running process using the information from the OS MMU tables. An automatic table-walk method is available in TRACE32, walking through the OS MMU tables to find a valid logical-to-physical translation, in case it’s not already cached in TRACE32.
 
 
[[File:TRACE32 MMU page tables reduced.png|center|frame]]
==== Debug of kernel modules ====
The Linux kernel can be compiled to allow linking of additional modules at runtime (kernel objects). The Lauterbach debuggers also support kernel modules debugging, starting from the initialization function.
 
 
[[File:TRACE32 debug of kernel modules.png|center|frame]]
Virtual address spaces are distinguished in TRACE32 using the concept of spaceID. The memory addressing is extended using the lower 16 bit of the process PID, allowing in this way to distinguish between equal virtual addresses for different processes.
 
 
[[File:TRACE32 debug of user process.png|center|frame]]
* The ETR can send the trace data stream to a memory location on the AXI bus: in this way you can use the DRAM as a big onchip trace memory.
The trace data can be read out via JTAG, when the trace recording has ended.
 
 
[[File:TRACE32 onchip trace.png|center|frame]]
The Lauterbach ETM preprocessors implement an AutoFocus technology which calibrates the trace-data sampling points in order to compensate for the effects of wave reflections, component tolerances, different trace lengths, limited pad driver capabilities, signal coupling, affecting the sampling of high-speed parallel buses.
 
 
[[File:TRACE32 offchip trace.png|center|frame]]
 
 
[[File:TRACE32 offchip trace part 2.png|center|frame]]
The i.MX 8M Application Processor implements a PCIe Gen 2 interface which allows to reach a speed of 5GT/s. The PowerTrace Serial can be configured as PCIe end-point and its PCIe memory can be mapped in the ETR. In this way the program flow trace exported via ETR can be stored offchip in the PowerTrace Serial memory.
 
[[File:TRACE32 PCIe.png|center|frame]]
=== Energy profiling ===
Using a Lauterbach Analog Probe, it’s possible to measure up to 4 voltage channels (1 at a time, shared with current channels) and 3 current channels (1 at a time, shared with voltage channels; shunt resistor required).
* to optimize the code to reduce energy consumption
Specific views are available in TRACE32 to analyze the instantaneous power and energy consumed for a given function. Additional settings are available for triggering: e.g. voltage or current are greater / smaller than upper / lower limits.
 
 
[[File:TRACE32 energy profiling.png|center|frame]]
=== Summary view ===
In the pictures below, all the concepts previously discussed are shown as a summary global view of TRACE32 debugger.
 
 
[[File:TRACE32 summary view.png|center|frame]]
==Resources==The TRACE32 scripts used for this demonstration can be downloaded [[:File:Mito8M-TRACE32-debug-trace-energy-profiling.zip|here]]. Webinar recording is also avalaible. It is in Italian, but it is possible to enable English subtitles as well. {{#ev:youtube|FGZ7jjzzelU|600|center|Webinar recording|frame}} == Lauterbach References ===
[[File:Logo Lauterbach.png|frame]]
This chapter article has been mainly written by the Lauterbach Italian branch office.
<u>Contact information:</u>
Tel. +39 02 45490282
email [[mailto:info_it@lauterbach.it]info_it@lauterbach.it]
Web [https://www.lauterbach.com www.lauterbach.it]
4,650
edits

Navigation menu