OpenOCD remote debugging

Sysprogs forums Forums VisualGDB OpenOCD remote debugging

This topic contains 5 replies, has 3 voices, and was last updated by  support 1 week, 5 days ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #21079


    I am trying to remotely debug a bare metal application running on an ST NUCLEO-F746ZG evaluation board using VisualGDB. My only possibility for doing this is over an Ethernet cable.

    I have loaded a Raspberry PI 3B with OpenOCD, enabled the bcm2835gpio option and wired up the RPi to the ST SWD lines. This appears to be working. So I have OpenOCD running correctly in the RPi and able to program and debug via Telnet or the GDB command line. So although I can now remotely debug via an Ethernet cable, I can only do so at command line level and this is not useful to me because my application uses steppers and I seriously need the real time charting features of VisualGDB.

    Here is my OpenOCD config file on the RPi

    # Config for using Raspberry Pi’s expansion header
    # This is best used with a fast enough buffer but also
    # is suitable for direct connection if the target voltage
    # matches RPi’s 3.3V and the cable is short enough.
    # Do not forget the GND connection, pin 6 of the expansion header.

    interface bcm2835gpio

    bcm2835gpio_peripheral_base 0x3F000000

    # Transition delay calculation: SPEED_COEFF/khz – SPEED_OFFSET
    # These depend on system clock, calibrated for stock 700MHz
    # bcm2835gpio_speed SPEED_COEFF SPEED_OFFSET
    bcm2835gpio_speed_coeffs 146203 36

    # Each of the JTAG lines need a gpio number set: tck tms tdi tdo
    # Header pin numbers: 23 22 19 21
    # bcm2835gpio_jtag_nums 11 25 10 9

    # Each of the SWD lines need a gpio number set: swclk swdio
    # Header pin numbers: 22 18
    bcm2835gpio_swd_nums 25 24

    # If you define trst or srst, use appropriate reset_config
    # Header pin numbers: TRST – 26, SRST – 18

    # bcm2835gpio_trst_num 7
    # reset_config trst_only

    bcm2835gpio_srst_num 18
    reset_config srst_only srst_push_pull

    # or if you have both connected,
    # reset_config trst_and_srst srst_push_pull
    #source [find interface/raspberrypi2-native.cfg]
    transport select swd

    set WORKAREASIZE 0x2000
    source [find target/stm32f7x.cfg]

    #reset_config srst_only srst_nogate
    adapter_nsrst_delay 100
    adapter_nsrst_assert_width 100

    reset halt

    This is similar to the OpenOCD config file used on the PC but obviously this is configuring OpenOCD on the Raspberry Pi.

    Here is the output from OpenOCD, running on the Raspberry Pi:

    pi@raspberrypi:~/OpenOcd $ sudo openocd
    Open On-Chip Debugger 0.10.0+dev-00430-g06123153 (2018-06-08-21:58)
    Licensed under GNU GPL v2
    For bug reports, read
    BCM2835 GPIO nums: swclk = 25, swdio = 24
    BCM2835 GPIO config: srst = 18
    srst_only separate srst_gates_jtag srst_push_pull connect_deassert_srst
    adapter speed: 2000 kHz
    adapter_nsrst_delay: 100
    srst_only separate srst_nogate srst_push_pull connect_deassert_srst
    cortex_m reset_config sysresetreq
    adapter_nsrst_delay: 100
    adapter_nsrst_assert_width: 100
    Info : BCM2835 GPIO JTAG/SWD bitbang driver
    Info : SWD only mode enabled (specify tck, tms, tdi and tdo gpios to add JTAG mode)
    Info : clock speed 2002 kHz
    Info : SWD DPIDR 0x5ba02477
    Warn : Silicon bug: single stepping will enter pending exception handler!
    Info : stm32f7x.cpu: hardware has 8 breakpoints, 4 watchpoints
    Info : Listening on port 3333 for gdb connections
    TargetName Type Endian TapName State
    — —————— ———- —— —————— ————
    0* stm32f7x.cpu cortex_m little stm32f7x.cpu running
    target halted due to debug-request, current mode: Thread
    xPSR: 0x01000000 pc: 0x0800bc58 msp: 0x20050000
    Info : Listening on port 6666 for tcl connections
    Info : Listening on port 4444 for telnet connections

    So now I want to debug remotely from VisualGDB. Here is a link describing how to do this from Eclipse, using an OpenOCD plugin:

    Does anyone know whether it is possible to configure VisualGDB to work in the same way?






    No problem, please try this build:

    We have added support for specifying remote host in the “Custom GDB Stub” debug mode (requires the Custom edition or higher):

    You should now be able to configure your embedded project to launch OpenOCD on Raspberry Pi.

    You must be logged in to view attached files.


    Thank for very much for the update and for doing this so quickly.

    I am getting errors when I try to run because I cannot seem to establish a GDB connection between my PC and OpenOCD on the RPi (I had assumed that because I could establish a SSH connection then a GDB connection would work as well).

    VisualGDB is licensed to Tatum Maskell at Silent Sentinel Limited No connection could be made because the target machine actively refused it.
    “monitor” command not supported by this target.
    You can’t do that when your target is `exec’

    If I run GDB from the cmd window I get:

    (gdb) target remote No connection could be made because the target machine actively refused it.

    Telnet to RPi OpenOCD is also not working although SSH to RPi is and I can also establish a VNC connection. I can establish a telnet connection from the PC to another RPi application, so this makes me think that the RPi OpenOCD application is not listening even though it says that it is.

    However RPi OpenOCD seems to be listening correctly on ports 3333 (GDB) and 4444 (telnet) because I have done some testing on the RPi side using the loopback address and telnet. It open the telnet connection on 4444 and it it opens and then immediately drops the GDB connection because the telnet protocol is being used (however I think this is a good indication that the GDB listener on port 3333 is up and running).

    I have tried disabling the Windows firewall and have also checked the RPi firewall settings and nothing seems to be being blocked.

    So this seems to be a telnet and GDB connection issue between the PC and the RPi OpenGDB app.

    If you do have any ideas on this then I would be very grateful for some help however this does seem to be an issue on the RPi side so I am about to try on the RPi forum to see if they can help me

    Thanks again for your prompt assistance and I will be back in touch if I hit any more problems on the VisualGDB side.




    You might be running a firewall on the Raspberry Pi side. You could try checking with Wireshark whether there’s any reply from Raspberry Pi when you try connecting to that port. Another option would be to try other ports or use netcat instead of OpenOCD to listen to incoming connections to see if the problem is caused by OpenOCD (it might be listening exclusively on the socket).



    Do you have some tutorial how exactly to fill the form (command, arguments etc. )?



    Sorry, as this setup is relatively fragile and error-prone, we do not support it officially and cannot suggest an OpenOCD command line that will just work.

    If you are able to get a meaningful debug session when running gdb and OpenOCD from command line (and could share the command lines and manual setup commands), we can help you configure VisualGDB to achieve equivalent results.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.