Skip to content

Commit

Permalink
boards: add ESP32-S3-Box support
Browse files Browse the repository at this point in the history
  • Loading branch information
gschorcht committed Jul 7, 2023
1 parent e487ac5 commit 8100478
Show file tree
Hide file tree
Showing 10 changed files with 527 additions and 0 deletions.
34 changes: 34 additions & 0 deletions boards/esp32s3-box/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (c) 2020 HAW Hamburg
# 2023 Gunar Schorcht
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.

config BOARD
default "esp32s3-box" if BOARD_ESP32S3_BOX

config BOARD_ESP32S3_DEVKIT
bool
default y
select BOARD_COMMON_ESP32S3
select CPU_MODEL_ESP32S3_WROOM_1X_N16R8V
select HAS_ESP_JTAG
select HAS_PERIPH_I2C
select HAS_PERIPH_SPI
select HAS_PERIPH_UART
select HAS_PERIPH_USBDEV
select HAS_TINYUSB_DEVICE
# Only this board has a requirement to use USB_BOARD_RESET with STDIO_USB_SERIAL_JTAG
select MODULE_USB_BOARD_RESET if MODULE_STDIO_USB_SERIAL_JTAG
select REQUIRES_USB_STDIO if MODULE_USBUS || MODULE_TINYUSB_DEVICE

select HAVE_ILI9341

choice STDIO_IMPLEMENTATION
default MODULE_STDIO_CDC_ACM if MODULE_USBUS
default MODULE_STDIO_TINYUSB_CDC_ACM if MODULE_TINYUSB_DEVICE
default MODULE_STDIO_USB_SERIAL_JTAG
endchoice

source "$(RIOTBOARD)/common/esp32s3/Kconfig"
5 changes: 5 additions & 0 deletions boards/esp32s3-box/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
MODULE = board

DIRS = $(RIOTBOARD)/common/esp32s3

include $(RIOTBASE)/Makefile.base
14 changes: 14 additions & 0 deletions boards/esp32s3-box/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ifeq (,$(filter stdio_% slipdev_stdio usbus usbus% tinyusb_device,$(USEMODULE)))
# Use stdio_usb_serial_jtag if no other stdio is requested explicitly
# and neither USBUS nor tinyusb_device are used
USEMODULE += stdio_usb_serial_jtag
# Even if only stdio_usb_serial_jtag is enabled, usb_board_reset is enabled
# since there should be a CDC ACM interface in any case. This is necessary,
# for example, to reset the board if stdio_cdc_acm or stdio_tinyusb_cdc_acm
# was previously used.
# USEMODULE += usb_board_reset
# include $(RIOTMAKE)/tools/usb_board_reset.mk
endif

include $(RIOTBOARD)/common/esp32s3/Makefile.dep
include $(RIOTBOARD)/common/makefiles/stdio_cdc_acm.dep.mk
15 changes: 15 additions & 0 deletions boards/esp32s3-box/Makefile.features
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CPU_MODEL = esp32s3_wroom_1x_n16r8v

# additional features provided by the board
FEATURES_PROVIDED += periph_i2c
FEATURES_PROVIDED += periph_spi
FEATURES_PROVIDED += periph_uart
FEATURES_PROVIDED += periph_usbdev

# unique features provided by the board
FEATURES_PROVIDED += esp_jtag
FEATURES_PROVIDED += tinyusb_device
FEATURES_PROVIDED += highlevel_stdio

# common board and CPU features
include $(RIOTBOARD)/common/esp32s3/Makefile.features
5 changes: 5 additions & 0 deletions boards/esp32s3-box/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
PORT_LINUX ?= /dev/ttyACM0

OPENOCD_CONFIG ?= board/esp32s3-builtin.cfg

include $(RIOTBOARD)/common/esp32s3/Makefile.include
26 changes: 26 additions & 0 deletions boards/esp32s3-box/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (C) 2023 Gunar Schorcht
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup boards_esp32s3_box
* @{
*
* @file
* @brief Board specific initializations for ESP32-S3-Box
*
* @author Gunar Schorcht <gunar@schorcht.net>
*/

#include "board.h"

void board_init(void)
{
#if MODULE_ILI9341
gpio_init(LCD_BACKLIGHT, GPIO_OUT);
#endif
}
149 changes: 149 additions & 0 deletions boards/esp32s3-box/doc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
/*
* Copyright (C) 2023 Gunar Schorcht
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @defgroup boards_esp32s3_box ESP32-S3-Box
* @ingroup boards_esp32s3
* @brief Support for the ESP32-S3-Box
* @author Gunar Schorcht <gunar@schorcht.net>

\section esp32s3_box ESP32-S3-Box

## Table of Contents {#esp32s3_box_toc}

1. [Overview](#esp32s3_box_overview)
2. [Hardware](#esp32s3_box_hardware)
1. [MCU](#esp32s3_box_mcu)
2. [Board Configuration](#esp32s3_box_board_configuration)
3. [Board Pinout](#esp32s3_box_pinout)
3. [Flashing the Device](#esp32s3_box_flashing)

## Overview {#esp32s3_box_overview}

The Espressif ESP32-S3-Box is a AIoT development platform for the ESP32-S3 SoC.

\image html https://raw.githubusercontent.com/espressif/esp-box/master/docs/_static/esp32_s3_box.png "ESP32-S2-Box" width=400px
\image html https://obrazki.elektroda.pl/4333131800_1637933077_bigthumb.jpg "Hardware Overview" width=700px

The ESP32-S3-Box has following main features:

<center>
|Feature | Support |
|:--------------------------------------------|:-------:|
| ESP32-S3 SoC | yes |
| 16 MB Flash | yes |
| 8 MB QSPI RAM | yes |
| 2.4" LCD Display 320 x 240 with ILI9342C | yes |
| Capacitive Touch Panel | no |
| Dual Microphone ES7210 | no |
| Speaker Codec ES8311 | no |
| 3-axis Gyroscope, 3-axis Accelerometer | no |
| 2 x Digilent Pmod(TM) Connectors | yes |
| USB Type-C | yes |
</center>
<br>

The Espressif ESP32-S3-Box is shipped with a Dock which exposes the
2 x Digilent Pmod(TM) Connectors.

[Back to table of contents](#esp32s3_box_toc)

## Hardware {#esp32s3_box_hardware}

This section describes

- the [MCU](#esp32s3_box_mcu),
- the default [board configuration](#esp32s3_box_board_configuration),
- the [board pinout](#esp32s3_box_pinout).

[Back to table of contents](#esp32s3_box_toc)

### MCU {#esp32s3_box_mcu}

Most features of the ESP32-S3-Box are provided by the ESP32-S3 SoC. For detailed
information about the ESP32-S3 SoC variant (family) and ESP32x SoCs,
see section \ref esp32_mcu_esp32 "ESP32 SoC Series".

[Back to table of contents](#esp32s3_box_toc)

### Board Configuration {#esp32s3_box_board_configuration}

The following table shows the default ESP32-S3-Box configuration, which is
sorted according to the defined functionality of GPIOs. This configuration can
be overridden by \ref esp32_application_specific_configurations
"application-specific configurations".

<center>
Function | GPIOs | Remarks | Configuration
:---------------|:-------|:--------|:----------------------------------
BUTTON0 | GPIO0 | Boot Mode Button | |
I2C_DEV(0) SCL | GPIO40 | PMOD1 | \ref esp32_i2c_interfaces "I2C Interfaces"
I2C_DEV(0) SDA | GPIO41 | PMOD1 | \ref esp32_i2c_interfaces "I2C Interfaces"
SPI_DEV(0) CLK | GPIO12 | PMOD2, SPI2_HOST (FSPI) is used | \ref esp32_spi_interfaces "SPI Interfaces"
SPI_DEV(0) MISO | GPIO13 | PMOD2, SPI2_HOST (FSPI) is used | \ref esp32_spi_interfaces "SPI Interfaces"
SPI_DEV(0) MOSI | GPIO11 | PMOD2, SPI2_HOST (FSPI) is used | \ref esp32_spi_interfaces "SPI Interfaces"
SPI_DEV(0) CS0 | GPIO10 | PMOD2, SPI2_HOST (FSPI) is used | \ref esp32_spi_interfaces "SPI Interfaces"
SPI_DEV(1) CLK | GPIO7 | LCD SCK, SPI3_HOST is used | \ref esp32_spi_interfaces "SPI Interfaces"
SPI_DEV(1) MISO | GPIO35 | not used, SPI3_HOST is used | \ref esp32_spi_interfaces "SPI Interfaces"
SPI_DEV(1) MOSI | GPIO6 | LCD SDA, SPI3_HOST is used | \ref esp32_spi_interfaces "SPI Interfaces"
SPI_DEV(1) CS0 | GPIO5 | LCD CS, SPI3_HOST is used | \ref esp32_spi_interfaces "SPI Interfaces"
UART_DEV(0) TxD | GPIO43 | PMOD2 | \ref esp32_uart_interfaces "UART interfaces"
UART_DEV(0) RxD | GPIO44 | PMOD2 | \ref esp32_uart_interfaces "UART interfaces"
</center>
\n

[Back to table of contents](#esp32s3_box_toc)

### Board Pinout {#esp32s3_box_pinout}

The following figures show the pinouts as configured by default board
definition.

@image html https://raw.githubusercontent.com/espressif/esp-box/master/docs/_static/_get_started_static/hardware_pmod.png "ESP32-S3-BoxC-1 Pinout" width=900px

The corresponding schematics can be found:

- [ESP32-S3-Box](https://github.com/espressif/esp-box/blob/master/hardware/esp32_s3_box_v2.5/schematic/SCH_ESP32-S3-BOX_V2.5_20211011.pdf)
- [ESP32-S3-Box Dock](https://github.com/espressif/esp-box/blob/master/hardware/esp32_s3_box_dock_v1.0/schematic/ESP32-S3-BOX-DOCK_V1D0_20210922.pdf)

[Back to table of contents](#esp32s3_box_toc)

## Flashing the Device {#esp32s3_box_flashing}

Since the ESP32-S3-Box does not have a USB-to-Serial chip, the easiest way to
flash it is using the USB Serial/JTAG interface. Just connect the ESP32-S3-Box
to your host computer and use the following command:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BOARD=esp32s3-box make flash ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Usually the make system resets the ESP32-S3-Box before flashing to enable the
USB Serial/JTAG controller and to reboot the ESP32-S3 in download mode.

In some very special cases this reset does not work and the programmer cannot
connect to the card, so the flashing is aborted with a timeout:
```
Serial port /dev/ttyACM0
Connecting...
...
serial.serialutil.SerialTimeoutException: Write timeout
```
This can happen either if RIOT is not yet installed or if the USB port was
previously used with the USB OTG controller, for example with USBUS or tinyUSB.
In this case, restart the ESP32-S3-Box manually into download mode by pressing
and releasing the RESET button while holding down the BOOT button.
In download mode, the USB Serial/JTAG interface is always available.

@note If the USB port was previously used with the USB OTG controller, an
automatic restart of the ESP32-S3 with the flashed application is not
possible. In this case the ESP32-S3-Box must be reset manually using the RESET
button. In all other cases the ESP32-S3 automatically restarts with
the flashed application.

[Back to table of contents](#esp32s3_box_toc)
*/
105 changes: 105 additions & 0 deletions boards/esp32s3-box/include/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Copyright (C) 2023 Gunar Schorcht
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup boards_esp32s3_box
* @brief Board definitions for ESP32-S3-Box boards
* @{
*
* The board definitions in this file are for the Espressif ESP32-S3-Box.
*
* Any modifications required for specific applications
* can be overridden by \ref esp32_application_specific_configurations
* "application-specific board configuration".
*
* @file
* @author Gunar Schorcht <gunar@schorcht.net>
*/

#ifndef BOARD_H
#define BOARD_H

#include <stdint.h>

/**
* @name Button pin definitions
* @{
*/

/**
* @brief Default button GPIO pin definition
*
* ESP32-S3-Box boards have a BOOT button connected to GPIO0, which can be
* used as button during normal operation. Since the GPIO0 pin is pulled up,
* the button signal is inverted, i.e., pressing the button will give a
* low signal.
*/
#define BTN0_PIN GPIO0

/**
* @brief Default button GPIO mode definition
*/
#define BTN0_MODE GPIO_IN_PU

/**
* @brief Default interrupt flank definition for the button GPIO
*/
#ifndef BTN0_INT_FLANK
#define BTN0_INT_FLANK GPIO_FALLING
#endif

/**
* @brief Definition for compatibility with previous versions
*/
#define BUTTON0_PIN BTN0_PIN

/** @} */

/**
* @name LCD display configuration
*
* ESP32-S3-Box uses a LCD display with an ILI9342C as driver chip.
* This configuration cannot be changed.
* @{
*/
#if MODULE_ILI9341
#define LCD_DC GPIO4
#define LCD_CS GPIO5
#define LCD_RST GPIO48
#define LCD_BACKLIGHT GPIO45

#define BACKLIGHT_ON gpio_set(LCD_BACKLIGHT)
#define BACKLIGHT_OFF gpio_clear(LCD_BACKLIGHT)

#define ILI9341_PARAM_SPI SPI_DEV(1)
#define ILI9341_PARAM_SPI_CLK SPI_CLK_10MHZ
#define ILI9341_PARAM_CS LCD_CS
#define ILI9341_PARAM_DCX LCD_DC
#define ILI9341_PARAM_RST LCD_RST
#define ILI9341_PARAM_RGB 0
#define ILI9341_PARAM_INVERTED 0
#define ILI9341_PARAM_ROTATION LCD_MADCTL_MX | LCD_MADCTL_MY
#define ILI9341_PARAM_NUM_LINES 320U
#define ILI9341_PARAM_RGB_CHANNELS 240U
#endif
/** @} */

/* include common board definitions as last step */
#include "board_common.h"

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __cplusplus
} /* end extern "C" */
#endif

#endif /* BOARD_H */
/** @} */
Loading

0 comments on commit 8100478

Please sign in to comment.