Skip to content

Commit

Permalink
boards: xtensa: Add support for Lolin S2 Mini
Browse files Browse the repository at this point in the history
Add support for LOLIN S2 Mini board, a cheap board
also sold as Wemos S2 Mini.

Signed-off-by: Moritz Fischer <moritzf@google.com>
  • Loading branch information
mfischer committed May 3, 2023
1 parent 2b4fdd1 commit 38b97a2
Show file tree
Hide file tree
Showing 10 changed files with 330 additions and 1 deletion.
8 changes: 8 additions & 0 deletions boards/xtensa/esp32s2_lolin_mini/Kconfig.board
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# ESP32S2 LOLIN S2 MINI board configuration

# Copyright (c) 2023 Google, LLC
# SPDX-License-Identifier: Apache-2.0

config BOARD_ESP32S2_LOLIN_MINI
bool "ESP32S2 Lolin Mini Board"
depends on SOC_ESP32S2
15 changes: 15 additions & 0 deletions boards/xtensa/esp32s2_lolin_mini/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# ESP32S2 LOLIN S2 MINI board configuration

# Copyright (c) 2023 Google, LLC
# SPDX-License-Identifier: Apache-2.0

config BOARD
default "esp32s2_lolin_mini"
depends on BOARD_ESP32S2_LOLIN_MINI

config ENTROPY_GENERATOR
default y

config HEAP_MEM_POOL_SIZE
default 32768 if WIFI
default 4096
9 changes: 9 additions & 0 deletions boards/xtensa/esp32s2_lolin_mini/board.cmake
Original file line number Diff line number Diff line change
@@ -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)
92 changes: 92 additions & 0 deletions boards/xtensa/esp32s2_lolin_mini/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
.. _esp32s2_lolin_mini:

ESP32-S2
########

Overview
********

ESP32-S2 is a highly integrated, low-power, single-core Wi-Fi Microcontroller SoC, designed to be secure and
cost-effective, with a high performance and a rich set of IO capabilities. [1]_

The features include the following:

- RSA-3072-based secure boot
- AES-XTS-256-based flash encryption
- Protected private key and device secrets from software access
- Cryptographic accelerators for enhanced performance
- Protection against physical fault injection attacks
- Various peripherals:

- 43x programmable GPIOs
- 14x configurable capacitive touch GPIOs
- USB OTG
- LCD interface
- camera interface
- SPI
- I2S
- UART
- ADC
- DAC
- LED PWM with up to 8 channels

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: esp32s2_lolin_mini
:goals: build

The usual ``flash`` target will work with the ``esp32s2_lolin_mini`` board
configuration after putting the board into bootloader mode by holding the '0'
button then pressing 'RST' and releasing the 'RST' button.

Here is an example for the :ref:`hello_world`
application.

.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: esp32s2_lolin_mini
:goals: flash

Open a serial port using e.g. screen

.. code-block:: shell
screen /dev/ttyUSB0 115200
After the board has been manually 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! esp32s2_lolin_mini
References
**********

.. [1] https://www.espressif.com/en/products/socs/esp32-s2
.. _`ESP32S2 Technical Reference Manual`: https://espressif.com/sites/default/files/documentation/esp32-s2_technical_reference_manual_en.pdf
.. _`ESP32S2 Datasheet`: https://www.espressif.com/sites/default/files/documentation/esp32-s2_datasheet_en.pdf
22 changes: 22 additions & 0 deletions boards/xtensa/esp32s2_lolin_mini/esp32s2_lolin_mini-pinctrl.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2023 Google, LLC
*
* SPDX-License-Identifier: Apache-2.0
*/

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

&pinctrl {

uart0_default: uart0_default {
group1 {
pinmux = <UART0_TX_GPIO16>;
};
group2 {
pinmux = <UART0_RX_GPIO17>;
bias-pull-up;
};
};
};
143 changes: 143 additions & 0 deletions boards/xtensa/esp32s2_lolin_mini/esp32s2_lolin_mini.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/*
* Copyright (c) 2023 Google, LLC
*
* SPDX-License-Identifier: Apache-2.0
*/

/dts-v1/;

#include <espressif/esp32s2.dtsi>
#include "esp32s2_lolin_mini-pinctrl.dtsi"

/ {
model = "esp32s2_lolin_mini";
compatible = "espressif,esp32s2";

aliases {
sw0 = &user_button;
led0 = &user_led;
watchdog0 = &wdt0;
};

chosen {
zephyr,sram = &sram0;
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
zephyr,flash = &flash0;
};

power-states {
light_sleep: light_sleep {
compatible = "zephyr,power-state";
power-state-name = "standby";
min-residency-us = <200>;
exit-latency-us = <60>;
};

deep_sleep: deep_sleep {
compatible = "zephyr,power-state";
power-state-name = "soft-off";
min-residency-us = <2000>;
exit-latency-us = <212>;
};
};

leds {
compatible = "gpio-leds";
user_led: led {
gpios = <&gpio0 15 GPIO_ACTIVE_HIGH>;
label = "LED1";
};
};

gpio_keys {
compatible = "gpio-keys";
user_button: user_button {
label = "0";
gpios = <&gpio0 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
};
};
};

&cpu0 {
clock-frequency = <ESP32_CLK_CPU_240M>;
cpu-power-states = <&deep_sleep &light_sleep>;
};

&uart0 {
status = "okay";
current-speed = <115200>;
pinctrl-0 = <&uart0_default>;
pinctrl-names = "default";
};

&gpio0 {
status = "okay";
};

&gpio1 {
status = "okay";
};

&timer0 {
status = "disabled";
};

&timer1 {
status = "disabled";
};

&timer2 {
status = "disabled";
};

&timer3 {
status = "disabled";
};

&trng0 {
status = "okay";
};

&flash0 {
status = "okay";
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;

/* Reserve 60kB for the bootloader */
boot_partition: partition@1000 {
label = "mcuboot";
reg = <0x00001000 0x0000F000>;
read-only;
};

/* Reserve 1024kB for the application in slot 0 */
slot0_partition: partition@10000 {
label = "image-0";
reg = <0x00010000 0x00100000>;
};

/* Reserve 1024kB for the application in slot 1 */
slot1_partition: partition@110000 {
label = "image-1";
reg = <0x00110000 0x00100000>;
};

/* Reserve 256kB for the scratch partition */
scratch_partition: partition@210000 {
label = "image-scratch";
reg = <0x00210000 0x00040000>;
};

storage_partition: partition@250000 {
label = "storage";
reg = <0x00250000 0x00006000>;
};
};
};

&wdt0 {
status = "okay";
};
14 changes: 14 additions & 0 deletions boards/xtensa/esp32s2_lolin_mini/esp32s2_lolin_mini.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
identifier: esp32s2_lolin_mini
name: Lolin ESP32-S2 Mini
type: mcu
arch: xtensa
toolchain:
- zephyr
supported:
- gpio
- watchdog
- uart
testing:
ignore_tags:
- net
- bluetooth
22 changes: 22 additions & 0 deletions boards/xtensa/esp32s2_lolin_mini/esp32s2_lolin_mini_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SPDX-License-Identifier: Apache-2.0

CONFIG_XTENSA_RESET_VECTOR=n

CONFIG_BOARD_ESP32S2_LOLIN_MINI=y
CONFIG_SOC_ESP32S2=y
CONFIG_MAIN_STACK_SIZE=2048

CONFIG_CONSOLE=y
CONFIG_SERIAL=y
CONFIG_UART_CONSOLE=y

CONFIG_XTENSA_USE_CORE_CRT1=n

CONFIG_GPIO=y

CONFIG_GEN_ISR_TABLES=y
CONFIG_GEN_IRQ_VECTOR_TABLE=n

CONFIG_CLOCK_CONTROL=y

CONFIG_BOOTLOADER_ESP_IDF=y
4 changes: 4 additions & 0 deletions boards/xtensa/esp32s2_lolin_mini/support/openocd.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set ESP_RTOS none

source [find interface/ftdi/esp32s2_kaluga_v1.cfg]
source [find target/esp32s2.cfg]
2 changes: 1 addition & 1 deletion tests/lib/heap/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
tests:
libraries.heap:
tags: heap
platform_exclude: m2gl025_miv qemu_xtensa esp32s2_saola esp32s3_devkitm
platform_exclude: m2gl025_miv qemu_xtensa esp32s2_saola esp32s3_devkitm esp32s2_lolin_mini
filter: not CONFIG_SOC_NSIM
timeout: 480

0 comments on commit 38b97a2

Please sign in to comment.