23 Feb 2021

GDB+OpenOCD an ADI Target with The Yocto Project/Openembedded

UPDATE: unfortunately the "fix" I suggest below doesn't work :-( It seemed to work yesterday because the half-dozen times or so that I used it, the connection, coincidentally, was robust. But running it many many dozens of times today, I do see it failing. As does the cross-gdb binary supplied by ADI. So there's something wrong with the connection between openocd and gdb. Sometimes they connect just fine, other times something goes wrong. Probably an issue with the closed-source openocd binary, or an issue with the openocd configuration files for the JTAG or the target.



I'm working with a board from Analog Devices. Unfortunately it's not possible to use upstream openocd. You have to use the openocd binary that comes with their Developer's Kit.

Although I'm forced to use their openocd binary, I wanted to be able to use my own cross-gdb; one that I could build as part of my Yocto/OE-generated SDK. But whenever I tried connecting my cross-gdb (arm-oe-linux-gnueabi-gdb) to their openocd I would get errors, and further debugging wasn't possible.

I start their openocd and get the regular openocd information:

# bin/openocd --search share/openocd/scripts/ -f interface/ice1000.cfg -f target/adspsc58x.cfg
Open On-Chip Debugger (Analog Devices CCES 2.8.0 OpenOCD 0.9.0-g5030ad7) 0.9.0
Licensed under GNU GPL v2
Report bugs to <processor.tools.support@analog.com>
adapter speed: 1000 kHz
Info : transports supported by the debug adapter: "jtag", "swd"
Info : auto-select transport "jtag"
halt and restart using CTI
trst_only separate trst_push_pull
Info : ICE-1000 firmware version is 1.0.2
Info : clock speed 1000 kHz
Info : JTAG tap: adspsc58x.adjc tap/device found: 0x128080cb (mfg: 0x065, part: 0x2808, ver: 0x1)
Info : JTAG tap: adspsc58x.dap enabled
Info : adspsc58x.dap: hardware has 3 breakpoints, 2 watchpoints
Info : adspsc58x.dap: but you can only set 1 watchpoint

I then startup the arm-oe-linux-gnueabi-gdb that was built as part of the Yocto/OE SDK that I generated:

$ arm-oe-linux-gnueabi-gdb u-boot-sc589-ezkit
GNU gdb (GDB) 8.2
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-oesdk-linux --target=arm-oe-linux-gnueabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from u-boot-sc589-ezkit...done.
(gdb) 

So far, so good. However, the moment I connect the two… In gdb I get:

(gdb) target remote :3333
Remote debugging using :3333
warning: remote target does not support file transfer, attempting to access files from local filesystem.
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.

and in openocd I get:

Info : accepting 'gdb' connection on tcp/3333
Warn : system reset not supported for ADSP-SC58x silicon revision 0.0 and 0.1
Info : ttbcr 0ttbr0 0ttbr1 0
Info : adspsc58x.dap rev 1, partnum c05, arch f, variant 0, implementor 41
Info : number of cache level 1
Info : adspsc58x.dap cluster 0 core 0 mono core
target state: halted
target halted in Thumb state due to debug-request, current mode: Supervisor
cpsr: 0x800001f3 pc: 0x00004810
MMU: disabled, D-Cache: disabled, I-Cache: disabled
semihosting is enabled
Error: Timeout waiting for cortex_a_exec_opcode
Error: Timeout waiting for InstrCompl=1
Warn : negative acknowledgment, but no packet pending
Error: Timeout waiting for InstrCompl=1
Error: Timeout waiting for InstrCompl=1
Warn : negative acknowledgment, but no packet pending
Error: Timeout waiting for InstrCompl=1
Error: Timeout waiting for InstrCompl=1
Warn : negative acknowledgment, but no packet pending
Error: Timeout waiting for InstrCompl=1
Error: Timeout waiting for InstrCompl=1
Warn : negative acknowledgment, but no packet pending
Error: Timeout waiting for InstrCompl=1

Searching the Internet for solutions I was excited to find that the gdb "set sysroot <path>" was supposed to solve my problems, but it didn't. However the "set solib-absolute-prefix <path>" did! Simply set this option to the absolute path of the Yocto/OE-generated rootfs and everything works again.

$ arm-oe-linux-gnueabi-gdb u-boot-sc589-ezkit
GNU gdb (GDB) 8.2
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-oesdk-linux --target=arm-oe-linux-gnueabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from u-boot-sc589-ezkit...done.
(gdb) set solib-absolute-prefix /z/2.6-build-thud/sc589-ezkit/build/tmp-glibc/work/adsp_sc589_ezkit-oe-linux-gnueabi/core-image-minimal/1.0-r0/rootfs/
(gdb) target remote :3333
Remote debugging using :3333
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
0x00005392 in ?? ()
(gdb) load init-sc589-ezkit.elf 
Loading section .text, size 0x510 lma 0x20080000
Start address 0x20080024, load size 1296
Transfer rate: 24 KB/sec, 1296 bytes/write.
(gdb) c
Continuing.
^C
Program received signal SIGINT, Interrupt.
0x00005394 in ?? ()
(gdb) load u-boot-sc589-ezkit
Loading section .text, size 0x2d59c lma 0xc2200000
Loading section .rodata, size 0xb3a7 lma 0xc222d59c
Loading section .hash, size 0x18 lma 0xc2238944
Loading section .data, size 0x2458 lma 0xc223895c
Loading section .got.plt, size 0xc lma 0xc223adb4
Loading section .u_boot_list, size 0x894 lma 0xc223adc0
Loading section .rel.dyn, size 0x7308 lma 0xc223b654
Loading section .dynsym, size 0x30 lma 0xc224295c
Loading section .dynstr, size 0x1 lma 0xc224298c
Loading section .dynamic, size 0x90 lma 0xc2242990
Loading section .interp, size 0x14 lma 0xc2242a20
Loading section .gnu.hash, size 0x18 lma 0xc2242a34
Start address 0xc2200000, load size 272968
Transfer rate: 32 KB/sec, 10498 bytes/write.
(gdb) c
Continuing.

NOTE: both the init-sc589-ezkit.elf and the u-boot-sc589-ezkit binaries are the ones I have built via Yocto/OE. So it's possible to build and use your own cross-gdb, initializer (init-sc589-ezkit-elf), and u-boot that are built with Yocto/OE.

Notice, as well, that I still get those warnings about not being able to find dynamic linker breakpoints, but at least I'm able to proceed.

No comments: