Configuration File for IDE Debug 2.0 MKR1010

Hello...
I want to debug sketches on my MKR1010 board. For this I need a configuration file. Creating the file yourself is very complex. Is there a simple example that can be added to configure the hardware and software settings?
Regards Jurgen

Hi @riejue1. Your Arduino MKR WiFi 1010 board can be used with the Arduino IDE 2.x debugger without the need for any configuration file. The configuration file is only needed if you are using a non-standard debug probe that requires a special configuration.

You will need a CMSIS-DAP compliant debug probe. This is a separate piece of hardware that you must connect to the SWD header footprint on the bottom of the MKR WiFi 1010 board:
MKR SWD
(picture is of MKR Zero, but the pinout is the same on the MKR WiFi 1010)

The tutorial is here:

This tutorial mentions the "Atmel-ICE" debugger, but it can be followed with any CMSIS-DAP compliant debug probe. There are several options available. This is the one I use:

Hi in0,
Thank you very much for your reply.
Your hint gave me the idea to use my Segger J-LINK. There is also a tutorial on how to do this.

regards Jurgen

Hi in0,
thank you very much for yor Reply.
I have a Segger-Llink Debugger and I have this configuriert for my MKR1010 Wifi. A GDB server is required for this,

You will also need to download the J-Link GDB Server software, here. The J-Link GDB Server is a remote server for the GNU Debugger (GDB) which allows to use a J-Link probe with GDB or any toolchain which uses GDB as debugging interface, like the Arduino IDE 2.0.

This software is only available for UNIX. But I need it for Windows 10. Can I have the GDB for Windows 10?
If I start the Arduino IDE 2.0 for debugging an error appears:ArduinoIDE-2-0-Fehler
SeggerJlink
Regards Jurgen

I'm sure that's not true. I don't recommend it because it is not such a "plug and play" experience as with the CMSIS-DAP compliant debuggers, but I have used this proprietary segger software with the Arduino IDE 2.x debugger on Windows, using the same approach as described in the tutorial you linked. Everything you need is installed with the the “J-Link Software and Documentation Pack“:
https://www.segger.com/downloads/jlink/#J-LinkSoftwareAndDocumentationPack

It looks like it has detected the jlink just fine, but then not connected to the MKR WiFi 1010. Carefully check your connections between the jlink and the MKR WiFi 1010. I have the feeling that the technique shown in the tutorial that uses a proto shield to press a header on the SWD header footprint will not always provide a good electrical connection, so if you are doing that, try wiggling everything around a bit.

Make sure the MKR WiFi 1010 is powered.

Hi in0,
many thanks for your response.
I have tested the connection to the solder PADs at MKR1010 Board. The connection is OK.
Can I test the Firmware at the MKR1010 Board?. Perhaps it is communication Error between MKR Board and JLINK.

furthermore:
I found a bug, I have to choose Target Interface SWD, not JTAG.

JLINK_Fenster

I have to run JLinkGDBServer.exe manually. Why is it not called via "launch.json" script?
{
"servertype": "jlink",
"device": "ATSAMD21G18",
"interface": "SWD",
"svd_path": "ATSAMD21G18A.svd",
"serverpath": "C: \ Program Files (x86) \ SEGGER \ JLink"
}
The file is not executed. I can't understand way this.

Do I have to connect the MKR1010 via USB in addition to the debugger connection?


Further Errors issues:

If I start a Debug-session at IDE, always appears : "Error: unable to find CMSIS-DAP device" and issue the Message :

ArduinoIDE-2-0-Fehler

What does this error message mean?

SVD_Error
Regards Jurgen

Hello ...,
I am using a MKR1010 WIFI board. I have connected this to a Segger JLINK EDU debugger and try to debug using the IDE 2.0 under Windows 10.
I used the blink sketch to try it out. To activate the debug mode, I generated a .JSON file:
{
"servertype": "jlink",
"device": "ATSAMD2G18",
"interface": "SWD",
"serverpath": "C: / Program Files (x86) /SEGGER/JLink/JLinkGDBServerCL.exe"
}
When I start the debug mode,

StartDebugModeSept

the following messages appear.

FehlermeldungSept

When I call the command "JLinkGDBServerCL.exe" under Windows 10 "cmd" the following messages appear:

What I do not understand is that a DGB server has to be started under Windows, but where ?
Both the Segger Debuger and the MKR board have to listen on the same port, not in different.

IDE 2.0
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Segger Debugger
Listening on TCP/IP port 2331

I have already described my problem under Configuration File for IDE Debug 2.0 MKR1010. Unfortunately I didn't get an answer to my last post and I made some changes .

Regards Jurgen

Cross-posts merged. Please only create one forum topic per subject matter @riejue1

Because you didn't follow the tutorial correctly:

{
      "servertype": "jlink",     
      "device": "ATSAMD21G18",
      "interface": "SWD",
      "serverpath": "C:/Program Files (x86)/SEGGER/JLink/JLinkGDBServer"
}

The tutorial is maybe a little confusing because it doesn't add the optional .exe file extension, which might make you think the JLinkGDBServer part of the path is a folder, but this is the executable name.


Now I see you added an executable to the path, so you're on track.

You have inserted spaces into the path. You have to get the path exactly right or it won't work.

I also recommend you to use JLinkGDBServer.exe instead of JLinkGDBServerCL.exe. I don't know what the difference is, but the tutorial says to use JLinkGDBServer, so I would use JLinkGDBServer.

FYI, I just tried Arduino IDE 2.0.0-beta.11 with J-Link, following the instructions in the tutorial, and it's working fine for me.

Just follow the tutorial carefully and everything will work fine. There are no additional steps required. It will start the GDB server for you.

Hello in0,
thank you very much for your reply.
I have another Post sended:
https://forum.arduino.cc/t/debuggen-with-mkr1010-wifi-per-ide2-0/901494/2

In this post I have some changes. Despite these changes, my debugger still doesn't work. I do not know why.

In an Usermanual from Segger JLINK I have found this:

4.2.2 Setting up GDB Server CL version
The command line version of GDB Server is part of the J-Link Software Package for all supported platforms. On Windows its name is JLinkGDBServerCL.exe, on Linux and Mac it is JLinkGDBServer.

Starting GDB Server on Windows
To start GDB Server CL on Windows, open the ’Run’ prompt (Windows-R) or a command
terminal (cmd) and enter
\JLinkGDBServerCL.exe .

In many attempts I have transferred the original instructions from

to my TestSketch and have not come to any success.
The last build you can see at the above Link.
Regards Jurgen

I saw it. That one was merged into this one:

Please post your current configuration file.

Please also tell me what is the filename of that configuration file and where it is located.

Hi in0,
thank you for your reply.
My configuration file current:

Path from my sketch and the configuration File:

Regards Jurgen

OK, great. I think I spotted the problem. Unfortunately the tutorial doesn't make any mention of it, but the original description of the system from one of the people involved in the debugger development provides more details:
https://github.com/arduino/arduino-ide/issues/87#issuecomment-774362701

In order to use it you'll need to create a local debug_custom.json file and override the properties you want to replace.
In this example I override interface, servertype and serverpath to use a J-Link with a Nano 33 IoT.
Mind that you don't need the whole structure of a launch.json file, we only override the configuration generated via CLI on the fly and replace the nodes which are specified in this new JSON

{
  "servertype": "jlink",
  "device": "ATSAMD21G18",
  "interface": "swd",
  "serverpath": "/usr/local/bin/JLinkGDBServer"
}

So it's required that the file be named debug_custom.json, not launch.json.

The reason for this is explained earlier in that thread:

we're creating the configuration on the fly based on the platform, so custom parameters specified in launch.json are not supported.

OK, I tried it with JLinkGDBServerCL.exe and it works fine for me, just the same as with JLinkGDBServer.exe, so I think that's OK.

Hi in0,
thank you for your reply.
Everything I do, I always get the same answer:

Something is different by me as by you.

I'm using Windows 10 Version 20H2 (Build 19042.1165).

My IDE2.0 is version: 2.0.0-beta.11 Dattj2021-08-25T08: 44: 50.693Z (1 week ago) CLI version: 0.18.3 alpha [d710b642]

My J-Link adapter is:

What can it be that it doesn't work as by you?

regards Jurgen

I just spotted another error. You have the device set to "ATSAM21G18". That is wrong. It must be exactly "ATSAMD21G18".


Please follow these instructions exactly and very carefully:

  1. Select File > New from the Arduino IDE's menus.
  2. Click the downward pointing triangle button at the right side of the IDE's tab bar.
  3. From the dropdown menu, select "New Tab.
  4. In the "Name for new file field, type: debug_custom.json
  5. Click the OK button.
  6. Paste the following text into the "debug_custom.json" tab:
    {
      "servertype": "jlink",
      "device": "ATSAMD21G18",
      "interface": "SWD",
      "serverpath": "C:/Program Files (x86)/SEGGER/JLink/JLinkGDBServerCL.exe"
    }
    
  7. Select File > Save from the Arduino IDE's menus.
  8. Connect your MKR WiFi 1010 board to your computer.
  9. Select your MKR WiFi 1010 board from the board menu.
  10. Check Sketch > Optimize for debugging in the Arduino IDE menu.
  11. Select Sketch > Upload from the Arduino IDE's menus.
  12. Wait for the upload to finish.
  13. Connect the J-Link to your MKR WiFi 1010 board.
  14. Connect the J-Link to your computer.
  15. From the button bar along the top side of the Arduino IDE window, click the "Start Debugging" button.

The following should now happen:

  • Debug sidebar opens in the Arduino IDE
  • SEGGER J-Link GDB Server window opens

You can now start debugging. The above steps are everything you need to do to start the debugging process. Please don't add any extra steps.

It works. :grinning:

You have helped me a lot.
I thank you for serving tireless efforts.
But I still have a little question, how can I debug a sketch (blink)?

Regards Jurgen

Yay! I'm very glad to hear it. As I mentioned, the process using the CMSIS-DAP compliant programmer is much more simple. It's especially easy if you use the Zero, since it has a built-in debugger. Hopefully the system for using other types of debuggers will be made more friendly over time.

You can click on the left margin of the sketch editor pane to set breakpoints. The program execution will halt once it reaches a breakpoint.

You can use the "Step Into" button to step into the implementation of a function call to see its source code. You can use the "Step Out" button to move a level back up the call stack. You can see the entire call stack in the "CALL STACK" section of the debugger side bar.

You can use the "Step Over" button to step through the execution of the code line by line.

You can add expressions to the "WATCH" section of the debugger sidebar by clicking the + button and its value will be shown and updated as the program runs.

You can click the "Stop" button once you are finished with your debugging session.

There are a few other more advanced features of the debugger, but those are probably the most useful things.

1 Like

Thank you again for your tireless efforts.
I've now figured out how to load and debug some sketch. In fact, it is not easy. Still a viable solution.

You're welcome. I'm glad if I was able to be of assistance.