PROGRAMMING ATSAMD21 on PCB without Ard Uno Board

Hello creators: I would like to create a PCB with ATSAMD21G18A to measure the signal from an IMU via i2c and solder a USB type C port for programming on the Arduino IDE (so I have a single board to take me to the lab). is there a way to program and upload the codes without using an extra Arduino for the bootloader? if there is a bootloader to be soldered directly on the PCB so as to avoid carrying an Arduino with me. thanks :slight_smile:

Hi @andreaarcarisi

If you're creating a PCB for the SAMD21, i can recommend reading SAMD21 Datasheet, Section 42. Schematic Checklist.

To program the microcontroller with a bootloader, you'll need to access to its SWD port. The standard programmer interface is a 2x5, 1.27mm pitch pin header like this one:

They're usually available through hole or surface mount (like the one above).

1 Like

now I look on the datasheet thanks. actually my idea was to solder a bootloader on the pcb so that I just need to connect the pcb to the pc and program directly via Arduino IDE. advice?

for example the Seeeduino XIAO

Hi @andreaarcarisi

The SWD port not only allows the SAMD21 to be programmed with the bootloader, but also allows for advanced debugging. However, this requires a programmer, which are available from various manufacturers. Some are relatively cheap, others more expensive.

Once the programmer has loaded the bootloader on to the microcontroller (via the SWD port), only then can the programmer be removed and sketches uploaded directly over the microcontroller's native USB port.

The bootloader itself is just a piece of firmware that sits in a partition in the microcontroller's flash memory and controls the uploading of sketches.

Individual SAMD21 chips ordered from a supplier won't come with a bootloader, therefore once you've soldered them on to your PCBs, you'll first have to use a programmer to upload the bootloader to the microcontroller yourself.

So the necessary steps are if I understand correctly:

  1. I buy the sam21d on a site for example digitkey
  2. weld it on the pcb and weld the SWD port as well
  3. I connect a SWD device on the PCB and load the bootloader
  4. now on I just connect the USB of the pc and the USB of the PCB and load all the programs I want as if it were an arduino

to load the bootloader what steps do I have to do? are there cheap devices to do this?

Hi @andreaarcarisi

Yes, that's the procedure.

Regarding programmers, some implement CMSIS-DAP (Debug Access Port) which implements a standard programmer interface, basically this means that they don't require the installation of any additional drivers. Others require software drivers to be downloaded and installed. Both types essentially do the same job.

I use the Atmel ICE Basic programmer. It implements CMSIS-DAP, but I bought it when they were a lot cheaper than they are today. They might be outdated and replaced by now, I haven't checked.

I've also got a Segger J-Link Edu Mini, it's quite a bit cheaper, but is non-CMSIS-DAP and is only for non-commercial use.

I'm sure that there are others that can point you cheaper programmers than these.

To upload the bootloader binary, I used Atmel/Microchip Studio. It also allows you to see an change the microcontroller's fuse settings, which can be quite useful at times.

1 Like

I'm a little confused, I'll ask some completely ignorant questions: why do they cost so much if in the end you only have to use it the first time to load the bootloader? I found some that cost even €2 and I don't understand what changes.
or because some tutorials talk about using the arduino uno board? that is, in the end my idea is to recreate a single PCB piece as an arduino uno that I connect to the PC and load the files. I apologize in advance if my questions are trivial but I can't find clear and specific guides for such a procedure.

Hi @andreaarcarisi

The SAMD21 uses ARM architecture, whereas the Uno/Nano/Mega etc.. uses AVR. With the older AVR Arduino boards it's possible to configure one board to act as a programmer, to program another. I'm not aware of any similar solution for Arduino based ARM microcontrollers. These require a programmer.

Yes, there's a huge variation in the cost of the programmers themselves. The Atmel ICE Basic used to be quite reasonably priced, but hugely increased when Atmel were taken over by Microchip. The programmers themselves can be used not only to upload the bootloader, but also to debug programs as well, employing some advanced diagnostic features.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.