Notifications
Clear all

Pico & Thonny - Debug

7 Posts
3 Users
0 Likes
6,658 Views
(@goodolebob)
Member
Joined: 4 years ago
Posts: 7
Topic starter  

Using Thonny for MicroPython IDE with RP Pico. It works as expected except it will not allow a debug while configured for "MicroPython (Raspberry Pi Pico).

However, it will allow debug operations in the Run menu ONLY IF configured as "The same interpreter which runs Thonny (default)"; but with that configuration it will not save a file to the Pico.

Any ideas much appreciated. : )


   
Quote
Topic Tags
(@jfabernathy)
Member
Joined: 3 years ago
Posts: 141
 

The only way I know to really debug the Pico with setting breakpoints, and/or conditional breakpoints, watch variables, and single step is to use the C/C++ SDK with VSCode and wire up the 3 SWD pins to a Raspberry Pi 4 controlling the debug. That works great, but then you are at the same level of coding as with Arduino. Most of the interpreters don't have that capability.

I do know that with CircuitPython it can be built with Debug turned on so you can use the debug capabilities of underlying IDE to debug with breakpoints, etc. I have not had to do that with Pico yet, though and hope I don't. That was a real pain for the ESP32-S2.

If your code won't compile, have another glass of bourbon. Eventual the problem will be solved.


   
ReplyQuote
(@goodolebob)
Member
Joined: 4 years ago
Posts: 7
Topic starter  

@jfabernathy

There is a video on YouTube demonstrating how to debug in Thonny by selecting options from the "Run" menu pulldown, BUT those selections are dimmed-out in the menu when Thonny's interpreter  is configured for the Pico and all other named devices except "The same interpreter which runs Thonny (default)".

image

 I do appreciate the alternatives suggested, but each would seem unnecessary if the config in Thonny worked.

The script area and the shell area ARE communicating normally with the Pico when configured.

.                    Many thanks      : )


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1122
 

@goodolebob

I think the Thonny debug only works when using the same interpreter as the Thonny (the default) by design and it will not work with the other alternative interpreters.   This is from memory when I decided to use Thonny (on my mac) for my MicroPython programming a year back.


   
ReplyQuote
(@goodolebob)
Member
Joined: 4 years ago
Posts: 7
Topic starter  

@byron

Some fog lifts ... some remains.  I changed from the Pico interpreter config to the Default where the debug icon are highlighted with the following result.

* It will debug using the default interpreter.

* It will only allow me to save the file to the local C: drive ... not to the Pico.

* It will only load from the C: drive ... not the Pico.

Appearances to me are:

* Operation with the Pico config is fine ... unless debug is desired.

* If debug is desired, then reconfig the interpreter to Default and use the C: drive.

* Re-config to Pico config to save "fixed" file on Pico and access Pico files.

 

It appears that when configuring for a Pico, that Thonny ONLY debugs with its Default configuration ... not the Pico one.  That restricts interaction with the Pico.  This tidbit is noted nowhere that I can find in documentation or video.

Many thanks to all for help on the Forum.     : )


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1122
 

@goodolebob

One other thing I will mention that when coding in Python I have never used a debugger.   I've made plenty of errors but debugging is readily accomplished using a bunch of print statements.  

For some longer code scripts I sometimes put in a global variable of Debug = True and then use if statements to check if Debug is true to see if I want a bunch of print statements to activate.  These can all be deleted in the final 'production' code.

The other thing, which one should do anyway, is to make good use of the try / except error checking and to print out as appropriate when an error exception is caught.

And then theres the pdb - the python debugger library, though not for MicroPython.  But for MicroPython this article maybe of interest.

https://core-electronics.com.au/tutorials/connect-to-MicroPython-in-windows.html

 

This post was modified 3 years ago by byron

   
ReplyQuote
(@goodolebob)
Member
Joined: 4 years ago
Posts: 7
Topic starter  

@byron

You nailed it, Byron.  : )

I'm not yet deep enough into MicroPython yet to really need a debug, but wanted to know if my install of Thonny was broken in not being able to debug code. 

Many thanks for the info on the subject which has allowed me to devise a work-around for that when using the Pico and Thonny IDE.


   
ReplyQuote