Debug Linux running on i.MX93EVK with Lauterbach TRACE32

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Debug Linux running on i.MX93EVK with Lauterbach TRACE32

Debug Linux running on i.MX93EVK with Lauterbach TRACE32

This article explains how to get started with JTAG debugging of the Linux kernel running on the A55 of iMX93EVK.

We will be using Lauterbach Trace32 to debug iMX93EVK. Here is a list of pre-requisites that is expected from the readers:-

1. Basic knowledge to get started on Trace32 - Please refer
Learning and Training | Lauterbach TRACE32

2. You should have Linux source code and steps to build the kernel.

3. Trace32 Software with a license to debug A55




COMPONENTS

 

Hardware required: -
 

iMX93EVK running 6.6.52 BSP

Lauterbach Power Debug E40 with a Debug cable

Software required: -
Trace32

Linux kernel source code

 




Linux Kernel Modifications


Step 1:- In arch/arm64/configs/imx_v8_defconfig, please make sure that:-

CONFIG_DEBUG_INFO_REDUCED=n
CONFIG_DEBUG_INFO = y

CONFIG_KALLSYMS=y

 

Step-2 :- Enabling JTAG debugging in Linux

On iMX93EVK LPUART5 is MUX'd with the JTAG pins

gaurav_sharma_0-1744718613352.png

 

so if we want to debug the linux kernel via JTAG, we will have to disable it.

Go to the device tree source file -

arch/arm64/boot/dts/freescale/imx93-11x11-evk.dts


Change the status of the following node to 'disabled'
 

gaurav_sharma_1-1744718678374.png

 

Step 2:- Build the kernel. vmlinux will be created as part of this. This has the Linux kernel along with the debug symbols required for Trace32 debugging.


Step-3 At this point either you can copy the linux-imx folder to your local windows machine where Trace32 is installed, or you can simply map the linux machine as a network drive so that the same folder '/opt/samba/nxg05261/linux-imx' is accessible on windows.

The motive of this exercise is to use 'vmlinux' and the linux source files present in this folder from trace32 cmm scripts that we will be executing.

 

Step-4 Replace the newly built kernel 'Image' - arch/arm64/boot/Image with the one present in the boot partition of imx93evk. You can simply copy this Image to iMX93EVK via scp and copy it to the folder - /run/media/boot-mmcblk0p1


Note:- Please make sure that the kernel version that is running on the box and the one you have built should be the same otherwise there will be debug symbols mismatch

After copying the Image, reboot iMX93EVK.






Debugging with Trace32


Step-1 Configuring Uboot bootargs

Cpu idle state interferes with the JTAG debugging by impacting the clocks so we need to disable the cpu idle power management. We do this by appending "cpuidle.off=1" to the bootargs:-

a. Stop at Uboot prompt.
b. Execute command -

setenv mmcargs "setenv bootargs ${jh_clock} ${mcore_clk} console=${console} root=${mmcroot}  cpuidle.off=1"

[do not omit the inverted commas in the command]



Step-2 Boot to Linux prompt
 

Step-3 Connect the USB cable of Lauterbach Power Debug probe to your windows machine and Open t32 - C:\T32\bin\windows64\t32start.exe
 

gaurav_sharma_5-1744718944949.png

Select 'PowerView Instance' and click on 'Start'. A window like below will appear: -
 

gaurav_sharma_6-1744719062494.png


Step- 4 Extract MMU translation info for the debugger

For this either you can execute the below commands on the T32 in sequence: -

 

RESet

SYStem.RESet

SYStem.CPU IMX93-CA55

SYStem.JtagClock 10MHz

SYStem.CONFIG.DEBUGPORTTYPE JTAG

SYStem.Option EnReset OFF

CORE.ASSIGN 1. 2.

SYStem.Option MMUSPACES ON

SYStem.Option IMASKASM ON

SYStem.Mode Attach

Data.LOAD.Elf <path_of_vmlinux> /NoCODE

DO ~~/demo/arm/kernel/linux/board/generic-template/detect_translation.cmm

OR


simply edit the attached cmm script - detect_address_translation.cmm and modify the <path_of_vmlinux> as per your file location. Then execute it like this:-

Do <file_path>/detect_address_translation.cmm

In my case, this command was: -

Do C:\Users\nxg05261\Documents\cmm_scripts\detect_address_translation.cmm

Note:- <path_of_vmlinux> in my case was  C:\T32\demo\arm\bootloader\uboot\vmlinux. You can modify it as per the location where you have copied 'vmlinux'

-- After executing the above commands, debugger address translation will be displayed: - 

gaurav_sharma_8-1744719186783.png

 

Now we will copy the above highlighted lines and paste it in the final cmm script that we will use for debugging. For readers' convenience this info has been collated into the final script - 'linux_attach_t32.cmm', attached with this blog.
 
Disclaimer
:-

The lines that are highlighted depends on the kernel version and customer design decisions, so it is strongly advised to take the output of detect_translation.cmm for your system and then paste it in the cmm script, instead of using the exact output that I have shown in the above picture.

File -> Open File -> linux_attach_t32.cmm

gaurav_sharma_9-1744719239784.png



-- Click on 'Do' button to execute the script till the end.

gaurav_sharma_0-1744719677000.png



-- Set a breakpoint at start_kernel

b.s start_kernel /Onchip
 
[Optional]Check the breakpoint via 'b.l'
 

gaurav_sharma_1-1744719798475.png



-- Hit 'go' at t32 to let the cores execute the instructions, you will see 'running' state

 

gaurav_sharma_2-1744719826022.png



-- Enter 'reboot' at Linux prompt and stop at Uboot command line prompt

you will see trace32 at 'system down' state: -

gaurav_sharma_3-1744719897706.png



-- Execute 'system.mode.attach' at t32 to attach to the system, you will again see 'running' state


-- Execute 'break' to stop the running state

-- Check if the breakpoint 'start_kernel' still exist via command 'b.l'

-- If you see the breakpoint is still set, Execute 'go' at t32 to take the cores to the running state.

-- Then, at Uboot prompt, execute 'boot' so that it may load the linux kernel to the memory.
 

As soon as you do that you would see that Uboot will try to load kernel.

The last print you will see on the serial console will be: -

"Starting kernel …'

the execution will stop and at t32 you will see that the breakpoint is hit, meaning the Program Counter is at the address of the function 'start_kernel'


gaurav_sharma_4-1744720057810.png

 

Note- The Warning that you might observe[like in the above picture] means that trace32 is not able to find the source file 'main.c'. So you will not be able to see the 'C' source code at this point. To resolve this:-



-- Right click on the 'List.auto' window where you see the assembly code. Click on 'Resolve Path' and navigate to the init/main.c in your kernel source code folder and click Open. You would see that the source path translation is now correct and you're able to view the disassembly as well as the source code: -
 

gaurav_sharma_5-1744720161325.png

 

Now we will load kernel symbols and apply 2 breakpoints in the linux kernel to demonstrate kernel debugging:-
 

-- Load the kernel symbols

Data.LOAD "C:\T32\demo\arm\bootloader\uboot\vmlinux"  H:0x0::0x0 /NoCODE /SOURCEPATH Z:\linux-imx


gaurav_sharma_6-1744720206901.png

 

-- Apply breakpoints at t32 window

b imx_rpmsg_init

b imx_drm_bind
 

[Optionally] you can verify the breakpoints via 'b.l'

gaurav_sharma_0-1744781339510.png

These breakpoints are temporary as you can see in the above snapshot. That means after they are hit, they will be removed, so to make them permanent:-

Right click the breakpoint -> Change -> Uncheck Temporary -> Click Ok

like depicted in the following snapshots: -

gaurav_sharma_1-1744781477140.png

 

gaurav_sharma_2-1744781531859.png

 



gaurav_sharma_7-1744720262647.png

 

Now, to reach the next breakpoint, execute 'go' on the t32

gaurav_sharma_8-1744720292331.png

At this point linux kernel execution has reached the function imx_rpmsg_init

 

Again, to reach the next breakpoint, execute 'go'

gaurav_sharma_0-1744720569015.png

 

So this is how you start debugging the linux kernel. Apart from this, there is a nice t32 feature called 'linux awareness' which allows you to easily debug the kernel loadable modules, user space applications amongst other things. To explore 'linux awareness', you can go about checking the 'Linux' drop down menu present at the top. Plenty of support documents are available on the web.
 

gaurav_sharma_1-1744720601236.png

 

gaurav_sharma_2-1744720619336.png

 


Feel free to drop in the comments section or DM if you have any queries.

Happy debugging!!


 

标签 (1)
附件
100% 有帮助 (1/1)
版本历史
最后更新:
‎04-16-2025 03:12 AM
更新人: