Debugging nano 33 BLE with IDE 2-b4. Debug configuration?

Very excited to learn that new IDE 2 supports debugging. According to docu here, nano 33 BLE should support debugging, as the text in the link says: As of today, the debugger supports all the Arduino boards based on the SAMD and Mbed platforms (MKR family, Nano 33 IoT, Nano 33 BLE, Portenta, Zero).).

Downloaded and installed IDE 2.0.0-beta4 and got myself Nano 33 BLE Sense board. Installed support for Arduino mbed-enabled Boards. I can compile and upload a sketch, so far so good.

Trying to debug, I am asked for a configuration in form of a launch.json file (screenshot attached). What should I enter here? I see in some websites that the configuration for some includes also "Arduino" - I only have "No Configurations / Add Configuration" ?

Also for my understanding - do I need additional debugger soldered onto the 5 pins on the bottom of the PCB, such as ST/Link or Segger J-Link, for the debugging to work on nano 33 BLE Sense, or does it work via std. USB connection?

Thank you!

xrk:
According to docu here, nano 33 BLE should support debugging, as the text in the link says: As of today, the debugger supports all the Arduino boards based on the SAMD and Mbed platforms (MKR family, Nano 33 IoT, Nano 33 BLE, Portenta, Zero).).

Hi @xrk. Unfortunately this is not really supported right now. The only boards that have true support are the SAMD boards (e.g., Zero, MKR, Nano 33 IoT). It is theoretically possible to use the debugger with the Nano 33 BLE, but there is currently no documentation for how to do this and it is not a point and click operation like it is with the SAMD boards.

If you study the information provided at the links I shared here and do enough experimentation, you will probably be able to achieve it:
https://forum.arduino.cc/index.php?topic=733007.msg4931888#msg4931888

xrk:
Trying to debug, I am asked for a configuration in form of a launch.json file (screenshot attached). What should I enter here? I see in some websites that the configuration for some includes also "Arduino" - I only have "No Configurations / Add Configuration" ?

If the platform was configured for full debugger support, as it is for the SAMD boards, then that would be the case. You could just click the debug button and it would be all configured for use with any CMSIS-DAP compliant debug probe.

In the case of boards platforms that are not configured, or other types of debug probes, it is necessary to do the configuration yourself. There is some information about that off of the link I shared above.

xrk:
Also for my understanding - do I need additional debugger soldered onto the 5 pins on the bottom of the PCB, such as ST/Link or Segger J-Link, for the debugging to work on nano 33 BLE Sense, or does it work via std. USB connection?

You do need a hardware debug probe. I don't know whether you would be able to use the ST-Link with the Nano 33 BLE. I have done some research on that subject and it seemed like it is maybe possible with some custom firmware, but not guaranteed.

The J-Link is definitely usable. In fact, Segger even provides some documentation specifically for the Nano 33 BLE, though not specific to Arduino IDE 2.x:
https://wiki.segger.com/Arduino_Nano_33_BLE

This requirement for a separate debug probe is the case for most of the Arduino boards. The Zero is an exception because it has a built-in CMSIS-DAP compliant debug probe, so that is a very convenient board to use with the Arduino IDE 2.x debugger.

The Arduino Portenta H7 also has the ability for debugging without any extra hardware, but this is done using the Lauterbach TRACE32 debugger application rather than the Arduino IDE 2.x:

Thank you for this excellent answer! This helps me further a lot in understanding how the debug in Arduino works.

I was already wondering what magic there is to make in-circuit-debugging work without additional hardware... As I have a Segger J-Link EDU mini, I will try to set it up on my Nano 33 BLE Sense. I found a neat webpage explaining how to setup this with Arduino IDE v2.

Interesting info also on the Portenta and even more on the Zero!

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

I have also seen that article. There are a couple things I'll add.

I was annoyed by the fact that the article author added a screenshot of their configuration, rather than text. One thing that is very convenient is you can add a "debug_custom.json" file to your sketch with your debugger configuration and the Arduino IDE 2.x will load this configuration. Although I find using my CMSIS-DAP debugger more convenient, I have also used my J-Link successfully with my SAMD boards. This is what my "debug_custom.json" file looks like for that purpose:

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

The "serverpath" is dependent on where you have installed the J-Link support software.

Normally you would type 'r' to run your program, but doing that seems to run the bootloader code. To execute your sketch, type 'start' followed by the ENTER key.

You can do this if you like, but it's not required. The debugger has a GUI, which is on the side bar of the IDE. People who are experienced with GDB may prefer to just use the terminal, but I think the GUI is more "Arduino style".

I need further help. I hooked up my Nano 33 BLE Sense to Segger J-Link EDU Mini via Adafruit SWD breakout:

Using Segger J-Flash software, I can connect to the nRF52840 µC just fine. Also nicely functioning is stepping and debugging with Segger Ozone by loading the Blink.ino.elf there (finding the *.elf file under user profile AppData\Local\Temp\arduino-sketch- is tedious though).

Unfortunately using Arduino IDE v2b4, I am still not progressing. I tried your debug_custom.json tip. I put it with a following content:

{
  "servertype": "jlink",
  "device": "nRF52840_xxAA",
  "interface": "swd",
  "serverpath": "C:/Program Files (x86)/SEGGER/JLink/JLinkGDBServer.exe"
}

into the same directory as my test blink.ino, also tried it in subfolder .theia, but it does not seem to be loaded, as the debug configuration dialog in Arduino IDE 2-b4 remains empty (No Configurations / Add Configuration displayed only) and by hitting the green play/Start Debugging button, empty launch.json opens.

Next I tried to fill launch.json with following:

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  "version": "0.2.0",
  "configurations": [
    {
      "cwd": "${workspaceRoot}",
      "executable": "./bin/executable.elf",
      "name": "Debug Microcontroller",
      "request": "launch",
      "type": "cortex-debug",
      "servertype": "jlink"
    }
  ]
}

But this apparently is not accepted, as I still cannot start debugging. Also, every time I reopen the project, it resets launch.json to an empty file.

Any further tips would be greatly appreciated! Thanks!

I've had exactly the same problem (configuration not saving and debugger not starting). I've posted a bug for this over on GitHub. Debugger configuration will not save and will not be used. · Issue #315 · arduino/arduino-ide · GitHub

1 Like

Thanks for taking the time to submit a bug report @Tjpetz!

@Tjpetz have a look here:
https://forum.arduino.cc/t/information-about-debugging/699788/8
I was able to get debugger running with Nano 33 BLE Sense and IDE 2b4 using the steps written there.

Thanks @xrk i’l give that a try this weekend. I know the debugger can work as I’ve used it in vocode. It will be nice to have it working in the Arduino IDE.

With VSCode + PlatformIO it is also very easy, just add debug_tool = jlink to the ini file.
Nevertheless, I guess, the majority of users will be using Arduino IDE, so it would be nice if the setup gets more streamlined (I assume it will, before the beta tag gets removed).

@xrk Thanks!

I finally got some time to try this out. I've got it working using your platform.txt file. I see that you include the following lines:

tools.gdb.path={runtime.tools.arm-none-eabi-gcc-7-2017q4.path}/bin/
tools.gdb.cmd=arm-none-eabi-gdb
tools.gdb.cmd.windows=arm-none-eabi-gdb.exe
tools.gdb.debug.pattern="{path}/{cmd}" --interpreter=mi2 -ex "set pagination off" --baud 115200 -ex "set target-charset ASCII" -ex "target remote {debug.port}" {build.path}/{build.project_name}.elf

Which seem to be missing from ubidefeo's suggestion. Once I added those lines it stopped trying to create the empty (or nearly empty) launch.json file.

Note, like you, I get the warnings/errors telling me I need to load both mbed based board modules and the one with all the boards is named deprecated. (Not really a major issue just a bit of pain.)

Thanks again for your pointer!

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