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.