Installing the UF2 Bootloader

Originally developed by Microsoft, the USB Flashing Format (UF2) is a way of programming microcontrollers. With UF2, a microcontroller will enumerate as a mass storage device over USB (i.e. a USB drive). You can then drag-and-drop code onto the drive, and UF2 will re-program the microcontroller with your code. This process makes it easier to program microcontrollers, as you no longer need a special programming device (like a JTAG programmer) or a special program (such as Arduino).

Adafruit has forked the UF2 code and added support for specific SAMD21 and SAMD51 boards, making it even easier to load UF2 onto your board!

Windows 7 Drivers

If you're using Windows 7, you need to install a driver before continuing (not needed for Windows 10)

If you're using Windows 7, use the link below visit the Adafruit drivers page. You will not need to install drivers on Mac, Linux or Windows 10.

Download the UF2 Arduino Installer

Navigate to the Adafruit uf2-samdx1 GitHub repository and click on Releases. Alternatively, you can just click on this link to go directly there:

 

Newer releases of the UF2 bootloader are found at the top of the page. Find the .ino file with your board's name and with the newest version number. The file will have the following naming scheme (with [your board's name] replaced by the name of your board and vx.x.x-adafruit.x replaced by the newest release number):

update-bootloader-[your board's name]-vx.x.x-adafruit.x.ino

For example, if you wanted to download the UF2 installer for the Arduino MKRZero, you would look for a filename like update-bootloader-mkrzero-vx.x.x-adafruit.x.ino. Click on that name to download the .ino file.

Note that in the screenshot, the newest file is v2.0.0-adafruit.7. The particular version number might be different for you; just download whatever is newest!

Upload UF2 with Arduino

In Arduino, click on File > Open..., and locate your downloaded .ino file. Select it, and click Open. If you get a pop-up window stating that the file "needs to be inside a sketch folder" with the same name, click OK.

Feel free to take a look at the code. Most of it should be a series of unreadable raw bytes in hexadecimal format. This is the bootloader in bytecode! The rest of the program simply uploads this code to the correct spot in memory on your microcontroller.

Make sure your board is connected to your computer. In Arduino, go to Tools > Board, and select your board (I'll use MKRZero in this example). Go to Tools > Port, and select the serial port associated with your board (e.g. COM3 on Windows or /dev/tty.usbmodemfd1441 on macOS).

Click the Upload button.

You should see a message at the bottom of the Arduino IDE that says Done uploading if your code has been successfully compiled and flashed to your board.

Most Arduino-compatible boards have an onboard LED. If UF2 was flashed successfully, you should see this LED slowly pulsing on and off.

With or without the LED, you should see a new drive appear on your computer. Open your file explorer/finder and look at your list of available drives. The UF2 drive should be called [board name]BOOT in all capital letters. Click on it, and you should see the files CURRENT.UF2INDEX.HTM, and INFO_UF2.TXT.

If you see this, then the UF2 bootloader was installed successfully. Hooray!

Learning More About UF2

If you would like to understand more about how UF2 works and the contents of the files on your UF2 drive, check out the UF2 Bootloader Details page on this tutorial.

This guide was first published on Dec 14, 2018. It was last updated on Dec 14, 2018. This page (Installing the UF2 Bootloader) was last updated on Jun 20, 2019.