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.
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:
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.
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:
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.