Pi Pico - Generating Uf2 from Bin

Hi

I am using Pi Pico with MBed. I can export the Bin file but I want to generate a UF2 file so that I can load the program via USB onto multiple boards. Is there a way to do this?

If not, has the algorithm been made available to directly program the bin files via USB (UART)?

I need a way to be able to update the Pi Pico in-system. So, please give me some suggestions if the above are not feasible. I'm really trying to avoid MicroPython if I can.

Thank you

There's a link to uf2tool on that webpage that creates UF2 files from binary files. That might be what you need.

Hi @spaceacejammer

You need to run a Javascipt file called bin2uf2.js that converts the binary to the UF2 format.

It's a cool feature that once you've got the UF2 file, you can program the microcontroller by simply dragging and dropping it on to your board's UF2 booloader drive. No messing around with programming applications.

In the past, I believe I ran it from a Node.js command line, detailed here:

There's also a plug-in for the Arduino IDE on Github here, (although I haven't tried it):

Arduino distributes compiled versions of Raspberry Pi's "elf2uf2" tool along with the installation of the "Arduino Mbed OS RP2040 Boards" platform, and the 3rd party "Raspberry Pi RP2040 Boards" platform does the same. So if you have installed either of those via the Arduino IDE Boards Manager, you already have the tool on your computer. You can also get the compiled tool from Arduino directly from the download links under the "Assets" section of each release page here:

https://github.com/arduino/rp2040tools/releases/latest

Or the same here for the earlephilhower version here:

https://github.com/earlephilhower/pico-quick-toolchain/releases/latest

Of course, this tool uses the .elf file, not the .bin. The Arduino IDE 2.x Sketch > Export Compiled Binary feature (as well as arduino-cli compile --export-binaries) also save the .elf file to the build/arduino.mbed_rp2040.pico subfolder of the sketch folder.

Thank you. I previously tried the IDE plugin but it only support IDE v1.8.8. It crashes with v1.1.16 as I see in the issue log. So it's probably not being maintained which is a shame.

Thank you. I going to try installing IDE RC 2.0 and will try this method. It sounds like what I can use. I will feed back my results.

uf2 is a Microsoft standard format that is well-described here: GitHub - microsoft/uf2: UF2 file format specification
There seem to be "many" converter programs (elf, bin, hex, etc), but most of them are distributed in source (python, rust, etc) and so would require some environment on a PC to produce an executable. The Arduino IDE has a pre-built version of one of them in .../tools/rp2040tools/1.0.2/elf2uf2 - I don't understand the comment about "the plugin crashing" - this should be a standalone executable:

./elf2uf2 
Usage: elf2uf2 (-v) <input ELF file> <output UF2 file>

blurfl/makeUF2-tool uses the Arduino IDE 1.x plugin (AKA "tool") system, similar to the official "WiFi101 / WiFiNINA Firmware Updater" that comes pre-installed with the Arduino IDE, or the popular 3rd party "ESP Exception Decoder" and "ESP8266 Sketch Data Upload" projects.

The system was never properly documented by Arduino, but some info and a demo is shipped with Arduino IDE 1.x (originating all the way back in the project's Processing IDE roots):

I've managed to create the U2f file using the tool you mentioned and IDE RC 2. Thank you. Tested this this morning and it works when the U2f file is dragged and dropped into the USB drive.

Thank you to everyone for the help and time!

You are welcome. I'm glad it's working. Thanks for taking the time to post an update with your findings.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.