# Pi Pico - Generating Uf2 from Bin

**URL:** <https://forum.arduino.cc/t/pi-pico-generating-uf2-from-bin/955306>\
**Category:** 3rd Party Boards\
**Created:** [February 4, 2022, 5:23pm UTC](https://forum.arduino.cc/t/pi-pico-generating-uf2-from-bin/955306 "2022-02-04T17:23:00Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![spaceacejammer](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@spaceacejammer](https://forum.arduino.cc/u/spaceacejammer)\
**Post date:** [February 4, 2022, 5:23pm UTC](https://forum.arduino.cc/t/pi-pico-generating-uf2-from-bin/955306/1 "2022-02-04T17:23:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![markd833](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/markd833/32/1186928_2.png) [@markd833](https://forum.arduino.cc/u/markd833)\
**Post date:** [February 4, 2022, 6:19pm UTC](https://forum.arduino.cc/t/pi-pico-generating-uf2-from-bin/955306/2 "2022-02-04T18:19:29Z")

</div>

> **[Adafruit Feather M0 Express](https://learn.adafruit.com/adafruit-feather-m0-express-designed-for-circuit-python-circuitpython/uf2-bootloader-details)**
>
> Get started quickly using Arduino or CircuitPython on the Feather M0 Express.

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

---

<div class="post-metadata">

**Author:** ![MartinL](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/martinl/32/216911_2.png) [@MartinL](https://forum.arduino.cc/u/MartinL)\
**Post date:** [February 4, 2022, 6:33pm UTC](https://forum.arduino.cc/t/pi-pico-generating-uf2-from-bin/955306/3 "2022-02-04T18:33:49Z")

</div>

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:

> **[GitHub - todbot/samd21-programming-notes: SAMD21 programming notes](https://github.com/todbot/samd21-programming-notes#program-arduino-sketch-with-uf2---trinket-m0)**
>
> SAMD21 programming notes. Contribute to todbot/samd21-programming-notes development by creating an account on GitHub.

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

> **[GitHub - blurfl/makeUF2-tool: A tool for the Arduino IDE to make a UF2 file...](https://github.com/blurfl/makeUF2-tool)**
>
> A tool for the Arduino IDE to make a UF2 file from a compiled sketch binary .bin file. - GitHub - blurfl/makeUF2-tool: A tool for the Arduino IDE to make a UF2 file from a compiled sketch binary .b...

---

<div class="post-metadata">

**Author:** ![in0](https://avatars.discourse-cdn.com/v4/letter/i/77aa72/32.png) [@in0](https://forum.arduino.cc/u/in0)\
**Post date:** [February 4, 2022, 7:29pm UTC](https://forum.arduino.cc/t/pi-pico-generating-uf2-from-bin/955306/4 "2022-02-04T19:29:55Z")

</div>

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](https://github.com/earlephilhower/arduino-pico) 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](https://github.com/arduino/rp2040tools/releases/latest)

Or the same here for the [earlephilhower](https://github.com/earlephilhower) version here:

[https://github.com/earlephilhower/pico-quick-toolchain/releases/latest](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`](https://arduino.github.io/arduino-cli/latest/commands/arduino-cli_compile/)) also save the `.elf` file to the `build/arduino.mbed_rp2040.pico` subfolder of the sketch folder.

---

<div class="post-metadata">

**Author:** ![spaceacejammer](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@spaceacejammer](https://forum.arduino.cc/u/spaceacejammer)\
**Post date:** [February 5, 2022, 11:33am UTC](https://forum.arduino.cc/t/pi-pico-generating-uf2-from-bin/955306/5 "2022-02-05T11:33:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![spaceacejammer](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@spaceacejammer](https://forum.arduino.cc/u/spaceacejammer)\
**Post date:** [February 5, 2022, 11:37am UTC](https://forum.arduino.cc/t/pi-pico-generating-uf2-from-bin/955306/6 "2022-02-05T11:37:53Z")

</div>

> [@in0](#):
>
> elf2uf2

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.

---

<div class="post-metadata">

**Author:** ![westfw](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/westfw/32/213443_2.png) [@westfw](https://forum.arduino.cc/u/westfw)\
**Post date:** [February 6, 2022, 9:36am UTC](https://forum.arduino.cc/t/pi-pico-generating-uf2-from-bin/955306/7 "2022-02-06T09:36:37Z")

</div>

uf2 is a Microsoft standard format that is well-described here: [GitHub - microsoft/uf2: UF2 file format specification](https://github.com/microsoft/uf2)  
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:

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

```

---

<div class="post-metadata">

**Author:** ![in0](https://avatars.discourse-cdn.com/v4/letter/i/77aa72/32.png) [@in0](https://forum.arduino.cc/u/in0)\
**Post date:** [February 6, 2022, 10:08am UTC](https://forum.arduino.cc/t/pi-pico-generating-uf2-from-bin/955306/8 "2022-02-06T10:08:30Z")

</div>

> [@westfw](#):
>
> I don't understand the comment about "the plugin crashing"

[`blurfl/makeUF2-tool`](https://github.com/blurfl/makeUF2-tool) uses the Arduino IDE 1.x plugin (AKA "tool") system, similar to the official [" **WiFi101 / WiFiNINA Firmware Updater**"](https://github.com/arduino/WiFi101-FirmwareUpdater-Plugin) that comes pre-installed with the Arduino IDE, or the popular 3rd party [" **ESP Exception Decoder**"](https://github.com/me-no-dev/EspExceptionDecoder) and [" **ESP8266 Sketch Data Upload**"](https://github.com/esp8266/arduino-esp8266fs-plugin) 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):

> <https://github.com/arduino/Arduino/tree/master/build/shared/tools>
>
> //github.com/arduino/Arduino/tree/master/build/shared/tools

---

<div class="post-metadata">

**Author:** ![spaceacejammer](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@spaceacejammer](https://forum.arduino.cc/u/spaceacejammer)\
**Post date:** [February 7, 2022, 7:54am UTC](https://forum.arduino.cc/t/pi-pico-generating-uf2-from-bin/955306/9 "2022-02-07T07:54:15Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![in0](https://avatars.discourse-cdn.com/v4/letter/i/77aa72/32.png) [@in0](https://forum.arduino.cc/u/in0)\
**Post date:** [February 7, 2022, 12:56pm UTC](https://forum.arduino.cc/t/pi-pico-generating-uf2-from-bin/955306/10 "2022-02-07T12:56:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [August 6, 2022, 12:56pm UTC](https://forum.arduino.cc/t/pi-pico-generating-uf2-from-bin/955306/11 "2022-08-06T12:56:11Z")

</div>

Closed on August 6, 2022, 12:56pm UTC

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