Problem using/understanding zero bootloader

Hi.

First, thx to arduino community for great work :slight_smile:

I have an homemade adafruit m0 (it was out of stock so I assembled one :blush: ). It works great, I burned their bootloader with AS7. Upload using native port in arduino + adafruit definition is ok, blink sketch works fine.

But I have designed my custom board (adafruit m0 board was a test to be more confident as I'm new to 32bit atmel..32bit in general except esp).
My new board is based on ATSAMD21E17. Only one usb port for native, there is a ws2812 on PA15 (maybe not the best choice??).
For this custom board, again, I have no problem to burn a bootloader with AS (I'm using a segger ob) but I was thinking, perhaps I was too naive, that would work in arduino ide. Not my case, still too noob lol.

But when I try to upload I get : No device found on COM14

What am I missing here? Can you point me to the right direction please?

I tried to compile samd21_sam_ba.atsln from ArduinoCore-samd/bootloaders/zero at master ยท arduino/ArduinoCore-samd ยท GitHub but I get an ugly : sam.h no such file or directory
And I'm not sure if compiling it for atsamd21E17 would be ok ??
I know that I won't always need a bootloader (as I have a jlink tool) but that could be useful and would like to understand my mistake.
Thx in advance for your help and time :wink:

no answer what is missing when using atmel sam ba??

It's solved using another bootloader :slight_smile: I will try to understand what I was missing but it's fine for me now.cool.

Which bootloader solved the issue?

The sam.h file can be found here:
https://forum.arduino.cc/index.php?topic=382953.0

It appears that to get the Zero bootloader to work with this chip, it needs to be modified. There are some references to a "magic number" for double tap reset detection which points to the end of RAM. But the end of RAM on an e17 is not at the same location as a g18 because the former has half the RAM.

Also, the linker script for the bootloader references the amount of RAM on the processor because the stack begins at the end of RAM and grows downward. This will probably also affect your compiled application if the boards file isn't modified to specify the correct processor.

In other words, this processor requires both a unique bootloader and a unique board definition in the IDE to make it work properly.

I too am working with the SAMDE17A and will be attempting to compile a bootloader for it soon. I'll share my results when I get it working.

@scswift: thx for your answer and these interesting infos :slight_smile: Glad to talk to you, your neutrino seems a nice board :wink:

I understand about pins definitions etc and different chips/boards.. but the one I tried first was Atmel sam ba for ATSAMD21E17 (.hex provided on zrecommerce github, but originally from atmel). But it was not working, perhaps because I didn't have good board def, (and arduino core???) and usb drivers. About usb drivers I need to look how that works too...seems if I use adafruit m0 and for fun/test upload sketch with Zero board, it change the name of my device in windows (I know it's interchangeable but not recommanded because of mapping, that just was dumb tests).

I read your problem with atsamd21e17. This is what helped me to find the right bootloader. thx :slight_smile: So to answer, I am using Mattairtech ATSAMD21E17 bootloader and boards def. There is also e16 and e18, and he seems to work on L21 family which was the first reason why I moved to atsam "zeros" (for non pico, I am waiting esp32..), so L21 ->more mem than 328p, cheaper than 1284p. I'm learning there are cons to move to 32bits (I knew it). Like for instance board defines in libs, timings etc...mattairtech does not seem to be detected as Zero but as a dedicated board (maybe I'm wrong but I had to add some define in some of my libs). Now, I need to dig and understand sam ba...

And if you want to know, I'm using 15pf :wink:
I can't wait to see your results! Just curious, do you have a github??

See you soon

I was also unable to get the sam-ba bootloader to work with the IDE. I'm not sure why. I altered the boards file to have the correct processor type and VID/PID, but it still did not detect the board on the COM port. I'm pretty sure either a comment somewhere in the code, or on this forum by one of the creators of the Arduino it was said that the Zero bootloader was just an optimized version of SAM-BA and that either one would work with the IDE but that seems not to be the case.

It's unfortunate to hear you had to alter some of the libraries to detect the board as a Zero. I guess that's something I will look into. I believe it may be possible to just alter the Zero's boards file to add some variants to it. I don't want to have to distribute a bunch of libraries with one slight change to the defines just to make it work with the IDE. Though it seems that's what they intended for people to do. Maybe I can make a distribution with all the unmodified libraries but keep the Zero name in the board definition so all those files don't need to be altered, because it would be a real pain if every time there was an update I had to alter all the source files anew when the hardware is practically identical.

And if you want to know, I'm using 15pf :wink:

I'm using 22pF caps on my board. Adafruit uses 22pF on their M0 board as well. I don't know that 22pF is the best value, but it seems like the most popular choice.

And no, I don't have a github yet.

I too have the exact same problem. I also built my own board with an ATSAMD21G18 and modeled the schematic after the arduino zero. I could not load that bootloader in atmel studio, but i could flash the adafruit feather m0 bootloader.

Arduino IDE would not flash the board though, could not detect it. Here's whats weird. After a few minutes of double tapping the reset button, arduino IDE finally flashed sketches successfully as long as i double tapped the reset button very fast. This worked for a few weeks.

Then i just built a replicate board, and now i'm stuck unable to use Arduino IDE. no amount of double tapping works.

The strange behavior is that the board appears on COM11. When it worked, the double tap would re-appear on COM12. Successful flash, then back to COM11.

Now my newest board only stays on COM11. Its like the double tap is gone, but i'm using the same hex file as before "featherm0bootloader_160305.hex."

So summary, built 2 identical boards with a SAMD21. flashed the same bootloader file to each board, one works with reset the other does not. Now the reset button does reboot the device, but it just doesnt kick into bootloader mode or whatever they call it. very weird.

Also to the person who had "no file sam.h" errors in atmel studio. To solve those issues you have to link to the arduino core files for SAMD21. I went thru each file that gave an error and changed the link of the include files. Point to where they are in the arduino folders...

I've just built two custom boards, one using the SAMD21G18A and the other using its larger sibling the SAMD21J18A, both accepted the Arduino Zero bootloader with any issues. The bootloader was uploaded using the Arduino IDE and an Atmel ICE connected to the board's SWD port.

When I've had connection issues it's usually been my soldering that's at fault. Although, I recently experienced a similar issue, only being able to upload by forcing the board into bootloader mode using double tap. It was either moving to the lastest Zero (1.6.5) and Arduino IDE (1.6.9) builds, or adding the line:

while (!SerialUSB);ย  ย   // Wait for the native USB port to be ready

...after SerialUSB.begin() in my sketch that worked. I can't recall which of the two solved it, but things went back to normal after making the these changes.

Has anyone had any success uploading sketch from Arduino IDE with an ATSAMD21E17D? I'm having a similar issue which i post at here.