Overview
abin2uf2
is a Python program that
- transmogrifies Astrobe’s
.bin
file into UF2 format, - can directly upload the UF2 file to the Pico.
The transmogrification has two aspects:
- chop up the binary into 256 bytes blocks, inserting the required headers, and
- prepend the required code for the second boot phase of the RP2040.
The program consists of two files, namely the Python program itself, plus the UF2 binary with the boot code (boot2.uf2).
The Python version used to develop the program is 3.12.
Installation for Command Line Usage
This is how I install abin2uf2
:1
- put
abin2uf2.py
andbootstage2.uf2
into any directory, which must be on$PYTHONPATH
; - one possibility is to leave the two files in their directory in the repo structure, so you get and “install” any updates automatically. Just put the directory on
$PYTHONPATH
; - run the program with the
-m
option for Python (without the.py
extension).
Hence, to transmogrify one of the examples, I run in the Windows PowerShell, assuming the Pico’s drive is ‘F:’:
PS python -m abin2uf2 BlinkPlus.bin -d F:
Of course you can copy the UF2 file manually to the Pico’s drive, without using the -d
option.
Run python -m abin2uf2 -h
for some help.
Installation for Astrobe’s Tool Menu
Install as outlined above, then add this – mutatis mutandis – to your Tools.ini
file in the corresponding Astrobe configs folder:
[Command3]
MenuItem=Create and Upload &UF2
Path=C:\Users\gray\AppData\Local\Programs\Python\Python312\python.exe
Parameters=-m abin2uf2 %FileDir%\%FileRoot%.bin -d F:
WorkingFolder=%FileDir%
ConsoleApp=TRUE
Prompt=FALSE
The drive letter is “hard-coded”, since I don’t want to enter it with the parameter dialog of Astrobe again and again, and the Pico always appears at the same letter on my machine. I am sure it would be possible to extend the Python program to search for the Pico’s drive name (it’s RPI-RP2
), ie. not the drive letter, but…
BOOTSEL
Don’t forget to put the Pico into BOOTSEL
mode before running abin2uf2
with uploading, ie. by using option -d
.
Do yourself a big favour and wire up a reset button to the RP2040’s RUN
pin if you use a board without one, such as the Pico.
Repository
-
Which may not the “right” way to do it, but it works. ↩︎