How to: 🥸 Make a UF2 Flash file from a single HEX file for Production

Hi there
So this may be useful to some of the makers and want-a-be programmers out there.
It’s way easier to Drag and Drop a Uf2 flash file on a Xiao Nrf52840 BLE or Sense in bootloader mode with the drive displayed in windows for example.

There are many, many discussions and tutorials about it, just google it but none that show the steps clear enough for me at least on a windows PC.
The First Step is easy,
If you use Arduino IDE it does most of the work for you, then you use a python script from a terminal window and it does the rest. Poof a “Flash.uf2”. Drag it on to an open Xiao in Bootloader mode and after the copy it resets and runs the code. Nothing to Compile or manually Flash. Great!

I started by making a TOOLS folder in the Arduino Sketch folder once, there I opened a terminal window with the Right Click like this

This is where some folks get tripped up , So pay Attention!!
You may get a POWER-Shell Terminal window, Just type “CMD” in the prompt and it will
jump to command com.

Assuming you have built a project in the IDE and you selected “Export Compiled Binary” from the sketch menu and that you have python 3 installed on your computer. With that being said, you now install adafruit nrfutil package. by Entering the first install string in the terminal window.

pip3 install --user adafruit-nrfutil

Then when it’s finished clone the repo,

git clone
cd Adafruit_nRF52_Bootloader
git submodule update --init
cd lib/uf2/utils

just copy and paste into the terminal window and you’ll know if it doesn’t’ install.

Now issue below command to make uf2 file. Make sure to change the filename and path of your .hex file. This will generate a .uf2 file with name flash.uf2

D:\Arduino_projects\tools\Adafruit_nRF52_Bootloader\lib\uf2\utils>python SelfTest.hex -c -f 0xADA52840
Converting to uf2, output size: 1076224, start address: 0x0
Wrote 1076224 bytes to flash.uf2

Now you have a Flash file you can drop on a Xiao and it Runs…

Here is the the format I used after copying the Hex file from, the build folder I previously exported. You can copy it to the uf2 tool folder or just right click and get the path and Paste it on the command line and remove the “” marks.

looks like this in the terminal window.

I will post some examples with the uf2 files alongside next…
GL :slight_smile: PJ


I created the .bin to .uf2 converter using Blazor WASM.
However, we have only tested with Seeed Studio XIAO SAMD21 and Wio Terminal. :sweat_smile:

It’s open source. Anyone can add functions. :wink:

1 Like

Thanks for sharing this doc.

Hi there,
Yes, I like that it’s bossac compliant and does the offset for you _2700
makes it easy to move code around with only USB :smile: :v:
SO many example sketches that don’t work for a users perticular Dev environment.
This allows a very fast sanity check without compiling a nibble of code. NICE!
Seeed, would do well by it’s users and newbies to provide more examples with a Uf2 flash file ready to drag and drop and be able to Go! IMO :+1:
Does two things instantly, Verifies Hardware configuration & sanity checks the users Dev environment, when it works the first time.

for example If you have the Arduino_BLE on your system and try to compile an ESP32xx example with BLE, it may look like it compiles ok, but the code doesn’t run. Of course it’s because it used the wrong lib and didn’t get an error in some cases…
So many pitfalls for new users, this would eliminate some of it. IMO.
GL :slight_smile: PJ

Hi there, Here are the examples with the uf2 files attached in the ZIP
GL :slight_smile: PJ

Thank you very much for sharing!

1 Like

Hi there,
Thanks for the Likes. :+1:
To mention at least the Basic of it and put a Bow on the topic.

The XIAO BLE Sense is equipped with the Adafruit nRF52 Bootloader 5, facilitating the UF2 flashing process.

UF2 Flashing Process

  1. Entering Bootloader Mode: Connect the XIAO BLE Sense to your computer via USB. Then, double-tap the reset button located to the left of the USB connector. This action will enable the bootloader mode, and the device will appear as a mass storage device named ‘XIAO BLE’ on your computer.

  2. Flashing the Firmware:

  • Navigate to the build or tools directory and locate the .uf2 file. Or to the folder you created to hold the flash.uf2 file.
  • Copy that .uf2 file to the root directory of the XIAO BLE mass storage device using either the command line or your file manager.
  1. Automatic Reset and Application Launch: After the UF2 file transfer is complete, the XIAO BLE Sense will automatically reset and launch the new application.

Enjoy :wink: :v: