boards: Add support for Wio Terminal

Add support for the Wio Terminal board, including support of its
sensors, MicroSD and LCD. Tested with samples already available.

Signed-off-by: Joel Guittet <joelguittet@gmail.com>
This commit is contained in:
Joel Guittet 2023-02-18 10:40:01 +01:00 committed by Maureen Helm
parent f2d43cf0ac
commit 63e9e37fc3
12 changed files with 673 additions and 1 deletions

View file

@ -0,0 +1,8 @@
# Copyright (c) 2023 Joel Guittet
# Wio Terminal board configuration
# SPDX-License-Identifier: Apache-2.0
config BOARD_WIO_TERMINAL
bool "Wio Terminal"
depends on SOC_PART_NUMBER_SAMD51P19A

View file

@ -0,0 +1,8 @@
# Copyright (c) 2023 Joel Guittet
# Wio Terminal board configuration
# SPDX-License-Identifier: Apache-2.0
config BOARD
default "wio_terminal"
depends on BOARD_WIO_TERMINAL

View file

@ -0,0 +1,5 @@
# Copyright (c) 2023 Joel Guittet
# SPDX-License-Identifier: Apache-2.0
include(${ZEPHYR_BASE}/boards/common/bossac.board.cmake)
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

View file

@ -0,0 +1,212 @@
.. _wio_terminal:
Wio Terminal
############
Overview
********
The Wio Terminal is a small (72 mm x 57 mm x 12 mm) and powerful ARM board with
wireless connectivity (2.4G/5G dual-band Wi-Fi and BLE 5.0), LCD display,
USB C port, FPC connector, microSD card slot, Raspberry Pi compatible 40-pins
header and 2 Grove connectors.
.. image:: img/wio_terminal.png
:width: 500px
:align: center
:alt: Seeed Studio Wio Terminal
Hardware
********
- ATSAMD51P19 ARM Cortex-M4F processor at 120 MHz
- 512 KiB flash memory and 192 KiB of RAM
- 4 MiB external flash
- MicroSD card slot
- RTL8720DN 2.4G/5G Dual Bands Wireless and BLE5.0 Combo Module
- 2.4inch LCD display
- LIS3DH accelerometer
- Microphone 1.0V-10V -42dB
- Speaker ≥78dB @10cm 4000Hz
- Light Sensor 400-1050nm
- Infrared Emitter 940nm
- GPIO 40 pin (Raspberry Pi compatible)
- 2x Grove connectors
- 1x user LED
- 3x user buttons
- 5-way user button
- Power/Reset/Boot mode switch
- Native USB port
Supported Features
==================
The wio_terminal board configuration supports the following hardware features:
.. list-table::
:header-rows: 1
* - Interface
- Controller
- Driver / Component
* - NVIC
- on-chip
- Nested vector interrupt controller
* - Flash
- on-chip
- Can be used with LittleFS to store files
* - SYSTICK
- on-chip
- Systick
* - WDT
- on-chip
- Watchdog
* - GPIO
- on-chip
- I/O ports
* - USART
- on-chip
- Serial port
* - I2C
- on-chip
- Inter-Integrated Circuit
* - SPI
- on-chip
- Serial Peripheral Interface port
* - TRNG
- on-chip
- True Random Number Generator
* - HWINFO
- on-chip
- Unique 128 bit serial number
* - RTC
- on-chip
- Real-Time Counter
* - USB
- on-chip
- USB device
* - PWM
- on-chip
- PWM
Other hardware features are not currently supported by Zephyr.
The default configuration can be found in the Kconfig file
:zephyr_file:`boards/arm/wio_terminal/wio_terminal_defconfig`.
Zephyr can use the default Cortex-M SYSTICK timer or the SAM0 specific RTC.
To use the RTC, set :kconfig:option:`CONFIG_CORTEX_M_SYSTICK=n` and set
:kconfig:option:`CONFIG_SYS_CLOCK_TICKS_PER_SEC` to no more than 32 kHZ divided
by 7, i.e. no more than 4500.
Connections and IOs
===================
The `Wio Terminal Getting started guide`_ has detailed information about the
board including `pinouts`_ and its `schematics`_.
System Clock
============
The SAMD51 MCU is configured to use the 32.768 kHz internal oscillator with the
on-chip PLL generating the 120 MHz system clock.
Serial Port
===========
Zephyr console output is available using the USB connector, which is used to
make the console available on PC as USB CDC class.
USB Device Port
===============
The SAMD51 MCU has a USB device port that can be used to communicate with a
host PC. See the :ref:`usb-samples` sample applications for more, such as the
:ref:`usb_cdc-acm` sample which sets up a virtual serial port that echos
characters back to the host PC.
Programming and Debugging
*************************
The Wio Terminal ships with an UF2 bootloader that is BOSSA compatible. The
bootloader can be entered by quickly tapping the reset button twice.
The UF2 file is generated when building the application, and it is possible to
use it to flash the target. Enter the bootloader by quickly sliding the power
button twice, and copy the UF2 file to the USB mass storage device. The device
reboots on the new firmware after the UF2 file has finished transferring.
Flashing
========
#. Build the Zephyr kernel and the :code:`button` sample application:
.. zephyr-app-commands::
:zephyr-app: samples/basic/button
:board: wio_terminal
:goals: build
:compact:
#. Swipe the reset/power button down twice quickly to enter bootloader mode
#. Flash the image:
.. zephyr-app-commands::
:zephyr-app: samples/basic/button
:board: wio_terminal
:goals: flash
:compact:
You should see the blue (user) LED flashing whenever you press the third
(counting from the top left) user button at the top of the Wio Terminal.
Debugging
=========
In addition to the built-in bootloader, the Wio Terminal can be flashed and
debugged using an SWD probe such as the Segger J-Link.
#. Solder cables to the code:`SWCLK`, :code:`SWDIO`, :code:`RESET`,
:code:`GND`, and :code:`3V3` pins. See `Test with SWD`_ for more
information.
#. Connect the board to the probe by connecting the :code:`SWCLK`,
:code:`SWDIO`, :code:`RESET`, :code:`GND`, and :code:`3V3` pins on the
Wio Terminal to the :code:`SWCLK`, :code:`SWDIO`, :code:`RESET`,
:code:`GND`, and :code:`VTref` pins on the `J-Link`_.
#. Flash the image:
.. zephyr-app-commands::
:zephyr-app: samples/basic/button
:board: wio_terminal
:goals: flash -r openocd
:compact:
#. Start debugging:
.. zephyr-app-commands::
:zephyr-app: samples/basic/button
:board: wio_terminal
:goals: debug
:compact:
References
**********
.. target-notes::
.. _Wio Terminal Getting started guide:
https://wiki.seeedstudio.com/Wio-Terminal-Getting-Started/
.. _pinouts:
https://wiki.seeedstudio.com/Wio-Terminal-Getting-Started/#pinout-diagram
.. _schematics:
https://wiki.seeedstudio.com/Wio-Terminal-Getting-Started/#resources
.. _Test with SWD:
https://wiki.seeedstudio.com/Wio-Terminal-Getting-Started/#test-with-swd
.. _J-Link:
https://www.segger.com/products/debug-probes/j-link/technology/interface-description/

View file

@ -0,0 +1,9 @@
# Copyright (c) 2023 Joel Guittet
# SPDX-License-Identifier: Apache-2.0
# SPI is implemented via sercom so node name isn't spi@...
list(APPEND EXTRA_DTC_FLAGS "-Wno-spi_bus_bridge")
# Suppress "unique_unit_address_if_enabled" to handle the following overlaps:
# - /soc/pinmux@41008000 & /soc/gpio@41008000
list(APPEND EXTRA_DTC_FLAGS "-Wno-unique_unit_address_if_enabled")

View file

@ -0,0 +1,22 @@
# SPDX-License-Identifier: Apache-2.0
source [find interface/jlink.cfg]
transport select swd
set CHIPNAME atsamd51p19
source [find target/atsame5x.cfg]
adapter_khz 500
reset_config srst_only
$_TARGETNAME configure -event gdb-attach {
echo "Debugger attaching: halting execution"
reset halt
}
$_TARGETNAME configure -event gdb-detach {
echo "Debugger detaching: resuming execution"
resume
}

View file

@ -0,0 +1,76 @@
/*
* Copyright (c) 2023 Joel Guittet
* SPDX-License-Identifier: Apache-2.0
*/
#include <dt-bindings/pinctrl/samd51p-pinctrl.h>
&pinctrl {
sercom0_spi_default: sercom0_spi_default {
group1 {
pinmux = <PB24C_SERCOM0_PAD0>,
<PB25C_SERCOM0_PAD1>,
<PC24C_SERCOM0_PAD2>;
};
};
sercom1_uart_default: sercom1_uart_default {
group1 {
pinmux = <PC22C_SERCOM1_PAD0>,
<PC23C_SERCOM1_PAD1>;
};
};
sercom2_uart_default: sercom2_uart_default {
group1 {
pinmux = <PB26C_SERCOM2_PAD0>,
<PB27C_SERCOM2_PAD1>;
};
};
sercom3_i2c_default: sercom3_i2c_default {
group1 {
pinmux = <PA17D_SERCOM3_PAD0>,
<PA16D_SERCOM3_PAD1>;
};
};
sercom4_i2c_default: sercom4_i2c_default {
group1 {
pinmux = <PA13D_SERCOM4_PAD0>,
<PA12D_SERCOM4_PAD1>;
};
};
sercom5_spi_default: sercom5_spi_default {
group1 {
pinmux = <PB2D_SERCOM5_PAD0>,
<PB3D_SERCOM5_PAD1>,
<PB0D_SERCOM5_PAD2>;
};
};
sercom6_spi_default: sercom6_spi_default {
group1 {
pinmux = <PC16C_SERCOM6_PAD0>,
<PC17C_SERCOM6_PAD1>,
<PC18C_SERCOM6_PAD2>;
};
};
sercom7_spi_default: sercom7_spi_default {
group1 {
pinmux = <PB20D_SERCOM7_PAD1>,
<PB18D_SERCOM7_PAD2>,
<PB19D_SERCOM7_PAD3>;
};
};
usb_dc_default: usb_dc_default {
group1 {
pinmux = <PA25H_USB_DP>,
<PA24H_USB_DM>;
};
};
};

View file

@ -0,0 +1,280 @@
/*
* Copyright (c) 2023 Joel Guittet
* SPDX-License-Identifier: Apache-2.0
*/
/dts-v1/;
#include <atmel/samd5xx19.dtsi>
#include "wio_terminal-pinctrl.dtsi"
#include <zephyr/dt-bindings/display/ili9xxx.h>
/ {
model = "Wio Terminal";
compatible = "seeed,wio-terminal";
chosen {
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,console = &wio_terminal_console;
zephyr,shell-uart = &wio_terminal_console;
zephyr,code-partition = &code_partition;
zephyr,display = &ili9341;
};
/* These aliases are provided for compatibility with samples */
aliases {
led0 = &led0;
sw0 = &user_button_0;
sw1 = &user_button_1;
sw2 = &user_button_2;
i2c0 = &sercom4;
i2c1 = &sercom3;
spi0 = &sercom5;
uart0 = &sercom2;
accel0 = &lis3dh;
sdhc0 = &sdhc0;
};
/* LEDs */
leds {
compatible = "gpio-leds";
led0: led_0 {
label = "LED";
gpios = <&porta 15 GPIO_ACTIVE_HIGH>;
};
};
/* Buttons */
gpio_keys {
compatible = "gpio-keys";
user_button_0: button_0 {
label = "User Button 0";
gpios = <&portc 26 GPIO_ACTIVE_LOW>;
};
user_button_1: button_1 {
label = "User Button 1";
gpios = <&portc 27 GPIO_ACTIVE_LOW>;
};
user_button_2: button_2 {
label = "User Button 2";
gpios = <&portc 28 GPIO_ACTIVE_LOW>;
};
joy_sel: joystick_selection {
label = "joystick selection";
gpios = <&portd 10 GPIO_ACTIVE_LOW>;
};
joy_down: joystick_down {
label = "joystick down";
gpios = <&portd 8 GPIO_ACTIVE_LOW>;
};
joy_up: joystick_up {
label = "joystick up";
gpios = <&portd 20 GPIO_ACTIVE_LOW>;
};
joy_left: joystick_left {
label = "joystick left";
gpios = <&portd 12 GPIO_ACTIVE_LOW>;
};
joy_right: joystick_right {
label = "joystick right";
gpios = <&portd 9 GPIO_ACTIVE_LOW>;
};
};
/* Regulators */
lcd_backlight_en {
compatible = "regulator-fixed";
regulator-name = "lcd_backlight_enable";
enable-gpios = <&portc 5 GPIO_ACTIVE_HIGH>;
regulator-boot-on;
};
rpi_power_3v3_en {
compatible = "regulator-fixed";
regulator-name = "rpi_power_3v3_enable";
enable-gpios = <&portc 15 GPIO_ACTIVE_LOW>;
regulator-boot-on;
};
rpi_power_5v_en {
compatible = "regulator-fixed";
regulator-name = "rpi_power_5v_enable";
enable-gpios = <&portc 14 GPIO_ACTIVE_HIGH>;
regulator-boot-on;
};
usb_power_5v_en {
compatible = "regulator-fixed";
regulator-name = "usb_power_5v_en";
enable-gpios = <&porta 27 GPIO_ACTIVE_LOW>;
};
};
&cpu0 {
clock-frequency = <120000000>;
};
&dmac {
status = "okay";
};
&flash0 {
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
boot_partition: partition@0 {
label = "uf2";
reg = <0x00000000 DT_SIZE_K(16)>;
read-only;
};
code_partition: partition@4000 {
label = "code";
reg = <0x4000 DT_SIZE_K(512-16)>;
read-only;
};
};
};
/* RTL8720D (Wifi/BLE) */
&sercom0 {
status = "okay";
compatible = "atmel,sam0-spi";
#address-cells = <1>;
#size-cells = <0>;
dipo = <2>;
dopo = <0>;
pinctrl-0 = <&sercom0_spi_default>;
pinctrl-names = "default";
cs-gpios = <&portc 25 GPIO_ACTIVE_LOW>;
};
/* RTL8720D (Wifi/BLE) */
&sercom1 {
status = "okay";
compatible = "atmel,sam0-uart";
current-speed = <115200>;
rxpo = <1>;
txpo = <0>;
pinctrl-0 = <&sercom1_uart_default>;
pinctrl-names = "default";
};
/* UART, Raspberry Pi connector */
&sercom2 {
status = "okay";
compatible = "atmel,sam0-uart";
current-speed = <115200>;
rxpo = <1>;
txpo = <0>;
pinctrl-0 = <&sercom2_uart_default>;
pinctrl-names = "default";
};
/* I2C1, Raspberry Pi and Groove connectors */
&sercom3 {
status = "okay";
compatible = "atmel,sam0-i2c";
clock-frequency = <I2C_BITRATE_FAST>;
#address-cells = <1>;
#size-cells = <0>;
pinctrl-0 = <&sercom3_i2c_default>;
pinctrl-names = "default";
};
/* I2C0, LIS3DH, ATECC608, Raspberry Pi connector */
&sercom4 {
status = "okay";
compatible = "atmel,sam0-i2c";
clock-frequency = <I2C_BITRATE_HIGH>;
#address-cells = <1>;
#size-cells = <0>;
pinctrl-0 = <&sercom4_i2c_default>;
pinctrl-names = "default";
/* LIS3DH */
lis3dh: lis3dh@18 {
compatible = "st,lis3dh", "st,lis2dh";
status = "okay";
reg = <0x18>;
irq-gpios = <&portc 21 GPIO_ACTIVE_HIGH>;
};
/* ATECC608A */
atecc608a@6a {
compatible = "atmel,atecc608";
reg = <0x6a>;
};
};
/* SPI, Raspberry Pi connector */
&sercom5 {
status = "okay";
compatible = "atmel,sam0-spi";
#address-cells = <1>;
#size-cells = <0>;
dipo = <2>;
dopo = <0>;
pinctrl-0 = <&sercom5_spi_default>;
pinctrl-names = "default";
cs-gpios = <&portb 1 GPIO_ACTIVE_LOW>;
};
/* microSD Card */
&sercom6 {
status = "okay";
compatible = "atmel,sam0-spi";
#address-cells = <1>;
#size-cells = <0>;
dipo = <2>;
dopo = <0>;
pinctrl-0 = <&sercom6_spi_default>;
pinctrl-names = "default";
cs-gpios = <&portc 19 GPIO_ACTIVE_LOW>;
/* microSD Card */
sdhc0: sdhc@0 {
compatible = "zephyr,sdhc-spi-slot";
reg = <0>;
spi-max-frequency = <24000000>;
mmc {
compatible = "zephyr,sdmmc-disk";
};
};
};
/* LCD */
&sercom7 {
status = "okay";
compatible = "atmel,sam0-spi";
#address-cells = <1>;
#size-cells = <0>;
dipo = <2>;
dopo = <3>;
pinctrl-0 = <&sercom7_spi_default>;
pinctrl-names = "default";
cs-gpios = <&portb 21 GPIO_ACTIVE_LOW>;
/* LCD */
ili9341: ili9341@0 {
compatible = "ilitek,ili9341";
spi-max-frequency = <24000000>;
reg = <0>;
cmd-data-gpios = <&portc 6 GPIO_ACTIVE_LOW>;
reset-gpios = <&portc 7 GPIO_ACTIVE_LOW>;
pixel-format = <ILI9XXX_PIXEL_FORMAT_RGB565>;
rotation = <270>;
width = <320>;
height = <240>;
};
};
/* USB */
zephyr_udc0: &usb0 {
status = "okay";
pinctrl-0 = <&usb_dc_default>;
pinctrl-names = "default";
wio_terminal_console: wio_terminal_console {
compatible = "zephyr,cdc-acm-uart";
};
};

View file

@ -0,0 +1,21 @@
identifier: wio_terminal
name: Wio Terminal
type: mcu
arch: arm
ram: 192
flash: 512
toolchain:
- zephyr
- gnuarmemb
- xtools
supported:
- adc
- counter
- dma
- gpio
- i2c
- pwm
- spi
- usb_cdc
- usb_device
- watchdog

View file

@ -0,0 +1,31 @@
# Copyright (c) 2023 Joel Guittet
# SPDX-License-Identifier: Apache-2.0
CONFIG_SOC_SERIES_SAMD51=y
CONFIG_SOC_PART_NUMBER_SAMD51P19A=y
CONFIG_SOC_ATMEL_SAMD5X_XOSC32K=y
CONFIG_SOC_ATMEL_SAMD5X_XOSC32K_AS_MAIN=y
CONFIG_BOARD_WIO_TERMINAL=y
CONFIG_ARM_MPU=y
CONFIG_CORTEX_M_SYSTICK=y
CONFIG_HW_STACK_PROTECTION=y
CONFIG_REGULATOR=y
CONFIG_GPIO=y
# BOSSA bootloader
CONFIG_BOOTLOADER_BOSSA=y
CONFIG_BOOTLOADER_BOSSA_ADAFRUIT_UF2=y
CONFIG_BUILD_OUTPUT_UF2=y
# Console over USB CDC-ACM
CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=y
CONFIG_USB_DEVICE_VID=0x2886
CONFIG_USB_DEVICE_PID=0x802D
CONFIG_USB_DEVICE_MANUFACTURER="Seeed Studio"
CONFIG_USB_DEVICE_PRODUCT="Wio Terminal"
CONFIG_USB_CDC_ACM_LOG_LEVEL_OFF=y

View file

@ -3,7 +3,7 @@ common:
adafruit_itsybitsy_m4_express atsame54_xpro atsamd21_xpro adafruit_trinket_m0
arduino_nano_33_iot arduino_zero atsamd21_xpro adafruit_feather_m0_basic_proto
adafruit_feather_m0_lora arduino_mkrzero atsaml21_xpro atsamr34_xpro stamp_c3
xiao_esp32c3
wio_terminal xiao_esp32c3
tags: drivers uart
tests:
drivers.uart.async_api: