# Arduino UNO R4 WiFi Debugging

**URL:** <https://forum.arduino.cc/t/arduino-uno-r4-wifi-debugging/1252465>\
**Category:** UNO R4 WiFi\
**Created:** [April 26, 2024, 2:14pm UTC](https://forum.arduino.cc/t/arduino-uno-r4-wifi-debugging/1252465 "2024-04-26T14:14:51Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![woolsey](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/woolsey/32/238912_2.png) [@woolsey](https://forum.arduino.cc/u/woolsey)\
**Post date:** [April 26, 2024, 2:14pm UTC](https://forum.arduino.cc/t/arduino-uno-r4-wifi-debugging/1252465/1 "2024-04-26T14:14:51Z")

</div>

It appears that debugging support was recently added to the Arduino IDE 2 and the Arduino R4 Boards package for the UNO R4 WiFi board, however, I get the following error when trying to enable debugging within the IDE.

embedded:startup.tcl:26: Error: Can't find interface/{programmer.protocol}.cfg in procedure 'script' at file "embedded:startup.tcl", line 26

Furthermore, I understand that a separate hardware debugger is not required with the UNO R4 WiFi as that capability is provided by the on-board ESP32-S3 module.

Am I missing something or is the debugging not yet supported for this board?

---

<div class="post-metadata">

**Author:** ![ptillisch](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@ptillisch](https://forum.arduino.cc/u/ptillisch)\
**Post date:** [April 26, 2024, 2:49pm UTC](https://forum.arduino.cc/t/arduino-uno-r4-wifi-debugging/1252465/2 "2024-04-26T14:49:13Z")

</div>

Hi @woolsey.

> [@woolsey](#):
>
> I get the following error when trying to enable debugging within the IDE.
> 
> embedded:startup.tcl:26: Error: Can't find interface/{programmer.protocol}.cfg in procedure 'script' at file "embedded:startup.tcl", line 26

Select **Tools \> Programmer \> ARM CMSIS-DAP compatible** from the Arduino IDE menus and then try again. This time the debugger should start up and work as expected.

The cause for the error was that you didn't have anything selected from this **Tools \> Programmer** menu. The menu was traditionally used to configure the IDE for use with an ISP programmer. Prior to Arduino IDE 2.3.0, by default a board was configured for a specific debug probe and [the procedure required to configure it for any other debug probe](https://docs.arduino.cc/tutorials/mkr-wifi-1010/mkr-jlink-setup/#debugging-in-arduino-ide-2:~:text=Add%20a,as%20your%20sketch) was quite complex. It is now possible for boards platform authors to offer configurations for a variety of different debug probes, which the user can pick from by selecting the probe they have from the **Tools \> Programmer** menu.

> [@woolsey](#):
>
> I understand that a separate hardware debugger is not required with the UNO R4 WiFi as that capability is provided by the on-board ESP32-S3 module.

That is correct!

> [@woolsey](#):
>
> is the debugging not yet supported for this board?

It is supported.

---

<div class="post-metadata">

**Author:** ![woolsey](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/woolsey/32/238912_2.png) [@woolsey](https://forum.arduino.cc/u/woolsey)\
**Post date:** [April 26, 2024, 4:43pm UTC](https://forum.arduino.cc/t/arduino-uno-r4-wifi-debugging/1252465/3 "2024-04-26T16:43:27Z")

</div>

Thank you for the prompt reply.

I set the programmer and I seem to be getting a little further along now, but am still getting some errors and a lot of strange behavior.

"OpenOCD: GDB Server Quit Unexpectedly. See gdb-server output for more details." where the gdb-server output shows the original error I posted.

"Unable to parse SVD file /Users/woolsey/Library/Arduino15/packages/arduino/hardware/renesas\_uno/1.1.0/svd/R7FA4M1AB.svd: Error: SVD error: Invalid 'derivedFrom' "P100PFS" for register "P30%sPFS""

Sometimes the debug session seems to run and I land at a breakpoint and sometimes it seems nothing happens. Sometimes the code stops at a breakpoint sometimes it stops on the line after the breakpoint. If the session does seem to work, sometimes stepping through the code works sometimes it doesn't. The Continue, Step Over, Step Into, Step Out operations don't seem to function as expected. For example, trying to step over a `digitalWrite()` call will drop me into a _tusb\_fifo.c_ file.

I am getting a lot of strange results and nothing seems to be reproducible.

---

<div class="post-metadata">

**Author:** ![ptillisch](https://avatars.discourse-cdn.com/v4/letter/p/ad7895/32.png) [@ptillisch](https://forum.arduino.cc/u/ptillisch)\
**Post date:** [April 26, 2024, 5:01pm UTC](https://forum.arduino.cc/t/arduino-uno-r4-wifi-debugging/1252465/4 "2024-04-26T17:01:41Z")

</div>

> [@woolsey](#):
>
> "Unable to parse SVD file /Users/woolsey/Library/Arduino15/packages/arduino/hardware/renesas\_uno/1.1.0/svd/R7FA4M1AB.svd: Error: SVD error: Invalid 'derivedFrom' "P100PFS" for register "P30%sPFS""

This bug is being tracked by the Arduino IDE developers here:

> <https://github.com/arduino/ArduinoCore-renesas/issues/276>
>
> \### Describe the problem
> 
> An alarming looking error notification appears when …the \[Arduino IDE 2.x integrated sketch debugger\](https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-debugger) is started with an \*\*UNO R4 Minima\*\* / \*\*WiFi\*\* target:
> 
> !\[image\](https://github.com/arduino/ArduinoCore-renesas/assets/8572152/e3345c4e-37d5-4900-b519-06a961f55ff6)
> 
> 🐛 The notification might lead the user to believe the debugger is in a non-functional state, even though it is functional.
> 
> 🐛 The notification might serve as a "red herring", derailing the user's troubleshooting efforts when the debugger is in a non-functional state for a completely unrelated reason.
> 
> \### To reproduce
> 
> 1. Connect the board to your computer as appropriate (directly via USB cable if using \*\*UNO R4 WiFi\*\*, via external debug probe if using \*\*UNO R4 Minima\*\*).
> 1. Select the board from the Arduino IDE menus.
> 1. Select \*\*Tools \> Programmer \> ARM CMSIS-DAP compatible\*\* from the Arduino IDE menus.
> 1. Select \*\*Sketch \> Verify/Compile\*\* from the Arduino IDE menus.
> 1. Wait for the compilation to finish successfully.
> 1. Click the "Start Debugging" button on the Arduino IDE toolbar.
> 
> 🐛 An error notification appears:
> 
> \`\`\`text
> Unable to parse SVD file C:\\Users\\per\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\renesas\_uno\\1.1.0/svd/R7FA4M1AB.svd: Error: SVD error: Invalid 'derivedFrom' "P100PFS" for register "P30%sPFS"
> \`\`\`
> 
> \### Expected behavior
> 
> Debugger starts without any errors.
> 
> \### "Arduino UNO R4 Boards" version
> 
> 1.1.0
> 
> \### Operating system
> 
> \- Windows
> \- Linux
> 
> \### Operating system version
> 
> \- Windows 11
> \- Ubuntu 22.04
> 
> \### Additional context
> 
> I am using Arduino IDE 2.3.2
> 
> \---
> 
> I did not check whether it also occurs for Portenta C33 because I don't own that board.
> 
> \<a name="workaround"\>\</a\>
> 
> \#### Workaround
> 
> Simply close the error notification and carry on using the debugger as usual.

A fix is already in progress:

> <https://github.com/arduino/ArduinoCore-renesas/pull/293>
>
> Fixes https://github.com/arduino/ArduinoCore-renesas/issues/276
> 
> The updated f…ile has been taken from \[here\](https://github.com/arduino/ArduinoCore-renesas/issues/276#issuecomment-2063771483). Thanks @embedded-kiddie

From my simple experiments using the debugger with my **UNO R4 WiFi** board, the bug doesn't appear to have any effect on the basic functionality of the debugger so my advice is to simply close the notification when it appears and carry on.

> [@woolsey](#):
>
> Sometimes the debug session seems to run and I land at a breakpoint and sometimes it seems nothing happens. Sometimes the code stops at a breakpoint sometimes it stops on the line after the breakpoint.

Did you select **Sketch \> Optimize for Debugging** from the Arduino IDE menus before you uploaded your sketch to the board? Normally we configure the compiler to aggressively optimize the program in order to make it run on the board more efficiently (in terms of clock cycles and/or memory usage). But that aggressive optimization can cause the generated binary program to differ so significantly from the source code that the debugger is not able to produce usable results. So when debugging we dial down the optimization level. This is the function of the **Sketch \> Optimize for Debugging** menu item in Arduino IDE.

---

<div class="post-metadata">

**Author:** ![woolsey](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/woolsey/32/238912_2.png) [@woolsey](https://forum.arduino.cc/u/woolsey)\
**Post date:** [April 26, 2024, 5:23pm UTC](https://forum.arduino.cc/t/arduino-uno-r4-wifi-debugging/1252465/5 "2024-04-26T17:23:05Z")

</div>

I did try the _Optimize for Debugging_ option, but it did not seem to make much of a difference. It does seem to stop at the actual breakpoints now when using the **Continue** button, but it does not appear to step through the code properly when using the stepping buttons.

I really appreciate your assistance, but perhaps I should just wait until a the issues you mentioned are fixed and try again at a later time.

---

<div class="post-metadata">

**Author:** ![tails4e](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tails4e/32/973857_2.png) [@tails4e](https://forum.arduino.cc/u/tails4e)\
**Post date:** [August 3, 2024, 9:30am UTC](https://forum.arduino.cc/t/arduino-uno-r4-wifi-debugging/1252465/6 "2024-08-03T09:30:48Z")

</div>

It's great to see there is now debugging support for the Uno R4 WIFI. Does anyone know if this is supported in VS Code? I have looked for tutorials in general and all seem to be very out of date, so would appreciate any guidance on how to debug the project I have with it.

---

<div class="post-metadata">

**Author:** ![embeddedkiddie](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/embeddedkiddie/32/1081520_2.png) [@embeddedkiddie](https://forum.arduino.cc/u/embeddedkiddie)\
**Post date:** [August 3, 2024, 12:39pm UTC](https://forum.arduino.cc/t/arduino-uno-r4-wifi-debugging/1252465/7 "2024-08-03T12:39:03Z")

</div>

Do you use Arduino by Microsoft or PlatformIO?  
I don't have experience with the Microsoft version, but for PlatformIO you can update [`R7FA4M1AB.svd`](https://github.com/arduino/ArduinoCore-renesas/tree/main/svd "ArduinoCore-renesas/svd at main · arduino/ArduinoCore-renesas") located somewhere in your PlatformIO install directory. (Sorry, I forgot the exact location.)

---

<div class="post-metadata">

**Author:** ![tails4e](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tails4e/32/973857_2.png) [@tails4e](https://forum.arduino.cc/u/tails4e)\
**Post date:** [August 3, 2024, 12:56pm UTC](https://forum.arduino.cc/t/arduino-uno-r4-wifi-debugging/1252465/8 "2024-08-03T12:56:59Z")

</div>

I'm using the Microsoft extension. Is there much advantage to the platformIO extension in general? I assume you can have either one or the other active, but not both, is that the case?

---

<div class="post-metadata">

**Author:** ![embeddedkiddie](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/embeddedkiddie/32/1081520_2.png) [@embeddedkiddie](https://forum.arduino.cc/u/embeddedkiddie)\
**Post date:** [August 3, 2024, 1:13pm UTC](https://forum.arduino.cc/t/arduino-uno-r4-wifi-debugging/1252465/9 "2024-08-03T13:13:24Z")

</div>

I'm sorry but I only tried PlatformIO a little when the original Arduino IDE editor was poor, but now I'm a user of the genuine Arduino IDE, so I can't say for sure which is better, Microsoft or PlatformIO.

Is there anyone who knows more about this?

---

<div class="post-metadata">

**Author:** ![tails4e](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/tails4e/32/973857_2.png) [@tails4e](https://forum.arduino.cc/u/tails4e)\
**Post date:** [August 4, 2024, 3:47pm UTC](https://forum.arduino.cc/t/arduino-uno-r4-wifi-debugging/1252465/10 "2024-08-04T15:47:33Z")

</div>

I could switch to the v2 Arduino IDE. Do you know if when debugging can you attach to the board when it's running and switch to single step to see where the program counter is? My use case is i have an application that has wifi, mqtt, SPI and a bunch of other stuff, and after a few days it hangs. So I want to attach to the board when it has hung and find where in the code and call stack it's happening... So I don't mind which IDE I use as long as I can do something like that...

---

<div class="post-metadata">

**Author:** ![embeddedkiddie](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/embeddedkiddie/32/1081520_2.png) [@embeddedkiddie](https://forum.arduino.cc/u/embeddedkiddie)\
**Post date:** [August 4, 2024, 9:44pm UTC](https://forum.arduino.cc/t/arduino-uno-r4-wifi-debugging/1252465/11 "2024-08-04T21:44:17Z")

</div>

Your question is getting a bit off-topic from the original questioner, so I would recommend starting a new thread, where you'll likely get a better answer.

---

<div class="post-metadata">

**Author:** ![ziriax](https://avatars.discourse-cdn.com/v4/letter/z/e0b2c6/32.png) [@ziriax](https://forum.arduino.cc/u/ziriax)\
**Post date:** [September 26, 2024, 9:35pm UTC](https://forum.arduino.cc/t/arduino-uno-r4-wifi-debugging/1252465/12 "2024-09-26T21:35:57Z")

</div>

What are the steps to get debugging working on the UNO R4 WiFi?

I selected the ARM CMSS-DAP compatible in the Programmers menu, but when clicking the debug button, I get the error

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

However, the gdb-server output doesn't show any error:

```arduino
[2024-09-26T21:33:37.580Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session connected. You can switch to "DEBUG CONSOLE" to see GDB interactions.
"C:\\Users\\Peter\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\openocd\\0.11.0-arduino2/bin/openocd" -c "gdb_port 50000" -c "tcl_port 50001" -c "telnet_port 50002" -s "s:\\Arduino\\tacho1" -f "C:/Users/Peter/AppData/Local/Programs/arduino-ide/resources/app/plugins/cortex-debug/extension/support/openocd-helpers.tcl" -f interface/cmsis-dap.cfg -f "C:\\Users\\Peter\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\renesas_uno\\1.2.1/debugger/select_swd.cfg" -f "C:\\Users\\Peter\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\renesas_uno\\1.2.1/debugger/R7FA4M1AB.cfg"
Open On-Chip Debugger 0.11.0+dev-gab95bac57-dirty (2021-05-11-10:45)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
CDRTOSConfigure
swd
adapter speed: 1000 kHz

Info : Listening on port 50001 for tcl connections
Info : Listening on port 50002 for telnet connections
[2024-09-26T21:33:37.658Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session closed
GDB server session ended. This terminal will be reused, waiting for next session to start...

```

version info (very latest)

```arduino
Version: 2.3.3
Date: 2024-09-25T09:41:18.242Z
CLI Version: 1.0.4

Copyright © 2024 Arduino SA

```

---

<div class="post-metadata">

**Author:** ![embeddedkiddie](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/embeddedkiddie/32/1081520_2.png) [@embeddedkiddie](https://forum.arduino.cc/u/embeddedkiddie)\
**Post date:** [September 28, 2024, 2:37am UTC](https://forum.arduino.cc/t/arduino-uno-r4-wifi-debugging/1252465/13 "2024-09-28T02:37:11Z")

</div>

Try the followings:

1. Activate **Optimize for Debugging** in **Sketch** on IDE menu.
2. Re-compile and upload.
3. Close all the **gdb-server** console if you have opened. If you already start **gdb-server** , push **Stop** button on **Debug** window (top left in IDE).
4. Try **Start Debugging**.

Then I get:

```arduino
Open On-Chip Debugger 0.11.0+dev-gab95bac57-dirty (2021-05-11-10:57)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
CDRTOSConfigure
swd
adapter speed: 1000 kHz

Info : Listening on port 50001 for tcl connections
Info : Listening on port 50002 for telnet connections
Info : CMSIS-DAP: SWD Supported
Info : CMSIS-DAP: FW Version = 2.0.0
Info : CMSIS-DAP: Serial# = 123456789101112
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 0 SWDIO/TMS = 0 TDI = 0 TDO = 0 nTRST = 0 nRESET = 0
Info : CMSIS-DAP: Interface ready
Info : clock speed 1000 kHz
Info : SWD DPIDR 0x5ba02477
Info : ra4m1.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : starting gdb server for ra4m1.cpu on 50000
Info : Listening on port 50000 for gdb connections
Info : accepting 'gdb' connection on tcp/50000
target halted due to debug-request, current mode: Thread 
xPSR: 0x81000000 pc: 0x00004278 msp: 0x20007ec8
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00001f34 msp: 0x20003990
force hard breakpoints

```

> [@ziriax](#):
>
> version info (very latest)
> 
> ```arduino
> Version: 2.3.3
> Date: 2024-09-25T09:41:18.242Z
> CLI Version: 1.0.4
> 
> Copyright © 2024 Arduino SA
> 
> ```

Mine is same as yours.

---

<div class="post-metadata">

**Author:** ![ziriax](https://avatars.discourse-cdn.com/v4/letter/z/e0b2c6/32.png) [@ziriax](https://forum.arduino.cc/u/ziriax)\
**Post date:** [September 28, 2024, 12:43pm UTC](https://forum.arduino.cc/t/arduino-uno-r4-wifi-debugging/1252465/14 "2024-09-28T12:43:15Z")

</div>

Thanks for the info!

Unfortunately, nothing seems to work. I updated the firmware, rebooted, ...

I decided to run the openocd command using Visual Studio, and it crashes with

```arduino
Exception thrown at 0x00657CFF in openocd.exe: 0xC0000005: Access violation reading location 0x4F34702A.

```

Running with the `-d` flag on the command line, the last thing that is printed is

```arduino
Debug: 221 596 command.c:311 register_command(): registering 'test_mem_access'...

```

So it seems something in on my Windows 11 PC is incompatible with openocd.exe

I will see if I can make a debug build to report a bug.

---

<div class="post-metadata">

**Author:** ![ziriax](https://avatars.discourse-cdn.com/v4/letter/z/e0b2c6/32.png) [@ziriax](https://forum.arduino.cc/u/ziriax)\
**Post date:** [September 28, 2024, 12:53pm UTC](https://forum.arduino.cc/t/arduino-uno-r4-wifi-debugging/1252465/15 "2024-09-28T12:53:17Z")

</div>

It seems that using the latest version of openocd.exe fixed the problem.

```arduino
https://github.com/xpack-dev-tools/openocd-xpack/releases

```

I was able to set breakpoints and debug.
