Starting 2.3.0 debugger with J-Link fails: "unable to find CMSIS-DAP device"

After update to ARDUINO 2.3 the problem is here again. I can not debug the MKR 1310 anymore.
I set up the SEGGER JLink so it is able to connect to the target but it seems that some of the settings are not correct. ARDUINO is not able to connect the OPENocd anymore.
I am not sure what the message in the gbd-server window is telling me.
Licensed under GNU GPL v2
For bug reports, read
OpenOCD: Bug Reporting
CDRTOSConfigure
Info : auto-selecting first available session transport "swd". To override use 'transport select '.
none separate
adapter speed: 400 kHz
cortex_m reset_config sysresetreq
Info : Listening on port 50003 for tcl connections
Info : Listening on port 50004 for telnet connections
Error: unable to find CMSIS-DAP device

[2024-02-11T10:33:54.563Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session closed
GDB server session ended. This terminal will be reused, waiting for next session to start...
The .LOG of the SEGGER JLINK is not telling me anything because if I clear the information I got from manually starting the SEGGER JLINK GDB server log and start the ARDUINO debug session nothing is writen to the .LOG of JLINK.
Thanks for help

If I click the arrow in the debug tab a internal debug preset is shown. There I see different entries which do not correspond to the JLink settings I would need to use but changing is not possible because starting the debug session removes the changes because this file seems to be reloaded from .AppData.
Is there a way to change this presets?
Regards, Harald

Hi there. After updating the IDE to 2.3.1 I am not able to debug the MKR 1310 anymore. I have an EDU JLink probe connected and installed the sever software. If I start the JLink server UI I am able to connect to the MKR and the UI tells me it is waiting for a connection.
If I stop the sever UI and try to connect as described in the Debugging MKR I get the message that OPENOCD is not able to start. Sure. JLink server CL should be started which is described in custom_debug.JSON but it does not.
So I tried using the arrow left of the conf in the debug tab. A new .JSON is opened and there I see what I would need to change but my changes are not accepted. Might be some default config.
Anyone out there with a solution, hint or workaround?
Thanks, Harald

Hi there.
Is there any information about the port the IDE 2 client is communicating with the GBD server. it seems wheter the GBD server is launched nor the client is communicating with the server.
Any help to get MKR1310 to debug with JLINK EDU probe with IDE 2
As I figured out the tutorial is not correct in this case. Or am I wrong.
There is an launch.json automatically generated but this one is for openocd. I can not change the entries because this one is read only.
How can I point to JLinkGDBServerCL?
This would make it also possible to set the parameters for this one correct.
I can start JLinkGDBServer GUI so that it is waiting for connection and also the command line tool with the correct parameters so it connect to MKR and listen for connection to the debugger client.
Thanks for help.
regards, Harald

Same behaviour with IDE 2.3.1 Previous Version also was problematic but Support tells me a workaround
Now this again is not working.
I did the setup according to Debugging help file. But the Server is not started if I start Debugging with the BugButton. If I start the JLINK GUI I can setup correct. The Server is started and waiting for connection.
If I click the arrow close to the Configuration an extra .JSON pops up with settings. But this file is not allowed to be altered.
Can I change the position where IDE fetches the files used

Hi @HarrySatt. A significant rework of the debugger configuration system was released in Arduino IDE 2.3.0. This was necessary because as more and more Arduino boards platforms started taking advantage of the debugger feature, some advanced requirements emerged that were not properly accommodated by the original the initial experimental system.

The new system is more powerful and flexible, so this change will greatly benefit the platform developers and users in the years to come, but unfortunately it does require that those who are using a J-Link debug probe (or any other configuration that requires the use of the IDE's debug_custom.json feature) must make some adjustments to their workflow.

Instructions

  1. Open the sketch you want to debug in Arduino IDE.
  2. Select the "debug_custom.json" editor tab.
  3. Add this line at the top of the file:
    [
    
  4. Add this line at the top of the file:
    ]
    
  5. Add the following lines in the middle of the file
    "configId": "arduino:samd:mkrwan1310:programmer=jlink",
    "server": "jlink",
    "serverPath": "<JLinkGDBServer path>",
    
  6. Replace <JLinkGDBServer path> with the path to the J-Link GDB server tool, which you will find in the value of the existing serverpath key (note the lowercase p in path).
    You should now have something like this:
    [
      {
        "servertype": "jlink",
        "device": "ATSAMD21G18",
        "configId": "arduino:samd:mkrwan1310:programmer=jlink",
        "server": "jlink",
        "serverPath": "C:/Program Files/JLink/JLinkGDBServerCL",
        "interface": "swd",
        "serverpath": "C:/Program Files/JLink/JLinkGDBServerCL"
      }
    ]
    
  7. Select File > Save from the Arduino IDE menus.
  8. Select Tools > Board > Arduino SAMD Boards (32-bits ARM Cortex-M0+) > Arduino MKR WAN 1310 from the Arduino IDE menus.
  9. Select Tools > Programmer > Segger J-Link from the Arduino IDE menus.
  10. Select Sketch > Optimize for Debugging from the Arduino IDE menus (if it is not already enabled).
  11. Select Sketch > Verify/Compile from the Arduino IDE menus.
  12. Wait for the compilation to finish successfully.
  13. Connect your J-Link and MKR WAN 1310 to your computer as usual.
  14. Click the "Start Debugging" button on the Arduino IDE toolbar.

The debugger should now start up and work as expected.


Please let me know if you have any questions or problems while following those instructions.

Explanation

The instructions above will allow you to get back to using the debugger in this specific application of a J-Link debug probe and a MKR WAN 1310 board, but you (or others who have similar questions and find this thread during their researches) might be interested in understanding why these changes were necessary and how you might make equivalent migrations for other configurations. I'll provide relevant information below. If you aren't interested in "the boring details", you can feel free to skip the rest of this reply.

There are two separate factors you should be aware of:

Breaking change to debug_custom.json format

Previously, the data structure of the file was an object. For example:

{
  "servertype": "jlink",
  "device": "ATSAMD21G18",
  "interface": "SWD",
  "serverpath": "C:/Program Files/SEGGER/JLink/JLinkGDBServerCL"
}

It is now an array of objects. For example:

[
  {
    "servertype": "jlink",
    "device": "ATSAMD21G18",
    "interface": "SWD",
    "serverpath": "C:/Program Files/SEGGER/JLink/JLinkGDBServerCL"
  }
]

The benefit of this new structure is that it allows you to define multiple custom debugger configurations. For this reason, it is necessary to provide an identifier for each configuration so that Arduino IDE will know which one is appropriate to apply. This is done via the configId key. The value has the following format:

<board FQBN>:programmer=<programmer ID>

For example:

[
  {
    "configId": "arduino:samd:mkrwan1310:programmer=jlink",
    "servertype": "jlink",
    "device": "ATSAMD21G18",
    "interface": "SWD",
    "serverpath": "C:/Program Files/SEGGER/JLink/JLinkGDBServerCL"
  }
]

It might seem too confusing to figure out the FQBN and programmer ID, but you can get Arduino IDE to generate it for you:

  1. Select the board you are using from the Arduino IDE menus.
  2. Select the debug probe you are using from the Tools > Programmer menu in Arduino IDE.
    โ“˜ If there is no Tools > Programmer menu, you can skip this step.
  3. Select Sketch > Verify/Compile from the Arduino IDE menus.
  4. Wait for the compilation to finish successfully.
  5. Click the "Start Debugging" button on the Arduino IDE toolbar.
  6. Wait for the process to fail, as indicated by the appearance of an error notification at the bottom right corner of the Arduino IDE menu.
    โ“˜ The failure is expected since we haven't yet added the configId key to the debug_custom.json file. The purpose of clicking the "Start Debugging" button is only to cause Arduino IDE to generate the configId value, which is accomplished even when the debugger doesn't successfully start.
  7. Click the debugger icon on the activity bar on the left side of the Arduino IDE window.
    The "DEBUG" view will open in the left side panel.
  8. Click the gear icon ('Open "launch.json"') on the debugger toolbar.
    A "launch.json" tab will open in the editor.
  9. Find the appropriate configurations[*].configId key in launch.json and copy the value.
    For example, if the file contains this content:
    {
      "version": "0.2.0",
      "configurations": [
        {
          "configId": "arduino:samd:mkrwan1310:programmer=jlink",
    
    Then copy the "configId": "arduino:samd:mkrwan1310:programmer=jlink",.
  10. Select the "debug_custom.json" editor tab.
  11. Paste the copied configId key into the file.
  12. Select File > Save from the Arduino IDE menus.

Bug when overriding certain configuration keys

In addition to the intentionally introduced breaking change I described above, unfortunately a bug was also accidentally introduced that impacts users of the debug_custom.json feature:

I have already submitted a fix for the bug, but it will be some time before that is available as part of an Arduino IDE build. Fortunately it is possible to workaround the bug by using different key names in your debug_custom.json file:

Original key Workaround key
armToolchainPath toolchainPath
configFiles serverConfiguration.scripts
serverpath serverPath
servertype server

:exclamation: The workaround will stop working once the bug is fixed, so you should also leave the correct keys in your debug_custom.json file so that it will continue working even after you update Arduino IDE to a new version that has the fix.


Hi @ptillisch

Thank for fast response

I now changed the debug_custom.json to

[
  {
    "servertype": "jlink",
    "device": "ATSAMD21G18",
    "configId": "arduino:samd:mkrwan1310:programmer=jlink",
    "server": "jlink",
    "serverpath": "C:/Program Files/SEGGER/JLink_V794g/JLinkGDBServerCL.exe",
    "interface": "swd",
    "serverpath": "C:/Program Files/SEGGER/JLink_V794g/JLinkGDBServerCL.exe"
  }
]

The server path is pointing to the last update of JLink GBDB server and if I use it I see the CL server statement is working. Without parameters it fails. OK, that like it is.
The configId I checked as described. It is correct.
But if I start the debugging session I get the following result in "gbd-server" tab:

[2024-03-03T15:07:26.266Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session connected. You can switch to "DEBUG CONSOLE" to see GDB interactions. "C:\\Users\\haral\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\openocd\\0.10.0-arduino7/bin/openocd" -singlerun -nogui -if swd -port 50000 -swoport 50001 -telnetport 50002 -device ATSAMD21G18 Open On-Chip Debugger 0.10.0+dev-gf0767a31 (2018-06-11-13:36) Licensed under GNU GPL v2 For bug reports, read [http://openocd.org/doc/doxygen/bugs.html](http://openocd.org/doc/doxygen/bugs.html) C:\Users\haral\AppData\Local\Arduino15\packages\arduino\tools\openocd\0.10.0-arduino7/bin/openocd: unknown option -- n [2024-03-03T15:07:26.333Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session closed GDB server session ended. This terminal will be reused, waiting for next session to start...

and in the "Debug Console" tab I receive:

Cortex-Debug: VSCode debugger extension version 1.5.1 git(be7d3c8+dirty). Usaage info: [https://github.com/Marus/cortex-debug#usage](https://github.com/Marus/cortex-debug#usage)

Reading symbols from C:\Users\haral\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\arm-none-eabi-objdump.exe --syms -C -h -w C:/Users\haral\AppData\Local\Temp\arduino\sketches\4121EFF1B69A8E40675BE333D4C5723A\Blink.ino.elf

Reading symbols from c:/users\haral\appdata\local\arduino15\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\bin\arm-none-eabi-nm.exe --defined-only -S -l -C -p C:/Users\haral\AppData\Local\Temp\arduino\sketches\4121EFF1B69A8E40675BE333D4C5723A\Blink.ino.elf

Launching GDB: "C:\\Users\\haral\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\7-2017q4\\bin\\arm-none-eabi-gdb.exe" -q --interpreter=mi2 "C:/Users\\haral\\AppData\\Local\\Temp\\arduino\\sketches\\4121EFF1B69A8E40675BE333D4C5723A\\Blink.ino.elf"

IMPORTANT: Set "showDevDebugOutput": "raw" in "launch.json" to see verbose GDB transactions here. Very helpful to debug issues or report problems

Launching gdb-server: "C:\\Users\\haral\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\openocd\\0.10.0-arduino7/bin/openocd" -singlerun -nogui -if swd -port 50000 -swoport 50001 -telnetport 50002 -device ATSAMD21G18

Please check TERMINAL tab (gdb-server) for output from C:\Users\haral\AppData\Local\Arduino15\packages\arduino\tools\openocd\0.10.0-arduino7/bin/openocd

Finished reading symbols from objdump: Time: 74 ms

Finished reading symbols from nm: Time: 76 ms

WARNING: Cortex-Debug will deprecate use of GDB version 8 after July 2022. Please upgrade to version 9+

Reading symbols from C:/Users\haral\AppData\Local\Temp\arduino\sketches\4121EFF1B69A8E40675BE333D4C5723A\Blink.ino.elf...done.

undefined: GDB Server Quit Unexpectedly. See gdb-server output for more details.

GDB never responded to an interrupt request. Trying to end session anyways

There seems something missing. do I have to add the parameters in the serverpath entry? How to get JLinkCL started instead of OpenGBD? That seems to be significant. As far to my understanding I eventually should see also the GUI if I use the server GUI edition.

Is it possible to edit the launch.json file to get these entries and parameters right?
The launch.json is:

{
  "version": "0.2.0",
  "configurations": [
    {
      "cwd": "${workspaceRoot}",
      "name": "Arduino",
      "request": "launch",
      "type": "cortex-debug",
      "executable": "C:\\Users\\haral\\AppData\\Local\\Temp\\arduino\\sketches\\4121EFF1B69A8E40675BE333D4C5723A/Blink.ino.elf",
      "servertype": "jlink",
      "serverpath": "C:\\Program Files\\SEGGER\\JLink-V94g\\JLinkGDBServerCL.exe",
      "armToolchainPath": "C:\\Users\\haral\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\7-2017q4/bin/",
      "configFiles": [
        "C:\\Users\\haral\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.8.13/variants/mkrwan1300/openocd_scripts/arduino_zero.cfg"
      ],
      "device": "ATSAMD21G18",
      "interface": "SWD"
    },
    {
      "configId": "arduino:samd:mkrwan1310:programmer=jlink",
      "cwd": "${workspaceRoot}",
      "request": "launch",
      "type": "cortex-debug",
      "executable": "C:\\Users\\haral\\AppData\\Local\\Temp\\arduino\\sketches\\4121EFF1B69A8E40675BE333D4C5723A/Blink.ino.elf",
      "toolchainPrefix": "arm-none-eabi",
      "servertype": "jlink",
      "device": "ATSAMD21G18",
      "serverpath": "C:\\Users\\haral\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\openocd\\0.10.0-arduino7/bin/openocd",
      "interface": "swd",
      "name": "Arduino MKR WAN 1310 (jlink)",
      "armToolchainPath": "C:\\Users\\haral\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\7-2017q4/bin/",
      "configFiles": [
        "C:\\Users\\haral\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.8.14/variants/mkrwan1300/openocd_scripts/arduino_zero.cfg"
      ]
    },
    {
      "configId": "arduino:samd:arduino_zero_edbg:programmer=sam_ice",
      "cwd": "${workspaceRoot}",
      "request": "launch",
      "type": "cortex-debug",
      "executable": "C:\\Users\\haral\\AppData\\Local\\Temp\\arduino\\sketches\\4121EFF1B69A8E40675BE333D4C5723A/Blink.ino.elf",
      "toolchainPrefix": "arm-none-eabi",
      "name": "Arduino Zero (Programming Port) (sam_ice)",
      "serverpath": "C:\\Users\\haral\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\openocd\\0.10.0-arduino7/bin/openocd",
      "servertype": "openocd",
      "armToolchainPath": "C:\\Users\\haral\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\7-2017q4/bin/",
      "configFiles": [
        "C:\\Users\\haral\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\samd\\1.8.14/variants/arduino_zero/openocd_scripts/arduino_zero.cfg"
      ]
    }
  ]
}

Where I see some tags I do not understand. Is it possible for me to change the contents? It seems it is not.

Thank you so far.

Have a nice day
@HarrySatt

The problem is here:

Due to the bug in Arduino IDE, this line doesn't have any effect. The result is that the default server path is used instead in `launch.json:

Please try this:

  1. Change line 7 of debug_custom.json from:
    "serverpath": "C:/Program Files/SEGGER/JLink_V794g/JLinkGDBServerCL.exe",
    
    to:
    "serverPath": "C:/Program Files/SEGGER/JLink_V794g/JLinkGDBServerCL.exe",
    
    Note that the "P' in path is uppercase. This is essential.
  2. Select File > Save from the Arduino IDE menus.
  3. Click the "Start Debugging" button on the Arduino IDE toolbar.

Hopefully this time the debugger will start up and work as expected.

That is correct. However, the file is regenerated whenever you click the "Start Debugging" button on the Arduino IDE toolbar, and is also stored in a temporary folder that could be deleted at any time and is no longer associated with the sketch if you save it to another location. So editing launch.json is only really useful for making temporary adjustments during a debugging session. The way to make persistent configuration modifications is through the debug_custom.json file.

1 Like

Hi. Thanks a lot.
Now the JLink debugger is working as expected. Really fine.
It is like always. Only one uppercase letter instead of lower case. :laughing:
have a nice day and lot of fun.
Harald

You are welcome. I'm glad it is working now.

Regards,
Per

Really fine. Minor Problems with uploading an altered sketch. Seems there is no active breakpoint allowed. If there is one upload wait infinite and stops with error.
So I set all breakpoinss inactive and upload is ok
Thanks for your help.
Have a nice day.
Harald

1 Like

Hello, if this is a new defect and you can open a GH issue, I will find time to fix it. Thanks


update:

OK. I found the problem. It's here: vscode-arduino-tools/src/debug.ts at 4938c4185bb39cdc0b709402d9bc8555d8274588 ยท arduino/vscode-arduino-tools ยท GitHub.

@dankeboy36 the issue is here:

and pull request here:

Review would be very much welcome.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.