Flashing application for Raspberry Pi Pico.
Used to serially flash the application firmware of a Pico, using Python.
The Pico is expected to run UsedBytes bootloader C application.
Instructions on how to flash the bootloader can be found on UsedBytes Blogpost
Originally the bootloader was written to be used with UsedBytes GoLang application, but since we would prefer to use Python on our deployment systems, the GoLang app has been re-written in Python.
The UART cable used for testing is a FTDI TTL-232R-3V3.
- Clone or download this repository.
- Navigate to the downloaded directory
pico-py-serial-flash
. - Create a new Python Virtual Environment (tested with Python3.10):
python3 -m venv [name-of-venv]
and replace[name-of-venv]
with a custom name. - Activate the newly created venv:
source [name-of-venv]/bin/activate
. - Install the modules in the requirements.txt file:
pip install -r requirements.txt
. - Done.
- Follow UsedBytes instructions on how to flash the Pico bootloader application to your Pico.
- Create an application
.elf
binary file that works with the bootloader (as explained in chapterBuilding programs to work with the bootloader
in UsedBytes instructions). - Activate your
pico-py-serial-flash
virtual environment (if not activated already)source [name-of-venv]/bin/activate
- Wire a serial cable to the UART0 (the default UART used for flashing in the bootloader application).
- The Pico stays in the bootloader, either by pulling down the
BOOTLOADER_ENTRY_PIN
(default is GPIO 15 of the Pico), or if the Pico has no application flashed on it. - Run the flasher application:
python3 main.py [port-to-uart-cable] [/path/to/elf/file.elf]
- For example:
python3 main.py /dev/ttyUSB0 /home/build/blink_noboot2.elf
- Wait for it to finish uploading, and voilà.
None. Please create a GitHub Issue
when you encounter any.
These are the shortcomings that the current Python implementation has. Please feel free to create a pull request
if you have implemented any changes or new features.
- There is no TCP implementation yet, to flash the Pico W over the air (unlike the original GoLang application).
- The application does not support uploading
.bin
files (with according offsets). - Could use some kind of progress tracker, even though the flashing process can be quite quick for smaller application.