board: m5stack_stamps3: Add support for M5Stack StampS3 development board

Adding support for M5Stack StampS3 development board, featuring an ESP32
MCU

Signed-off-by: Martin Kiepfer <mrmarteng@teleschirm.org>
This commit is contained in:
Martin Kiepfer 2024-01-02 18:35:40 +01:00 committed by Carles Cufí
parent b7a1ff7b18
commit 51e5ecf829
12 changed files with 641 additions and 0 deletions

View file

@ -0,0 +1,12 @@
# M5Stack StampS3 board configuration
# Copyright (c) 2023 Martin Kiepfer <mrmarteng@teleschirm.org>
# SPDX-License-Identifier: Apache-2.0
config BOARD_M5STACK_STAMPS3
bool "M5Stack StampS3 Development Board"
depends on SOC_SERIES_ESP32S3
choice SOC_PART_NUMBER
default SOC_ESP32S3_FN8
endchoice

View file

@ -0,0 +1,27 @@
# M5Stack StampS3 board configuration
# Copyright (c) 2023 Martin Kiepfer <mrmarteng@teleschirm.org>
# SPDX-License-Identifier: Apache-2.0
if BOARD_M5STACK_STAMPS3
config BOARD
default "m5stack_stamps3"
depends on BOARD_M5STACK_STAMPS3
config ENTROPY_GENERATOR
default y
config HEAP_MEM_POOL_ADD_SIZE_BOARD
int
default 98304 if WIFI
default 65536 if BT
default 4096
config KERNEL_MEM_POOL
default y
choice BT_HCI_BUS_TYPE
default BT_ESP32 if BT
endchoice
endif # BOARD_M5STACK_STAMPS3

View file

@ -0,0 +1,9 @@
# SPDX-License-Identifier: Apache-2.0
if(NOT "${OPENOCD}" MATCHES "^${ESPRESSIF_TOOLCHAIN_PATH}/.*")
set(OPENOCD OPENOCD-NOTFOUND)
endif()
find_program(OPENOCD openocd PATHS ${ESPRESSIF_TOOLCHAIN_PATH}/openocd-esp32/bin NO_DEFAULT_PATH)
include(${ZEPHYR_BASE}/boards/common/esp32.board.cmake)
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View file

@ -0,0 +1,199 @@
.. _m5stack_stamps3:
M5Stack StampS3
###############
Overview
********
M5Stack StampS3 is an ESP32-based development board from M5Stack.
It features the following integrated components:
- ESP32-S3FN8 chip (240MHz dual core)
- 512KB SRAM
- 384KB ROM
- 8MB Flash
- Wi-Fi
- Bluetooth
- User-Button
.. figure:: img/m5stack_stamps3.webp
:align: center
:alt: M5Stack StampS3
:width: 400 px
M5Stack StampS3 module
Functional Description
**********************
The following table below describes the key components, interfaces, and controls
of the M5Stack StampS3 module.
+---------------+-----------------------------------------------------------------+-----------+
| Key Component | Description | Status |
+===============+=================================================================+===========+
| ESP32-S3FN8 | This MPU-ESP32S3 module provides complete Wi-Fi and Bluetooth | supported |
| module | functionalities and integrates a 8MB flash. | |
+---------------+-----------------------------------------------------------------+-----------+
| Status LED | One user LED connected via :dtcompatible:`worldsemi,ws2812-spi` | supported |
| | interface (``led-strip``). | |
+---------------+-----------------------------------------------------------------+-----------+
| USB Port | USB interface. Power supply for the board as well as the | supported |
| | communication interface between a computer and the board. | |
+---------------+-----------------------------------------------------------------+-----------+
| User button | User button (``sw0``) | supported |
+---------------+-----------------------------------------------------------------+-----------+
Main connector header
=====================
The Zephyr m5stack_stamps3 board can be used on various applications. It
therefore publishes a header definition to be used in different shields:
:dtcompatible:`m5stack,stamps3-header`.
.. figure:: img/m5stack_stamps3_header.webp
:align: center
:alt: M5Stack StampS3 Header
:width: 400 px
M5Stack StampS3 connector header
Following interfaces are being exported for this header:
- ``m5stack_stamps3_clkout0``: PWM output with 2 channels (0 and 2).
- ``m5stack_stamps3_spilcd``: SPI interface for interfacing LCDs. Consists of a
CLK, MOSI and CS signal.
- ``m5stack_stamps3_i2c0`` and ``m5stack_stamps3_i2c1``: I2C interfaces (SDA, SCL).
- ``m5stack_stamps3_uart0``: UART interface (RXD, TXD).
- ``m5stack_stamps3_header``: All GPIOs are of course accessible via main header
definition.
+-----+-----------------------------------------+-----+---------------------------------+
| Pin | Functions | Pin | Functions |
+=====+=========================================+=====+=================================+
| 1 | | | |
+-----+-----------------------------------------+-----+---------------------------------+
| 2 | | | |
+-----+-----------------------------------------+-----+---------------------------------+
| 3 | ``m5stack_stamps3_clkout0`` - Channel 0 | | |
+-----+-----------------------------------------+-----+---------------------------------+
| 4 | | | |
+-----+-----------------------------------------+-----+---------------------------------+
| 5 | ``m5stack_stamps3_spilcd`` - MOSI | | |
+-----+-----------------------------------------+-----+---------------------------------+
| 6 | ``m5stack_stamps3_spilcd`` - CLK | | |
+-----+-----------------------------------------+-----+---------------------------------+
| 7 | ``m5stack_stamps3_spilcd`` - CS | 28 | **3V3** |
+-----+-----------------------------------------+-----+---------------------------------+
| 8 | | 27 | ``m5stack_stamps3_uart0`` - TXD |
+-----+-----------------------------------------+-----+---------------------------------+
| 9 | ``m5stack_stamps3_clkout0`` - Channel 2 | 26 | |
+-----+-----------------------------------------+-----+---------------------------------+
| 10 | | 25 | ``m5stack_stamps3_uart0`` - RXD |
+-----+-----------------------------------------+-----+---------------------------------+
| 11 | **GND** | 24 | |
+-----+-----------------------------------------+-----+---------------------------------+
| 12 | ``m5stack_stamps3_i2c1`` - SDA | 23 | |
+-----+-----------------------------------------+-----+---------------------------------+
| 13 | **5V** | 22 | **EN** |
+-----+-----------------------------------------+-----+---------------------------------+
| 14 | ``m5stack_stamps3_i2c1`` - SCL | 21 | |
+-----+-----------------------------------------+-----+---------------------------------+
| 15 | ``m5stack_stamps3_i2c0`` - SDA | 20 | |
+-----+-----------------------------------------+-----+---------------------------------+
| 16 | | 19 | |
+-----+-----------------------------------------+-----+---------------------------------+
| 17 | ``m5stack_stamps3_i2c0`` - SCL | 18 | **GND** |
+-----+-----------------------------------------+-----+---------------------------------+
Power supply
============
M5Stack StampS3 requires a single 5V input power supply. The module internally
features a DCDC (MUN3CAD01-SC) to generate the 3.3V needed for the MCU.
The **EN** signal (Pin 22) is an active low signal to enable the **3V3** power
supply. If this pin is pulled low this main 3.3V power supply for the MCU will be
deactivated. It is internally equipped with a pull-up and can hence be left open
if unused.
Start Application Development
*****************************
Before powering up your M5Stack StampS3, please make sure that the board is in good
condition with no obvious signs of damage.
System requirements
===================
Prerequisites
-------------
Espressif HAL requires WiFi and Bluetooth binary blobs in order work. Run the command
below to retrieve those files.
.. code-block:: console
west blobs fetch hal_espressif
.. note::
It is recommended running the command above after :file:`west update`.
Building & Flashing
-------------------
Build and flash applications as usual (see :ref:`build_an_application` and
:ref:`application_run` for more details).
.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: m5stack_stamps3
:goals: build
The usual ``flash`` target will work with the ``m5stack_stamps3`` board
configuration. Here is an example for the :ref:`hello_world`
application.
.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: m5stack_stamps3
:goals: flash
The baud rate of 921600bps is set by default. If experiencing issues when flashing,
try using different values by using ``--esp-baud-rate <BAUD>`` option during
``west flash`` (e.g. ``west flash --esp-baud-rate 115200``).
You can also open the serial monitor using the following command:
.. code-block:: shell
west espressif monitor
After the board has automatically reset and booted, you should see the following
message in the monitor:
.. code-block:: console
***** Booting Zephyr OS vx.x.x-xxx-gxxxxxxxxxxxx *****
Hello World! m5stack_stamps3
Debugging
---------
M5Stack StampS3 exports a JTAG-interface via Pins 19 (MTCK), 21 (MTDO), 23
(MTDI), 25 (MTMS).
.. note::
Please note that additional JTAG equipment is needed to utilize JTAG. Refer to
the ESP32S3 datasheet and the M5Stack StampS3 documentation for details.
Related Documents
*****************
- `M5Stack StampS3 schematic <https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/datasheet/Stamp/S007%20StampS3/Sch_M5StampS3_v0.2.pdf>`_
- `M5Stack StampS3 <https://docs.m5stack.com/en/core/StampS3>`_
- `ESP32 Datasheet <https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf>`_ (PDF)
- `ESP32 Hardware Reference <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/hw-reference/index.html>`_

View file

@ -0,0 +1,84 @@
/*
* Copyright (c) 2023 Martin Kiepfer <mrmarteng@teleschirm.org>
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/dt-bindings/pinctrl/esp-pinctrl-common.h>
#include <dt-bindings/pinctrl/esp32s3-pinctrl.h>
#include <zephyr/dt-bindings/pinctrl/esp32s3-gpio-sigmap.h>
&pinctrl {
uart0_default: uart0_default {
group1 {
pinmux = <UART0_TX_GPIO43>;
output-high;
};
group2 {
pinmux = <UART0_RX_GPIO44>;
bias-pull-up;
};
};
i2c0_default: i2c0_default {
group1 {
pinmux = <I2C0_SDA_GPIO13>,
<I2C0_SCL_GPIO15>;
bias-pull-up;
drive-open-drain;
output-high;
};
};
i2c1_default: i2c1_default {
group1 {
pinmux = <I2C1_SDA_GPIO11>,
<I2C1_SCL_GPIO12>;
bias-pull-up;
drive-open-drain;
output-high;
};
};
spim2_default: spim2_default {
group1 {
pinmux = <SPIM2_SCLK_GPIO6>,
<SPIM2_CSEL_GPIO7>;
};
group2 {
pinmux = <SPIM2_MOSI_GPIO5>;
output-low;
};
};
spim3_default: spim3_default {
group1 {
pinmux = <SPIM3_MOSI_GPIO21>;
output-low;
};
};
ledc0_default: ledc0_default {
group1 {
pinmux = <LEDC_CH0_GPIO9>; /* lcd backlight */
output-enable;
};
group2 {
pinmux = <LEDC_CH1_GPIO3>; /* beeper */
output-enable;
};
};
mcpwm0_default: mcpwm0_default {
group1 {
pinmux = <MCPWM0_OUT0A_GPIO9>; /* lcd backlight */
output-enable;
};
group2 {
pinmux = <MCPWM0_OUT1A_GPIO3>;
output-enable;
};
};
};

View file

@ -0,0 +1,195 @@
/*
* Copyright (c) 2023 Martin Kiepfer <mrmarteng@teleschirm.org>
*
* SPDX-License-Identifier: Apache-2.0
*/
/dts-v1/;
#include <espressif/esp32s3/esp32s3_fn8.dtsi>
#include "m5stack_stamps3-pinctrl.dtsi"
#include "m5stack_stamps3_connectors.dtsi"
#include <zephyr/dt-bindings/pwm/pwm.h>
#include <dt-bindings/led/led.h>
#include <dt-bindings/led/worldsemi_ws2812c.h>
#include <zephyr/dt-bindings/input/input-event-codes.h>
/ {
model = "M5Stack StampS3";
compatible = "m5stack,stamps3";
chosen {
zephyr,sram = &sram0;
zephyr,console = &usb_serial;
zephyr,shell-uart = &usb_serial;
zephyr,flash = &flash0;
zephyr,code-partition = &slot0_partition;
};
aliases {
sw0 = &user_button_0;
watchdog0 = &wdt0;
//pwm-0 = &ledc0;
i2c-0 = &i2c0;
led-strip = &status_rgb_led;
};
gpio_keys {
compatible = "gpio-keys";
/* This is the button that's underneath the LCD display */
user_button_0: button_0 {
label = "User button 0";
gpios = <&gpio0 0 GPIO_ACTIVE_LOW>;
zephyr,code = <INPUT_KEY_0>;
};
};
};
&cpu0 {
clock-frequency = <ESP32_CLK_CPU_240M>;
};
&cpu1 {
clock-frequency = <ESP32_CLK_CPU_240M>;
};
&usb_serial {
status = "okay";
};
&uart0 {
status = "okay";
current-speed = <115200>;
pinctrl-0 = <&uart0_default>;
pinctrl-names = "default";
};
&i2c0 {
status = "okay";
clock-frequency = <I2C_BITRATE_STANDARD>;
pinctrl-0 = <&i2c0_default>;
pinctrl-names = "default";
};
&i2c1 {
status = "okay";
clock-frequency = <I2C_BITRATE_STANDARD>;
pinctrl-0 = <&i2c1_default>;
pinctrl-names = "default";
};
&trng0 {
status = "okay";
};
&mcpwm0 {
status = "okay";
pinctrl-0 = <&mcpwm0_default>;
pinctrl-names = "default";
prescale = <255>;
prescale-timer0 = <100>;
prescale-timer1 = <100>;
};
&ledc0 {
pinctrl-0 = <&ledc0_default>;
pinctrl-names = "default";
status = "disabled";
#address-cells = <1>;
#size-cells = <0>;
channel0@0 {
reg = <0x0>;
timer = <0>;
};
channel0@1 {
reg = <0x1>;
timer = <0>;
};
};
&spi2 {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
pinctrl-0 = <&spim2_default>;
pinctrl-names = "default";
};
&spi3 {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
line-idle-low;
pinctrl-0 = <&spim3_default>;
pinctrl-names = "default";
status_rgb_led: ws2812@0 {
compatible = "worldsemi,ws2812-spi";
reg = <0x0>;
spi-max-frequency = <WS2812C_SPI_FREQ>;
chain-length = <1>;
color-mapping = <LED_COLOR_ID_GREEN>,
<LED_COLOR_ID_RED>,
<LED_COLOR_ID_BLUE>;
spi-one-frame = <WS2812C_ONE_FRAME>;
spi-zero-frame = <WS2812C_ZERO_FRAME>;
reset-delay = <250>;
};
};
&gpio0 {
status = "okay";
};
&gpio1 {
status = "okay";
};
&wdt0 {
status = "okay";
};
&timer0 {
status = "okay";
};
&timer1 {
status = "okay";
};
&flash0 {
status = "okay";
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
boot_partition: partition@0 {
label = "mcuboot";
reg = <0x00000000 0x0000F000>;
read-only;
};
slot0_partition: partition@10000 {
label = "image-0";
reg = <0x00010000 0x00100000>;
};
slot1_partition: partition@110000 {
label = "image-1";
reg = <0x00110000 0x00100000>;
};
scratch_partition: partition@210000 {
label = "image-scratch";
reg = <0x00210000 0x00040000>;
};
storage_partition: partition@250000 {
label = "storage";
reg = <0x00250000 0x00006000>;
};
};
};

View file

@ -0,0 +1,20 @@
identifier: m5stack_stamps3
name: M5Stack StampS3
type: mcu
arch: xtensa
toolchain:
- zephyr
supported:
- gpio
- i2c
- spi
- watchdog
- uart
- pwm
- pinmux
- nvs
testing:
ignore_tags:
- net
- bluetooth
vendor: m5stack

View file

@ -0,0 +1,48 @@
/*
* Copyright (c) 2023 Martin Kiepfer
* SPDX-License-Identifier: Apache-2.0
*/
/ {
m5stack_stamps3_header: m5stack_stamps3_header {
compatible = "m5stack,stamps3-header";
#gpio-cells = <2>;
gpio-map-mask = <0xffffffff 0xffffffc0>;
gpio-map-pass-thru = <0 0x3f>;
gpio-map =
<0 0 &gpio0 1 0>, /* GPIO/AIN */
<1 0 &gpio0 2 0>, /* GPIO/AIN */
<2 0 &gpio0 3 0>, /* GPIO/AIN/CLKOUT1-3 */
<3 0 &gpio0 4 0>, /* GPIO/AIN */
<4 0 &gpio0 5 0>, /* GPIO/AIN/SPI2-MOSI */
<5 0 &gpio0 6 0>, /* GPIO/AIN/SPI2-CLK */
<6 0 &gpio0 7 0>, /* GPIO/AIN/SPI2-CS */
<7 0 &gpio0 8 0>, /* GPIO/AIN */
<8 0 &gpio0 9 0>, /* GPIO/AIN/CLKOUT1-4 */
<9 0 &gpio0 10 0>, /* GPIO/AIN */
/* 10 GND */
<11 0 &gpio0 11 0>, /* GPIO/AIN/SDA1 */
/* 11 5V */
<12 0 &gpio0 12 0>, /* GPIO/AIN/SCL1 */
<14 0 &gpio0 13 0>, /* GPIO/AIN/SDA0 */
<15 0 &gpio0 14 0>, /* GPIO/AIN */
<16 0 &gpio0 15 0>, /* GPIO/AIN/SCL0 */
/* 17 GND */
<18 0 &gpio1 7 0>, /* GPIO/CLKOUT0-0 */
<19 0 &gpio0 0 0>, /* GPIO */
<20 0 &gpio1 8 0>, /* GPIO/CLKOUT0-1 */
/* 21 EN */
<22 0 &gpio1 9 0>, /* GPIO/CLKOUT1-0 */
<23 0 &gpio1 12 0>, /* GPIO/CLKOUT1-1/RXD0 */
<24 0 &gpio1 10 0>, /* GPIO */
<25 0 &gpio1 11 0>, /* GPIO/CLKOUT1.2/TXD0 */
<26 0 &gpio1 14 0>; /* GPIO */
/* 27 3V3 */
};
};
m5stack_stamps3_uart0: &uart0 {};
m5stack_stamps3_i2c0: &i2c0 {};
m5stack_stamps3_i2c1: &i2c1 {};
m5stack_stamps3_clkout0: &mcpwm0 {};
m5stack_stamps3_spilcd: &spi2 {};

View file

@ -0,0 +1,14 @@
# SPDX-License-Identifier: Apache-2.0
CONFIG_BOARD_M5STACK_STAMPS3=y
CONFIG_SOC_SERIES_ESP32S3=y
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_GPIO=y
CONFIG_CONSOLE=y
CONFIG_PWM=y
CONFIG_SERIAL=y
CONFIG_UART_CONSOLE=y
CONFIG_CLOCK_CONTROL=y

View file

@ -0,0 +1,33 @@
# Copyright (c) 2023 Martin Kiepfer
# SPDX-License-Identifier: Apache-2.0
description: |
GPIO pins exposed on M5Stack StampS3 module headers.
This binding provides a nexus mapping for 28 pins as depicted below.
0 GPIO
1 GPIO
2 GPIO/CLKOUT0
3 GPIO
4 GPIO/SPILCD
5 GPIO/SPILCD
6 GPIO/SPILCD 27 3V3
7 GPIO 26 GPIO
8 GPIO/CLKOUT0 25 GPIO/CLKOUT/TXD
9 GPIO 24 GPIO
10 GND 23 GPIO/CLKOUT/RXD
11 GPIO/SDA1 22 GPIO/CLKOUT
12 5V 21 EN
13 GPIO/SCL1 20 GPIO/CLKOUT
14 GPIO/SDA0 19 GPIO
15 GPIO 18 GPIO/CLKOUT
16 GPIO/SCL0 17 GND
Note: Please note that the StampS3 is not pin compatible to the
other Stamp variantes like StampC3 or Stamp-Pico.
compatible: "m5stack,stamps3-header"
include: [gpio-nexus.yaml, base.yaml]