Removing Bootloader Protection On The AdaFruit Metro / Arduino Zero / SAMD21

The Microchip/Atmel SAMD21G18A is a powerful Cortex M0+ based MCU with 256K flash and 32K of SRAM. It’s used in the Arduino Zero as well as the Adafruit Metro and Feather lines of development boards, and is becoming a popular choice for users looking for a low cost powerful ARM Cortex-M MCU.

The SAMD21G18A used in the Arduino and Adafruit development boards is programmed with a bootloader. The Arduino IDE uses this feature to download programs onto the MCU.

However, instead of the limited Arduino IDE, you can instead use an advanced development environment such as JumpStart C++, Keil, or IAR. Besides getting the full benefit of using C/C++, you also can use visual debuggers that are lacking in the Arduino IDE.

To best utilize these environments, you need to use a Cortex-M Debug Pod. The Arduino Zero has an embedded debug chip, and the Adafruit Metro board can be used with an external debug pod. Note: you will need to disable the bootloader protection, otherwise you will not be able to download programs.

To do that on the Adafruit Metro, you will first need to install Atmel Studio 7.x (AS7) and use the Segger JLINK. If do not have a JLINK, you can turn an embedded ST-LINK into a JLINK; see the Cortex-M Debug Pod article linked above

In the Arduino Zero case, you should just be able to use the embedded Atmel debug chip.

The following procedure should work with both the Adafruit Metro and the Arduino Zero, although I do not have a Zero handy to try it on.

To begin, connect the hardware together. To use the JLINK with the board, you will need the 20 pin to the 10 pin “JTAG to SWD Cable Adapter Board”: see https://www.adafruit.com/product/2094. (Link subject to change through the whim of Adafruit, but then use the phrase in quotation marks above as a search term ). You will also need the 10-pin cable!

Search for “Atmel Studio 7 download” to find the download link on Microchip’s site. I found that I had to download the “offline” installer version at over 800+ megabytes, as the smaller web installer version did not work for me. YMMV. Once you install AS7, invoke “Tools->Device Pack Manager”, then scroll down to the SAM21_DFP section

Install the 1.0.222 “Initial release” and at least the 1.3.331 “…Added fuses value-groups”. Then close AS7 and restart it.

Now invoke “Tools->Device Programming”. Under Tools, select J-Link (or the Atmel Debug Chip).

If the boards and debug pod are connected and powered, you should be able to select the device and SWD as the Interface, and then click “Apply”. Click on the “Fuses” label on the left hand pane, then scroll down on the “Fuse Name” section until you see USER_WORD_0.NVMCTRL_BOOTPROT. It should have the value 8192 bytes. This means that the first 8K bytes of the flash is reserved for the bootloader, and cannot be overwritten.

Click on the dropdown menu, and select “0 bytes”, then click “Program”. If all goes well, you should see the “Verify…OK” message. This process is reversible: you can find the bootloader image on the respective sites, and after you re-program in the bootloader, you can set the boot protection size back to 8192 bytes. Enjoy!

Scroll to Top