Debug i.MX8MP uboot with TRACE32

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Debug i.MX8MP uboot with TRACE32

shaojun_wang
NXP Employee
NXP Employee
3 0 3,788

This document shows how to debug i.MX8MP uboot with TRACE32 debugger.
For Linux debug, please check https://community.nxp.com/t5/Blogs/Debug-i-MX8MP-Linux-with-TRACE32/ba-p/1582382

1. Build uboot

Follow IMX_LINUX_USERS_GUIDE.pdf to build uboot and generate flash.bin.
We will boot i.MX8MP from eMMC/SD, attach TRACE32 and load uboot symbol.
The uboot image and symbol should come from the same build.

2. Run uboot and get relocate offset

Program flash.bin to eMMC or SD card, boot uboot and "Hit any key to stop autoboot". Run command bdinfo to get uboot reloc off value.

shaojun_wang_1-1678872140783.png

3. TRACE32 script

Attached imx8mp-uboot-attach.cmm is TRACE32 script. You need to modify Data.LOAD.Elf and SYMbol.reloc according to your environment.

3.1 Data.LOAD.Elf

The full command in this example is

Data.LOAD.Elf C:\Debugging\Linux\Sources\uboot-imx\u-boot /NoCODE /STRIPPART "uboot-imx" /SOURCEPATH C:\Debugging\Linux\Sources\uboot-imx

The first parameter C:\Debugging\Linux\Sources\uboot-imx\u-boot tells debugger where to download ELF file. Please note you should not use u-boot.bin.

/NoCODE: The option /NOCODE should be used to only load the symbols without uboot code.

/STRIPPART: With the option /STRIPPART you can remove parts of the path stored in the object file.

/SOURCEPATH: With the option /SourcePATH you can specify a basis directory for the source files.
For example, if you have compiled your uboot on a Linux machine in the directory /home/user/linux/uboot-imx, and you are running TRACE32 on a Windows machine where you have the uboot source files tree under C:\Debugging\Linux\Sources\uboot-imx, set /STRIPPART to “uboot-imx”, and set /SOURCEPATH to C:\Debugging\Linux\Sources.

With above setting, to look for the source file board/freescale/imx8mp_evk/imx8mp_evk.c, the debugger will here use the path
C:\Debugging\Linux\Sources\uboot-imx + /home/user/linux/uboot-imx/board/freescale/imx8mp_evk/imx8mp_evk.c
thus
C:\Debugging\Linux\Sources\uboot-imx/board/freescale/imx8mp_evk/imx8mp_evk.c

3.2 relocate offset

We have got relocate offset in step 2, replace the value in SYMbol.reloc command.

4. Attach i.MX8MP board to TRACE32 debugger

Connect TRACE32 to JTAG port, open TRACE32 ICE Arm USB, then from “File->Run Script...”, run imx8mp-uboot-attach.cmm, you will see below window, TRACE32 is attached to i.MX8MP uboot.

shaojun_wang_2-1678873697411.png

If you want to debug some function, such as boot_jump_linux, you can set break point with command
break.set boot_jump_linux
Then press Go button in TRACE32 PowerView, and run boot command in uboot, uboot will continue to run and stop at boot_jump_linux, as shown in below figure.

shaojun_wang_3-1678873874536.png