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) Unable to start debugging with Adafruit M4 Airlift and Segger Jlink (Read 2711 times)
Steve Scholl
Junior Member
**
Offline


Posts: 16
Joined: Jan 29th, 2020
Unable to start debugging with Adafruit M4 Airlift and Segger Jlink
Jan 16th, 2021 at 11:02pm
Print Post  
Hi,

I get this error when attempting to debug:

"Unable to start debugging. Unable to establish a connection to GDB. Debug out may contain more information"

Originally i was getting a "Can't find ... arduino_zero.cfg" error. I was able to address that by creating a board.txt based on the instructions in a this post https://www.visualmicro.com/forums/YaBB.pl?num=1589097101/3 ;

That worked once, in that I was able to start debugging and hit a breakpoint, but only one time. The next time I tried to start debugging Visual Studio stopped responding during the upload. Eventually I killed it from Task Manager then rebooted my PC. Since then I always get the Unable to start debugging error.

I've attached the Micro Build output and board.buildinfo.

Debug Output:
Starting: arduino7\bin/openocd.exe" -d2 -s arduino7/share/openocd/scripts/" -f "interface/jlink.cfg" -c "transport select swd" -f "target/atsame5x.cfg" -c "init; reset halt"
Starting: gcc\9-2019q4/bin\arm-none-eabi-gdb.exe" --interpreter=mi
arduino7\bin/openocd.exe" exited with code 1 (0x1).

board.txt:
tools.jlink.server.targetCmd=-c "transport select swd" -f "target/atsame5x.cfg"
tools.jlink.program.targetCmd=-c "transport select swd"  -f "target/atsame5x.cfg"

Zadig shows that my Jlink is using the WinUSB driver.

thanks,
steve

  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Steve Scholl
Junior Member
**
Offline


Posts: 16
Joined: Jan 29th, 2020
Re: Unable to start debugging with Adafruit M4 Airlift and Segger Jlink
Reply #1 - Jan 16th, 2021 at 11:22pm
Print Post  
I figured out how to modify my board.txt to get the log file output from openocd. 

swd
embedded:startup.tcl:60: Error: Can't find target/atsame5x.cfg
in procedure 'script' 
at file "embedded:startup.tcl", line 60
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2174
Joined: Feb 13th, 2019
Re: Unable to start debugging with Adafruit M4 Airlift and Segger Jlink
Reply #2 - Jan 17th, 2021 at 3:31pm
Print Post  
Thanks for the report, and the detail.

It appears to be incorrectly picking up the OpenOCD from the Adafruit package.

If you add the below to the board.txt in your project does this allow the target.cfg to be found?
Code
Select All
tools.openocd.path={runtime.tools.openocd-0.10.0.20200213.path}
runtime.tools.openocd.path={runtime.tools.openocd-0.10.0.20200213.path} 

  
Back to top
 
IP Logged
 
Steve Scholl
Junior Member
**
Offline


Posts: 16
Joined: Jan 29th, 2020
Re: Unable to start debugging with Adafruit M4 Airlift and Segger Jlink
Reply #3 - Jan 17th, 2021 at 6:24pm
Print Post  
With those changes I got a different error:

Error: Can't find interface/jlink.cfg

I was able to address that and get debugging to work by adding the following line to board.txt

tools.openocd.scriptPath=-s "{runtime.tools.openocd-0.10.0.20200213.path}/scripts/"

Is that the fix you would recommend?


Even with that fix I'm stymied by Uploader issues. I have been using the Bootloader, but that only works once. After a debugging session, ended by choosing Stop Debugging, subsequent uploads fail. I've also tried using both of the Jlink Hardware Programmer options available in the Uploader sub menu but both always fail. I've attached a file with the output from all 3 options.

  

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


Posts: 2174
Joined: Feb 13th, 2019
Re: Unable to start debugging with Adafruit M4 Airlift and Segger Jlink
Reply #4 - Jan 18th, 2021 at 11:41am
Print Post  
Thanks for the detail.

This may be due to the flashing process of this board being more complex than most, (like the DUE) it may need additional NVM bits setting as part of the flash process, to ensure the board flashes correctly, and runs your program afterwards.

Can you confirm the debugging works if the sketch is uploaded via Serial/FileSystem? 
If you reset the board after debugging has stopped, does the flash process work?
  
Back to top
 
IP Logged
 
Steve Scholl
Junior Member
**
Offline


Posts: 16
Joined: Jan 29th, 2020
Re: Unable to start debugging with Adafruit M4 Airlift and Segger Jlink
Reply #5 - Jan 18th, 2021 at 6:35pm
Print Post  
If I upload over a Com port, then yes debugging does work. I can set and hit breakpoints, inspect variables, single step, etc.

When I Stop Debugging or Detach All, the program executing on the Airlift stops (i.e. LEDS stop updating and logging output ceases). I cannot upload. Resetting the board doesn't fix the upload (it doesn't even restart the program on the Airlift)

In case this info helps track down the issue, I have discovered that I can re-enable uploading by disconnecting then reconnecting the USB cable attached to the jlink, then resetting the board. With this reset, the program on the Airlift starts again and the Com port reappears in the Device Manager (it disappeared upon hitting reset after Stop Debugging)
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2174
Joined: Feb 13th, 2019
Re: Unable to start debugging with Adafruit M4 Airlift and Segger Jlink
Reply #6 - Jan 19th, 2021 at 1:13pm
Print Post  
Thanks for the detail around this.

Does adding the below line to the board.txt allow the board to re-connect after debugging, without the manual reset?
Code
Select All
tools.jlink.midebugger.stop.commands=reset run; 



(This can also be entered manually during debugging to see the effect as shown in this video
« Last Edit: Jan 19th, 2021 at 1:13pm by Simon@Visual Micro »  
Back to top
 
IP Logged
 
Steve Scholl
Junior Member
**
Offline


Posts: 16
Joined: Jan 29th, 2020
Re: Unable to start debugging with Adafruit M4 Airlift and Segger Jlink
Reply #7 - Jan 20th, 2021 at 5:59am
Print Post  
I was not able to get this to work. I tried both modifying board.txt and entering the commands manually. Here are the 5 things I tried:

#1
Modified board.txt
Start Debugging
Stop Debugging (while program running)

Error: Commands are only accepted when the process is stopped.


#2 
Modified board.txt
Start Debugging
Hit Breakpoint
Stop Debugging

Undefined command: "reset". Try "help".


#3
Start Debugging
Hit Breakpoint
In the command window:
>Debug.MIDebugExec reset run;

Undefined command: "reset".  Try "help".


#4
Start Debugging
Hit Breakpoint
In the command window:
>Debug.MIDebugExec run

The "remote" target does not support "run".  Try "help target" or "continue".


#5
Starting Debugging
Hit Breakpoint
In the command window:
>Debug.MIDebugExec continue

This locked up Visual Studio completely. Had to kill it from Task Manager.
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2174
Joined: Feb 13th, 2019
Re: Unable to start debugging with Adafruit M4 Airlift and Segger Jlink
Reply #8 - Jan 27th, 2021 at 2:04pm
Print Post  
Thanks for the detail and perseverance.

If you change the board.txt command / run the below commands via Debug.MIDebugExec does it improve? (I had incorrectly given OpenOCD Commands instead of GDB commands previously).
Code
Select All
tools.jlink.midebugger.stop.commands=monitor reset run;kill 



Also if you find VS locks up when working in VS Console, killing the arm-none-eabi-gdb.exe via Task Manager often unlocks it without a full VS Restart.
  
Back to top
 
IP Logged
 
Steve Scholl
Junior Member
**
Offline


Posts: 16
Joined: Jan 29th, 2020
Re: Unable to start debugging with Adafruit M4 Airlift and Segger Jlink
Reply #9 - Jan 28th, 2021 at 4:50am
Print Post  
No problem. I get that remotely debugging a problem through somebody else's hands with the ping time of a rover on Pluto is challenging.

Some good news. The latest commands work when at a breakpoint, whether the commands are in board.txt or manually entered. The program on the Airlift restarts and I can upload a new build.

Unfortunately it doesn't work if the program on the Airlift is running. Using the modified board.txt, when I choose Stop Debugging the following happens:
Error: Commands are only accepted when the process is stopped. (this is printed twice)
The program on the Airlift stops.
Visual Studio temporarily hangs (1-2 minutes).
Unable to upload a new build to the Airlift without yanking usb cables and resetting it.

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


Posts: 2174
Joined: Feb 13th, 2019
Re: Unable to start debugging with Adafruit M4 Airlift and Segger Jlink
Reply #10 - Jan 28th, 2021 at 10:46am
Print Post  
Thanks for the detail, and measured responses are better than rushing when problem solving... just like driving the Rover...

We will look into adding an option to "Break All" before it begins running the stop commands, to ensure this works as expected when the code is running and stop is pressed, and update when there is movement on this element.

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


Posts: 2174
Joined: Feb 13th, 2019
Re: Unable to start debugging with Adafruit M4 Airlift and Segger Jlink
Reply #11 - Jan 29th, 2021 at 3:51pm
Print Post  
We have released a new version which supports an additional property, which will force "Break All" to be run before the Custom GDB Stop commands.

e.g.
Code
Select All
# Force "Break All" [||] to be pressed before running the stop commands
tools.jlink.midebugger.stop.break=true
# Run these GDB commands instead of just stopping immediately
tools.jlink.midebugger.stop.commands=monitor reset run;kill  



Let us know if this resolves the issue.
NOTE - There may be a brief error on locating the source file as it stops (depending on where the system is as the stop button is pushed)
  
Back to top
 
IP Logged
 
Steve Scholl
Junior Member
**
Offline


Posts: 16
Joined: Jan 29th, 2020
Re: Unable to start debugging with Adafruit M4 Airlift and Segger Jlink
Reply #12 - Jan 30th, 2021 at 6:25pm
Print Post  
Works great! 

It took me a bit to realize the version i needed wasn't available from Extensions and Updates inside of VS yet. Once I got that sorted out I tested it a half dozen times. It worked every time and  I didn't experience the "brief error" you mentioned might happen.

Thanks for the all help.


Recapping for other viewers, this is what is working for me:

Visual Micro Version 2021.106.2 with the following modifications to board.txt.

Code
Select All
tools.jlink.server.targetCmd=-c "transport select swd" -f "target/atsame5x.cfg"
tools.jlink.program.targetCmd=-c "transport select swd"  -f "target/atsame5x.cfg"

# Force "Break All" [||] to be pressed before running the stop commands
tools.jlink.midebugger.stop.break=true
# Run these GDB commands instead of just stopping immediately
tools.jlink.midebugger.stop.commands=monitor reset run;kill 

tools.openocd.path={runtime.tools.openocd-0.10.0.20200213.path}
runtime.tools.openocd.path={runtime.tools.openocd-0.10.0.20200213.path}
tools.openocd.scriptPath=-s "{runtime.tools.openocd-0.10.0.20200213.path}/scripts/" 




  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint