On Chip Debug For (Some) MicroPython
If you’ve used MicroPython a lot, that debugging often quantities to printing just a few issues out, attempting your code out, after which repeating. But [ghi-electronics] needs you to have full on-chip source-code debugging in Visual Studio. You don’t want something particular to make use of it — only a supported MicroPython host and the identical USB cable you program with now.
The draw back is that you simply both must construct a customized MicroPython picture and flash it or use one which they embrace. They help a number of Raspberry Pi Pico variations and ESP32 chips, as effectively. However, a minimum of one “odd” Pico we had mendacity round wouldn’t take the firmware. A inventory one did, and it labored as you’ll count on. Just a little extra investigation confirmed the odd Pico (an RP2040 GEEK) in all probability did take the firmware; it simply produced an error throughout setup. There is a identified drawback with Linux and the ESP32-S3 having related conduct.
Of course, you may construct your individual picture, however now you might be speaking a bit extra work to get a toolchain and all of the dependencies collectively. For easy packages, you may not want a full-blown debugger. But it’s good to have the ability to peek at variables and see the management movement visually.
There are just a few limitations documented on GitHub. For instance, you may’t catch exceptions that the code already catches, though, presumably, you can set a breakpoint within the exception handler. Breakpoints halt all threads. There are just a few different limits, however nothing we’d think about a showstopper.
Full Python has some debugging assistance constructed into it. MicroPython has among the similar issues, but it surely isn’t trivial to construct a debugger.


