Debugging Ublox C027 (from Eclipse?)

19 Nov 2015

Dear co-sufferers,

I'm trying to find out how to properly connect a debugger to the Ublox C027, especially from Eclipse. As a test program, I'm using the C027 HelloWorld sample from mbed online, exported with a Makefile, and imported to Eclipse. I can build it and run it no problem, and I've been half-way successful in connecting OpenOCD from the command line:

>openocd -f ..\scripts\board\mbed-lpc1768.cfg

GNU ARM Eclipse 64-bits Open On-Chip Debugger 0.9.0-00073-gdd34716-dirty (2015-05-19-09:55)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'swd'
adapter speed: 10 kHz
adapter_nsrst_delay: 200
cortex_m reset_config sysresetreq
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 1.0
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 10 kHz
Info : SWD IDCODE 0x2ba01477
Info : lpc17xx.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : accepting 'gdb' connection on tcp/3333
undefined debug reason 7 - target needs reset
Warn : WARNING! The target is already running. All changes GDB did to registers will be discarded! Waiting for target to halt.

and debugging with gdb:

>arm-none-eabi-gdb C027_HelloWorld.elf -ex "target remote localhost:3333"

GNU gdb (GNU Tools for ARM Embedded Processors) 7.8.0.20150604-cvs
Copyright (C) 2014 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=i686-w64-mingw32 --target=arm-none-eabi".
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 C027_HelloWorld.elf...done.
Remote debugging using localhost:3333
0x00000000 in __isr_vector ()
(gdb) continue
Continuing.
WARNING! The target is already running. All changes GDB did to registers will be discarded! Waiting for target to halt.

Program received signal SIGINT, Interrupt.
0x0000127e in wait_us ()
(gdb) info registers
r0             0x1e9f4f0        32109808
r1             0xe8480000       -397934592
r2             0xb      11
r3             0x100002a0       268436128
r4             0x1cd966e        30250606
r5             0x1e8480 2000000
r6             0x12345678       305419896
r7             0x0      0
r8             0x53112309       1393632009
r9             0x10000214       268435988
r10            0xfff8000        268402688
r11            0x0      0
r12            0x0      0
sp             0x10007fe0       0x10007fe0
lr             0x127f   4735
pc             0x127e   0x127e <wait_us+14>
xPSR           0x81000000       -2130706432
(gdb) info locals
No symbol table info available.
(gdb) step
Single stepping until exit from function wait_us,
which has no line number information.
main () at main.cpp:19
19              myled = !myled;

But I'm wondering why the symbol table from the elf file cannot be used - to my understanding, it should be included when building with the compiler options "-O0 -g".

My other problem is that these operations do not seem to work when transferred to an Eclipse launch config, which is described here https://gnuarmeclipse.github.io/debug/openocd/ in great detail.

Started by GNU ARM Eclipse
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 1.0
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 10 kHz
Info : SWD IDCODE 0x2ba01477
Info : lpc17xx.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : accepting 'gdb' connection on tcp/3333
undefined debug reason 7 - target needs reset
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x1fff0080 msp: 0x10001ffc
Warn : negative acknowledgment, but no packet pending
Info : SWD IDCODE 0x2ba01477
Error: Failed to write memory at 0x00000004
Info : SWD IDCODE 0x2ba01477
Error: Failed to write memory at 0x00001004

Do you have a clue how to load the symbol table correctly? And maybe even how to configure the Eclipse launch config properly?

Is the OpenOCD script for the mbed-lpc1768 even correct? C027 has the same CPU, but it is a different board...

19 Nov 2015

Ok, I got a bit further. After starting OpenOCD from the command line as mentioned above, I have to connect to it via telnet and halt the C027:

telnet localhost 4444
halt

Then, gdb can be smoothly connected, and debugging with symbols works. That can alse be done as a 'C/C++ Remote application' in Eclipse, but OpenOCD and telnet must still be run from the command line every time.

Do you know how to configure a "GDB OpenOCD Debugging' launch config correctly? There are multiple 'reset' and 'halt' options, but none of them has the desired effect.

20 Nov 2015

Another update: The required 'halt' command can be sent only after an 'init' command to OpenOCD:

openocd -f ../scripts/board/mbed-lpc1768.cfg -c init -c halt

I've tested that on the command line, where it seems to work fine when connecting with gdb:

>arm-none-eabi-gdb.exe C027_HelloWorld.elf
...
Reading symbols from \firedect\dev\workspace\C027_mbed_HelloWorld\C027_HelloWorld.elf...done.
(gdb) target remote localhost:3333
Remote debugging using localhost:3333
0x00001498 in us_ticker_read ()
(gdb) continue
Continuing.

but it fails from within Eclipse with the following strange message:

Started by GNU ARM Eclipse
Info : accepting 'gdb' connection on tcp/3333
Warn : negative reply, retrying
Warn : acknowledgment received, but no packet pending
Warn : keep_alive() was not invoked in the 1000ms timelimit. GDB alive packet not sent! (1045). Workaround: increase "set remotetimeout" in GDB
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x1fff0080 msp: 0x10001ffc
Warn : keep_alive() was not invoked in the 1000ms timelimit. GDB alive packet not sent! (3949). Workaround: increase "set remotetimeout" in GDB
Warn : Verification will fail since checksum in image (0x00000000) to be written to flash is different from calculated vector checksum (0xefff59d6).
Warn : To remove this warning modify build tools on developer PC to inject correct LPC vector checksum.

Any ideas why that is? Thank you and have a nice weekend...

Please log in to post a reply.