How do I debug ESP8266 In Arduino IDE?

I'm using the Arduino IDE 2.0.3 for Ubuntu.

When I select the board NodeMCU or Generic Esp8266 module, it won't allow me to run the code in debug mode saying : Debugging is not supported by 'nodemcu' or 'esp8266'

So my question is how do I debug an Esp8266 code?

I am afraid that you are stuck with putting Serial.print()s at strategic places in your code and printing the value of relevant variables. You will be able to tell which parts of the code are running and see the values of variables used in while loops for instance

If you have spare pins you can also temporarily attach LEDs and make them come on at various points in the code so that you know what is running

Any debugging code in your sketch can be turned on and off at compile time by using #defined values to control which code is compiled into teh sketch

I just want to do it with breakpoints. Serial.print() takes to much time and it's very limited. I can't believe that there's no way to put a breakpoint in the Arduino IDE

The problem is not so much the IDE but the processors used by many of the boards used with it and the facilities that they support

Is there another IDE that supports breakpoints using the ESP8266 ?

I don't know, maybe vs code can do that. But it's a shame that we can't debug an esp in the arduino IDE

As UKHeliBob indicated, Arduino IDE 2.x does provide the capability to set breakpoints as well as other standard debugging operations:

However, this can only be done under the following conditions:

  • The board you are using is compatible with the free open source "Cortex-Debug" extension that provides the integrated sketch debugger in Arduino IDE 2.x.
  • The platform of the board has been configured for use with the Arduino IDE 2.x integrated sketch debugger.

Let's look at the first condition: as the name of the extension indicates, Cortex-Debug targets microcontrollers with an ARM Cortex-M IP core. ESP8266 uses a Tensilica core instead of Cortex-M, so that is not good news for the prospects of compatibility with the debugger. However, even though the author of the debugger targeted Cortex-M, it is possible other microcontrollers might be compatible as well, as discussed here:

I think it would be worth it for someone to do some experimentation to see whether it is possible. Note that Cortex-Debug is a VS Code extension, so you are welcome to install and use it in VS Code if it is more convenient to do the initial experimentation in that environment.


Now for the second condition: the ESP8266 platform developers have not added the necessary configuration properties to the platform files. The only Arduino boards platform I know of that has been configured for use with the debugger is the official "Arduino SAMD Boards (32-bits ARM Cortex-M0+)" platform, even though many other 3rd party platforms are for Cortex-M based microcontrollers that are definitely compatible with the debugger. At least for that platform, it only took adding a small number of lines to the boards.txt and platform.txt files to add debugger support. So that platform can serve as a model for anyone wanting to configure other platforms.

1 Like

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