XIAO SAMD21 (Seeeduino XIAO)
Downstream Copy!
This board description is a copy from Zephyr with a slightly changed name and will be used for further development, improvement and preparation of changes for Zephyr within Bridle. However, the original board description still lives within the Zephyr namespace under the original board name: Seeeduino XIAO.
Overview
The XIAO SAMD21 (Seeeduino XIAO) is a tiny (20 mm x 17.5 mm) ARM development board with onboard LEDs, USB port, and range of digital or analog I/O broken out onto 14 pins.

Hardware
ATSAMD21G18A [11] ARM Cortex-M0+ processor at 48 MHz
32.768 kHz crystal oscillator
256 KiB flash memory and 32 KiB of RAM
3 user LEDs (L/Rx/Tx)
One reset pad (solderable), beside an free GND pad
Seeed XIAO
headerNative USB port
Supported Features
The xiao_samd21
board configuration supports the following
hardware features:
Peripheral |
Kconfig option |
Devicetree compatible |
Zephyr API |
---|---|---|---|
PINCTRL |
|||
GPIO |
|||
UART |
|||
UDC (USB Device Controller) |
|||
I2C |
|||
SPI |
|||
PWM |
|||
DAC |
|||
ADC |
|||
RTC |
|||
Timer (Counter) |
|
||
Watchdog Timer (WDT) |
|||
Flash |
|||
DMA |
|||
HWINFO |
|||
CLOCK / PM |
not supported |
atmel,samd2x-gclk atmel,samd2x-pm |
|
NVIC |
N/A |
Nested Vector Interrupts Controller |
|
SYSTICK |
N/A |
Other hardware features are not currently supported by Zephyr.
The default configuration can be found in the Kconfig file boards/seeed/xiao_samd21/xiao_samd21_defconfig.
Board Configurations
The xiao_samd21
board can be configured for the following
different use cases.
west build -b xiao_samd21
Use the serial port SERCOM5 over Seeed XIAO
header as Zephyr console
and for the shell.
west build -b xiao_samd21 -S usb-console
Use the native USB device port with CDC-ACM as Zephyr console and for the shell.
Connections and IOs
The XIAO SAMD21 wiki [5] has detailed information about the board including pinouts [6] and the schematic [7]. There are also design data for Eagle [8] and KiCAD [9].
System Clock
The SAMD21 MCU is configured to use the 32.768 kHz external crystal with the on-chip PLL generating the 48 MHz system clock. The internal APB and GCLK unit are set up in the same way as the upstream Arduino libraries.
GPIO (PWM) Ports
The SAMD21 MCU has 2 GPIO ports, 3 PWM able Timer/Capture-Counter (TCC) and
2 simple Timer/Counter (TC). On the XIAO SAMD21, TCC2 channel 1 is available
on first user LED (L), all other user LEDs can be controlled as GPIO. Only if
CONFIG_PWM_SAM0_TCC
is enabled then the first user LED (L)
is driven by TCC2 instead of by GPIO. All channels of TCC0 and TCC1 are
available on the Seeed XIAO
header.
ADC/DAC Ports
The SAMD21 MCU has 1 DAC and 1 ADC. On the XIAO SAMD21, the DAC voltage output
(VOUT) is available on A0 of the Seeed XIAO
header. The ADC channels 4 and
18 are available on A1 and A2 of the Seeed XIAO
header. Whenever other GPIO
(PWM) or serial ports are not needed and are disabled by DT overlays, up to
11 ADC channels can be configured according to the next table (default function
in bold).
SAMD21 |
ADC |
DAC |
|
---|---|---|---|
D0/A0/DAC |
PA2 |
AIN0 |
VOUT |
D1/A1 |
PA4 |
AIN4 |
|
D2/A2 |
PA10 |
AIN18 |
|
D3/A3 |
PA11 |
AIN19 |
|
D4/A4/SDA |
PA8 |
AIN16 |
|
D5/A5/SCL |
PA9 |
AIN17 |
|
D6/A6/TX |
PB8 |
AIN2 |
|
D7/A7/RX |
PB9 |
AIN3 |
|
D8/A8/SCK |
PA7 |
AIN7 |
|
D9/A9/MISO |
PA5 |
AIN5 |
|
D10/A10/MOSI |
PA6 |
AIN6 |
SPI Port
The SAMD21 MCU has 6 SERCOM based SPIs. On the XIAO SAMD21, SERCOM0 can be put
into SPI mode and used to connect to devices over the Seeed XIAO
header
pin 9 (MISO), pin 10 (MOSI), and pin 8 (SCK).
I2C Port
The SAMD21 MCU has 6 SERCOM based USARTs. On the XIAO SAMD21, SERCOM2 is
available on the Seeed XIAO
header pin 4 (SDA) and pin 5 (SCL).
Serial Port
The SAMD21 MCU has 6 SERCOM based USARTs. On the XIAO SAMD21, SERCOM4 is the
Zephyr console and is available on the Seeed XIAO
header pins 7 (RX) and
6 (TX).
USB Device Port
The SAMD21 MCU has a (native) USB device port that can be used to communicate with a host PC. See the USB device support sample applications for more, such as the USB CDC-ACM sample which sets up a virtual serial port that echos characters back to the host PC. As an alternative to the default Zephyr console on serial port the Bridle USB Console Snippet (usb-console) can be used to enable CDC ACM and switch the console to USB:
USB device idVendor=2886, idProduct=802f, bcdDevice= 4.01 USB device strings: Mfr=1, Product=2, SerialNumber=3 Product: XIAO SAMD21 (CDC ACM) Manufacturer: Seeed Studio SerialNumber: AC3FB5052F48A3F7
Programming and Debugging
The XIAO SAMD21 ships the BOSSA compatible UF2 bootloader [2] also known as Arduino Zero Bootloader [3], a modern SAM-BA [1] (Boot Assistant) replacement. The bootloader can be entered by shorting the RST and GND pads twice:
USB device idVendor=2886, idProduct=002f, bcdDevice=42.01 USB device strings: Mfr=1, Product=2, SerialNumber=0 Product: Seeeduino XIAO Manufacturer: Seeed Studio SerialNumber: 2601F57F2E175D24AC3FB5052F48A3F7
Additionally, if CONFIG_USB_CDC_ACM
is enabled then the
bootloader will be entered automatically when you run west flash
.

Tip
When ever you need to restore this original bootloader you should read and following the directions in Flashing the Arduino Bootloader using DAP Link [4]. There is also a backup copy of the original bootloader together with a ready to use Segger JFlash control file inside the Bridel project:
There are also SWD pads on board (PCB bottom side) which have to be used with tools like Segger J-Link for programming for bootloader restore or direct programming and debugging.
Flashing
Build the Zephyr kernel and the Hello World sample application:
west build -b xiao_samd21 -p -d build/xiao_samd21 zephyr/samples/hello_world
Connect the XIAO SAMD21 to your host computer using USB.
Connect a 3.3 V USB to serial adapter to the board and to the host. See the Serial Port section above for the board’s pin connections.
Run your favorite terminal program to listen for output. Under Linux the terminal should be
/dev/ttyUSB0
. For example:minicom -D /dev/ttyUSB0 -o
The
-o
option tells minicom not to send the modem initialization string. Connection should be configured as follows:Speed: 115200
Data: 8 bits
Parity: None
Stop bits: 1
Short the RST and GND pads twice quickly to enter bootloader mode.
Flash the image:
west flash -d build/xiao_samd21
You should see “Hello World! xiao_samd21” in your terminal.
Debugging
Debugging is only possible over SWD!
Do the for the debug session necessary steps as before except enter the bootloader mode and the flashing.
Connect the Segger J-Link to the SWD header (J10).
Flash the image and attach a debugger to your board:
west build -b xiao_samd21 -p -d build/xiao_samd21 zephyr/samples/hello_world -- -DBOARD_FLASH_RUNNER=openocd west debug -d build/xiao_samd21
You should ends up in a debug console (e.g. a GDB session).
More Samples
LED Blinky
west build -b xiao_samd21 -p -d build/xiao_samd21 zephyr/samples/basic/blinky
west flash -d build/xiao_samd21
LED Fade
west build -b xiao_samd21 -p -d build/xiao_samd21 zephyr/samples/basic/fade_led
west flash -d build/xiao_samd21
Basic Threads
west build -b xiao_samd21 -p -d build/xiao_samd21 zephyr/samples/basic/threads
west flash -d build/xiao_samd21
Hello Shell with USB-CDC/ACM Console
west build -b xiao_samd21 -p -S usb-console -d build/xiao_samd21 bridle/samples/helloshell
west flash -d build/xiao_samd21
Simple test execution on target
(text in bold is a command input)
uart:~$ hello -h
hello - say hello
uart:~$ hello
Hello from shell.
uart:~$ hwinfo devid
Length: 16
ID: 0x2601f57f2e175d24ac3fb5052f48a3f7
uart:~$ kernel version
Zephyr version 4.1.0
uart:~$ bridle version
Bridle version 4.1.0
uart:~$ bridle version long
Bridle version 4.1.0.0
uart:~$ bridle info
Zephyr: 4.1.0
Bridle: 4.1.0
uart:~$ device list
devices:
- eic@40001800 (READY)
DT node labels: eic
- gpio@41004480 (READY)
DT node labels: portb
- gpio@41004400 (READY)
DT node labels: porta
- snippet_cdc_acm_console_uart (READY)
DT node labels: snippet_cdc_acm_console_uart
- sercom@42001800 (READY)
DT node labels: sercom4 xiao_serial
- adc@42004000 (READY)
DT node labels: adc
- dac@42004800 (READY)
DT node labels: dac0 xiao_dac
- nvmctrl@41004000 (READY)
DT node labels: nvmctrl
- sercom@42001000 (READY)
DT node labels: sercom2 xiao_i2c
- tcc@42002800 (READY)
DT node labels: tcc2
- leds (READY)
uart:~$ history
[ 0] history
[ 1] device list
[ 2] bridle info
[ 3] bridle version long
[ 4] bridle version
[ 5] kernel version
[ 6] hwinfo devid
[ 7] hello
[ 8] hello -h
Operate with the red Rx user LED:
uart:~$ gpio get gpio@41004400 18
0
uart:~$ gpio conf gpio@41004400 18 ol0
uart:~$ gpio set gpio@41004400 18 1
uart:~$ gpio set gpio@41004400 18 0
uart:~$ gpio blink gpio@41004400 18
Hit any key to exit
Operate with the blue user LED:
uart:~$ pwm usec tcc@42002800 1 20000 20000
uart:~$ pwm usec tcc@42002800 1 20000 19000
uart:~$ pwm usec tcc@42002800 1 20000 18000
uart:~$ pwm usec tcc@42002800 1 20000 17000
uart:~$ pwm usec tcc@42002800 1 20000 16000
uart:~$ pwm usec tcc@42002800 1 20000 15000
uart:~$ pwm usec tcc@42002800 1 20000 10000
uart:~$ pwm usec tcc@42002800 1 20000 5000
uart:~$ pwm usec tcc@42002800 1 20000 2500
uart:~$ pwm usec tcc@42002800 1 20000 500
uart:~$ pwm usec tcc@42002800 1 20000 0
Operate with the loop-back wire from A0 (DAC CH0 VOUT) to A1 (ADC CH2 AIN):
uart:~$ dac setup dac@42004800 0 10
uart:~$ adc adc@42004000 resolution 12
uart:~$ adc adc@42004000 acq_time 10 us
uart:~$ adc adc@42004000 channel positive 4
uart:~$ dac write_value dac@42004800 0 512
uart:~$ adc adc@42004000 read 4
read: 2028
uart:~$ dac write_value dac@42004800 0 1023
uart:~$ adc adc@42004000 read 4
read: 4054
uart:~$ flash read nvmctrl@41004000 134c0 40
000134C0: 78 69 61 6f 5f 73 61 6d 64 32 31 00 48 65 6c 6c |xiao_sam d21.Hell|
000134D0: 6f 20 57 6f 72 6c 64 21 20 49 27 6d 20 54 48 45 |o World! I'm THE|
000134E0: 20 53 48 45 4c 4c 20 66 72 6f 6d 20 25 73 0a 00 | SHELL f rom %s..|
000134F0: 28 75 6e 73 69 67 6e 65 64 29 20 63 68 61 72 20 |(unsigne d) char |
Erase, Write and Verify
uart:~$ flash read nvmctrl@41004000 3c000 40
0003C000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |........ ........|
0003C010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |........ ........|
0003C020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |........ ........|
0003C030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |........ ........|
uart:~$ flash test nvmctrl@41004000 3c000 400 2
Erase OK.
Write OK.
Verified OK.
Erase OK.
Write OK.
Verified OK.
Erase-Write-Verify test done.
uart:~$ flash read nvmctrl@41004000 3c000 40
0003C000: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f |........ ........|
0003C010: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f |........ ........|
0003C020: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f | !"#$%&' ()*+,-./|
0003C030: 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f |01234567 89:;<=>?|
uart:~$ flash page_info 3c000
Page for address 0x3c000:
start offset: 0x3c000
size: 256
index: 960
uart:~$ flash erase nvmctrl@41004000 3c000 400
Erase success.
uart:~$ flash read nvmctrl@41004000 3c000 40
0003C000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |........ ........|
0003C010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |........ ........|
0003C020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |........ ........|
0003C030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |........ ........|
The XIAO SAMD21 (Seeeduino XIAO) has no on-board I2C devices. For this example the Grove Temperature and Barometer Sensor – BMP280 [10] was connected.
uart:~$ log enable none i2c_sam0
uart:~$ i2c scan sercom@42001000
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- 77
1 devices found on sercom@42001000
uart:~$ log enable inf i2c_sam0
The I2C address 0x77
is a Bosch BMP280 Air Pressure Sensor and their
Chip-ID can read from register 0xd0
. The Chip-ID must be 0x58
:
uart:~$ i2c read_byte sercom@42001000 77 d0
Output: 0x58