How to setup the host system to debug via west gdbserver and Eclipse IDE? #west #gdb #eclipse


Stefan Jaritz
 

Hej,

Currently I am trying to figure out how to setup the debugger by the use of west. I manage to start the west debug server but I failed to connect.

Maybe I am missing something or anyone having the same problem.

My steps & workflow:

"setup zephyr"

1.) open terminal

2.) set environment by "source zephyr-env.sh"

3.) build my project

4.) run "west debugserver" from my build dir

"""


"""

"setup ide"

5.) open eclipse without setting the environment

6.) create a new debug config

6.1) set in Debugger tab:

6.1.1) Debugger >> gdbserver

6.1.2) Main >> "gdb Debugger": = /opt/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/arm-zephyr-eabi/arm-zephyr-eabi-gdb
6.1.3) Connection >> "host name" = localhost
6.1.4) Connection >> "port" = 6666


Eclipse fails to connect with:

"""

Error in final launch sequence:

Failed to execute MI command:
-target-select extended-remote localhost:6666
Error message from debugger back end:
Remote replied unexpectedly to 'vMustReplyEmpty': timeout
Failed to execute MI command:
-target-select extended-remote localhost:6666
Error message from debugger back end:
Remote replied unexpectedly to 'vMustReplyEmpty': timeout
Remote replied unexpectedly to 'vMustReplyEmpty': timeout

"""

The west console print:
"""

[100%] Built target kernel_elf
Using runner: openocd
Open On-Chip Debugger 0.10.0+dev-gea2753a7-dirty (2018-11-02-23:37)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
use the st link v2 cfg
set target to stm32f4x
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : clock speed 1800 kHz
Info : STLINK v2 JTAG v27 API v2 SWIM v6 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 2.521022
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
    TargetName         Type       Endian TapName State
--  ------------------ ---------- ------ ------------------ ------------
 0* stm32f4x.cpu       hla_target little stm32f4x.cpu       halted
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
adapter speed: 1800 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080082cc msp: 0x200038e0
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : accepting 'tcl' connection on tcp/6666

"""

Any ideas how to get the combination of west & eclipse for dbg done?


There is a nice document describing the first steps with west.

https://docs.zephyrproject.org/latest/west/flash-debug.html#debugging-west-debug-west-debugserver

Stef


Marti Bolivar <marti@...>
 

Hi,
On Thu, Nov 8, 2018 at 11:40 AM Stefan Jaritz <stefan@kokoontech.com> wrote:

Hej,

Currently I am trying to figure out how to setup the debugger by the use
of west. I manage to start the west debug server but I failed to connect.

Maybe I am missing something or anyone having the same problem.

My steps & workflow:

"setup zephyr"

1.) open terminal

2.) set environment by "source zephyr-env.sh"

3.) build my project

4.) run "west debugserver" from my build dir

"""


"""

"setup ide"

5.) open eclipse without setting the environment

6.) create a new debug config

6.1) set in Debugger tab:

6.1.1) Debugger >> gdbserver

6.1.2) Main >> "gdb Debugger": =
/opt/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/arm-zephyr-eabi/arm-zephyr-eabi-gdb
6.1.3) Connection >> "host name" = localhost
6.1.4) Connection >> "port" = 6666
Looks like eclipse is set up to use port 6666 for the GDB connection...



Eclipse fails to connect with:

"""

Error in final launch sequence:

Failed to execute MI command:
-target-select extended-remote localhost:6666
Error message from debugger back end:
Remote replied unexpectedly to 'vMustReplyEmpty': timeout
Failed to execute MI command:
-target-select extended-remote localhost:6666
Error message from debugger back end:
Remote replied unexpectedly to 'vMustReplyEmpty': timeout
Remote replied unexpectedly to 'vMustReplyEmpty': timeout

"""

The west console print:
"""

[100%] Built target kernel_elf
Using runner: openocd
Open On-Chip Debugger 0.10.0+dev-gea2753a7-dirty (2018-11-02-23:37)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
use the st link v2 cfg
set target to stm32f4x
Info : The selected transport took over low-level target control. The
results might differ compared to plain JTAG/SWD
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : clock speed 1800 kHz
Info : STLINK v2 JTAG v27 API v2 SWIM v6 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 2.521022
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
But 3333 is what is open for incoming gdb connections.

TargetName Type Endian TapName State
-- ------------------ ---------- ------ ------------------ ------------
0* stm32f4x.cpu hla_target little stm32f4x.cpu halted
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
adapter speed: 1800 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080082cc msp: 0x200038e0
Info : Listening on port 6666 for tcl connections
It seems openocd has opened 6666 for tcl, not gdb.

If you can change your eclipse configuration to use port 3333, it
should work. Otherwise, since you are using the openocd runner, you
can provide the --tcl-port and --gdb-port options to west debugserver
to change the gdb port to 6666 and the tcl port to something else.

From your build directory, you can obtain context-sensitive help
output about your debugserver configuration with:

$ west debugserver --context

That will print the configuration as well as any openocd-specific
options you can provide to west debugserver.

Hope this helps,
Marti

Info : Listening on port 4444 for telnet connections
Info : accepting 'tcl' connection on tcp/6666

"""

Any ideas how to get the combination of west & eclipse for dbg done?


There is a nice document describing the first steps with west.

https://docs.zephyrproject.org/latest/west/flash-debug.html#debugging-west-debug-west-debugserver

Stef




Stefan Jaritz
 

Merci


Port 3333 was the missing detail :D

A small add:

Debugging with the "C/C++ Remote Application" have problems resolving symbols and code. You get errors like that:

"""

Using runner: openocd
Open On-Chip Debugger 0.10.0+dev-gea2753a7-dirty (2018-11-02-23:37)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
use the st link v2 cfg
set target to stm32f4x
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : clock speed 1800 kHz
Info : STLINK v2 JTAG v27 API v2 SWIM v6 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.300981
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
    TargetName         Type       Endian TapName            State      
--  ------------------ ---------- ------ ------------------ ------------
 0* stm32f4x.cpu       hla_target little stm32f4x.cpu       running
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
adapter speed: 1800 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080083a0 msp: 0x200038e0
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : accepting 'gdb' connection on tcp/3333
Debugger attaching: halting execution
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
adapter speed: 1800 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080083a0 msp: 0x200038e0
force hard breakpoints
Info : device id = 0x30006441
Info : flash size = 1024kbytes
Error: Cortex-M Flash Patch Breakpoint rev.1 cannot handle HW breakpoint above address 0x1FFFFFFE
Error: can't add breakpoint: unknown reason
"""


The "GDB OpenOCD Debugging"(https://gnu-mcu-eclipse.github.io/debug/openocd/) Plugin works much better. It sets the firmware binary sources right and the RAM memory access.

You can access the openOCD server started by west or start it on your own. I attached a screenshot with the eclipse settings for everyone who likes to know.


Regards!

Stefan


On 08/11/2018 20:02, Marti Bolivar wrote:
Hi,
On Thu, Nov 8, 2018 at 11:40 AM Stefan Jaritz <stefan@...> wrote:
Hej,

Currently I am trying to figure out how to setup the debugger by the use
of west. I manage to start the west debug server but I failed to connect.

Maybe I am missing something or anyone having the same problem.

My steps & workflow:

"setup zephyr"

1.) open terminal

2.) set environment by "source zephyr-env.sh"

3.) build my project

4.) run "west debugserver" from my build dir

"""


"""

"setup ide"

5.) open eclipse without setting the environment

6.) create a new debug config

6.1) set in Debugger tab:

6.1.1) Debugger >> gdbserver

6.1.2) Main >> "gdb Debugger": =
/opt/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/arm-zephyr-eabi/arm-zephyr-eabi-gdb
6.1.3) Connection >> "host name" = localhost
6.1.4) Connection >> "port" = 6666
Looks like eclipse is set up to use port 6666 for the GDB connection...


Eclipse fails to connect with:

"""

Error in final launch sequence:

Failed to execute MI command:
-target-select extended-remote localhost:6666
Error message from debugger back end:
Remote replied unexpectedly to 'vMustReplyEmpty': timeout
Failed to execute MI command:
-target-select extended-remote localhost:6666
Error message from debugger back end:
Remote replied unexpectedly to 'vMustReplyEmpty': timeout
Remote replied unexpectedly to 'vMustReplyEmpty': timeout

"""

The west console print:
"""

[100%] Built target kernel_elf
Using runner: openocd
Open On-Chip Debugger 0.10.0+dev-gea2753a7-dirty (2018-11-02-23:37)
Licensed under GNU GPL v2
For bug reports, read
     http://openocd.org/doc/doxygen/bugs.html
use the st link v2 cfg
set target to stm32f4x
Info : The selected transport took over low-level target control. The
results might differ compared to plain JTAG/SWD
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : clock speed 1800 kHz
Info : STLINK v2 JTAG v27 API v2 SWIM v6 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 2.521022
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
But 3333 is what is open for incoming gdb connections.

     TargetName         Type       Endian TapName State
--  ------------------ ---------- ------ ------------------ ------------
  0* stm32f4x.cpu       hla_target little stm32f4x.cpu       halted
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
adapter speed: 1800 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080082cc msp: 0x200038e0
Info : Listening on port 6666 for tcl connections
It seems openocd has opened 6666 for tcl, not gdb.

If you can change your eclipse configuration to use port 3333, it
should work. Otherwise, since you are using the openocd runner, you
can provide the --tcl-port and --gdb-port options to west debugserver
to change the gdb port to 6666 and the tcl port to something else.

From your build directory, you can obtain context-sensitive help
output about your debugserver configuration with:

$ west debugserver --context

That will print the configuration as well as any openocd-specific
options you can provide to west debugserver.

Hope this helps,
Marti

Info : Listening on port 4444 for telnet connections
Info : accepting 'tcl' connection on tcp/6666

"""

Any ideas how to get the combination of west & eclipse for dbg done?


There is a nice document describing the first steps with west.

https://docs.zephyrproject.org/latest/west/flash-debug.html#debugging-west-debug-west-debugserver

Stef