ATSAMD21 Programming

Hello, I am trying to create an Arduino Compatible Development board using the ATSAMD21. However, when going through the insanely long datasheet, I noticed that there are no clearly defined pin numbers and functions.

I believe that the boot loader sets the pin functions? If so, how can I do that? I need multiple UARTS for my design.

Is there a default configuration? If so, how can I modify it because I need 3 UARTS.

Finally, how would I boot load the board? Do I need an external programmer or can I use another Arduino? And, which pins would I connect to and how?

Thank you!

nathancrane243:
Finally, how would I boot load the board?

That information is in the insanely long datasheet. Have you tried to do what you want to do, with an off the shelf ATSAMD21 board? Just to get started?

Have you designed any boards before? This is really a difficult project for a beginner.

nathancrane243:
Is there a default configuration? If so, how can I modify it because I need 3 UARTS.

The SERCOM ports are software-configurable. See: Overview | Using ATSAMD21 SERCOM for more SPI, I2C and Serial ports | Adafruit Learning System

You want Section 7 "I/O Multiplexing and Considerations."

See also: My spreadsheet that puts some of that info into a form (perhaps inaccurately) where you can re-sort on different columns and such.

And the pin mapping that Arduino uses, usually located in one of the variants/* files

Thank you for your feedback.

Do you know if there are any preexisting boot loader files that I could modify? Or any further documentation since this chip is very popular?

Also, what would I use to program that chip. I've seen people use an something called an ICE? And how would I connect it to the boards?

Finally, how do large companies like Arduino boot load all of their products?

nathancrane243:
Do you know if there are any preexisting boot loader files that I could modify? Or any further documentation since this chip is very popular?

Well, the MKR ZERO uses it.

nathancrane243:
I believe that the boot loader sets the pin functions?

No, the bootloader doesn't set the pin functions. That is done by the code in the hardware core:

most especially the variant files that westfw linked to already.

The Arduino bootloader is used to flash compiled binaries to the ATSAMD21G18 via a USB CDC serial port.

nathancrane243:
can I use another Arduino?

Yes. You can turn an Arduino into a programmer using the Adafruit_DAP library:

nathancrane243:
And, which pins would I connect to

SWCLK, SWDIO, and RESETN

nathancrane243:
And, which pins would I connect to and how?

Jumper wires and traces on your PCB.

nathancrane243:
Do you know if there are any preexisting boot loader files that I could modify?

The bootloader files are here:

nathancrane243:
Finally, how do large companies like Arduino boot load all of their products?

You can buy microcontrollers pre-flashed. I see that Microchip Direct doesn't offer it on this particular part. Distributors may offer their own service. For example:
https://www.digikey.com/en/resources/value-added-services/index

I don't know whether Arduino does that. The programming may be integrated into the testing process. The board is put on a test stand, flashed with the bootloader, then with a test program. You can see a video of a Zero being tested here:

The Zero has an onboard EDBG programmer, so they could be flashing the bootloader to the ATSAMD21G18 via the USB connection. On the ATSAMD21G18 boards without an EDBG like the MKR boards, the test stand would need to have an integrated programmer that connects to the SWD pads on the bottom of the board.

Do you know if there are any preexisting boot loader files that I could modify?

Sure. Arduino has a bootloader, Sparkfun has a bootloader, Adafruit has a bootloader - all open source, and most based on the Atmel SAM-BA bootloader, which is an app-note.

Also, what would I use to program that chip.

ATM "SWD" debugger. Atmel ICE, PICKit4, Microchip SNAP (cheap!), Seger Jlink, etc...

SWCLK, SWDIO, and RESETN

Also GND and usually Vcc (for the programmer to sense the target voltage.)

Here's a picture of a PICKit4 connecting to a SAM board. It happens to be a SAMC21 rather than a SAMD, but loading/debugging is the same.

Thank you so much!

I have a few more questions...

First of all, I was comparing the mkr boards schematics to the variants files and I noticed that the pin numbers do not match up. Why?

Also, I noticed that not all of the 48 pins are defined so could I add more functions?

Finally, what files would I use with the Atmel Ice to boot load the board using the pins SWCLK, SWDIO, and RESETN?

Thanks again!