Have I lost my code? :-) #10923
-
I have a Pico W and a few months ago wrote some code that reads from a one wire temp sensor, connects to the internet, posts the result to an iotplotter.com feed, sleeps and repeats. It took a few hours to get this working. I put the code in main.py so it would run at startup and I think the last thing I did was add a global exception handler which will do a restart if it gets an exception. It's been running for months, but every few days it stops working and I have to re-power it when it will again work for a few more days. Stupidly (in hindsight) the only copy of the code is on the pico itself. I didn't save a copy to my PC. Today I've tried to make some changes to it. Unfortunately when I now connect the pico to the PC it starts executing my code and I can't get a REPL or Thonny connection. I see my debug print statements being written to the console (COM3) and pressing ctrl-c or ctrl-d I can see my exception handler message and the code restarts. Pressing the stop/restart button in Thonny just restarts my lovely uninterruptable code. Thonny just reports "Device is busy" and offers the ctrl-c or press stop / restart advice. I realise I can probably hold down the bootsel button and reflash the micropython installation with a clean copy and get the device back to normal, but this presumably will lose my code. I've tried using rshell but that just says waiting for REPL and has the same issue as Thonny. Is there anyway I can get my code back? Or will I just have to learn my lesson and re-write it again without the aggressive exception handler this time. :-) Ideally I just want to rename the main.py file to something else before the code is able to start. Any advice is welcome! |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 12 replies
-
Try with mpremote. You should be able to enter REPL with a control C or do |
Beta Was this translation helpful? Give feedback.
-
This thread from the Raspberry Pi Forum might help: Recovering files from a Pico file system - Raspberry Pi Forums. You want to look for the entries that contain a link to 'dumplfs'. |
Beta Was this translation helpful? Give feedback.
-
In the same scenario I made once a firmware which renamed main.py during boot. I can create one for Pico W if you like. |
Beta Was this translation helpful? Give feedback.
-
It's here: https://github.com/robert-hh/Shared-Stuff/blob/master/firmware_rp2_W_main_rename.uf2 |
Beta Was this translation helpful? Give feedback.
-
Bonjour |
Beta Was this translation helpful? Give feedback.
-
A hint for future projects. Have a
The sleep ensures that even if the application completely locks up the machine, you can always reboot and issue |
Beta Was this translation helpful? Give feedback.
This thread from the Raspberry Pi Forum might help: Recovering files from a Pico file system - Raspberry Pi Forums. You want to look for the entries that contain a link to 'dumplfs'.