How do I create a UF2 file from 2.x?

Prior to 2.x, I used a “tool” from the tools menu for building UF2 files to distribute and update devices that I have made running on QTPY SAMD21.

How do I create a UF2 file in 2.x?

Hi @distropolis.

Was it this one?:

I see there that the "tool" is based on this JavaScript program:

The script takes the path of a .bin file as its argument.

I'll provide instructions you can follow to use it.

A. Install Prerequisites

Script

First you need to download that bin2uf2.js file:

  1. Click the following link:
    https://raw.githubusercontent.com/adafruit/uf2-samdx1/master/scripts/bin2uf2.js
    The plaintext version of the script will open in your web browser.
  2. Press the Ctrl+S keyboard shortcut.
    The "Save As" dialog will open.
  3. Save the script to a convenient location on your computer.

Node.js

If you don't already have it, you will need to install Node.js in order to run the JavaScript program. You can follow the instructions here to install it:

B. Convert .bin to UF2

  1. Open the sketch in Arduino IDE.
  2. Select Tools > Board > Adafruit SAMD Boards > Adafruit QT Py M0 (SAMD21) from the Arduino IDE menus.
  3. Select Sketch > Export Compiled Binary from the Arduino IDE menus.
    A compilation will start.
  4. Wait for the compilation to finish successfully.
  5. Select Sketch > Show Sketch Folder from the Arduino IDE menus.
    The sketch folder will open in your file manager.
  6. Open a command line terminal in the build\adafruit.samd.adafruit_qtpy_m0 subfolder of the sketch folder.
    Arduino IDE's "Export Compiled Binary" feature saves the compiled sketch binary in this folder.
  7. Type the following command into the terminal:
    node <path to bin2uf2.js> <.bin filename>
    
    (where <path to bin2uf2.js> is the path to the location where you saved bin2uf2.js while following the instructions above, and <.bin filename> is the filename of the .bin file from the build\adafruit.samd.adafruit_qtpy_m0 folder.
  8. Press the Enter key.

The command should run successfully (you might see some deprecation warnings, but you can ignore those). After that, you will find a file named flash.uf2 in the folder.

1 Like

Thank you so much for this. I just tested it out and it seems to work just fine.

Super clear instructions with great detail. I appreciate it.

You are welcome. I'm glad if I was able to be of assistance.

Regards, Per

1 Like

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