diff --git a/boards/common/esp32/include/board_common.h b/boards/common/esp32/include/board_common.h index f033a4a6a4..6c99331279 100644 --- a/boards/common/esp32/include/board_common.h +++ b/boards/common/esp32/include/board_common.h @@ -30,7 +30,9 @@ #include "cpu.h" #include "periph_conf.h" +#if MODULE_ARDUINO #include "arduino_pinmap.h" +#endif #include "periph/gpio.h" #include "sdk_conf.h" diff --git a/boards/esp32-ethernet-kit-v1_0/Kconfig b/boards/esp32-ethernet-kit-v1_0/Kconfig new file mode 100644 index 0000000000..6496a8ef83 --- /dev/null +++ b/boards/esp32-ethernet-kit-v1_0/Kconfig @@ -0,0 +1,22 @@ +# Copyright (c) 2020 HAW Hamburg +# Copyright (c) 2020 Google LLC +# +# 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 "esp32-ethernet-kit-v1_0" if BOARD_ESP32_ETHERNET_KIT_V1_0 + +config BOARD_ESP32_ETHERNET_KIT_V1_0 + bool + default y + select BOARD_COMMON_ESP32 + select CPU_MODEL_ESP32_WROVER_B + select HAS_ESP_SPI_RAM + select HAS_PERIPH_ADC + select HAS_PERIPH_ETH + select HAS_PERIPH_I2C + select HAS_PERIPH_PWM + +source "$(RIOTBOARD)/common/esp32/Kconfig" diff --git a/boards/esp32-ethernet-kit-v1_0/Makefile b/boards/esp32-ethernet-kit-v1_0/Makefile new file mode 100644 index 0000000000..ca00a69d9c --- /dev/null +++ b/boards/esp32-ethernet-kit-v1_0/Makefile @@ -0,0 +1,5 @@ +MODULE = board + +DIRS = $(RIOTBOARD)/common/esp32 + +include $(RIOTBASE)/Makefile.base diff --git a/boards/esp32-ethernet-kit-v1_0/Makefile.dep b/boards/esp32-ethernet-kit-v1_0/Makefile.dep new file mode 100644 index 0000000000..1b7c4590a7 --- /dev/null +++ b/boards/esp32-ethernet-kit-v1_0/Makefile.dep @@ -0,0 +1,6 @@ +include $(RIOTBOARD)/common/esp32/Makefile.dep + +# enables esp_eth as default network device +ifneq (,$(filter netdev_default,$(USEMODULE))) + USEMODULE += esp_eth +endif diff --git a/boards/esp32-ethernet-kit-v1_0/Makefile.features b/boards/esp32-ethernet-kit-v1_0/Makefile.features new file mode 100644 index 0000000000..dfe8c1633f --- /dev/null +++ b/boards/esp32-ethernet-kit-v1_0/Makefile.features @@ -0,0 +1,12 @@ +CPU_MODEL = esp32-wrover + +# common board and CPU features +include $(RIOTBOARD)/common/esp32/Makefile.features + +# additional features provided by the board +FEATURES_PROVIDED += periph_adc +FEATURES_PROVIDED += periph_i2c +FEATURES_PROVIDED += periph_pwm + +# unique features provided by the board +FEATURES_PROVIDED += esp_spi_ram diff --git a/boards/esp32-ethernet-kit-v1_0/Makefile.include b/boards/esp32-ethernet-kit-v1_0/Makefile.include new file mode 100644 index 0000000000..1491356c36 --- /dev/null +++ b/boards/esp32-ethernet-kit-v1_0/Makefile.include @@ -0,0 +1,7 @@ +PSEUDOMODULES += esp32_ethernet_kit +PSEUDOMODULES += esp32_ethernet_kit_v1_0 + +# configure the serial interface +PORT_LINUX ?= /dev/ttyUSB1 + +include $(RIOTBOARD)/common/esp32/Makefile.include diff --git a/boards/esp32-ethernet-kit-v1_0/doc.txt b/boards/esp32-ethernet-kit-v1_0/doc.txt new file mode 100644 index 0000000000..ec17a3ccf2 --- /dev/null +++ b/boards/esp32-ethernet-kit-v1_0/doc.txt @@ -0,0 +1,123 @@ +/* + * Copyright (C) 2018 Gunar Schorcht + * Copyright (C) 2020 Google LLC + * + * 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_esp32_esp-ethernet-kit-v1_0 ESP32-Ethernet-Kit v1.0 + * @ingroup boards_esp32 + * @brief Support for for Espressif ESP32-Ethernet-Kit v1.0 + * @author Gunar Schorcht + * @author Erik Ekman + +## Table of Contents + +1. [Overview](#overview) +2. [Hardware](#hardware) + 1. [MCU](#mcu) + 2. [Board Configuration](#board_configuration) + 3. [Board Pinout](#pinout) +3. [Flashing the Device](#flashing) +4. [On-Chip Debugging with the device](#debugging) +5. [Other Documentation Resources](#other-resources) + +## Overview    [[TOC](#toc)] + +The Espressif [ESP32-Ethernet-Kit](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/hw-reference/esp32/get-started-ethernet-kit-v1.0.html) is a development board that uses the ESP32-WROVER-B module. Most important features of the board are + +- 100 Mbps Ethernet via IP101G PHY +- USB bridge with JTAG interface + +Furthermore, some GPIOs are broken out for extension. The USB bridge based on FDI FT2232HL provides a JTAG interface for OCD debugging through the USB interface. + +## Hardware    [[TOC](#toc)] + +This section describes + +- the [MCU](#mcu), +- the default [board configuration](#board_configuration), +- the [board pinout](#pinout). + +### MCU    [[TOC](#toc)] + +Most features of the board are provided by the ESP32 SoC. For detailed +information about the ESP32, see section \ref esp32_mcu "MCU ESP32". + +### Board Configuration    [[TOC](#toc)] + +ESP32-Ethernet-Kit v1.0 has the following on-board components + +- 100 Mbps Ethernet via IP101G PHY +- USB bridge with JTAG interface + +For detailed information about the configuration of ESP32 boards, see +section Peripherals in \ref esp32_riot. + +@note +Only a few GPIOs are broken out and available for external hardware on ESP32-Ethernet-Kit boards. Which GPIOs are available as peripherals depends on used modules. + +
+\anchor esp32_ethernet_kit_table_board_configuration +Function | GPIOs | Remarks |Configuration +:---------------|:-------|:--------|:---------------------------------- +BTN0 | GPIO0 | not available if `esp_eth` is used | | +ADC | GPIO34, GPIO35, GPIO36, GPIO39 | | \ref esp32_adc_channels "ADC Channels" +DAC | - | | \ref esp32_dac_channels "DAC Channels" +PWM_DEV(0) | GPIO4 | | \ref esp32_pwm_channels "PWM Channels" +I2C_DEV(0):SDA | GPIO32 | | \ref esp32_i2c_interfaces "I2C Interfaces" +I2C_DEV(0):SCL | GPIO33 | | \ref esp32_i2c_interfaces "I2C Interfaces" +SPI_DEV(0):CLK | GPIO14 | HSPI is used | \ref esp32_spi_interfaces "SPI Interfaces" +SPI_DEV(0):MISO | GPIO12 | HSPI is used | \ref esp32_spi_interfaces "SPI Interfaces" +SPI_DEV(0):MOSI | GPIO13 | HSPI is used | \ref esp32_spi_interfaces "SPI Interfaces" +SPI_DEV(0):CS0 | GPIO15 | HSPI is used | \ref esp32_spi_interfaces "SPI Interfaces" +UART_DEV(0):TxD | GPIO1 | Console (configuration is fixed) | \ref esp32_uart_interfaces "UART interfaces" +UART_DEV(0):RxD | GPIO3 | Console (configuration is fixed) | \ref esp32_uart_interfaces "UART interfaces" +
+ +@note +- GPIO4 only works properly on the board if the function switch for GPIO4 (DIP SW 5) is OFF. +- SPI_DEV(0) is not available if module `esp_jtag` is used. For the SPI_DEV(0) pins to work properly, the function switches (DIP switches) for the JTAG signals must be set to OFF. + +### Board Pinout    [[TOC](#toc)] + +The board schematic can be found [here](https://dl.espressif.com/dl/schematics/SCH_ESP32-ETHERNET-KIT_A_V1.0_20190517.pdf). + +By default, only 3 bidirectional GPIO pins are unused: GPIO4, GPIO32, GPIO33. The suggested configuration is for PWM +and I2C, but they can also be used for SPI or another serial port. By disabling the JTAG interface on the board, +another 4 GPIOs can be made available (GPIO12, GPIO13, GPIO14, GPIO15). + +## Flashing the Device    [[TOC](#toc)] + +Flashing RIOT is quite straight forward. The board has a Micro-USB connector with reset/boot/flash logic. Just connect the board using the programming port to your host computer and type: +``` +make flash BOARD=esp32-ethernet-kit-v1_0 ... +``` + +The USB bridge is based on FDI FT2232HL and offers two USB interfaces: + +- the first interface is the JTAG interface for [On-Chip debugging](#debugging) +- the second interface is the console interface, which is also used for flashing + +Therefore, you have to declare the USB interface in the make command. For example, if the ESP32-Ethernet-Kit is connected to the host computer through the USB interfaces `/dev/ttyUSB0` and `/dev/ttyUSB1`, the make command would be used as following: +``` +make flash BOARD=esp32-ethernet-kit-v1_0 PORT=/dev/ttyUSB1 ... +``` + +For detailed information about ESP32 as well as configuring and compiling RIOT for ESP32 boards, see \ref esp32_riot. + +## On-Chip Debugging with the Device    [[TOC](#toc)] + +Since the USB bridge based on FDI FT2232HL provides a JTAG interface for debugging through an USB interface, using ESP32-Ethernet-Kit is the easiest and most convenient way for On-Chip debugging. Please refer the [ESP-IDF Programming Guide](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/jtag-debugging/index.html) for details on how to setup and how to use ESP32-Ethernet-Kit and OpenOCD. + +To use the JTAG interface, the `esp_jtag' module must be used to disable the `SPI_DEV(0)` which normally uses the GPIOs for the JTAG signals. +USEMODULE=esp_jtag make flash BOARD=esp32-ethernet-kit-v1_0 ... +Furthermore the function switches (DIP switches) for the JTAG signals must be set to ON. + +## Other Documentation Resources    [[TOC](#toc)] + +There is a comprehensive [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/hw-reference/esp32/get-started-ethernet-kit-v1.0.html) for the ESP32-Ethernet-Kit with a lot information about hardware configuration. + */ diff --git a/boards/esp32-ethernet-kit-v1_0/include/board.h b/boards/esp32-ethernet-kit-v1_0/include/board.h new file mode 100644 index 0000000000..aee0421aa8 --- /dev/null +++ b/boards/esp32-ethernet-kit-v1_0/include/board.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2018 Gunar Schorcht + * Copyright (C) 2020 Google LLC + * + * 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_esp32_esp-ethernet-kit-v1_0 + * @file + * @{ + */ + +#ifndef BOARD_H +#define BOARD_H + +#include + +/* include common board definitions as last step */ +#include "board_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Initialize the board specific hardware + */ +static inline void board_init(void) { + /* there is nothing special to initialize on this board */ + board_init_common(); +} + +/** + * @name ESP32 Ethernet (EMAC) configuration + * @{ + */ +#define EMAC_PHY_IP101G 1 /**< IP101G used as PHY interface */ +#define EMAC_PHY_ADDRESS 1 /**< PHY1 used as base address */ +#define EMAC_PHY_SMI_MDC_PIN 23 /**< SMI MDC pin */ +#define EMAC_PHY_SMI_MDIO_PIN 18 /**< SMI MDC pin */ +#define EMAC_PHY_CLOCK_MODE ETH_CLOCK_GPIO0_IN /**< external 50 MHz clock */ +#define EMAC_PHY_POWER_PIN GPIO5 /**< PHY RESET_N connected to pin 5 */ +/** @} */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif + +#endif /* BOARD_H */ +/** @} */ diff --git a/boards/esp32-ethernet-kit-v1_0/include/gpio_params.h b/boards/esp32-ethernet-kit-v1_0/include/gpio_params.h new file mode 100644 index 0000000000..64dd0fcd8f --- /dev/null +++ b/boards/esp32-ethernet-kit-v1_0/include/gpio_params.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2018 Gunar Schorcht + * Copyright (C) 2020 Google LLC + * + * 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. + */ + +#ifndef GPIO_PARAMS_H +#define GPIO_PARAMS_H + +/** + * @ingroup boards_esp32_esp-ethernet-kit-v1_0 + * @brief Board specific configuration of direct mapped GPIOs + * @file + * @author Gunar Schorcht + * @author Erik Ekman + * @{ + */ + +#include "board.h" +#include "saul/periph.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief LED and button configuration + */ +static const saul_gpio_params_t saul_gpio_params[] = +{ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* GPIO_PARAMS_H */ +/** @} */ diff --git a/boards/esp32-ethernet-kit-v1_0/include/periph_conf.h b/boards/esp32-ethernet-kit-v1_0/include/periph_conf.h new file mode 100644 index 0000000000..dc54ea9f88 --- /dev/null +++ b/boards/esp32-ethernet-kit-v1_0/include/periph_conf.h @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2018 Gunar Schorcht + * Copyright (C) 2020 Google LLC + * + * 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_esp32_esp-ethernet-kit-v1_0 + * @brief Peripheral MCU configuration for Espressif ESP32-Ethernet-Kit + * @file + * @author Gunar Schorcht + * @author Erik Ekman + */ + +#ifndef PERIPH_CONF_H +#define PERIPH_CONF_H + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + * @name ADC and DAC channel configuration + * @{ + */ + +/** + * @brief Declaration of GPIOs that can be used as ADC channels + * + * @note As long as the GPIOs listed in ADC_GPIOS are not initialized as ADC + * channels with the `adc_init` function, they can be used for other + * purposes. + */ +#ifndef ADC_GPIOS +#define ADC_GPIOS { GPIO34, GPIO35, GPIO36, GPIO39 } +#endif + +/** + * @brief Declaration of GPIOs that can be used as DAC channels + * + * ESP32-Ethernet-Kit has no GPIOs left that might be used as DAC channels. + */ +#ifndef DAC_GPIOS +#define DAC_GPIOS { } +#endif +/** @} */ + +/** + * @name I2C configuration + * + * @note The GPIOs listed in the configuration are only initialized as I2C + * signals when module `periph_i2c` is used. Otherwise they are not + * allocated and can be used for other purposes. + * + * @{ + */ +#ifndef I2C0_SPEED +#define I2C0_SPEED I2C_SPEED_FAST /**< I2C bus speed of I2C_DEV(0) */ +#endif +#ifndef I2C0_SCL +#define I2C0_SCL GPIO33 /**< SCL signal of I2C_DEV(0) */ +#endif +#ifndef I2C0_SDA +#define I2C0_SDA GPIO32 /**< SDA signal of I2C_DEV(0) */ +#endif +/** @} */ + +/** + * @name PWM channel configuration + * + * @note As long as the according PWM device is not initialized with + * the `pwm_init`, the GPIOs declared for this device can be used + * for other purposes. + * + * @{ + */ +#ifndef PWM0_GPIOS +#ifdef MODULE_ESP32_ETHERNET_KIT_V1_0 +#define PWM0_GPIOS { GPIO4 } +#else +#define PWM0_GPIOS { GPIO2, GPIO4 } +#endif +#endif /* PWM0_GPIOS */ + +/** PWM_DEV(1) is not used */ +#ifndef PWM1_GPIOS +#define PWM1_GPIOS { } +#endif +/** @} */ + + +/** + * @name UART configuration + * + * ESP32 provides 3 UART interfaces at maximum: + * + * UART_DEV(0) uses fixed standard configuration.
+ * UART_DEV(1) is not available.
+ * UART_DEV(2) is not available.
+ * @{ + */ +#define UART0_TXD GPIO1 /**< direct I/O pin for UART_DEV(0) TxD, can't be changed */ +#define UART0_RXD GPIO3 /**< direct I/O pin for UART_DEV(0) RxD, can't be changed */ +/** @} */ + + +#ifdef __cplusplus +} /* end extern "C" */ +#endif + +/* include common board definitions as last step */ +#include "periph_conf_common.h" + +#endif /* PERIPH_CONF_H */ +/** @} */ diff --git a/cpu/esp32/Kconfig b/cpu/esp32/Kconfig index 6aa2356c25..a71aae7742 100644 --- a/cpu/esp32/Kconfig +++ b/cpu/esp32/Kconfig @@ -28,6 +28,10 @@ config CPU_MODEL_ESP32_WROVER bool select CPU_FAM_ESP32 +config CPU_MODEL_ESP32_WROVER_B + bool + select CPU_FAM_ESP32 + config CPU_MODEL_ESP32_D0WD bool select CPU_FAM_ESP32 @@ -76,6 +80,7 @@ config CPU_FAM config CPU_MODEL default "esp32-wroom_32" if CPU_MODEL_ESP32_WROOM_32 default "esp32-wrover" if CPU_MODEL_ESP32_WROVER + default "esp32-wrover" if CPU_MODEL_ESP32_WROVER_B default "esp32-d0wd" if CPU_MODEL_ESP32_D0WD config CPU