hippy
Posts: 12930
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

STICKY: MicroPython for Pico, Pico-W and RP2 Resources

Tue Apr 20, 2021 1:30 pm

MicroPython Firmware

Please note that Pico and Pico-W boards require different MicroPython firmware to be loaded, as do non-Pico boards. You must select the correct firmware UF2 file for the board you have.

The latest pre-built MicroPython UF2 files for the Pico can be downloaded from - The latest pre-built MicroPython UF2 files for the Pico-W can be downloaded from - The latest pre-built MicroPython UF2 files for RP2040-based boards other than the Pico or Pico-W, which can differ from the UF2 files provided for the Pico and Pico-W, can be found via - The full MicroPython github source is at - The MicroPython port for Pico, Pico-W and RP2 can be found within that at - What's New in MicroPython releases - Bug reports should be raised here -
Extensions to MicroPython Firmware

MicroPython is shifting sand. While extensions presented here may have worked when released that is no guarantee that the MicroPython developers won't suddenly and unexpectedly change things which stops those extensions from working.

Documentation

The Official Raspberry Pi Pico Guide "Get Started with MicroPython on Raspberry Pi Pico" can be purchased, viewed or downloaded as a PDF file, here - The Official "Raspberry Pi Pico Python SDK" PDF can be viewed or downloaded as - Official documentation for MicroPython can be found here - The official MicroPython "Quick reference for the RP2" can be found at - Details of "Libraries specific to the RP2" can be found here - The Official MicroPython Wiki - click on the "Pages" link towards the top right of the page to reveal what is covered - can be found here -
Community

GitHub Discussions is the place for MicroPython discussions, questions, etc, which can be found here - The archive of the superseded Official MicroPython Forum can be found here - MicroPython's Twitter presence is at - MicroPython's Facebook presence is at - If you wish to sponsor the on-going development of MicroPython; please see here -
Libraries and Packages

Installing packages with 'mip' - which supersedes 'upip' and is pre-installed for Pico W - which can be used to install libraries and packagesfrom MicroPython-Lib and elsewhere, is detailed here - MicroPython-Lib - "A repository of libraries designed to be useful for writing MicroPython applications" can be found here - Awesome MicroPython - "A curated list of awesome MicroPython libraries, frameworks, software and resources" can be found at - Adafruit's guide for using CircuitPython libraries with MicroPython can be found at -
Programming and Development Tools

IDE Command line The Raspberry Pi 'Flash Nuke' UF2 file can be downloaded from - Hippy's less drastic "Rename main.py" UF2 file can be found here -
Host interaction

Belay is a Python library which allows a Python program on a Pi or other host to include MicroPython code which, when invoked, will be executed on a Pico, Pico-W or other board running MicroPython, without having to explicitly write or load any code for that board.
Other MicroPython forks for Pico, Pico-W or RP2
Trademarks
  • "Python" and the Python Logo are trademarks of the Python Software Foundation.
Last edited by hippy on Sun Nov 27, 2022 8:50 pm, edited 20 times in total.

hippy
Posts: 12930
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: STICKY: MicroPython for Pico, Pico-W and RP2 Resources

Fri Feb 11, 2022 9:06 pm

Getting and Building MicroPython from Source

Please note these instructions require all prerequistes for building a C program for a Pico or Pico-W to be installed. Please see the official 'Getting Started' guides for installing those.

Code: Select all

cd ~/pico
git clone https://github.com/micropython/micropython.git
git clone https://github.com/micropython/micropython-lib.git
cd micropython
git submodule update --init
make -C ports/rp2 BOARD=PICO_W submodules
make -C mpy-cross
cd ports
cd rp2
mkdir build
cd build
cmake ..
make
picotool info -a fimware.uf2
Then bootload 'firmware.uf2' to your Pico.

Building for a Pico-W

The Pico-W requires different firmware to the Pico. This must be built separately and additionally -

Code: Select all

cd ~/pico/micropython/ports/rp2
mkdir build-PICO_W
cd build-PICO_W
cmake -DMICROPY_BOARD=PICO_W ..
make
picotool info -a fimware.uf2
Then bootload 'firmware.uf2' to your Pico-W.

Building for other non-Pico boards

MicroPython needs to be built for the board it is to be used upon. While the build for the Pico will likely run on other boards it may restrict the file system to around 1.4MB even though more than 2MB of Flash memory is fitted to the board and other board-specific features may not be available.

To identify which boards are supported -

Code: Select all

cd ~/pico/micropython/ports/rp2
ls boards
Then, for the board one wants to build for, in this case "PIMORONI_TINY2040" -

Code: Select all

mkdir build-PIMORONI_TINY2040
cd build-PIMORONI_TINY2040
cmake -DMICROPY_BOARD=PIMORONI_TINY2040 ..
make
Keeping MicroPython source code up to date

To keep MicroPython source code up to date -

Code: Select all

cd ~/pico/micropython
git pull
git submodule update --init

Code: Select all

cd ~/pico/micropython-lib
git pull
After the first build you should only need to go to the 'build' directory and re-issue the 'make' command to rebuild.

If things go wrong after editing or adding to the source code, particularly if there are any weird 'QSTR' type issues, the first thing to try is ...

Code: Select all

cd ..
rm -r build
mkdir build
cd build
cmake ..
make
Last edited by hippy on Sat Oct 15, 2022 5:38 pm, edited 5 times in total.

hippy
Posts: 12930
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: STICKY: MicroPython for Pico, Pico-W and RP2 Resources

Fri Jul 08, 2022 10:19 am

Controlling the on-board LED of Pico and Pico-W

The on-board LED of both the Pico and Pico-W should be controlled in the following manner -

Code: Select all

from machine import Pin
led = Pin("LED", Pin.OUT)
led.off()
led.on()
led.value(0)
led.value(1)
In earlier versions of MicroPython for the Pico the LED could be controlled by referencing GPIO pin 25 which was directly connected to the on-board LED. On the Pico-W this pin is used to control the CYW43439 wireless chip which itself controls the on-board LED. The mechanism above allows the on-board LED to be controlled regardless of whether a Pico or Pico-W is being used.

Please note that the MicroPython firmware, the UF2 file, is different for Pico and Pico-W and the appropriate firmware should be installed for the board you are using.

The latest version of the MicroPython firmware can be downloaded from -

Pico : https://micropython.org/download/rp2-pico
Pico-W : https://micropython.org/download/rp2-pico-w

Return to “MicroPython”