Skip to content
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

cpu/esp: integrate ESP specific netdev configuration in Kconfig #17426

Open
wants to merge 14 commits into
base: master
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
11 changes: 2 additions & 9 deletions boards/esp32-ethernet-kit-v1_0/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ config BOARD
config BOARD_ESP32_ETHERNET_KIT_V1_0
bool
default y
select BOARD_COMMON_ESP32
select CPU_MODEL_ESP32_WROVER_B
select HAS_ESP_JTAG
select HAS_PERIPH_ADC
select HAS_PERIPH_ETH
select HAS_PERIPH_I2C
select HAS_PERIPH_PWM
select HAS_PERIPH_SPI if !MODULE_ESP_JTAG
select BOARD_ESP32_ETHERNET_KIT

source "$(RIOTBOARD)/common/esp32/Kconfig"
rsource "Kconfig.esp32-ethernet-kit"
14 changes: 14 additions & 0 deletions boards/esp32-ethernet-kit-v1_0/Kconfig.esp32-ethernet-kit
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
config BOARD_ESP32_ETHERNET_KIT
bool
default y
select BOARD_COMMON_ESP32
select CPU_MODEL_ESP32_WROVER_B
select HAS_ESP_JTAG
select HAS_ESP_ETH
select HAS_PERIPH_ADC
select HAS_PERIPH_ETH
select HAS_PERIPH_I2C
select HAS_PERIPH_PWM
select HAS_PERIPH_SPI if !MODULE_ESP_JTAG

source "$(RIOTBOARD)/common/esp32/Kconfig"
11 changes: 2 additions & 9 deletions boards/esp32-ethernet-kit-v1_1/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ config BOARD
config BOARD_ESP32_ETHERNET_KIT_V1_1
bool
default y
select BOARD_COMMON_ESP32
select CPU_MODEL_ESP32_WROVER_B
select HAS_ESP_JTAG
select HAS_PERIPH_ADC
select HAS_PERIPH_ETH
select HAS_PERIPH_I2C
select HAS_PERIPH_PWM
select HAS_PERIPH_SPI if !MODULE_ESP_JTAG
select BOARD_ESP32_ETHERNET_KIT

source "$(RIOTBOARD)/common/esp32/Kconfig"
source "$(RIOTBOARD)/esp32-ethernet-kit-v1_0/Kconfig.esp32-ethernet-kit"
11 changes: 2 additions & 9 deletions boards/esp32-ethernet-kit-v1_2/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ config BOARD
config BOARD_ESP32_ETHERNET_KIT_V1_2
bool
default y
select BOARD_COMMON_ESP32
select CPU_MODEL_ESP32_WROVER_E
select HAS_ESP_JTAG
select HAS_PERIPH_ADC
select HAS_PERIPH_ETH
select HAS_PERIPH_I2C
select HAS_PERIPH_PWM
select HAS_PERIPH_SPI if !MODULE_ESP_JTAG
select BOARD_ESP32_ETHERNET_KIT

source "$(RIOTBOARD)/common/esp32/Kconfig"
source "$(RIOTBOARD)/esp32-ethernet-kit-v1_0/Kconfig.esp32-ethernet-kit"
1 change: 1 addition & 0 deletions boards/esp32-olimex-evb/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ config BOARD_ESP32_OLIMEX_EVB
select BOARD_COMMON_ESP32
select CPU_MODEL_ESP32_WROOM_32
select HAS_ARDUINO
select HAS_ESP_ETH
select HAS_PERIPH_ADC if USEMODULE_OLIMEX_ESP32_GATEWAY
select HAS_PERIPH_I2C
select HAS_PERIPH_PWM
Expand Down
15 changes: 14 additions & 1 deletion boards/esp32-wrover-kit/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ config BOARD_ESP32_WROVER_KIT
select HAS_PERIPH_SPI
select HAS_SDCARD_SPI

select HAVE_ILI9341
select HAVE_ILI9341 if !MODULE_ESP32_WROVER_KIT_CAMERA

menu "ESP32 WROVER-KIT options"
depends on TEST_KCONFIG
depends on BOARD_ESP32_WROVER_KIT

config MODULE_ESP32_WROVER_KIT_CAMERA
bool "OV7670 Camera Interface used"
help
ESP-WROVER-KIT has a separate OV7670 camera interface. If it is
used a number of GPIOs and other peripherals are not available.
Select whether the camera interface is used.

endmenu

source "$(RIOTBOARD)/common/esp32/Kconfig"
30 changes: 30 additions & 0 deletions cpu/esp32/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ config HAS_CPU_ESP32
help
Indicates that the current CPU is 'esp32'.

config HAS_ESP_ETH
bool
help
Indicates that an ESP Ethernet interface is present.

config HAS_ESP_RTC_TIMER_32K
bool
help
Expand Down Expand Up @@ -121,6 +126,31 @@ config MODULE_ESP_JTAG

endmenu

# ESP32 specific module dependencies
config MODULE_ESP_ETH
bool
depends on HAS_ARCH_ESP32
select MODULE_ESP_IDF_ETH
select MODULE_ESP_IDF_ETH_PHY
select MODULE_NETDEV_ETH
select MODULE_NETOPT
select MODULE_ZTIMER_MSEC

config MODULE_ESP_WIFI_ANY
bool
depends on HAS_ARCH_ESP32
select MODULE_ESP_IDF_HEAP
select MODULE_ESP_IDF_NVS_FLASH
select MODULE_ESP_IDF_WPA_SUPPLICANT_CRYPTO
select MODULE_ESP_IDF_WPA_SUPPLICANT_PORT

config MODULE_ESP_WIFI_ENTERPRISE
bool
depends on HAS_ARCH_ESP32
select MODULE_ESP_IDF_WPA_SUPPLICANT_WPA2_EAP_PEER
select MODULE_ESP_IDF_WPA_SUPPLICANT_WPA2_TLS
select MODULE_ESP_IDF_WPA_SUPPLICANT_WPA2_UTILS

rsource "periph/Kconfig"
rsource "vendor/esp-idf/Kconfig"
source "$(RIOTCPU)/esp_common/Kconfig"
4 changes: 1 addition & 3 deletions cpu/esp32/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ ifneq (,$(filter newlib,$(USEMODULE)))
endif

ifneq (,$(filter esp_eth,$(USEMODULE)))
USEMODULE += esp_freertos
USEMODULE += esp_idf_eth
USEMODULE += esp_idf_eth_phy
USEMODULE += netdev_eth
Expand All @@ -21,7 +20,6 @@ endif

ifneq (,$(filter esp_wifi_any,$(USEMODULE)))
# add additional modules used for any WiFi interface
USEMODULE += esp_freertos
USEMODULE += esp_idf_heap
USEMODULE += esp_idf_nvs_flash
USEMODULE += esp_idf_wpa_supplicant_crypto
Expand Down Expand Up @@ -66,7 +64,7 @@ ifneq (,$(filter periph_i2c,$(USEMODULE)))
endif
endif

ifneq (,$(filter esp_now esp_wifi esp_spi_ram,$(USEMODULE)))
ifneq (,$(filter esp_wifi_any esp_spi_ram,$(USEMODULE)))
# the ESP-IDF heap has to be used if SPI RAM is used
USEMODULE += esp_idf_heap
endif
Expand Down
142 changes: 86 additions & 56 deletions cpu/esp32/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1421,12 +1421,15 @@ make -C examples/gnrc_networking BOARD=...

@note
- Module `esp_wifi` is not enabled automatically when module
`netdev_default` is used.
- Leave 'ESP_WIFI_PASS' undefined to connect to an open WiFi access point.
- The Wifi network interface (module `esp_wifi`) and the
[ESP-NOW network interface](#esp32_esp_now_network_interface) (module `esp_now`)
can be used simultaneously, for example, to realize a border router for
a mesh network which uses ESP-NOW.
`netdev_default` is used.
- Leave `#ESP_WIFI_PASS` undefined to connect to an open WiFi access point.
- The @ref esp32_wifi_network_interface (module `esp_wifi`) and
the @ref esp32_esp_now_network_interface (module `esp_now`) can be used
simultaneously, for example, to realize a border router for a mesh network
which uses ESP-NOW.
In this case the ESP-NOW interface must use the same channel as the AP of the
infrastructure WiFi network. All ESP-NOW nodes must therefore be compiled with
the channel of the AP asvalue for the parameter `#ESP_NOW_CHANNEL`.

[Back to table of contents](#esp32_toc)

Expand Down Expand Up @@ -1455,16 +1458,17 @@ following configuration parameters have to be defined:
Parameter | Default | Description
:-------------------|:----------|:------------
#ESP_WIFI_SSID | "RIOT_AP" | SSID of the AP to be used.
ESP_WIFI_EAP_ID | none | Optional anonymous identity used in phase 1 (outer) EAP authentication.[1]
ESP_WIFI_EAP_USER | none | User name used in phase 2 (inner) EAP authentication.
ESP_WIFI_EAP_PASS | none | Password used in phase 2 (inner) EAP authentication.
#ESP_WIFI_EAP_ID | "" | Optional anonymous identity used in phase 1 (outer) EAP authentication.[1]
#ESP_WIFI_EAP_USER | "user" | User name used in phase 2 (inner) EAP authentication.
#ESP_WIFI_EAP_PASS | "pass" | Password used in phase 2 (inner) EAP authentication.
#ESP_WIFI_STACKSIZE | #THREAD_STACKSIZE_DEFAULT | Stack size used for the WiFi netdev driver thread.

</center><br>

[1] If the optional anonymous identy `ESP_WIFI_EAP_ID` is not defined, the user
name `ESP_WIFI_EAP_USER` defined for phase 2 (inner) EAP authentication is used
as identity in phase 1.
1. If the optional anonymous identy `#ESP_WIFI_EAP_ID` is not defined, the user
name `#ESP_WIFI_EAP_USER` defined for phase 2 (inner) EAP authentication is
used as identity in phase 1. The identity in phase 1 (outer) authentication
is sent as plain text with no encryption.

These configuration parameter definitions, as well as enabling the `esp_wifi`
module, can be done either in the makefile of the project or at make command
Expand All @@ -1478,22 +1482,22 @@ make -C examples/gnrc_networking BOARD=...

@note
- Since there is no possibility to add the CA certificate to the RIOT image,
the verification of the AP certificate is not yet supported.
the verification of the AP certificate is not yet supported.
- Module `esp_wifi_enterprise` is not enabled automatically when module
`netdev_default` is used.
- The Wifi network interface (module `esp_wifi_enterprise`) and the
[ESP-NOW network interface](#esp32_esp_now_network_interface) (module `esp_now`)
can be used simultaneously, for example, to realize a border router for
a mesh network which uses ESP-NOW.
In this case the ESP-NOW interface must use the same channel as the AP of the
infrastructure WiFi network. All ESP-NOW nodes must therefore be compiled with
the channel of the AP as value for the parameter 'ESP_NOW_CHANNEL'.
`netdev_default` is used.
- The @ref esp32_wifi_network_interface (module `esp_wifi_enterprise`) and
the @ref esp32_esp_now_network_interface (module `esp_now`) can be used
simultaneously, for example, to realize a border router for a mesh network
which uses ESP-NOW.
In this case the ESP-NOW interface must use the same channel as the AP of the
infrastructure WiFi network. All ESP-NOW nodes must therefore be compiled with
the channel of the AP as value for the parameter `#ESP_NOW_CHANNEL`.

[Back to table of contents](#esp32_toc)

## WiFi SoftAP Network Interface {#esp32_wifi_ap_network_interface}

The RIOT port for the ESP32 supports a `netdev` interface for the ESP32 WiFi
The RIOT port for the ESP SoCs supports a `netdev` interface for the ESP WiFi
SoftAP mode. Module `esp_wifi_ap` has to be enabled to use it.

The following parameters can be configured:
Expand All @@ -1512,11 +1516,11 @@ Parameter | Default | Description

</center><br>

[1] If no password is provided, the interface will be "open", otherwise it
uses WPA2-PSK authentication mode.<br>
[2] If #ESP_WIFI_SSID_DYNAMIC is set to 1, a dynamic SSID is generated for the
SoftAP by extending the defined SSID (`ESP_WIFI_SSID`) with the MAC address
of the SoftAP interface used, e.g.: `RIOT_AP_aabbccddeeff`
1. If no password is provided, the interface will be "open", otherwise it
uses WPA2-PSK authentication mode.<br>
2. If `#ESP_WIFI_SSID_DYNAMIC` is set to 1, a dynamic SSID is generated for the
SoftAP by extending the defined SSID (`#ESP_WIFI_SSID`) with the MAC address
of the SoftAP interface used, e.g.: `RIOT_AP_aabbccddeeff`

These configuration parameter definitions, as well as enabling the `esp_wifi_ap`
module, can be done either in the makefile of the project or at make command
Expand All @@ -1532,67 +1536,93 @@ make -C examples/gnrc_networking BOARD=...
- The `esp_wifi_ap` module is not used by default when `netdev_default` is used.
- Supports open and WPA2-PSK authentication modes.
- The ESP-NOW network interface and the WiFi SoftAP network interface can not
be used simultaneously.
be used simultaneously.

@warning
The SoftAP may or may not be at all reliable sometimes, this is a known
problem with the Wi-Fi network interface, even on the official ESP-IDF.
problem with the Wi-Fi network interface, even with the official ESP-IDF.
The problem is that the AP doesn't cache multicast data for connected
stations, and if stations connected to the AP are power save enabled,
they may experience multicast packet loss. This affects RIOT, because
NDP relies on multicast packets to work correctly.
Refer to the SDK documentation from Espressif on
[AP Sleep](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/wifi.html#ap-sleep)
Refer to the SDK documentation from Espressif on [AP Sleep]
(https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/wifi.html#ap-sleep)
for more information.

[Back to table of contents](#esp32_toc)

## ESP-NOW Network Interface {#esp32_esp_now_network_interface}

With ESP-NOW, the ESP32 provides a connectionless communication technology,
With ESP-NOW, the ESP MCUs provide a connectionless communication technology,
featuring short packet transmission. It applies the IEEE802.11 Action Vendor
frame technology, along with the IE function developed by Espressif, and CCMP
encryption technology, realizing a secure, connectionless communication
solution.

The RIOT port for ESP32 implements in module `esp_now` a `netdev`
The RIOT port for ESP MCUs implements with module `esp_now` a `netdev`
driver which uses ESP-NOW to provide a link layer interface to a meshed network
of ESP32 nodes. In this network, each node can send short packets with up to
of ESP nodes. In this network, each node can send short packets with up to
250 data bytes to all other nodes that are visible in its range.

@note Module `esp_now`module is not enabled automatically if the
`netdev_default` module is used. Instead, the application has to add the
`esp_now` module in its makefile when needed.<br>
@note Module `esp_now` is enabled automatically if the `netdev_default` module
is used and no other interface is defined as default `netdev`. If it is not
enabled as default `netdev`, it can be enabled by using the `esp_now` module
if needed.
<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
USEMODULE += esp_now
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

For ESP-NOW, ESP32 nodes are used in WiFi SoftAP + Station mode to advertise
their SSID and become visible to other ESP32 nodes. The SSID of an ESP32 node
For ESP-NOW, ESP nodes are used in WiFi SoftAP + Station mode to advertise
their SSID and become visible to other ESP nodes. The SSID of an ESP node
is the concatenation of the prefix `RIOT_ESP_` with the MAC address of its
SoftAP WiFi interface. The driver periodically scans all visible ESP32 nodes.
SoftAP WiFi interface. The driver periodically scans all visible ESP nodes.

The following parameters are defined for ESP-NOW nodes. These parameters can be overridden by
[application-specific board configurations](#esp32_application_specific_board_configuration).
The following configuration parameters are defined for ESP-NOW nodes.
These parameters can be overridden by [application-specific board configurations]
(#esp32_application_specific_board_configuration).

<center>

Parameter | Default | Description
:-----------------------|:--------------------------|:-----------
ESP_NOW_SCAN_PERIOD_MS | 10000UL | Defines the period in ms at which an node scans for other nodes in its range. The default period is 10 s.
ESP_NOW_SOFT_AP_PASS | "ThisistheRIOTporttoESP" | Defines the passphrase as clear text (max. 64 chars) that is used for the SoftAP interface of ESP-NOW nodes. It has to be same for all nodes in one network.
ESP_NOW_CHANNEL | 6 | Defines the channel that is used as the broadcast medium by all nodes together.
ESP_NOW_KEY | NULL | Defines a key that is used for encrypted communication between nodes. If it is NULL, encryption is disabled. The key has to be of type `uint8_t[16]` and has to be exactly 16 bytes long.
Parameter | Default | Description
:-----------------------|:---------------|:-----------
#ESP_NOW_SCAN_PERIOD_MS | 10000UL | Scan interval for peer nodes in ms
#ESP_NOW_SOFT_AP_PASS | "This is RIOT" | Passphrase for the SoftAP interface as clear text [1]
#ESP_NOW_CHANNEL | 6 | Channel used for ESP-NOW in the 2.4 GHz band [2]
#ESP_NOW_KEY | "" | 128-bit key used for encrypted communication [3]
</center><br>

</center>
1. The passphrase is used for the SoftAP interface of ESP-NOW nodes. It
is defined as a string with a maximum of 64 characters and must be the
same for all nodes in the network.

2. The channel is in the range of 1 to 13. Please note that in some regions
not all 13 channels may be used for regulatory reasons. Select a channel
that is allowed in your region.
If ESP-NOW is used together with an infrastructure WiFi network, the
channel must be the same as used by the AP of the infrastructure WiFi.

3. The key has to be defined to enable encrypted communication between ESP-NOW
nodes. The key is 16 bytes long and is defined by a string of 8-bit hex
values separated by spaces, for example:
```
"0f 1e 2d 3c 4b 5a 69 78 87 96 a5 b4 c3 d2 e1 f0"
```
An empty string for this parameter means that the encryption is not used.
If less than 16 bytes are defined by the string, the remaining bytes of
the key are filled with 0.

@note The ESP-NOW network interface (module `esp_now`) and the
[Wifi network interface](#esp32_wifi_network_interface) (module `esp_wifi` or `esp_wifi_enterprise`)
can be used simultaneously, for example, to realize a border router for
a mesh network which uses ESP-NOW.
In this case the ESP-NOW interface must use the same channel as the AP of the
infrastructure WiFi network. All ESP-NOW nodes must therefore be compiled with
the channel of the AP asvalue for the parameter 'ESP_NOW_CHANNEL'.
@note
- If encrypted communication is used, a maximum of 6 nodes can
communicate with each other, while in unencrypted mode, up to
20 nodes can communicate.<br>
- ESP-NOW network interface (module `esp_now`) and the
[Wifi network interface](#esp32_wifi_network_interface) (module `esp_wifi`
or `esp_wifi_enterprise`) can be used simultaneously, for example, to
realize a border router for a mesh network which uses ESP-NOW.
In this case, the ESP-NOW interface must use the same channel as the AP of
the infrastructure WiFi network. All ESP-NOW nodes must therefore be compiled
with the channel of the AP as the value for the `#ESP_NOW_CHANNEL` parameter.

[Back to table of contents](#esp32_toc)

Expand Down
2 changes: 2 additions & 0 deletions cpu/esp8266/Kconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright (c) 2020 HAW Hamburg
# 2021 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
Expand Down Expand Up @@ -66,6 +67,7 @@ config CPU

source "$(RIOTCPU)/esp_common/Kconfig"

# ESP8266 specific module dependencies
config MODULE_ESP_I2C_SW
bool
default y if MODULE_PERIPH_I2C
Expand Down
Loading