Skip to content

Commit

Permalink
board support: added support for the Seeed Studio XIAO SAMD21 board
Browse files Browse the repository at this point in the history
  • Loading branch information
linguini1 committed Nov 6, 2024
1 parent 38f0056 commit e7f51e1
Show file tree
Hide file tree
Showing 13 changed files with 1,182 additions and 0 deletions.
138 changes: 138 additions & 0 deletions Documentation/platforms/arm/samd2l2/boards/xiao-seeeduino/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
========================
Seeed Studio Xiao SAMD21
========================

The `Seeed Studio Xiao SAM21 <https://wiki.seeedstudio.com/Seeeduino-XIAO/>`_ is the first of the XIAO family, and is a
general purpose, low-power and tiny board. It can be referred to as the "Seeed Studio Xiao SAMD21" or the "Xiao
Seeeduino".

.. figure:: seeed-xiao-samd21.jpg
:align: center

Features
========

* ATSAMD21G18A-MU microcontroller chip @48MHz
* 256KB flash
* 32KB SRAM
* 14 pins (11 analog, 11 digital)
* 10 PWM interfaces
* 1 DAC output pin
* Serial wire debug interface
* 1 I2C interface
* 1 SPI interface
* 1 UART interface
* USBC interface
* Serial communication indicator LEDs for TX and RX (blue)
* Power indicator LED (green)
* Blinkable LED (yellow)

Serial Console
==============

By default, the serial console appears on the board's UART interface. Pin 9 is
TX and pin 7 is RX.

Pin Mapping
===========

Pins are numbered anticlockwise from the USB connector.

===== ======== ========================================
Pin Signal Notes
===== ======== ========================================
0 PA2 A0/D0/DAC
1 PA4 A1/D1
2 PA10 A2/D2
3 PA11 A3/D3
4 PA8 A4/D4/SDA (I2C)
5 PA9 A5/D5/SCL (I2C)
6 PB08 A6/D6/TX (UART)
7 PB09 A7/D7/RX (UART)
8 PA7 A8/D8/SCK (SPI)
9 PA5 A9/D9/MISO (SPI)
10 PA6 A10/D10/MOSI (SPI)
11 3V3
12 GND
13 5V You can supply 5V power on this pin too.
===== ======== ========================================

There are also four pads on the back side of the board. SWCLK, SWDIO for serial
wire debugging, and RST and GND for resetting the board. These same two pins are
also exposed on the top of the board.

Power Supply
============

The board can be powered through a USB-C connection. It can also be supplied 5V
power through it's 5V power pin.

There is an additional two pads for powering the board (VIN and GND) on the back
side. The board accepts anywhere between 3.3V and 5V.

Installation
============

To build NuttX for the Xiao Seeduino, you can use the following configuration
commands within the cloned ``nuttx`` repository:

.. code-block:: console
$ ./tools/configure.sh xiao-seeeduino:nsh
$ make
This will generate a ``nuttx.hex`` file. To put the program on your board, you
can choose from one of the following:

1. Convert the hex file to a uf2 file using the `Microsoft uf2 tool <https://github.com/microsoft/uf2/>`_:

.. code-block:: console
$ git clone https://github.com/microsoft/uf2.git
$ cd uf2/utils
$ python uf2conv.py -f 0x68ed2b88 -b 0x2000 nuttx.hex -o nuttx.uf2
Then, plug your board into the host computer using the USB-C interface. Short
the RST (reset) pad with ground twice in a row quickly. The board will be
detected as mass storage under the name "Arduino", and its orange LED will be
pulsing slowly. You can then copy the UF2 file to the drive/storage device
which appears. Once the file is done copying, the board will auto-eject and
you will have an NSH console on the UART pins!

.. todo::
Maybe this process should be part of the post-build scripts, since the
Microsoft UF2 tools is MIT licensed.

2. Flash the hex file using the ``bossac`` tool. You can find the source for it
`here <https://github.com/shumatech/BOSSA/>`_, or you can install it on Arch
Linux via the AUR with this command:

.. code-block:: console
$ yay -S bossa
Then, plug your Seeduino in via USB-C to the host computer and short the RST
(reset) and ground pins twice in a row quickly. The board will be detected as
mass storage under the name "Arduino", and its orange LED should be pulsing.
You can then run the following command:

.. code-block:: console
$ sudo stty -F <path/to/xiao-USB-port> 1200
$ sudo bossac -i -d --port=<path/to/xiao-USB-port> -i -w -v nuttx.hex -R
.. todo::
The ``bossac`` utility doesn't actually work for programming in my testing
yet. It is what the Arduino IDE uses but I haven't managed to get the
commmand line working. Using the commands listed above does actually
detect the board but the programming itself fails with "Flash command
failed". This needs more debugging.

Configurations
==============

nsh
---

Basic NuttShell configuration with the console enabled on the UART interface at
115200 bps. Comes with "Hello world" demo.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions boards/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2329,6 +2329,15 @@ config ARCH_BOARD_SAMD21_XPLAINED
This board features the ATSAMD21J18A MCU (Cortex-M0+ with 256KB of FLASH
and 32KB of SRAM).

config ARCH_BOARD_XIAO_SEEEDUINO
bool "Seeed Studio XIAO SAMD21"
depends on ARCH_CHIP_SAMD21J18A
select ARCH_HAVE_LEDS
---help---
The port of NuttX to the Seeed Studio XIAO SAMD21 board.
This board features the ATSAMD21J18A MCU (Cortex-M0+ with 256KB of FLASH
and 32KB of SRAM) in a tiny footprint.

config ARCH_BOARD_SAME54_XPLAINED_PRO
bool "Atmel SAME54-Xplained Pro development board"
depends on ARCH_CHIP_SAME54P20
Expand Down Expand Up @@ -3467,6 +3476,7 @@ config ARCH_BOARD
default "sama5d4-ek" if ARCH_BOARD_SAMA5D4_EK
default "samd20-xplained" if ARCH_BOARD_SAMD20_XPLAINED
default "samd21-xplained" if ARCH_BOARD_SAMD21_XPLAINED
default "xiao-seeeduino" if ARCH_BOARD_XIAO_SEEEDUINO
default "same54-xplained-pro" if ARCH_BOARD_SAME54_XPLAINED_PRO
default "saml21-xplained" if ARCH_BOARD_SAML21_XPLAINED
default "sam3u-ek" if ARCH_BOARD_SAM3UEK
Expand Down Expand Up @@ -3945,6 +3955,9 @@ endif
if ARCH_BOARD_SAMD21_XPLAINED
source "boards/arm/samd2l2/samd21-xplained/Kconfig"
endif
if ARCH_BOARD_XIAO_SEEEDUINO
source "boards/arm/samd2l2/xiao-seeeduino/Kconfig"
endif
if ARCH_BOARD_SAME54_XPLAINED_PRO
source "boards/arm/samd5e5/same54-xplained-pro/Kconfig"
endif
Expand Down
12 changes: 12 additions & 0 deletions boards/arm/samd2l2/xiao-seeeduino/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

if ARCH_BOARD_XIAO_SEEEDUINO

menu "XIAO Seeeduino"

endmenu # XIAO Seeeduino

endif # ARCH_BOARD_XIAO_SEEEDUINO
59 changes: 59 additions & 0 deletions boards/arm/samd2l2/xiao-seeeduino/configs/nsh/defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
# CONFIG_DISABLE_POSIX_TIMERS is not set
# CONFIG_NSH_DISABLEBG is not set
# CONFIG_NSH_DISABLESCRIPT is not set
# CONFIG_NSH_DISABLE_CMP is not set
# CONFIG_NSH_DISABLE_DD is not set
# CONFIG_NSH_DISABLE_EXEC is not set
# CONFIG_NSH_DISABLE_EXIT is not set
# CONFIG_NSH_DISABLE_GET is not set
# CONFIG_NSH_DISABLE_HEXDUMP is not set
# CONFIG_NSH_DISABLE_IFCONFIG is not set
# CONFIG_NSH_DISABLE_ITEF is not set
# CONFIG_NSH_DISABLE_LOOPS is not set
# CONFIG_NSH_DISABLE_LOSETUP is not set
# CONFIG_NSH_DISABLE_MKRD is not set
# CONFIG_NSH_DISABLE_PS is not set
# CONFIG_NSH_DISABLE_PUT is not set
# CONFIG_NSH_DISABLE_SEMICOLON is not set
# CONFIG_NSH_DISABLE_UNAME is not set
# CONFIG_NSH_DISABLE_WGET is not set
# CONFIG_NSH_DISABLE_XD is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="xiao-seeeduino"
CONFIG_ARCH_BOARD_XIAO_SEEEDUINO=y
CONFIG_ARCH_CHIP="samd2l2"
CONFIG_ARCH_CHIP_SAMD21J18A=y
CONFIG_ARCH_CHIP_SAMD2X=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_BOARD_LOOPSPERMSEC=3410
CONFIG_BUILTIN=y
CONFIG_DEFAULT_SMALL=y
CONFIG_EXAMPLES_HELLO=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INIT_STACKSIZE=1536
CONFIG_INTELHEX_BINARY=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE=1536
CONFIG_PTHREAD_STACK_DEFAULT=1536
CONFIG_RAM_SIZE=32768
CONFIG_RAM_START=0x20000000
CONFIG_RR_INTERVAL=200
CONFIG_SAMD2L2_SERCOM4=y
CONFIG_SCHED_WAITPID=y
CONFIG_START_DAY=18
CONFIG_START_MONTH=10
CONFIG_START_YEAR=2024
CONFIG_SYSTEM_NSH=y
CONFIG_TASK_NAME_SIZE=0
CONFIG_USART4_RXBUFSIZE=64
CONFIG_USART4_SERIAL_CONSOLE=y
CONFIG_USART4_TXBUFSIZE=64
Loading

0 comments on commit e7f51e1

Please sign in to comment.