Menu Close

Programming bootloader on SAMD21

What a adventure!

I have this project where I wanted to use the SAMD21 because I need more RAM then Arduino 328 and has build in Real Time Clock (RTC). I started my project using Sparkfun SAMD21G Mini Breakout. I need to be very low energy (uA) . So I decided to make bare minimum SAMD21 and found this 
http://www.technoblogy.com/show?2833

I tried to flash using the Sparkfun Mini to program my brand new SAMD21 and that did not work.

I then found this user who had the same issue as me

I had trouble burning the bootloader for any SFE samd21 boards and replaced the OpenOCD sketch upload section of sparkfun samd21 package platform.txt, with the the one from the aruduino samd platform.txt and that seemed to have allowed me to burn bootloaders.
https://github.com/sparkfun/Arduino_Boards/issues/57

well that did not work so I decided to get the Segger programmer for 30$ on digikey. I said that the amount of time I lost trying to figure out how to flash bootloader was worth the 30$ (+8$ shipping) But guess what, the segger was not straight forward as I thought.

First I followed Adafruit instructions here
https://learn.adafruit.com/how-to-program-samd-bootloaders/programming-the-bootloader-with-atmel-studio

All the hardware is good but when it’s time to read the chip, I got this

I double check everything, power supply, wiring, decoupling cap, etc.
Until I realise that the image from adafruit website show the wrong way to connect the flat cable on the Segger!

I flip the cable, burn the bootloader and boom got it working!

not really, I had to one issue when I burn the bootloader. We need to write 0x07 in the BOOTPROT but I can’t!

I just keep programming like it was nothing… then after flashing I need to write 0x2 in BOOTPROT but I can’t! It’s the drop down menu and can’t write anything in it.

lol

Once everything programmed, I plug USB in computer and “sorry device not recognized“. (Slap in face) I disconnect USB or I rebooted… can’t remember. What I can tell you is that since I installed Atmel Studio and Segger, my computer as crash/frooze 3 times in less then 1 hour! Yep.

After booting, it recognize the Trinket M0 and I was able to flash it. I did however had to press reset button twice to enter bootloader. Which I sort of been doing since I started with SAMD21… I did install the windows driver that fix that issue for 1 day. (I could just keep click programming in Arduino IDE without double tapping reset button)

Here it is! 50ms ON, 2000ms OFF!

As you can see, no need to have the 32khz oscillator! I do need that 10uF cap and will but more decoupling cap, it’s very unstable if I move breadboard with all my crappy wires.

I will now move to step 2 of this project, connect all the other peripherals.

Leave a Reply

Your email address will not be published. Required fields are marked *