Go Down

Topic: Atsamd21g18 Bootloader (Read 12667 times) previous topic - next topic

sifbor

Hi,

how do I flash a Bootloader on an ATSAMD21G18 with nothing on it (fresh from the factory)!

Is it really necesarry to use a Atmel ICE or ist there a way to use the Arduino Uno as ISP?

Thanks in advance:)

MartinL

Hi sifbor,

You'll need an Atmel ICE. I bought the Atmel ICE Basic, it costs about the same as an Arduino Zero.

If you're making a custom board, then you'll need to include the 10-pin SWD header, so that the Atmel ICE can connect to the SAMD21 micro-controller. Once you've connected the Atmel ICE, you can use the Arduino IDE to burn the bootloader.

There's no way to use the Arduino Uno ISP for ARM boards such as the SAMD21.

sifbor

Hi MartinL,

thank you for your quick and informative reply.
Is it correct, that I can use the Arduino/Genuino Zero Bootloader?
If yes, can I programm the micro-controller using the native USB-Port?

Thanks:)

MartinL

Hi sifbor,

Quote
Is it correct, that I can use the Arduino/Genuino Zero Bootloader?
Quote
If yes, can I programm the micro-controller using the native USB-Port?
The answer is yes to both questions.

Once you've uploaded the bootloader using the Atmel ICE you can remove it and thereafter program the SAMD21 using it's native port.

MartinL

#4
May 19, 2016, 10:05 am Last Edit: May 19, 2016, 10:19 am by MartinL
I've also recently managed to get the Arduino Bootloader to work successfully with the larger SAMD21J18A, that has 14 more IO pins and 2 more timers (TC6 and TC7) than the Zero's SAMD21G18A.

I just thought it might be useful to know, if you happen to be making your own custom boards and your project requires more IO than the SAMD21G can provide.

All I needed to do was to change the __SAMD21G18A__ definition to __SAMD21J18A__ in the Zero's "boards.txt" file and add the extra pins to its "variant.cpp". (It even worked without these changes, provided I only used the same pins as the Zero).

I'm now working on adding this custom board to the IDE's Boards Manager, as it will save me having to change these files everytime I want to go back using the Zero. All I know at the moment is that it has something to do with JSON files.

AloyseTech

Hi Martin,

Take a look here for a samd21 core, with J18A variant and with .json file implementation :
https://github.com/AtmelUniversityFrance/atmel-samd21-xpro-boardmanagermodule/releases

MartinL

#6
May 19, 2016, 03:17 pm Last Edit: May 19, 2016, 03:37 pm by MartinL
Hi AloyseTech,

That's really useful. Looks like the source code contains everything you need to get the SAMD21J set-up and running with the Arduino IDE.

Thanks for the link.

Martin

AloyseTech

Looks like the source code contains everything you need to get the SAMD21J set-up and running with the Arduino IDE.

I confirm this ;)

jecottrell

Can I reflash the bootloader through the Arduino IDE with the ATMEL-ICE? I got the impression from reading somewhere, that reflashing requires resetting some fuse bits that is not possible with the Arduino IDE.

Also, in my programmers tab...

Atmel EDBG
Atmel-ICE
Atmel SAM-ICE

Appear three times. Is there any way to clean that up?

Thanks,

John

jecottrell

Was finally successful reflashing bootloader via AS7. First hurdle cleared.

This was what got me about 90% of the way:
http://www.arduino.org/learning/tutorials/advanced-guides/how-to-burn-the-bootloader-on-an-arduino-m0-using-atmel-studio

But, the bootloader they use in the demo won't load on the Sparkfun SAMD21 Mini Breakout. It said the file type was incompatible. That got me confused that it was .hex vs. a .bin issue. But in the end, it must have been something else. Sparkfun doesn't have a .hex of their bootloader available and looked like I was going to have to compile my own. But, the Adafruit Feather m0 bootloader worked fine.

MartinL

Hi John

Quote
Can I reflash the bootloader through the Arduino IDE with the ATMEL-ICE?
Yes you can.

Quote
But, the bootloader they use in the demo won't load on the Sparkfun SAMD21 Mini Breakout. It said the file type was incompatible. That got me confused that it was .hex vs. a .bin issue. But in the end, it must have been something else. Sparkfun doesn't have a .hex of their bootloader available and looked like I was going to have to compile my own. But, the Adafruit Feather m0 bootloader worked fine.
Your issue could be do with the fact that Arduino.cc and Arduino.org use different bootloaders. The Arduino.cc uses a modified SAM-BA bootloader for their Arduino/Genuino Zero, while Arduino.org uses the STK500v2 for their M0/M0 Pro.

The consequence is that the Zero and M0/M0 Pro are incompatible each other's IDEs unless you first burn the corresponding bootloader.

SahanaSwee

HI ,
 

Am new to arduino M0. We had bought the chip alone from Digikey.
I had given the Native USB connection as it in schematic.
I need to bootload the chip(ATSAMD21G18 chip).
We had soldered in the conversion board and necessary connections had been made.


Can any one help me please...


Thanks in advance.

MartinL

#12
Jul 11, 2016, 03:09 pm Last Edit: Jul 11, 2016, 03:14 pm by MartinL
Hi SahanaSwee,

If you've got a custom board, then you'll need to burn the bootloader using the Atmel-ICE connected to your board's 10-pin SWD port. The Atmel-ICE costs about the same as an Arduino Zero, I bought the Atmel-ICE Basic.

The procedure is as follows:

1) Start the Arduino IDE, in the menu go to Tool->Board and select "Arduino/Genuino Zero (Native USB Port)".
2) Connect the Atmel-ICE to your board's 10-pin SWD port.
3) Plug the Atmel-ICE's USB cable into your PC or laptop.
4) Plug in your board's USB cable into your PC or laptop.
5) In the Arduino IDE's menu go to Tools->Programmer->Atmel ICE.
6) Then in the menu go to Tools->Burn Bootloader.
7) After the bootloader's been burned, unplug your board's USB followed by the ICE's USB.
8) Remove the Atmel-ICE from your board's SWD port.

You should now be able to just connect your board's native USB port and upload sketches using the Arduino IDE, (without the Atmel-ICE).

arzaman

Hi

I have a custom developed device with SAMD21G  MCU and SAM-BA bootloader on top (SparkFun version)
I have experience lot of issue and instability using the Arduino IDE and the BOSSAC programmer over USB to load executable on the flash  and sometimes I got error in uploading sometimes in the verification phase..sometimes the load is ok but the code is corrupted

I check USB cable , I tried different HW (windows based)‚Ķbut the issue is quite random  and also sparkfun report issue on the  SAMD21 USB-to-Serial converter and programmer and my impression is that the tool chain (arduino IDE + bossac + SAM-BA bootloader) is quite fragile !

https://learn.sparkfun.com/tutorials/samd21-minidev-breakout-hookup-guide/troubleshooting

Don't know if there are more "stable" and performant bootloader (native zero bootloader?) but I would like to change approach moving to a MSD (mass storage device) bootloader with just drug and drop of the .bin file in the flash memory but in the same time would like to keep a certain compatibility with Arduino IDE

Is there any way after sketch compilation via IDE to export/copy the .bin executable file in a specified folder  (the emulated flash disk) ? maybe using a "custom programmer" that just copy paste the .bin generated file to the target folder

Idea is to use IDE for compilation and that use a drag and drop approach of the .bin file with a MSD bootloader

Any idea how to do or experience?

Br
Davide

AloyseTech

#14
Aug 01, 2016, 09:35 pm Last Edit: Aug 01, 2016, 09:37 pm by AloyseTech
Justin Mattair has ported an MSD bootloader to the Samd21 chip. You can find it here. You'll need an Atmel ICE (or any other JTAG programmer) thhough.
To "generate" the binary file from you program, click on Sketch->Export Compiled Binary. It will put the .bin file in the same folder as the Arduino program.

Go Up