This is an data page for advanced users who are curious how nosotros go code from your calculator into your Express board!

Adafruit SAMD21 (M0) and SAMD51 (M4) boards feature an improved bootloader that makes it easier than ever to flash different code onto the microcontroller. This bootloader makes it easy to switch between Microsoft MakeCode, CircuitPython and Arduino.

Instead of needing drivers or a carve up programme for flashing (say, bossac, jlink or avrdude), one tin simply elevate a file onto a removable bulldoze .

The format of the file is a piddling special. Due to 'operating organization woes' you cannot but drag a binary or hex file (trust us, we tried information technology, information technology isn't cross-platform uniform). Instead, the format of the file has extra information to assist the bootloader know where the data goes. The format is called UF2 (USB Flashing Format). Microsoft MakeCode generates UF2s for flashing and CircuitPython releases are too bachelor as UF2. You can also create your own UF2s from binary files using uf2tool, available here.

The bootloader is also BOSSA compatible , so it tin be used with the Arduino IDE which expects a BOSSA bootloader on ATSAMD-based boards

For more information about UF2, you can read a bunch more than at the MakeCode blog, then check out the UF2 file format specification.

Visit Adafruit's fork of the Microsoft UF2-samd bootloader GitHub repository for source code and releases of pre-congenital bootloaders on CircuitPython.org.

The bootloader is not needed when changing your CircuitPython code. Its merely needed when upgrading the CircuitPython cadre or changing between CircuitPython, Arduino and Microsoft MakeCode.

arduino_compatibles_CircuitPython_Boot_Sequence_1.png

Entering Bootloader Style

The first step to loading new code onto your board is triggering the bootloader. It is easily done by double tapping the reset push. In one case the bootloader is active you will see the small red LED fade in and out and a new drive will appear on your computer with a proper noun ending in Kicking. For example, feathers show up equally FEATHERBOOT, while the new CircuitPlayground shows up equally CPLAYBOOT, Trinket M0 will show upward as TRINKETBOOT, and Gemma M0 will show up as GEMMABOOT

Furthermore, when the bootloader is active, it will alter the color of one or more onboard neopixels to indicate the connection condition, blood-red for disconnected and green for connected. If the lath is plugged in but however showing that its disconnected, try a dissimilar USB cable. Some cables merely provide power with no advice.

For example, here is a Plume M0 Express running a colorful Neopixel swirl. When the reset button is double clicked (about half second betwixt each click) the NeoPixel will stay green to allow you know the bootloader is active. When the reset push is clicked once, the 'user program' (NeoPixel color swirl) restarts.

If the bootloader couldn't get-go, you will become a carmine NeoPixel LED.

That could mean that your USB cable is no skilful, information technology isn't continued to a figurer, or perchance the drivers could not enumerate. Endeavour a new USB cable first. Then try another port on your computer!

Once the bootloader is running, check your reckoner. Y'all should see a USB Disk drive...

arduino_drive.png

Once the bootloader is successfully continued y'all can open the drive and browse the virtual filesystem. This isn't the same filesystem as you employ with CircuitPython or Arduino. It should have three files:

  • CURRENT.UF2 - The current contents of the microcontroller flash.
  • Index.HTM - Links to Microsoft MakeCode.
  •  INFO_UF2.TXT - Includes bootloader version info. Please include it on bug reports.

arduino_contents.png

Using the Mass Storage Bootloader

To flash something new, merely elevate any UF2 onto the drive. Afterwards the file is finished copying, the bootloader volition automatically restart. This usually causes a alarm about an dangerous eject of the bulldoze. Yet, its non a problem. The bootloader knows when everything is copied successfully.

arduino_uf2.png

You lot may become an alert from the Bone that the file is being copied without it'south properties. You tin only click Yes

arduino_properties.png

Yous may besides get get a complaint that the bulldoze was ejected without warning. Don't worry about this. The drive simply ejects one time the bootloader has verified and completed the procedure of writing the new lawmaking

Using the BOSSA Bootloader

As mentioned before, the bootloader is also compatible with BOSSA, which is the standard method of updating boards when in the Arduino IDE. It is a command-line tool that can exist used in whatever operating system. We won't comprehend the total use of the bossac tool, suffice to say information technology can practice quite a bit! More information is available at ShumaTech.

Windows 7 Drivers

If you are running Windows vii (or, goodness, something earlier?) Yous volition need a Serial Port driver file. Windows 10 users do not demand this and so skip this step.

You tin can download our full driver package here:

Download and run the installer. We recommend just selecting all the series port drivers available (no damage to do and so) and installing them.

arduino_adafruit_products_3select.png

Verifying Serial Port in Device Director

If you're running Windows, its a proficient idea to verify the device showed up. Open up your Device Manager from the control panel and wait under Ports (COM & LPT) for a device called Plumage M0 or Circuit Playground or whatever!

arduino_driver.png

If y'all see something similar this, it means you lot did not install the drivers. Go dorsum and try again, and then remove and re-plug the USB cable for your board

arduino_nodrive.png

Running bossac on the command line

If yous are using the Arduino IDE, this stride is not required. Just sometimes you desire to read/write custom binary files, say for loading CircuitPython or your own code. We recommend using bossac v i.vii.0 (or greater), which has been tested. The Arduino branch is most recommended.

Y'all tin download the latest builds here. The mingw32 version is for Windows, apple-darwin for Mac OSX and various linux options for Linux. Once downloaded, extract the files from the zip and open the command line to the directory with bossac.

With bossac versions 1.9 or later, you must use the --offset parameter on the control line, and it must have the correct value for your lath.

With bossac version 1.9 or later, you must give an--offset parameter on the command line to specify where to commencement writing the firmware in wink memory. This parameter was added in bossac 1.8.0 with a default of0x2000, but starting in 1.9, the default offset was inverse to0x0000, which is not what you lot want in most cases. If y'all omit the statement for bossac ane.9 or subsequently, you will probably encounter a "Verify Failed" error from bossac.  Remember to change the option for-p or--port to match the port on your Mac.

Replace the filename beneath with the name of your downloaded .bin : it will vary based on your lath!

Using bossac Versions 1.vii.0, 1.8

There is no--offset parameter available. Apply a command line like this:

bossac -p=/dev/cu.usbmodem14301 -e -w -v -R adafruit-circuitpython-boardname-version.bin

For case,

bossac -p=/dev/cu.usbmodem14301 -e -w -v -R adafruit-circuitpython-feather_m0_express-three.0.0.bin

Using bossac Versions i.9 or Subsequently

For M0 boards, which have an 8kB bootloader, you must specify-outset=0x2000, for instance:

bossac -p=/dev/cu.usbmodem14301 -e -w -v -R --offset=0x2000 adafruit-circuitpython-feather_m0_express-3.0.0.bin

For M4 boards, which accept a 16kB bootloader, y'all must specify-offset=0x4000, for instance:

bossac -p=/dev/cu.usbmodem14301 -e -w -five -R --offset=0x4000 adafruit-circuitpython-feather_m4_express-three.0.0.bin

This willerase the chip,write the given file,5erify the write andReset the lath. On Linux or MacOS you may need to run this control withsudo ./bossac ..., or add yourself to thedialoutgroup offset.

arduino_bossac.png

Updating the bootloader

The UF2 bootloader is relatively new and while nosotros've done a ton of testing, it may contain bugs. Commonly these bugs consequence reliability rather than fully preventing the bootloader from working. If the bootloader is flaky then you can try updating the bootloader itself to potentially improve reliability.

If you're using MakeCode on a Mac, yous need to make certain to upload the bootloader to avoid a serious problem with newer versions of MacOS. See instructions and more than details here.

In full general, you shouldn't take to update the bootloader! If you practice think you're having bootloader related issues, please post in the forums or discord.

Updating the bootloader is equally easy as flashing CircuitPython, Arduino or MakeCode. Simply enter the bootloader as above and then elevate the update bootloader uf2 file below. This uf2 contains a program which volition unlock the bootloader section, update the bootloader, and re-lock it. It will overwrite your existing code such every bit CircuitPython or Arduino so make certain everything is backed upwardly!

After the file is copied over, the bootloader will be updated and announced once more. The INFO_UF2.TXT file should show the newer version number inside.

For case:

UF2 Bootloader v2.0.0-adafruit.5 SFHWRO
Model: Metro M0
Board-ID: SAMD21G18A-Metro-v0

Lastly, reload your code from Arduino or MakeCode or flash the latest CircuitPython core.

Below are the latest updaters for various boards. The latest versions can always be found here.  Look for the update-bootloader... files, not the bootloader... files.

Getting Rid of Windows Pop-ups

If y'all do a lot of evolution on Windows with the UF2 bootloader, you may get bellyaching by the abiding "Hey you inserted a bulldoze what practice you lot want to do" popular-ups.

  • arduino_hwsond.png

Become to the Control Panel. Click on the Hardware and Audio header

  • arduino_autoplay.png

Click on the Autoplay header

  • arduino_noauto.png

Uncheck the box at the summit, labeled Apply Autoplay for all devices

Making your own UF2

Making your own UF2 is easy! All you need is a .bin file of a program you wish to wink and the Python conversion script. Make sure that your programme was compiled to start at 0x2000 (8k) for M0 boards or 0x4000 (16kB) for M4 boards. The bootloader takes up the first 8kB (M0) or 16kB (M4). CircuitPython's linker script is an case on how to do that.

Once y'all have a .bin file, yous simply need to run the Python conversion script over information technology. Hither is an example from the directory with uf2conv.py. This command will produce a firmware.uf2 file in the aforementioned directory as the source firmware.bin. The uf2 can and so be flashed in the same way as above.

# For programs with 0x2000 offset (default) uf2conv.py -c -o build-circuitplayground_express/firmware.uf2 build-circuitplayground_express/firmware.bin  # For programs needing 0x4000 offset (M4 boards) uf2conv.py -c -b 0x4000 -o build-metro_m4_express/firmware.uf2 build-metro_M4_express/firmware.bin                
# For programs with 0x2000 first (default) uf2conv.py -c -o build-circuitplayground_express/firmware.uf2 build-circuitplayground_express/firmware.bin  # For programs needing 0x4000 offset (M4 boards) uf2conv.py -c -b 0x4000 -o build-metro_m4_express/firmware.uf2 build-metro_M4_express/firmware.bin                

This guide was first published on Mar 31, 2017. It was last updated on Mar 31, 2017.

This folio (UF2 Bootloader Details) was last updated on Apr 10, 2022.

Text editor powered by tinymce.