For those of you who have used the SAMD21 from sparkfun and are looking to burn a custom bootloader to the ATSAMD21g18 chip microcontroller unit (MCU) or develop your own printed circuit board application, this instructables page will take you through the necessary steps for burning the bootloader operation.
This instructables will show how to bootload a SAMD21 Development Board sold by Sparkfun Electronics and will also give you some insight on how to burn a bootloader for other ATSAMD21g18 devices such as the Adafruit Feather M0 and the Arduino Zero.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Materials Needed
This instructables page will assume you have some soldering experience. If you don't, no worries there is only one component you need to solder together. Below is a video for an introduction on how to solder made by electronhacks on youtube.
Here is the link for a soldering station I would recommend buying (no solder included):
---Required Materials ---
All of the materials for this tutorial can be bought from ww.digikey.com
- J-Link EDU (or any other SWD compatible programmer)
- Olimex JTAG 20 PIN 0.1" TO 10 PIN 0.05" adapter
- 10 Positions Header Connector 0.050" (1.27mm) Through Hole Gold
--- Required Software ---
The Arduino IDE https://www.arduino.cc/en/Main/Software
You will also need to download Atmel Studio. I use version 7 of ATMEL Studio.
Step 2: Understanding Bootloader and Serial Wire Debug (SWD)
This may seem like a daunting thing to understand, but this is important for those of you who are looking to use the ATSAMD21g18 chip for printed circuit board applications.
So what is a bootloader? Well a bootloader is a small code that allows you to upload firmware (source code) that makes your microcontroller adaptable for different applications. When you buy the ATSAMD21g18 chip from a electronics vendor such as digikey, you will need to do whats called "burning the bootloader" to make it compatible to program over the arduino IDE.
--Serial Wire Debug (SWD)--
The ATSAMD21g18 chip uses an ARM Cortex-M0+ processor and can be programmed through Serial Wire Debug (SWD). Programming through SWD requires an external programmer such as the J-link EDU or ATMEL ICE BASIC. Most ARM Cortex-M based processors require an external programmers.
For the SAMD21 development board there is a 10 pin interface for SWD. While not all the pins are required, these are the essential ones:
- VCC - 3.3 V power
- GND (two separate pins) - ground
- SWDCLK - Clock
- SWDIO - Bidirectional Input/Output
Step 3: Hooking Up Everything!
- The very first thing you should do with the SAMD21 development board is to solder the 10-pin interconnectors to your board. In my case, I ran out of interconnectors and manually soldered on the individual pins I required. I would recommend against this since it does require a lot of fine soldering and taking things apart.
- From there, plug in your olimex J-link adapter to your J-link EDU debug probe and attach the 10-pin IDC ribbon cable which came with adapter.
- Plug in the other end of the ribbon cable to your SAMD21. Note that the red wire on the ribbon cable should be on the side labeled as 3.3V on the SAMD21 board.
- Plug in both your SAMD21 board and your J-link EDU to your computer's USB ports.
Step 4: Erasing ATSAMD21g18 Chip
For burning the bootloader, we need to use ATMEL Studio. Once you have it opened, go to tools > Device Programming (or Ctrl+Shift+P).
The Device programmer window should open.
- On the top bar of interface settings, under tool click on J-link or the debugger you are using.
- Under Interface select SWD and click Apply.
- Click Read Device Signature make sure target voltage is 3.3V
- Click on Device memories and select erase chip.
You should get something in the output terminal that says "Erase...Ok"
Step 5: Burning the Bootloader
Follow the link to the Sparkfun Github Repository and download the zip file and unzip it to your preferred destination.
- Click on Fuses and select program. This verifies the internal registers of the ATSAMD21 chip.
- Finally to burn the bootloader, click back on Device memories. Under the bar labelled flash, click on the browse for file icon and find the folder where you extracted the zip file you got from github labelled "SAMD21_Dev_Breakout-master" Under Firmware, make sure you search for all file types as we will using the samd21_sam_ba_sparkfun.bin file. Click on the file and select open. Finally, select program right next to flash and you will get a response in the output prompt saying: "Verifying Flash...OK" . Congratulations you have successfully bootloaded the SAMD21 chip!
Participated in the
Microcontroller Contest 2017