Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 8 Replies) openOCD remote debugging (Read 2735 times)
anatom74
Junior Member
**
Offline


Posts: 31
Joined: Aug 8th, 2015
openOCD remote debugging
Nov 24th, 2020 at 5:17am
Print Post  
Has anyone tried remote debugging with openOCD?

Based on instructions:
https://www.visualmicro.com/post/2016/01/17/3rd-Party-Hardware-GDB-Configuration... just changing localhost to remote openOCD server ip in board.txt did not do the trick:
Code
Select All
tools.gdb.tcp=[server ip]:3333
 

  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2145
Joined: Feb 13th, 2019
Re: openOCD remote debugging
Reply #1 - Nov 24th, 2020 at 10:23am
Print Post  
Have you tried using the Custom JSON File to adjust this?
https://www.visualmicro.com/page/Debugging-Using-Custom-Hardware.aspx

This is a more direct way to alter the configuration in use, and if you enable Upload > Verbose, and attempt to attach your debugger, the JSON will be shown in the Micro Build Output, which can then be added to the Custom Debugger file for alteration.

Once the file is present select the "Manual / Custom" Hardware Debug option to use it.

If you would like more assistance with this configuration please attach the build log with the settings shown at the top of this page so we can understand your configuration further.
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2145
Joined: Feb 13th, 2019
Re: openOCD remote debugging
Reply #2 - Nov 24th, 2020 at 3:28pm
Print Post  
After further testing with OpenOCD running via CMD on another machine:

There will need to be an additional parameter added into the OpenOCD Start command, just before the debugger *.cfg file:
Code
Select All
-c "bindto 0.0.0.0" 



This will ensure it binds to all network interfaces on the machine instead of just the loopback interface (default).

Also ensure the openocd.exe, or port 3333 has been opened in the firewall for the OpenOCD machine.
  
Back to top
 
IP Logged
 
anatom74
Junior Member
**
Offline


Posts: 31
Joined: Aug 8th, 2015
Re: openOCD remote debugging
Reply #3 - Nov 25th, 2020 at 3:37pm
Print Post  
Indeed, I would need some assistance, so here's a JSON:

Code
Select All
{
  "serverLaunchTimeout": 5000,
  "filterStdout": false,
  "filterStderr": true,
  "targetArchitecture": "arm",
  "stopAtEntry": false,
  "externalConsole": false,
  "MIMode": "gdb",
  "MIDebuggerServerAddress": "192.168.10.198:3333",
  "cwd": Debug",
  "MIDebuggerPath": -none-eabi-gcc\\9.2.1-1.1/bin\\arm-none-eabi-gdb.exe",
  "MIDebuggerArgs": "",
  "debugServerPath": "C:\\ProgramData\\vmicro\\tools\\openocd-0.10.0.20200213\\bin/openocd.exe",
  "debugServerArgs": "-d2 -l \\Debug/SimpleRTC.ino_DebugOpenOCD.log}\" -s \"C:\\ProgramData\\vmicro\\tools\\openocd-0.10.0.20200213/scripts/\" -f \"interface/stlink.cfg\" -f \"board/st_nucleo_f4.cfg\" -c \"init\"",
  "program": pleRTC.ino.elf",
  "logging": {
    "moduleLoad": false,
    "trace": false,
    "engineLogging": false,
    "programOutput": false,
    "exceptions": false,
    "traceResponse": false
  },
  "visualizerFile": Debug\\debugger_tmp.natvis",
  "showDisplayString": true
}
 

  
Back to top
 
IP Logged
 
anatom74
Junior Member
**
Offline


Posts: 31
Joined: Aug 8th, 2015
Re: openOCD remote debugging
Reply #4 - Nov 25th, 2020 at 4:00pm
Print Post  
startup of remote server looks like:
Code
Select All
source [find interface/stlink-v2-1.cfg]

source [find target/stm32f4x.cfg]
bindto 0.0.0.0
# use hardware reset, connect under reset
reset_config srst_only srst_nogate
adapter srst delay 100
adapter srst pulse_width 100
init
targets
#reset hal 




but still getting an error:

Code
Select All
Uploading 'SimpleRTC' to 'Nucleo-64' using 'COM9'
Uploader started for board Nucleo-64
Upload method will be: bootloader
Uploading via Bootloader
C:\ProgramData\vmicro\tools\openocd-0.10.0.20200213\bin\openocd.exe -d2 -s "C:\ProgramData\vmicro\tools\openocd-0.10.0.20200213/scripts/" -f "interface/stlink.cfg" -f "board/st_nucleo_f4.cfg" -c "echo -n {****[vMicro]**** Uploading ELF :}" -c "reset_config; telnet_port disabled; program no.elf} reset;reset_config;shutdown"
Open On-Chip Debugger 0.10.0+dev-01058-g853a05287 (2020-02-13-16:41)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
The uploader process failed
# Copy build result to 'Project>Property Pages>Intermediate Directory'
# Destination: y%20Examples/SimpleRTC/Debug/
debug_level: 2

Warn : Interface already configured, ignoring
Error: already specified hl_layout stlink
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
****[vMicro]**** Uploading ELF :Info : clock speed 2000 kHz
Error: open failed
in procedure 'program'
** OpenOCD init failed **
shutdown command invoked
 


  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2145
Joined: Feb 13th, 2019
Re: openOCD remote debugging
Reply #5 - Nov 25th, 2020 at 4:10pm
Print Post  
Thanks for the detail.

If OpenOCD is running happily on the target machine, then the only issue looks to be that it is still present in the JSON file on the machine running VS (so it will try to start an instance locally).

If you comment out the "debugServerPath" and "debugServerArgs" in the JSON file, it should then connect to the other PC as expected.
  
Back to top
 
IP Logged
 
anatom74
Junior Member
**
Offline


Posts: 31
Joined: Aug 8th, 2015
Re: openOCD remote debugging
Reply #6 - Nov 25th, 2020 at 4:36pm
Print Post  
Even though I removed the suggested lines from JSON, the result is the same.

Looks like it does not recognize Manual /Custom switch
« Last Edit: Nov 25th, 2020 at 4:42pm by anatom74 »  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2145
Joined: Feb 13th, 2019
Re: openOCD remote debugging
Reply #7 - Nov 25th, 2020 at 5:02pm
Print Post  
Just to check, did you add the JSON file to the project from the vMicro Option?

"Right Click on the Project in Solution Explorer > Add > Custom GDB Debugger (Advanced)"


  
Back to top
 
IP Logged
 
anatom74
Junior Member
**
Offline


Posts: 31
Joined: Aug 8th, 2015
Re: openOCD remote debugging
Reply #8 - Nov 25th, 2020 at 5:22pm
Print Post  
Yes, I did exactly like described. It created JSON file with placeholders which I then populated. See attachments.
« Last Edit: Nov 25th, 2020 at 5:23pm by anatom74 »  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2145
Joined: Feb 13th, 2019
Re: openOCD remote debugging
Reply #9 - Nov 25th, 2020 at 5:38pm
Print Post  
Thanks for confirming.  Are you currently running Debug > Start Debugging?

In this scenario the only option is to use Debug > Attach to Process, as the uploader isn't configured to run via GDB.
  
Back to top
 
IP Logged
 
anatom74
Junior Member
**
Offline


Posts: 31
Joined: Aug 8th, 2015
Re: openOCD remote debugging
Reply #10 - Nov 25th, 2020 at 6:19pm
Print Post  
Yes, I was using Debug>Start Debugging.

Now when I run debugger as suggested, it works, but as uploader isn't configured, I'm unable to upload code. Is there a solution to do it also remotely?
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2145
Joined: Feb 13th, 2019
Re: openOCD remote debugging
Reply #11 - Nov 25th, 2020 at 7:10pm
Print Post  
We have no direct support for this at present.

It may be possible using GDB (via OpenOCD) as we are here, with the load command and the elf file:
https://sourceware.org/gdb/current/onlinedocs/gdb/Target-Commands.html

Alternatively you could create a telnet connection to the OpenOCD instance (normally :4444) and run the OpenOCD commands from the upload output to perform the upload.
(You need to copy the elf to the machine running OpenOCD first, and use the local path from the PC running OpenOCD in the command)

e.g. Snippet from output above:
Uploading via Bootloader
Code
Select All
C:\ProgramData\vmicro\tools\openocd-0.10.0.20200213\bin\openocd.exe -d2 -s "C:\ProgramData\vmicro\tools\openocd-0.10.0.20200213/scripts/" -f "interface/stlink.cfg" -f "board/st_nucleo_f4.cfg" -c "echo -n {****[vMicro]**** Uploading ELF :}" -c "reset_config; telnet_port disabled; program no.elf} reset;reset_config;shutdown" 



If the file is e.g. on C:\SimpleRTC.ino.elf on the OpenOCD machine, then connect telnet to it, and the command to run in OpenOCD would become:
Code
Select All
reset_config; telnet_port disabled; program {C:\SimpleRTC.ino.elf} reset;reset_config; 



« Last Edit: Nov 25th, 2020 at 7:24pm by Simon@Visual Micro »  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint