How to debug uboot (imx8mp)

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

How to debug uboot (imx8mp)

Jump to solution
6,467 Views
dennis3
Contributor V

I'm attempting to add display support to uboot for our mipi display on the imx8m plus.

https://community.nxp.com/t5/i-MX-Processors/imx8mp-add-mipi-display-splash-screen-to-uboot/td-p/128...

Can someone provide insight into how to get uart support earlier in the boot process?  I'd like to enable verbose printing as early as possible so I can determine where the problem is occurring. 

Labels (1)
Tags (1)
0 Kudos
Reply
1 Solution
6,332 Views
dennis3
Contributor V

I was able to debug uboot w/ jtag using openocd 0.11 on the imx8mp.  (Previous to 0.11 required patches but it seemed to work find now as there is an included profile for the imx8mp-evk board.)

Here are some relevant links from other posts and some discoveries.

1) http://fatalfeel.blogspot.com/2015/12/openocd-with-eclipse-debug-kernel-of.html

An older link and targeted at the imx6 but some content for modifying and loading uboot was still relevant. I modified the cache file referenced but other mods didn't seem applicable in the imx8mp version of uboot and it worked without them. (Perhaps additional debugging functionality could be achieved.)

2) change u-boot config to use CONFIG_CC_OPTIMIZE_FOR_SIZE=n

3) change Makefile to 
  KBUILD_CFLAGS += -O2 -fno-omit-frame-pointer -fno-optimize-sibling-calls
  I don't know why, but if I try to use -O0 as for better debugging, I got linker errors.  I never debugged this but was still able to debug using -O2.

4) run openocd w/ jlink debugger attached:
  openocd -f /usr/share/openocd/scripts/interface/jlink.cfg -f /usr/share/openocd/scripts/board/imx8mp-evk.cfg

5) add arm toolkit to path:
 export PATH=$PATH:<android build>/prebuilts/gcc/linux-x86/aarch64/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/bin

6) run gdb (from out/target/product/<your board>/obj/UBOOT_OBJ)
  aarch64-linux-gnu-gdb
  > target extended-remote :3333

7) for debugging u-boot before it relocates it's code:
 > mon halt
 > symbol-file u-boot
 > load u-boot
 > # set breakboints
 > continue

for debugging u-boot after it relocates.  I started u-boot from the normal power on and stopped it at the command prompt.
 > u-boot>bdinfo
# bdinfo will show you the relocate address
# in gdb
 > add-symbol-file u-boot <relocate address>
 > continue

Issues I had:
 openocd didn't seem to be able to handle resets.  It would lose all connection, reset the board, but you'd have to start over connecting to the debugger so other tutorials/info that included commands for "mon reset" needed modified to not do that.

View solution in original post

0 Kudos
Reply
4 Replies
6,333 Views
dennis3
Contributor V

I was able to debug uboot w/ jtag using openocd 0.11 on the imx8mp.  (Previous to 0.11 required patches but it seemed to work find now as there is an included profile for the imx8mp-evk board.)

Here are some relevant links from other posts and some discoveries.

1) http://fatalfeel.blogspot.com/2015/12/openocd-with-eclipse-debug-kernel-of.html

An older link and targeted at the imx6 but some content for modifying and loading uboot was still relevant. I modified the cache file referenced but other mods didn't seem applicable in the imx8mp version of uboot and it worked without them. (Perhaps additional debugging functionality could be achieved.)

2) change u-boot config to use CONFIG_CC_OPTIMIZE_FOR_SIZE=n

3) change Makefile to 
  KBUILD_CFLAGS += -O2 -fno-omit-frame-pointer -fno-optimize-sibling-calls
  I don't know why, but if I try to use -O0 as for better debugging, I got linker errors.  I never debugged this but was still able to debug using -O2.

4) run openocd w/ jlink debugger attached:
  openocd -f /usr/share/openocd/scripts/interface/jlink.cfg -f /usr/share/openocd/scripts/board/imx8mp-evk.cfg

5) add arm toolkit to path:
 export PATH=$PATH:<android build>/prebuilts/gcc/linux-x86/aarch64/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/bin

6) run gdb (from out/target/product/<your board>/obj/UBOOT_OBJ)
  aarch64-linux-gnu-gdb
  > target extended-remote :3333

7) for debugging u-boot before it relocates it's code:
 > mon halt
 > symbol-file u-boot
 > load u-boot
 > # set breakboints
 > continue

for debugging u-boot after it relocates.  I started u-boot from the normal power on and stopped it at the command prompt.
 > u-boot>bdinfo
# bdinfo will show you the relocate address
# in gdb
 > add-symbol-file u-boot <relocate address>
 > continue

Issues I had:
 openocd didn't seem to be able to handle resets.  It would lose all connection, reset the board, but you'd have to start over connecting to the debugger so other tutorials/info that included commands for "mon reset" needed modified to not do that.

0 Kudos
Reply
6,459 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hello dennis3,

You already have uart before the MIPI is enable you can do verbose just call the uart inside of the code, if you used your own MIPI driver is possible that runs the MIPI firts of the UART just change this part.

Regards

0 Kudos
Reply
6,404 Views
dennis3
Contributor V

The driver that is crashing is the mxc_lcdifv3 driver.  It has the flag DM_FLAG_PRE_RELOC.  So when it crashes, uart messages have not begun to print yet.  I removed that flag for curiosity and received an error stating the memory allocation of the frame buffer had failed and the pre-reloc was required.

So it's still unknown what is causing the actual failure of the lcdif driver during prereloc phase driver binding.  I tried commenting out the entire driver implementation and it still fails to boot.  So something with the display system in general is failing.

Would still appreciate ideas on how to get earlier debugging messages or another way to find the root cause of this failure.

0 Kudos
Reply
6,452 Views
dennis3
Contributor V

Thank you for the reply.  I have already added print statements for debugging in the various mipi and panel drivers but unfortunately, they are not printing yet.

0 Kudos
Reply