From 38b97a2dcd54345a0bf47bf8a320f88d7cfdab7c Mon Sep 17 00:00:00 2001 From: Moritz Fischer Date: Sun, 9 Apr 2023 17:54:54 -0700 Subject: [PATCH] boards: xtensa: Add support for Lolin S2 Mini Add support for LOLIN S2 Mini board, a cheap board also sold as Wemos S2 Mini. Signed-off-by: Moritz Fischer --- .../xtensa/esp32s2_lolin_mini/Kconfig.board | 8 + .../esp32s2_lolin_mini/Kconfig.defconfig | 15 ++ boards/xtensa/esp32s2_lolin_mini/board.cmake | 9 ++ .../xtensa/esp32s2_lolin_mini/doc/index.rst | 92 +++++++++++ .../esp32s2_lolin_mini-pinctrl.dtsi | 22 +++ .../esp32s2_lolin_mini/esp32s2_lolin_mini.dts | 143 ++++++++++++++++++ .../esp32s2_lolin_mini.yaml | 14 ++ .../esp32s2_lolin_mini_defconfig | 22 +++ .../esp32s2_lolin_mini/support/openocd.cfg | 4 + tests/lib/heap/testcase.yaml | 2 +- 10 files changed, 330 insertions(+), 1 deletion(-) create mode 100644 boards/xtensa/esp32s2_lolin_mini/Kconfig.board create mode 100644 boards/xtensa/esp32s2_lolin_mini/Kconfig.defconfig create mode 100644 boards/xtensa/esp32s2_lolin_mini/board.cmake create mode 100644 boards/xtensa/esp32s2_lolin_mini/doc/index.rst create mode 100644 boards/xtensa/esp32s2_lolin_mini/esp32s2_lolin_mini-pinctrl.dtsi create mode 100644 boards/xtensa/esp32s2_lolin_mini/esp32s2_lolin_mini.dts create mode 100644 boards/xtensa/esp32s2_lolin_mini/esp32s2_lolin_mini.yaml create mode 100644 boards/xtensa/esp32s2_lolin_mini/esp32s2_lolin_mini_defconfig create mode 100644 boards/xtensa/esp32s2_lolin_mini/support/openocd.cfg diff --git a/boards/xtensa/esp32s2_lolin_mini/Kconfig.board b/boards/xtensa/esp32s2_lolin_mini/Kconfig.board new file mode 100644 index 000000000000000..44a7e81aec62fc7 --- /dev/null +++ b/boards/xtensa/esp32s2_lolin_mini/Kconfig.board @@ -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 diff --git a/boards/xtensa/esp32s2_lolin_mini/Kconfig.defconfig b/boards/xtensa/esp32s2_lolin_mini/Kconfig.defconfig new file mode 100644 index 000000000000000..7724f8c90a1a096 --- /dev/null +++ b/boards/xtensa/esp32s2_lolin_mini/Kconfig.defconfig @@ -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 diff --git a/boards/xtensa/esp32s2_lolin_mini/board.cmake b/boards/xtensa/esp32s2_lolin_mini/board.cmake new file mode 100644 index 000000000000000..2f04d1fe8861ea6 --- /dev/null +++ b/boards/xtensa/esp32s2_lolin_mini/board.cmake @@ -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) diff --git a/boards/xtensa/esp32s2_lolin_mini/doc/index.rst b/boards/xtensa/esp32s2_lolin_mini/doc/index.rst new file mode 100644 index 000000000000000..0e5c970077b5125 --- /dev/null +++ b/boards/xtensa/esp32s2_lolin_mini/doc/index.rst @@ -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 diff --git a/boards/xtensa/esp32s2_lolin_mini/esp32s2_lolin_mini-pinctrl.dtsi b/boards/xtensa/esp32s2_lolin_mini/esp32s2_lolin_mini-pinctrl.dtsi new file mode 100644 index 000000000000000..19c0c17c66e4416 --- /dev/null +++ b/boards/xtensa/esp32s2_lolin_mini/esp32s2_lolin_mini-pinctrl.dtsi @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2023 Google, LLC + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include + +&pinctrl { + + uart0_default: uart0_default { + group1 { + pinmux = ; + }; + group2 { + pinmux = ; + bias-pull-up; + }; + }; +}; diff --git a/boards/xtensa/esp32s2_lolin_mini/esp32s2_lolin_mini.dts b/boards/xtensa/esp32s2_lolin_mini/esp32s2_lolin_mini.dts new file mode 100644 index 000000000000000..0e759e22c2ed13f --- /dev/null +++ b/boards/xtensa/esp32s2_lolin_mini/esp32s2_lolin_mini.dts @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2023 Google, LLC + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +#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 = ; + 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"; +}; diff --git a/boards/xtensa/esp32s2_lolin_mini/esp32s2_lolin_mini.yaml b/boards/xtensa/esp32s2_lolin_mini/esp32s2_lolin_mini.yaml new file mode 100644 index 000000000000000..3764f5eddd74f79 --- /dev/null +++ b/boards/xtensa/esp32s2_lolin_mini/esp32s2_lolin_mini.yaml @@ -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 diff --git a/boards/xtensa/esp32s2_lolin_mini/esp32s2_lolin_mini_defconfig b/boards/xtensa/esp32s2_lolin_mini/esp32s2_lolin_mini_defconfig new file mode 100644 index 000000000000000..505631c26082fa3 --- /dev/null +++ b/boards/xtensa/esp32s2_lolin_mini/esp32s2_lolin_mini_defconfig @@ -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 diff --git a/boards/xtensa/esp32s2_lolin_mini/support/openocd.cfg b/boards/xtensa/esp32s2_lolin_mini/support/openocd.cfg new file mode 100644 index 000000000000000..f75d53b0b34cd47 --- /dev/null +++ b/boards/xtensa/esp32s2_lolin_mini/support/openocd.cfg @@ -0,0 +1,4 @@ +set ESP_RTOS none + +source [find interface/ftdi/esp32s2_kaluga_v1.cfg] +source [find target/esp32s2.cfg] diff --git a/tests/lib/heap/testcase.yaml b/tests/lib/heap/testcase.yaml index 37ce33e2a4975a9..d55f9299c218d1a 100644 --- a/tests/lib/heap/testcase.yaml +++ b/tests/lib/heap/testcase.yaml @@ -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