I can download code and execute. How do I do normal debugging?

I can compile and flash the device and my new code comes up running. Have a few debugging questions.

  1. How can I stop execution, resume execution and restart execution?
  2. How can I set a breakpoint and single step from there?

Thanks

@rfsweitzer, since the Particle devices are embedded devices, on-chip debugging is not that easy.

The easy, but limited, form of debugging is to make liberal use of serial.print() statements or use the new logging functionality. Those allow you to follow your code along and see how far your code executes.

To do debugging on-chip as you are requesting is a bit more involved.
First, you will have to install a fully local toolchain so that you can compile locally, instead of using the cloud. (Normally there are 3 or 4 parts of firmware on the device, only one of which is your application firmware).
Second you have to compile a monolithic firmware (combining all the particle and application firmwares into a single firmware) along with a debugging tool.
Search the forums for advice on installing a local toolchain, and for how to do a monolithic build.
Search the forums for OpenOCD for more references to a debugging tool.
Once your debugging firmware is built and flashed to the device, then you need to interact with it through a JTAG tool.
Again, search the forums for JTAG, although there are JTAG tools also used for other purposes.

I have not done this myself, so beyond this, I will have to leave it to others on this forum who have greater expertise.

1 Like

There is a Particle FAQ for doing source-level debugging on the Photon/Electron using Eclipse. Fair warning: it’s a pain to set up and use, so I do use debugging prints most of the time, but once in a while you get a problem where the debugger is really necessary so it’s a nice tool to have for when you need it.

https://docs.particle.io/faq/particle-tools/eclipse-debug/

2 Likes