I recently got a low-cost ARM Cortex M0 based ( Atmel SAMD21G18A ) board , a clone of the Robotdyn SAMD21 M0-mini board and wanted to make a custom Arduino IDE compatible bootloader using the Atmel Studio IDE – it has the GNU-ARM toolchain built in.
The user L-LED was not mounted, so the RX- and TX-LEDs could be used as bootloading progress indicators. It turned out that a fresh installed Arduino IDE is able to add GNU ARM Cortex M0+ toolchain for various Arduino boards that uses the Atmel SAMD21 microcontroller.
Steps involved to make the custom bootloader are these, assuming Windows 10 is used:
- Download the Arduino IDE v. 1.18.13 from here: Arduino IDE , do not use Microsoft App Store to inatall the Arduino IDE.!
- Install to the default installation path: C:\Program Files (x86)\Arduino
- Select Tools -> Board -> Boards Manager . Scroll down to find and install the Arduino package: Arduino SAMD Boards ( 32 bits ARM Cortex M0+ ). After installation , goto Tools -> Board and select the Arduino MKRZero board :
- Close the Arduino IDE. Bootloader source code for the bootloaders shown for the Arduino SAMD boards are found in the path: C:\Users\foo\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.9\bootloaders , replace foo with your Win 10 user name , and enable “show hidden files” in Explorer View. Contents of the bootloaders folder:
- Download and install the Atmel Studio IDE ( I used version 7.0.2397 ) from here: Atmel Studio download
- The zero folder holds the source files for the Arduino SAMD21 bootloaders. Copy the zero folder to: C:\Users\foo\Documents\Atmel Studio\7.0 , foo is your user name.
- Open the zero folder in C:\Users\foo\Documents\Atmel Studio\7.0 , foo is your user name. In the zero folder find and click the samd21_sam_ba.atsln Atmel Studio project file:
- Atmel Studio starts the project . Press F7 to build the bootloader:
- Some Warnings will show, but the “Build succeeded.” is OK. The bootloader .hex file from the compilation is found in the folder from step 7 and can be flashed to the SAMD21G18A microcontroller via the on-board SWD connector. At this point a customized Arduino compatible SAMD21 bootloader can be made by modifying the files in the Atmel Studio project to fulfill the actual needs. I made a bootloader version that used the RX- and TX-LEDs to indicate, that the bootloader is running. This version of the bootloader is here: SAMD21 custom bootloader. A small demo video is to be seen here: Youtube ldr
- To flash the bootloader, refer to the blog: Atmel Studio 7 and SAMD21 – ARM Cortex M0+