t2-firmware
Firmware for Tessel 2's SAMD21 coprocessor and related SoC code
Tessel 2 firmware: the SAMD21 coprocessor side
Firmware for Tessel 2's SAMD21 coprocessor, covering module port control, the USB and SPI bridge to the SoC, updates, and onboard SWD debugging.
What the coprocessor does
This repository holds the firmware for Tessel 2's SAMD21 coprocessor, plus related SoC code, written in C. The SAM D21 is the go-between: it controls the two module ports' GPIO, SPI, UART, I2C, and ADC interfaces from the SoC, transfers data and commands between USB and the SoC for the Tessel CLI, provides a USB serial console for the SoC, programs the SoC's SPI flash over USB, and manages power state for both the SoC and the module ports. The license is recorded as NOASSERTION.
The directory layout
The structure is documented directory by directory. firmware holds the main SAMD21 source. common has utilities for SAMD21 peripherals and board-specific headers. deps contains dependency submodules, Atmel headers and the USB stack. boot is the USB DFU bootloader. soc runs the bridge daemon that talks to the MCU over SPI, and node holds the Node libraries for controlling the module ports through the MCU.
The SPI bridge
The bridge between the MT7620 SoC and the SAMD21 MCU is modeled loosely on USB, providing three bidirectional channels between Unix domain sockets on the SoC's Linux side and functions in the MCU firmware. Pipe 0 connects to a pair of USB endpoints for Tessel CLI communication with the Linux system; pipes 1 and 2 control the two module ports. The README notes a constraint: the MT7620 SPI controller is designed only to talk to SPI flash and is not full duplex, so the protocol works around that. A transaction has a setup phase and an optional data phase, starting with the SoC driving SYNC low, and each side exchanging a magic number plus channel state before data flows.
Updating and recovering
Updates use dfu-util, with a Homebrew install command in the README. Plug the Tessel into USB while holding the button by the logo to enter bootloader mode, shown by a blinking power LED. The note is specific about scope: this updates only the SAMD21 coprocessor firmware, while OpenWrt on the SoC updates separately through the t2-cli update command. One of Tessel's features is onboard SWD, letting you program and debug the SAMD21 from the SoC without an external adapter. The README warns against flashing the bootloader unless you must, since a broken SAMD21 bootloader may need a physical SWD adapter to recover, and the SAMD21 also sequences the SoC power rails on bootup.
Community notes