MicroPython v1.18 on Pico
Code: Select all
from time import sleep, ticks_ms, ticks_diff
import micropython
import machine
def main():
led0 = machine.Pin(25, machine.Pin.OUT)
last_update = ticks_ms()
while True:
led0.toggle()
if ticks_diff(ticks_ms(), last_update) > 1000:
last_update = ticks_ms()
print(".", end="")
main()
The LED should light up (it's actually blinking very fast).
Use PuTTY to connect. You'll see a period printed once per second. All is well.
Disconnect and fire-up Thonny to edit the file. Add a single line just above main():
Code: Select all
from time import sleep, ticks_ms, ticks_diff
import micropython
import machine
@micropython.native
def main():
led0 = machine.Pin(25, machine.Pin.OUT)
last_update = ticks_ms()
while True:
led0.toggle()
if ticks_diff(ticks_ms(), last_update) > 1000:
last_update = ticks_ms()
print(".", end="")
main()
On Windows you get an error message from PuTTY saying it cannot connect. On Linux (using minicom or something else) it just doesn't connect.
Launch Thonny again. Can't connect.
You can reset the board all you want, you will not be able to connect to it in any way, Windows or Linux. It is, for all intents and purposes no different from bricked.
The only way to get it back is to use the flash_nuke.uf2 utility to clear out flash (thanks jimmo for the link):
https://learn.adafruit.com/intro-to-rp2 ... f2-3083182
One way to partially fix it is to add a delay. I used sleep(15) before main runs. With this you can connect to the USB serial port during that period and all is well. If you wait until the loop starts running you will not be able to connect. Remove @micropython.native and everything works as expected.
BTW, I ran the same tests under v1.19.1. Same problem.
My hypothesis is that 'native is causing some of the interrupts to not configure correctly. On my application the UARTs don't seem to be working reliably as well. Again, adding a delay allows for connection during that delay and everything works, not after.
I'd like some feedback on this before raising the issue. One question being: Does it happen on boards other than Pico? I don't have any, so I can't test.
Thanks.
-Martin