Zero Bootloader question

Hello,
I can not find this information anywhere so I ask here:

I thought that the Atmel SAM-D MCUs are factory-equipped with a bootloader by Atmel (SAM-BA).

When I read the Arduino documentation for the Zero I would think that the Zero is equipped with an Arduino-made bootloader (and the USB VID defined in the drivers inf-file for the Zero is the one owned by Arduino).

So i really wonder what’s right?

Thanks for your answers.

the SAMD21 series is not factory equipped with Atmels SAM-BA --> http://www.atmel.com/Images/Atmel-42366-SAM-BA-Bootloader-for-SAM-D21_ApplicationNote_AT07175.pdf (see 1.2.1 in this document)

You can do it by yourself - the bootloaders are here: --> http://www.atmel.com/images/Atmel-42366-SAM-BA-Bootloader-for-SAM-D21_ApplicationNote_AT07175.zip --> mirror: on github

On the Arduino Zero it is done already.

So you can use the "native USB Port" on the Zero together with the BOSSA flash tool --> https://github.com/shumatech/BOSSA/tree/arduino --> Win Installer (.msi) for "BOSSA 1.5-arduino" with gui (alternatively you can use the Atmel SAM-BA flash tool as well)

The Arduino IDE uses the BOSSA flash tool too (in a command line variant called "bossac"), if you select "Arduino Zero (Native USB Port)" as your board in the Arduino IDE.

I want to add that on the Zero board we are using a modified version of the sam-ba bootloader to improve upload performance.

You can find the source code here: https://github.com/arduino/ArduinoCore-samd/tree/master/bootloaders/zero

and if you are curious the list of patches is here: https://github.com/arduino/ArduinoCore-samd/commits/master/bootloaders/zero

basically we added three new commands to the bootloader to perform: - Full flash memory erase in one single command - Multiple pages write in block - Verify through CRC (no need to resend the whole sketch)

We needed to patch also "bossac" that now is able to detect if the bootloader implements these features (or fallback to the "slow" standard sam-ba protocol).

ah, thanks, that's very interesting,

cmaglie: I want to add that on the Zero board we are using a modified version of the sam-ba bootloader to improve upload performance.

is it 4kB or 8kB big ? (do you use "SAM_BA_USBCDC_ONLY for only USB CDC interface" or "SAM_BA_BOTH_INTERFACES for enabling both the interfaces")

cmaglie: You can find the source code here: https://github.com/arduino/ArduinoCore-samd/tree/master/bootloaders/zero

is the file "samd21_sam_ba.bin" from this location a "ready to burn" bootloader for empty stock Atmel Chips SAMD21G18. (burn with the "Atmel ICE" for example ?)

cmaglie: We needed to patch also "bossac" that now is able to detect if the bootloader implements these features (or fallback to the "slow" standard sam-ba protocol).

are this patches present in this github branch https://github.com/shumatech/BOSSA/tree/arduino already ? (if not where may I find it ?)


If I read your post right I suppose that there is still a "cross-compatibiliy" of (MCU-side) bootloaders an (PC-side) flash tools (?) - the modified arduino bootloader (MCU side) can still work with the "normal" BOSSA Tool and even work with the stock Atmel "SAM-BA" flash-tool ? - the patched bossac tool (from Arduino IDE 1.6.5) cann still work with the old (unmodified) stock Atmel SAM-BA Bootloader on the MCU-side ?

Dirk67: is it 4kB or 8kB big ? (do you use "SAM_BA_USBCDC_ONLY for only USB CDC interface" or "SAM_BA_BOTH_INTERFACES for enabling both the interfaces")

8Kb, and uses SAM_BA_BOTH_INTERFACES

Dirk67: is the file "samd21_sam_ba.bin" from this location a "ready to burn" bootloader for empty stock Atmel Chips SAMD21G18.

Yes, we use it for the "Burn bootloader" command of the Arduino IDE.

Dirk67: are this patches present in this github branch https://github.com/shumatech/BOSSA/tree/arduino already ?

yup, you can find most (probably all of them) on the commits on Apr 21, 2015 https://github.com/shumatech/BOSSA/commits/arduino

Dirk67: If I read your post right I suppose that there is still a "cross-compatibiliy" of (MCU-side) bootloaders an (PC-side) flash tools (?) - the modified arduino bootloader (MCU side) can still work with the "normal" BOSSA Tool and even work with the stock Atmel "SAM-BA" flash-tool ? - the patched bossac tool (from Arduino IDE 1.6.5) cann still work with the old (unmodified) stock Atmel SAM-BA Bootloader on the MCU-side ?

yes any combination should work (I say should because I didn't tried every possible permutation of CPU/Bootloader, but for me it's working so far). The trick is that the bootloader advertise his features in the version string and bossac uses the extended features only if available:

https://github.com/shumatech/BOSSA/blob/arduino/src/Samba.cpp#L115

Hi, Is there any chance a tutorial comes up with instructions on how to burn the bootloader? I mean something that could be written for beginner. I would really be interested in such a document describing procedures, software and hardware requirements.

Regards AloyseTech

just use the "Burn bootloader" command of the Arduino IDE :grin: or do you mean: burning it to a "naked" SAMD21G18 Chip from stock ?

I may plan to do a custom board to fit a hand held device design. I would like to use the native USB port to upload code so I don't have to put another chip like the 16u2 on my board. Let's say I have just my samd21 on this board with the sub connector. How can I burn the bootloader ?

please read here
“building your own board”
GitHub - femtoduino/femto-usb: FemtoUSB - ATMEL ARM Cortex M0+ (SAMD21), 256KB @ 48MHz, 3V3

just the USB-port on your custom board is not enough,
you need a “Cortex Debug Connector (10- pin)” [0,05" micro spacing pin header]
(as you can see on the zero board as well).
http://infocenter.arm.com/help/topic/com.arm.doc.faqs/attached/13634/cortex_debug_connectors.pdf

It works of course with the (free) Atmel-Studio and an ATMEL-ICE programmer (~ $90)
(–> http://www.atmel.com/tools/atatmel-ice.aspx )
(ATMEL-ICE is capable for debugging purposes as well [not just for “flashing”])

but I think there are other solutions that are more simple and cheaper (and open source)…

maybe some other experienced guys can give answers …

There is no alternative to the ATMEL ICE? Like an arduino as ISP but arduino as ATMEL-ICE? Or the arduino is to slow?

AloyseTech: There is no alternative to the ATMEL ICE?

why ? too expensive ?

it's a good part: - you can use it right out of the Arduino IDE as well - you may use it as a debugger as well - it can flash other 8bit & 32bit AVR's as well as ISP - it can flash even the Attiny's

there is a cheap bare PCB Verrsion of it / around $30 net --> http://www.newark.com/atmel/atatmel-ice-pcba/debugger-programmer-arm-avr-mcu/dp/45X9868?ost=ATATMEL-ICE-PCBA Europe: https://hbe-shop.de/Art-2407171-ATMEL-ATATMEL-ICE-PCBA-DEBUGGER-ATMEL-ARM-AVR-PCBA-KIT France: http://fr.farnell.com/atmel/atatmel-ice-pcba/debogeur-atmel-arm-avr-kit-pcba/dp/2407171

--> http://www.farnell.com/datasheets/1835727.pdf

.

Yes, I always try to find the cheapest alternative... This pcb version looks good. Thanks for your help Dirk67 :)

Also to note - the Arduino Zero has a breakout for the 10-pin Cortex header - I believe (you may have to remove some resistors on the Zero PCB) that you can use the Arduino Zero as a programmer too.

I don't own one (yet) so this is just conjecture, and assumptions based on looking at the schematic for the Arduino Zero. Perhaps someone on the Dev team, or an owner of the Zero, may be able to confirm this for you?

I'd asked the Zero Pro guy about using the Zero as a programmer but he didn't seem to think it was possible. I could have sworn the Arduino team said at one point it could be. But he said the EDBG couldn't program multiple chips connected to it at the same time.

I believe the EBDG is the type of programmer that uses two ways comms, which would indeed make it impossible to connect to multiple chips at the same time.

However, the schematic for the Zero (I haven't checked this on the Zero Pro) shows that the 10-pin Cortex Debug header - not the one to program the EBDG, the other one - is connected as it should be to PROGRAM the on board D21... Which also means it's in parallel with the pins the EDBG uses to program it in the first place.

This means it's (probably) possible to program the on board D21 with this header, but I also remember seeing some 0R resistors somewhere along the line. I believe they are connecting the lines from the EDBG to the D21, and removing them would take the on board D21 out of the equation, whilst keeping the 10-pin header connected to the EDBG.

If this is the case, simply removing these resistors would allow you to target an external board (as I believe was the original intention). It's then down to the EBDG firmware as to whether it can target only D21G18's, the entire D21 range, the entire SAMD range, or even a wider range than that.

The Zero Pro schematic is different from the Zero, however if it was designed properly then it should still have the 0R resistors - otherwise the second 10-pin header would be completely redundant.

Ah, yeah... there were some 0 ohm resistors there I noticed when designing the Neutrino. I couldn't fathom why they'd be there but that makes a lot of sense.

Hi. I`m reading this thread, and i just throwed my design in to bin. Would JTAGICE3 + arduino ide be ok to load bootloader onto SAND21 bootloader?? Never ever done this in my life so not sure where to start.

scswift is the "Neutrino" preburned with bootloader??

thank you.

mOskit:

Yes, the Neutrino comes with the Zero's bootloader pre-installed. I use the Atmel ICE to load it.

that jtagice3 i have dont seems to have SWD interface. Any suggestions on how to load bootloader onto ic with programming socket?? if needed ill buy Atmel ICE as you have

UPDATE: Atmel JTAGICE3 is compatible with SAM ic after firmware ugrade.

Hate to potentially go over old ground here, but is it ever going to be possible to get up and running with a SAMD21 in my own project as quickly as it is with an ATMEGA328P?

Right now, I pop my 328P chips onto a custom-made PCB, and connect up my Uno and flash the boot loader. I remove them from the boot loading PCB and put them into my project PCB where just the TX/RX/RESET pins are exposed and away I go.

The method with the SAMD21 as I understand it goes something like this:

Buy a $90 part from Atmel Download and compile my own boot loader (I'm on OS X) Load this onto the chip Place this chip in my project PCB and expose certain pins (still not entirely clear which ones) Can't use my Arduino as an ISP so have to keep the $90 ISP around.

Is this going to change or become more streamlined in the future? Is it ever going to be possible to flash the boot loader using an Arduino on OS X?

I don't need fancy step-through debugging because I'll just be reusing my old Arduino Uno code for the most part, just with a faster chip with more interrupts and better floating-point capabilities.