Page 1 of 1

Updating Pi Pico with MicroPython kills the flash drive

Posted: Wed Jan 12, 2022 8:21 pm
by GilbertGagne
Here's what I've done:
1. Held reset while powering up Pi Pico
2. File manager shows flash drive Rp1-Rp2 (D:)
3. Copied MicroPython update file: rp2-pico-20210902-v1.17.UF2 to flash Rp1-Rp2 (D:)
4. Flash drive Rp1-Rp2 (D:) disappears from file manager
5. Openned CoolTerm and hit "connect" ;it shows Com3 /9600 8 N-1, and REPL prompt
6. typed the following script after REPL prompt:

>>> from machine import Pin
>>> from time import sleep
>>> led = Pin(25, Pin.OUT)
>>> while True:
... led.toggle()
... sleep(0.1)
...
And the LED on Pi Pico is now blinking at 10Hz rate. This shows that Pi Pico is working properly.
However, file manager does not show any flash drive.

7. Openned Thonny v3.3.13 and started typing the same script as above:

Python 3.7.9 (bundled)
>>> from machine import Pin
Traceback (most recent call last):
File "<pyshell>", line 1, in <module>
ModuleNotFoundError: No module named 'machine'
>>>

I decided to update the Pi Pico with CIRCUITPYTHON

1. Held reset while powering up Pi Pico
2. File manager shows flash drive: CIRCUITPY (D:)
3. Copied file: adafruit-circuitpython-raspberry_pi_pico-en_US-7.2.0-alpha.1.UF2 to flash drive CIRCUITPY (D:)
4. Copied a script file named main.py and containing the 10 Hz blinking program to the flash drive
5. Openned Thonny with file main.py selected from the Pi Pico flash drive
6. Hit "run current script" and this shows in shell:

Python 3.7.9 (bundled)
>>> %cd 'D:\'
>>> %Run main.py
Traceback (most recent call last):
File "D:\main.py", line 1, in <module>
from machine import Pin
ModuleNotFoundError: No module named 'machine'

It seems circuitpython doesn't know about Raspberry Pi Pico.

My main problem is still -How to make Pi Pico execute a script on powering up.
Can anyone help with this problem?

Re: Updating Pi Pico with MicroPython kills the flash drive

Posted: Wed Jan 12, 2022 8:48 pm
by scruss
GilbertGagne wrote:
Wed Jan 12, 2022 8:21 pm
...
And the LED on Pi Pico is now blinking at 10Hz rate. This shows that Pi Pico is working properly.
However, file manager does not show any flash drive.
Yes, this is the expected behaviour with MicroPython. The flash drive is an very unreliable form of storage.
I decided to update the Pi Pico with CIRCUITPYTHON
...
It seems circuitpython doesn't know about Raspberry Pi Pico.
It does, it's effectively now a separate language. It doesn't have machine, it has different module names.
My main problem is still -How to make Pi Pico execute a script on powering up.
In MicroPython - save a script called main.py into the flash of your Pico using Thonny.

Re: Updating Pi Pico with MicroPython kills the flash drive

Posted: Wed Jan 12, 2022 9:23 pm
by fdufnews

Code: Select all

 Openned Thonny v3.3.13 and started typing the same script as above:

Python 3.7.9 (bundled)
>>> from machine import Pin
Traceback (most recent call last):
File "<pyshell>", line 1, in <module>
ModuleNotFoundError: No module named 'machine'
>>>
It seems you have selected the wrong interpreter in Thonny.
If MicroPython Pico interpreter is selected you have a different banner when the Pico is connected
Python is replaced by MicroPython followed by the release number of MicroPython

Re: Updating Pi Pico with MicroPython kills the flash drive

Posted: Thu Jan 13, 2022 10:48 pm
by GilbertGagne
Many thanks to scruss and fdufnews for their useful comments. It motivated me to digging seriously into the many parts of Thonny which I had brushed off as just an editor. In Thonny I was able to open a script file generated in Notepad and RUN on Pi Pico then saved it to Pi Pico.
Finally, cycled Pi Pico power and found my program running again. Goal accomplished!

Contrary to published propaganda, Raspberry Pi Pico is not an "easy" computer for the inexperienced. Climbing the learning curve requires big push from guys like scruss and fdufnews. Now I'm over the hump there's some real work ahead.