Hysen Labs
Open-source project
tessel/t2-firmware avatar
tessel

t2-firmware

Firmware for Tessel 2's SAMD21 coprocessor and related SoC code

100 stars39 forksCNOASSERTION
01
DEEP OPEN-SOURCE ANALYSIS

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.

02
DEEP OPEN-SOURCE ANALYSIS

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.

03
DEEP OPEN-SOURCE ANALYSIS

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.

04
DEEP OPEN-SOURCE ANALYSIS

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.

05
DEEP OPEN-SOURCE ANALYSIS

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.

07
DEEP OPEN-SOURCE ANALYSIS

Official sources

08
Community notes

Community notes