Code running from flash that I can't stop #13001
-
When I started with upython 5 years ago on pycom devices I could always kill a program with ctrlC in the repl and this worked if the program was running from flash or ram. With rpi 2040s and the current crop of esp32s I'm finding it impossible to terminate code running from flash, which means having to reflash the chip with upython each time I want to upgrade a main.py in flash since previous posts on this problem don't offer much in the way of solutions other than a hardware fix (like adding a press button that the code checks to see if you want to terminate it). Just wondering if anyone is familiar enough with the old pycom flavour of upython to explain why flash based code apparently listened on the USB & why this doesn't happen now days? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Odd. I use both RP2040 and a variety of Esp32 chips both S3 and C3 with the latest builds and have no problem breaking into REPL with ctrlC. I'm using mpremote to communicate with the boards. My main.py is normally a simple import of the actual program. If all else fails you can try using mpremote to overwrite the existing main.py even with the program running - works for me. Alternatively simply put a short delay at the top of main.py to give you time to break in. |
Beta Was this translation helpful? Give feedback.
-
Normal Python code can be interrupted with import time
while True:
print("Hello")
time.sleep(1) If this can't be interrupted your IDE is swallowing the |
Beta Was this translation helpful? Give feedback.
-
You can also make a try on launch your Project with an except KeyboardInterrupt, that work well for me.. |
Beta Was this translation helpful? Give feedback.
Normal Python code can be interrupted with
ctrl-c
. Exceptions are code that issuesmachine.deesleep()
and code that runs loops in C or inline assembler - if these run for too long they can disrupt the USB interface. I'd investigate with a simple Python loop:If this can't be interrupted your IDE is swallowing the
ctrl-c
characters (as suggested above).