Skip to content

Support StickC-Plus2 #90448

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions boards/m5stack/m5stickc_plus2/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (c) 2022 AVSystem Sławomir Wolf Sp.j. (AVSystem)
# SPDX-License-Identifier: Apache-2.0

config HEAP_MEM_POOL_ADD_SIZE_BOARD
int
default 4096 if BOARD_M5STICKC_PLUS2_ESP32_PROCPU
default 256 if BOARD_M5STICKC_PLUS2_ESP32_APPCPU
23 changes: 23 additions & 0 deletions boards/m5stack/m5stickc_plus2/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# M5StickC PLUS board configuration

# Copyright (c) 2022 AVSystem Sławomir Wolf Sp.j. (AVSystem)
# SPDX-License-Identifier: Apache-2.0

if BOARD_M5STICKC_PLUS2_ESP32_PROCPU

config GPIO_HOGS_INIT_PRIORITY
default 70

config MFD_INIT_PRIORITY
default 70

config REGULATOR_AXP192_AXP2101_INIT_PRIORITY
default 71

config GPIO_AXP192_INIT_PRIORITY
default 72

config REGULATOR_FIXED_INIT_PRIORITY
default 75

endif # BOARD_M5STICKC_PLUS2_ESP32_PROCPU
9 changes: 9 additions & 0 deletions boards/m5stack/m5stickc_plus2/Kconfig.m5stickc_plus2
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# M5StickC PLUS board configuration

# Copyright (c) 2022 AVSystem Sławomir Wolf Sp.j. (AVSystem)
# SPDX-License-Identifier: Apache-2.0

config BOARD_M5STICKC_PLUS2
select SOC_ESP32_PICO_D4
select SOC_ESP32_PROCPU if BOARD_M5STICKC_PLUS2_ESP32_PROCPU
select SOC_ESP32_APPCPU if BOARD_M5STICKC_PLUS2_ESP32_APPCPU
10 changes: 10 additions & 0 deletions boards/m5stack/m5stickc_plus2/Kconfig.sysbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2023 Espressif Systems (Shanghai) Co., Ltd.
# SPDX-License-Identifier: Apache-2.0

choice BOOTLOADER
default BOOTLOADER_MCUBOOT
endchoice

choice BOOT_SIGNATURE_TYPE
default BOOT_SIGNATURE_TYPE_NONE
endchoice
12 changes: 12 additions & 0 deletions boards/m5stack/m5stickc_plus2/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 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)

# the default ESP32 baud rate is not supported
board_runner_args(esp32 "--esp-baud-rate=1500000")
6 changes: 6 additions & 0 deletions boards/m5stack/m5stickc_plus2/board.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
board:
name: m5stickc_plus2
full_name: M5StickC PLUS2
vendor: m5stack
socs:
- name: esp32
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be esp32_pico_d4?

221 changes: 221 additions & 0 deletions boards/m5stack/m5stickc_plus2/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
.. zephyr:board:: m5stickc_plus2

Overview
********

M5StickC PLUS, one of the core devices in M5Stacks product series, is an ESP32-based development board.

M5StickC PLUS features the following integrated components:

- ESP32-PICO-D4 chip (240MHz dual core, 600 DMIPS, 520KB SRAM, Wi-Fi)
- ST7789v2, LCD TFT 1.14", 135x240 px screen
- IMU MPU-6886
- SPM-1423 microphone
- RTC BM8563
- PMU AXP192
- 120 mAh 3,7 V battery

Some of the ESP32 I/O pins are broken out to the board's pin headers for easy access.

Functional Description
**********************

The following table below describes the key components, interfaces, and controls
of the M5StickC PLUS board.

.. _ST7789v2: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/datasheet/core/ST7789V.pdf
.. _MPU-6886: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/datasheet/core/MPU-6886-000193%2Bv1.1_GHIC_en.pdf
.. _ESP32-PICO-D4: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/datasheet/core/esp32-pico-d4_datasheet_en.pdf
.. _SPM-1423: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/datasheet/core/SPM1423HM4H-B_datasheet_en.pdf
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move all the links to the end


+------------------+-------------------------------------------------------------------------+
| Key Component | Description |
+==================+=========================================================================+
| 32.768 kHz RTC | External precision 32.768 kHz crystal oscillator serves as a clock with |
| | low-power consumption while the chip is in Deep-sleep mode. |
+------------------+-------------------------------------------------------------------------+
| ESP32-PICO-D4 | This `ESP32-PICO-D4`_ module provides complete Wi-Fi and Bluetooth |
| module | functionalities and integrates a 4-MB SPI flash. |
+------------------+-------------------------------------------------------------------------+
| Diagnostic LED | One user LED connected to the GPIO pin. |
+------------------+-------------------------------------------------------------------------+
| USB Port | USB interface. Power supply for the board as well as the |
| | communication interface between a computer and the board. |
| | Contains: TypeC x 1, GROVE(I2C+I/O+UART) x 1 |
+------------------+-------------------------------------------------------------------------+
| Power Switch | Power on/off button. |
+------------------+-------------------------------------------------------------------------+
| A/B user buttons | Two push buttons intended for any user use. |
+------------------+-------------------------------------------------------------------------+
| LCD screen | Built-in LCD TFT display \(`ST7789v2`_, 1.14", 135x240 px\) controlled |
| | by the SPI interface |
+------------------+-------------------------------------------------------------------------+
| MPU-6886 | The `MPU-6886`_ is a 6-axis MotionTracking device that combines a |
| | 3-axis gyroscope and a 3-axis accelerometer. |
+------------------+-------------------------------------------------------------------------+
| Built-in | The `SPM-1423`_ I2S driven microphone. |
| microphone | |
+------------------+-------------------------------------------------------------------------+


Start Application Development
*****************************

Before powering up your M5StickC PLUS, please make sure that the board is in good
condition with no obvious signs of damage.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary info, to be removed.


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
*******************

.. zephyr:board-supported-runners::

Simple boot
===========

The board could be loaded using the single binary image, without 2nd stage bootloader.
It is the default option when building the application without additional configuration.

.. note::

Simple boot does not provide any security features nor OTA updates.

MCUboot bootloader
==================

User may choose to use MCUboot bootloader instead. In that case the bootloader
must be built (and flashed) at least once.

There are two options to be used when building an application:

1. Sysbuild
2. Manual build

.. note::

User can select the MCUboot bootloader by adding the following line
to the board default configuration file.

.. code:: cfg

CONFIG_BOOTLOADER_MCUBOOT=y

Sysbuild
========

The sysbuild makes possible to build and flash all necessary images needed to
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The sysbuild makes possible to build and flash all necessary images needed to
The sysbuild makes it possible to build and flash all necessary images needed to

bootstrap the board with the ESP32 SoC.

To build the sample application using sysbuild use the command:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To build the sample application using sysbuild use the command:
To build the sample application using sysbuild, use the command:


.. zephyr-app-commands::
:tool: west
:zephyr-app: samples/hello_world
:board: m5stickc_plus2
:goals: build
:west-args: --sysbuild
:compact:

By default, the ESP32 sysbuild creates bootloader (MCUboot) and application
images. But it can be configured to create other kind of images.

Build directory structure created by sysbuild is different from traditional
Zephyr build. Output is structured by the domain subdirectories:

.. code-block::

build/
├── hello_world
│ └── zephyr
│ ├── zephyr.elf
│ └── zephyr.bin
├── mcuboot
│ └── zephyr
│ ├── zephyr.elf
│ └── zephyr.bin
└── domains.yaml

.. note::

With ``--sysbuild`` option the bootloader will be re-build and re-flash
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
With ``--sysbuild`` option the bootloader will be re-build and re-flash
With ``--sysbuild`` option the bootloader will be re-built and re-flashed

every time the pristine build is used.

For more information about the system build please read the :ref:`sysbuild` documentation.

Manual build
============

During the development cycle, it is intended to build & flash as quickly possible.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
During the development cycle, it is intended to build & flash as quickly possible.
During the development cycle, it is intended to build & flash as quickly as possible.

For that reason, images can be built one at a time using traditional build.

The instructions following are relevant for both manual build and sysbuild.
The only difference is the structure of the build directory.

.. note::

Remember that bootloader (MCUboot) needs to be flash at least once.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Remember that bootloader (MCUboot) needs to be flash at least once.
Remember that bootloader (MCUboot) needs to be flashed at least once.


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: m5stickc_plus2/esp32/procpu
:goals: build

The usual ``flash`` target will work with the ``m5stickc_plus2`` board
configuration. Here is an example for the :zephyr:code-sample:`hello_world`
application.

.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: m5stickc_plus2/esp32/procpu
:goals: flash

The default baud rate for the M5StickC PLUS is set to 1500000bps. 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! m5stickc_plus2

Debugging
*********

M5StickC PLUS debugging is not supported due to pinout limitations.

Related Documents
*****************

- `M5StickC PLUS schematic <https://static-cdn.m5stack.com/resource/docs/products/core/m5stickc_plus2/m5stickc_plus_sch_03.webp>`_ (WEBP)
- `ESP32-PICO-D4 Datasheet <https://www.espressif.com/sites/default/files/documentation/esp32-pico-d4_datasheet_en.pdf>`_ (PDF)
- `M5StickC PLUS docs <https://docs.m5stack.com/en/core/m5stickc_plus2>`_
- `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>`_
61 changes: 61 additions & 0 deletions boards/m5stack/m5stickc_plus2/m5stickc_plus2-pinctrl.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2022 AVSystem Sławomir Wolf Sp.j. (AVSystem)
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/dt-bindings/pinctrl/esp-pinctrl-common.h>
#include <dt-bindings/pinctrl/esp32-pinctrl.h>
#include <zephyr/dt-bindings/pinctrl/esp32-gpio-sigmap.h>

&pinctrl {

uart0_tx_gpio1: uart0_tx_gpio1 {
pinmux = <UART0_TX_GPIO1>;
output-high;
};

uart0_rx_gpio3: uart0_rx_gpio3 {
pinmux = <UART0_RX_GPIO3>;
bias-pull-up;
};

spim2_miso_gpio12: spim2_miso_gpio12 {
pinmux = <SPIM2_MISO_GPIO12>;
};

spim2_mosi_gpio11: spim2_mosi_gpio11 {
pinmux = <SPIM2_MOSI_GPIO11>;
output-low;
};

spim2_sclk_gpio14: spim2_sclk_gpio14 {
pinmux = <SPIM2_SCLK_GPIO14>;
};

spim2_csel_gpio16: spim2_csel_gpio16 {
pinmux = <SPIM2_CSEL_GPIO16>;
};

spim3_default: spim3_default {
group1 {
pinmux = <SPIM3_MISO_GPIO36>,
<SPIM3_SCLK_GPIO13>,
<SPIM3_CSEL_GPIO5>;
};
group2 {
pinmux = <SPIM3_MOSI_GPIO15>;
output-low;
};
};

i2c0_default: i2c0_default {
group1 {
pinmux = <I2C0_SDA_GPIO21>,
<I2C0_SCL_GPIO22>;
bias-pull-up;
drive-open-drain;
output-high;
};
};
};
30 changes: 30 additions & 0 deletions boards/m5stack/m5stickc_plus2/m5stickc_plus2_appcpu.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2023 Espressif Systems (Shanghai) Co., Ltd.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put your own copyright everywhere

*
* SPDX-License-Identifier: Apache-2.0
*/
/dts-v1/;

#include <espressif/esp32/esp32_pico_d4.dtsi>
#include <espressif/partitions_0x1000_amp.dtsi>

/ {
model = "M5StickC Plus APPCPU";
compatible = "espressif,esp32";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the board's compatible

Suggested change
compatible = "espressif,esp32";
compatible = "m5stack,m5stickc_plus2";


chosen {
zephyr,sram = &sram1;
zephyr,ipc_shm = &shm0;
zephyr,ipc = &ipm0;
zephyr,flash = &flash0;
zephyr,code-partition = &slot0_appcpu_partition;
};
};

&ipm0 {
status = "okay";
};

&trng0 {
status = "okay";
};
Loading
Loading