Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
Support requests without the output above may be impossible to answer, so please help us to help you
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
Segger jLink + Feather M0 == Confused (Read 213 times)
Joshua Gall
Junior Member
**
Offline



Posts: 15
Segger jLink + Feather M0 == Confused
Mar 4th, 2020 at 6:37am
 
I recently picked up a Segger jLink Edu, wanting to upgrade my debugging game from print statements to something a bit less pedestrian. I installed the software from Segger, which went easy enough. Soldered some leads from the jLink to the Feather M0 that I'm using, again, super easy. Plugged the jLink and the feather into two conveniently available front ports on my development box, and well, nothing seems to work.

I'm lost, very lost, and was hopeful someone here might be able to answer a couple questions:

1. I read about using the zadig app to update my drivers, but I'm not sure exactly "what" to update. Is it the jLink device that's listed, and if so, which driver do you update it to? I tried all of them and nothing seemed to have any effect other than making the Segger applications angry.

2. I'm pretty confident that my jLink is connected to my Feather properly (wiring wise), but how do you confirm that you didn't connect something incorrectly?

3. Trying to upload and debug a simple blink sketch via VS 2019 and Visual Micro yields the following error. Note that I have the following configured via Visual Micro: Adafruit Feather M0 board, COM9 Port (J-Link), J-Link over OpenOCD, Enable Programmer, Debug: Hardware, Segger JLink (SWD), No Project or Library Optimizations.

Code:
Debugger: Segger JLink (SWD)
Compiling 'Blink' for 'Adafruit Feather M0'
Build Folder: "file:///C:/Users/jgall/AppData/Local/Temp/VMBuilds/Blink/adafruit_adafruit_feather_m0/Debug"
Program size: 10,840 bytes (used 4% of a 262,144 byte maximum) (0.27 secs)

Uploading 'Blink' to 'Adafruit Feather M0' using 'J-Link over OpenOCD'
Uploader started for board Adafruit Feather M0
Uploader will use programmer name: adafruit_jlink
C:\Users\jgall\AppData\Local\arduino15\packages\arduino\tools\openocd\0.9.0-arduino\bin\openocd.exe -d2 -s "C:\Users\jgall\AppData\Local\arduino15\packages\arduino\tools\openocd\0.9.0-arduino/share/openocd/scripts/" -f "C:\Users\jgall\AppData\Local\arduino15\packages\adafruit\hardware\samd\1.5.5/variants/feather_m0/openocd_scripts/feather_m0.cfg" -c "telnet_port disabled; program {{C:\Users\jgall\AppData\Local\Temp\VMBuilds\Blink\adafruit_adafruit_feather_m0\Debug/Blink.ino.elf}} verify reset; shutdown"
Open On-Chip Debugger 0.9.0-gd4b7679 (2015-06-10-22:24)
	The upload process has finished.
Licensed under GNU GPL v2

# MI Debugger Properties
{
  "serverLaunchTimeout": 5000,
  "filterStdout": false,
  "filterStderr": true,
  "targetArchitecture": "arm",
  "stopAtEntry": false,
  "externalConsole": false,
  "MIMode": "gdb",
  "MIDebuggerServerAddress": "localhost:3333",
  "cwd": "C:\\Users\\jgall\\AppData\\Local\\Temp\\VMBuilds\\Blink\\adafruit_adafruit_feather_m0\\Debug",
  "MIDebuggerPath": "C:\\Users\\jgall\\AppData\\Local\\arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\4.8.3-2014q1/bin\\arm-none-eabi-gdb.exe",
  "MIDebuggerArgs": "",
  "debugServerPath": "C:\\ProgramData\\vmicro\\tools\\openocd-0.10.0.1\\bin/openocd.exe",
  "debugServerArgs": "-d2 -l \"{C:\\Users\\jgall\\AppData\\Local\\Temp\\VMBuilds\\Blink\\adafruit_adafruit_feather_m0\\Debug/Blink.ino_DebugOpenOCD.log}\" -s\"C:\\ProgramData\\vmicro\\tools\\openocd-0.10.0.1/scripts/\" -f \"C:\\ProgramData\\vmicro\\tools\\openocd-0.10.0.1/scripts/interface/jlink.cfg\" -c \"transport select swd\" -f \"C:\\Users\\jgall\\AppData\\Local\\arduino15\\packages\\adafruit\\hardware\\samd\\1.5.5/variants/feather_m0/openocd_scripts/feather_m0.cfg\" -c \"init\"",
  "program": "C:/Users/jgall/AppData/Local/Temp/VMBuilds/Blink/adafruit_adafruit_feather_m0/Debug/Blink.ino.elf",
  "logging": {
    "moduleLoad": false,
    "trace": false,
    "engineLogging": false,
    "programOutput": false,
    "exceptions": false,
    "traceResponse": false
  },
  "visualizerFile": "C:\\Users\\jgall\\AppData\\Local\\Temp\\VMBuilds\\Blink\\adafruit_adafruit_feather_m0\\Debug\\debugger_tmp.natvis",
  "showDisplayString": true
}
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
debug_level: 2
Error: Debug adapter does not support any transports? Check config file order.
Error: unable to select a session transport. Can't continue.
shutdown command invoked
 



After this error message outputs, I get a visual studio modal error window stating "Unable to start debugging. Unable to establish a connection to GDB. Debug output may contain more information".

Also, pasting this in results in syntax errors regarding an unexpected token '-d' in expression or statement

Code:
"C:\ProgramData\vmicro\tools\openocd-0.10.0.1\bin/openocd.exe" -d2 -l "{C:\Users\jgall\AppData\Local\Temp\VMBuilds\Blink\adafruit_adafruit_feather_m0\Debug/Blink.ino_DebugOpenOCD.log}" -s"C:\ProgramData\vmicro\tools\openocd-0.10.0.1/scripts/" -f "C:\ProgramData\vmicro\tools\openocd-0.10.0.1/scripts/interface/jlink.cfg" -c "transport select swd" -f "C:\Users\jgall\AppData\Local\arduino15\packages\adafruit\hardware\samd\1.5.5/variants/feather_m0/openocd_scripts/feather_m0.cfg" -c "init" 



So looking at my list of things, I'm assuming there are several issues.

1. I've not updated or added any drivers, mostly cuz I don't know which device to update to what driver.
2. There seems to be a syntax error of some kind when trying to execute openocd.
3. I tried to debug with both the JLink over OpenOCD and JLink over OpenOCD (vMicro). Neither worked, both OpenOCD command line statements resulting in the same syntax error statement with the only exception being the path to different versions of OpenOCD.

I appreciate the length of this post, and any thoughts you might have on things I can try. I'm eager to learn more, and up my debugging game.



Back to top
 
 
IP Logged
 
Simon Hopkinson
Administrator
*****
Offline



Posts: 186
Re: Segger jLink + Feather M0 == Confused
Reply #1 - Mar 4th, 2020 at 9:46am
 
Thanks for the detail and information around what you have tried, it is very useful:

1) The Zadig Driver is needed for the JLink device, and when installed it allows the JLink to work with OpenOCD.  This will need removing if you wish to use the Segger JLink tools directly to my knowledge.

2) Connections to the Feather would be the SWD pins, and the VCC + GND to the J-Link, the Adafruit site has this page detailing where to solder the SWDIO/SWDCLK pins.

3) Can you confirm which version of Visual Micro you are using?

4) The command line you ran resulting in the error does not yield the same error on my machine (with 1.5.10 core, and up to date vMicro), and in all scenarios the config file in use with OpenOCD comes from the board core. An update may improve things with the core in use (1.5.5 installed, 1.5.10 available).

5) The "Jlink Over OpenOCD" uploader is from Adafruit, and the one with vMicro is our customised one (though believe they match beyond OpenOCD versions).

A log file is created by the below part of the command with further detail in it, which should show whether the JLink has been seen, and potentially further information about the issue.  If you remove this part of the command it will just write to the console instead.
Code:
-l "{C:\Users\jgall\AppData\Local\Temp\VMBuilds\Blink\adafruit_adafruit_feather_m0\Debug/Blink.ino_DebugOpenOCD.log}" 



Hopefully that resolves some of the questions, and if you can post the output from OpenOCD Log then we may be able to see more about what is wrong at present.
Back to top
 
 
IP Logged
 
Joshua Gall
Junior Member
**
Offline



Posts: 15
Re: Segger jLink + Feather M0 == Confused
Reply #2 - Mar 4th, 2020 at 2:00pm
 
Ok, a bit of progress here!

I ran the command line with the log portion removed and it still threw an error. Then I realized that powershell and cmd are different animals, switched to cmd and things ran properly but it did not find the JLink. I used Zadig to update the JLink driver to the libusbK driver, which I'm assuming is the correct one of the several we have to choose from, and re-ran the cmd with a successful result:

Code:
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
debug_level: 2
swd
none separate
adapter speed: 400 kHz
cortex_m reset_config sysresetreq
Info : No device selected, using first device.
Info : J-Link V10 compiled Jan  7 2020 16:51:47
Info : Hardware version: 10.10
Info : VTarget = 3.283 V
Info : clock speed 400 kHz
Info : SWD DPIDR 0x0bc11477
Info : at91samd21g18.cpu: hardware has 4 breakpoints, 2 watchpoints
 



So, switching back to VS2019, I'm using Visual Micro version 1912.28.2.

Here's the interesting thing...

I can successfully start the debugger (Via F5 Start Debugging) if I select the programmer to be JLink over OpenOCD. The green light on the JLink blinks/flickers (rapidly), the debugger starts, but none of my breakpoints actually hit/break. Being a software engineer in my professional life, I'm pretty good with the Visual Studio debugger, so I'm fairly confident they work the same way as they do in any other VS based application. In this scenario, Visual Studio gives me this in the output window (debug):

Code:
openocd: Open On-Chip Debugger 0.10.0
openocd: Licensed under GNU GPL v2
openocd: For bug reports, read
openocd: 	http://openocd.org/doc/doxygen/bugs.html
openocd: debug_level: 2
=thread-group-added,id="i1"
GNU gdb (GNU Tools for ARM Embedded Processors) 7.6.0.20140228-cvs
Copyright (C) 2013 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".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
=cmd-param-changed,param="pagination",value="off"
Note: automatically using hardware breakpoints for read-only addresses.
 



So, progress most certainly, but still not working as we'd hope.

Next I ran the exact scenario above but this time using the JLink over OpenOCD (vMicro) programmer, and get this in the output:

Code:
Debugger: Segger JLink (SWD)
Compiling 'Blink' for 'Adafruit Feather M0'
Build Folder: "file:///C:/Users/jgall/AppData/Local/Temp/VMBuilds/Blink/adafruit_adafruit_feather_m0/Debug"
Program size: 10,856 bytes (used 4% of a 262,144 byte maximum) (0.29 secs)

Uploading 'Blink' to 'Adafruit Feather M0' using 'J-Link over OpenOCD (vMicro)'
Uploader started for board Adafruit Feather M0
Uploader will use programmer name: vmjlink
C:\ProgramData\vmicro\tools\openocd-0.10.0.1\bin\openocd.exe -d2 -l "{C:\Users\jgall\AppData\Local\Temp\VMBuilds\Blink\adafruit_adafruit_feather_m0\Debug/Blink.ino_DebugOpenOCD.log}" -s "C:\ProgramData\vmicro\tools\openocd-0.10.0.1/share/openocd/scripts/" -f "interface/jlink.cfg" -c "transport select swd" -f "C:\Users\jgall\AppData\Local\arduino15\packages\adafruit\hardware\samd\1.5.5/variants/feather_m0/openocd_scripts/feather_m0.cfg" -c "echo -n {****[vMicro]**** Uploading ELF :}" -c "reset_config; telnet_port disabled; program {{C:\Users\jgall\AppData\Local\Temp\VMBuilds\Blink\adafruit_adafruit_feather_m0\Debug/Blink.ino.elf}} reset;reset_config; shutdown"
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
debug_level: 2
Error during upload using programmer
The uploader process failed

The uploader process failed
The uploader returned an error
 



To recap:

1. I updated the JLink USB driver with Zadig to what I "think" is the right driver: libusbK
2. I can debug with the programmer set to JLink over OpenOCD, but my breakpoints aren't being hit (NOTE: I added a breakpoint to a simple incremented counter variable, and another to a method invocation)
3. I cannot debug with the programmer set to JLink over OpenOCD (vMicro) at all, it results in error.
4. For the young players out there: cmd and powershell aren't the same thing. I use powershell every day so its kind of habit to use it...

Hopefully this provides a bit more insight into what's going on and the progress here.
Back to top
 
 
IP Logged
 
Joshua Gall
Junior Member
**
Offline



Posts: 15
Re: Segger jLink + Feather M0 == Confused
Reply #3 - Mar 5th, 2020 at 1:11am
 
a tiny bit of additional progress.

From the debugging troubleshooting page I tried the following:

Restart Target
If the debugger starts and connects, but you never land on your breakpoint..... stop the session, and reboot the target board using its reset button.  Try connecting the debugging session again, it should now work as expected...

So, I hit the reset button on the feather and now I get the following error loaded into a document in Visual Studio:

Quote:
Frame not in module
You can view disassembly in the disassembly window. to always view disassembly for missing source files, change the setting in the options dialog.


And the session is halted at line one of the disassembled code (0x00000000  ldrb      r4, [r7, #31]). Clicking Continue on the debugger results in the following error, 4 times (I've removed all breakpoints btw):

Quote:
@"The target is not in the halted nor running stated, stepi/continue ignored.\n"


On the fifth attempt to continue debugging, I get a Microsoft Visual Studio modal popup warning:

Quote:
Warning: Cannot insert hardware breakpoint 1. Could not insert hardware breakpoints: You may have requested too many hardware breakpoints/watchpoints.


Code:
openocd: Open On-Chip Debugger 0.10.0
openocd: Licensed under GNU GPL v2
openocd: For bug reports, read
openocd: 	http://openocd.org/doc/doxygen/bugs.html
openocd: debug_level: 2
=thread-group-added,id="i1"
GNU gdb (GNU Tools for ARM Embedded Processors) 7.6.0.20140228-cvs
Copyright (C) 2013 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".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
=cmd-param-changed,param="pagination",value="off"
Note: automatically using hardware breakpoints for read-only addresses.
@"The target is not in the halted nor running stated, stepi/continue ignored.\n"
@"The target is not in the halted nor running stated, stepi/continue ignored.\n"
@"The target is not in the halted nor running stated, stepi/continue ignored.\n"
@"The target is not in the halted nor running stated, stepi/continue ignored.\n"
 

Back to top
 
 
IP Logged
 
Simon Hopkinson
Administrator
*****
Offline



Posts: 186
Re: Segger jLink + Feather M0 == Confused
Reply #4 - Mar 5th, 2020 at 10:45am
 
Apologies for missing the previous post.

Zadig Driver - We have tested using the WinUSB Driver

Upload Error - In that command there was the -l logging command to the OpenOCD Log in the build directory.  If you remove the -l "{logfile}" part and re-run it you should be able to see more in the console, hopefully showing more information about the error.

Could you try updating the driver to the Win USB one, and then try just the debug attach (with code uploaded via USB or known good upload method).  Once the debugger is stable we can move onto the programmer more easily, and with less risk.

Back to top
 
 
IP Logged
 
Joshua Gall
Junior Member
**
Offline



Posts: 15
Re: Segger jLink + Feather M0 == Confused
Reply #5 - Mar 7th, 2020 at 3:58am
 
thanks for the suggestions, here's what I've found.

I've updated to the WinUSB driver, though I'm not sure if it made a difference or not.

I've also reburned a bootloader, which was an interesting experience since I've never had to do that before. The only way I could get this to work on this feather was to use the burn bootloader function in Visual Micro using the J-Link over OpenOCD option. Once re-bootloader'd, I was able to upload the blink sketch, and using visual studio's attach to process option, was able to halt at breakpoints and navigate them as you'd expect as a visual studio user. What I didn't expect was that once I stopped the debugging session, the feather seems to hard crash or hang or something and is irrecoverable and needs to be fully un-plugged for me to be able to reconnect and upload new code.

Now for using the JLink as a programmer; it's still not working with either JLink option, though I am getting a different error now, which may be due to the change in the USB driver:

Code:
C:\ProgramData\vmicro\tools\openocd-0.10.0.1\bin\openocd.exe -d2 -s "C:\ProgramData\vmicro\tools\openocd-0.10.0.1/share/openocd/scripts/" -f "interface/jlink.cfg" -c "transport select swd" -f "C:\Users\jgall\AppData\Local\arduino15\packages\adafruit\hardware\samd\1.5.5/variants/feather_m0/openocd_scripts/feather_m0.cfg" -c "echo -n {****[vMicro]**** Uploading ELF :}" -c "reset_config; telnet_port disabled; program {{C:\Users\jgall\AppData\Local\Temp\VMBuilds\Blink\adafruit_adafruit_feather_m0\Debug/Blink.ino.elf}} reset;reset_config; shutdown"



Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
debug_level: 2
swd
none separate
adapter speed: 400 kHz
cortex_m reset_config sysresetreq
****[vMicro]**** Uploading ELF :none separate
Info : No device selected, using first device.
Info : J-Link V10 compiled Jan  7 2020 16:51:47
Info : Hardware version: 10.10
Info : VTarget = 3.290 V
Info : clock speed 400 kHz
Info : SWD DPIDR 0x0bc11477
Info : at91samd21g18.cpu: hardware has 4 breakpoints, 2 watchpoints
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00010100 msp: 0x464c457c
** Programming Started **
auto erase enabled
Info : SAMD MCU: SAMD21G18A (256KB Flash, 32KB RAM)
wrote 32768 bytes from file C:\Users\jgall\AppData\Local\Temp\VMBuilds\Blink\adafruit_adafruit_feather_m0\Debug/Blink.ino.elf in 2.202114s (14.531 KiB/s)
** Programming Finished **
** Resetting Target **
Error: at91samd21g18.cpu -- clearing lockup after double fault
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0x00000003 pc: 0xfffffffe msp: 0x464c4558
none separate
shutdown command invoked
 



I find it curious that I get this kind of error when loading a program, but I'm able to use the JLink to reburn the bootloader.
Back to top
 
 
IP Logged
 
Joshua Gall
Junior Member
**
Offline



Posts: 15
Re: Segger jLink + Feather M0 == Confused
Reply #6 - Mar 10th, 2020 at 2:22pm
 
just giving this a quick bump. Any thoughts on where to go next for this issue?
Back to top
 
 
IP Logged
 
Simon Hopkinson
Administrator
*****
Offline



Posts: 186
Re: Segger jLink + Feather M0 == Confused
Reply #7 - Mar 10th, 2020 at 3:47pm
 
If you upload using the "JLink Over OpenOCD" option (from Adafruit core) as above, and then re-burn the bootloader, does the sketch run as normal (and attach on debug)?

Ill update on the specific error from the uploader when I know more...
Back to top
 
 
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print