ATSAMD21

This page gives an overview of the SAMD21 microcontroller present on Tangara's mainboard. We generally refer to this as the 'coprocessor' (probably not an accurate use of this term, but it'll do).

Pinouts

The KiCad schematic is the source of truth for how the SAMD21 is implemented on the mainboard PCB.

The short version is:

PeripheralFunction
SERCOM0SPI (to SD card)
SERCOM1I2C
SERCOM2UART (to ESP32)
DM/DPUSB

All other pins are either unconnected, or used as GPIOs.

Bootloader

If your Tangara was produced by cool tech zone, then it already has a bootloader firmware flashed, in addition to its regular operating firmware.

The source for the bootloader can be found here.

UF2 Flashing

The SAMD21's bootloader supports UF2 updates. This allows you to easily flash a new firmware, without a dedicated debugger (and often without opening the device).

Note: Most users should only very rarely need to update the firmware on their device's SAMD21.

To flash via UF2, you must first put the device into UF2 flashing mode. This can be done through the 'Settings > Firmware Update' menu on your device. If for some reason this menu is inaccessible, then you may instead activate UF2 flashing mode using the USB Serial debug console, by typing:

samd flash

If this method is also unavailable, then there is a third, more manual way to trigger UF2 flashing mode. However, this method does require disassembling your device. We recommend removing the battery and faceplate from the mainboard before attempting this method, in order to reduce the risk of damage.

Once this is done, set your lock switch to the unlocked position, and plug the mainboard into your computer via USB-C. Then, locate the SWD debug header.

Using a small pair of tweezers or jumper wire, short the 'RST' and 'GND' pins together. Then remove the short, short the two pads again within half a second, and remove the short again. You should see the SAMD21's UF2 bootloader appear as a USB device on your computer.

SWD Flashing

Note: if you are not creating your own Tangara from scratch, then it is unlikely you will ever need to flash the SAMD21 over SWD.

The SAMD21 on Tangara has dedicated pads for reflashing the firmware over SWD. See the electronic design page for infomation about locating and connecting to these pads.

Once you have obtained a debugger, and attached it to the SWD pads, flashing new firmware is relatively straightforward. For example, using a Black Magic Probe's GDB interface, the procedure is:

file <your-cool-here.elf>
monitor swdp_scan
attach 1
load
compare-sections