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*: add Kconfig #13135

Closed
wants to merge 8 commits into from
Closed
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
1 change: 1 addition & 0 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mainmenu "RIOT Configuration"
# For now, get used modules as macros from this file (see kconfig.mk)
osource "$(KCONFIG_GENERATED_DEPENDENCIES)"

rsource "cpu/Kconfig"
rsource "sys/Kconfig"

# The application may declare new symbols as well
Expand Down
11 changes: 11 additions & 0 deletions cpu/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright (c) 2020 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.
#
menu "CPU"

rsource "*/Kconfig"

endmenu # CPU
33 changes: 33 additions & 0 deletions cpu/esp32/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (c) 2020 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.
#

menuconfig KCONFIG_CPU_ESP32
bool "Configure ESP32 CPU"
depends on MODULE_ESP_ESP32
help
Configure ESP32 CPU via Kconfig.

if KCONFIG_CPU_ESP32

choice ESP32_DEFAULT_CPU_FREQ_MHZ
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to associate a symbol to the choice here, as it is not extended somewhere else.

bool "CPU frequency"
default ESP32_DEFAULT_CPU_FREQ_MHZ_80
help
Defines the CPU frequency.

config ESP32_DEFAULT_CPU_FREQ_MHZ_80
bool "80 MHz"
config ESP32_DEFAULT_CPU_FREQ_MHZ_160
bool "160 MHz"
config ESP32_DEFAULT_CPU_FREQ_MHZ_240
bool "240 MHz"
endchoice

rsource "esp-wifi/Kconfig"
rsource "$(RIOTBASE)/cpu/esp_common/esp-now/Kconfig"

endif # ESP32 settings
2 changes: 2 additions & 0 deletions cpu/esp32/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ ifneq (,$(filter 4 5,$(LOG_LEVEL)))
endif

# ESP32 pseudomodules
PSEUDOMODULES += esp_esp32
PSEUDOMODULES += esp_eth_hw
PSEUDOMODULES += esp_gdb
PSEUDOMODULES += esp_gdbstub
Expand All @@ -100,6 +101,7 @@ PSEUDOMODULES += esp_wifi_any
export TARGET_ARCH ?= xtensa-esp32-elf

USEMODULE += esp_common
USEMODULE += esp_esp32
USEMODULE += esp_idf
USEMODULE += esp_idf_driver
USEMODULE += esp_idf_esp32
Expand Down
20 changes: 10 additions & 10 deletions cpu/esp32/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1004,11 +1004,11 @@ Furthermore, the following configuration parameters have to be defined:

<center>

Parameter | Default | Description
:------------------|:--------------------------|:------------
ESP_WIFI_SSID | "RIOT_AP" | SSID of the AP to be used.
ESP_WIFI_PASS | "ThisistheRIOTporttoESP" | Passphrase used for the AP as clear text (max. 64 chars).
ESP_WIFI_STACKSIZE | #THREAD_STACKSIZE_DEFAULT |Stack size used for the WiFi netdev driver thread.
Parameter | Default | Description
:--------------------------|:--------------------------|:------------
#CONFIG_ESP_WIFI_SSID | "RIOT_AP" | SSID of the AP to be used.
#CONFIG_ESP_WIFI_PASS | "ThisistheRIOTporttoESP" | Passphrase used for the AP as clear text (max. 64 chars).
#CONFIG_ESP_WIFI_STACKSIZE | #THREAD_STACKSIZE_DEFAULT |Stack size used for the WiFi netdev driver thread.

</center>

Expand All @@ -1018,7 +1018,7 @@ line, e.g.:

```
USEMODULE=esp_wifi \
CFLAGS='-DESP_WIFI_SSID=\"MySSID\" -DESP_WIFI_PASS=\"MyPassphrase\"' \
CFLAGS='-DCONFIG_ESP_WIFI_SSID=\"MySSID\" -DCONFIG_ESP_WIFI_PASS=\"MyPassphrase\"' \
make -C examples/gnrc_networking BOARD=...
```

Expand Down Expand Up @@ -1049,10 +1049,10 @@ The following parameters are defined for ESP-NOW nodes. These parameters can be

Parameter | Default | Description
:---------|:--------|:-----------
ESP_NOW_SCAN_PERIOD | 10000000UL | Defines the period in us 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.
#CONFIG_ESP_NOW_SCAN_PERIOD | 10000000UL | Defines the period in us at which an node scans for other nodes in its range. The default period is 10 s.
#CONFIG_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.
#CONFIG_ESP_NOW_CHANNEL | 6 | Defines the channel that is used as the broadcast medium by all nodes together.
#CONFIG_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.

</center>

Expand Down
29 changes: 29 additions & 0 deletions cpu/esp32/esp-wifi/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) 2020 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.
#

menuconfig KCONFIG_MODULE_ESP_WIFI
bool "Configure ESP-WiFi netdev"
depends on MODULE_ESP_WIFI
help
Configure ESP-Wifi netdev when module esp_wifi is used.

if KCONFIG_MODULE_ESP_WIFI

config ESP_WIFI_SSID
string "SSID"
default "RIOT_AP"
help
This string defines the SSID of the AP to be used.

config ESP_WIFI_PASS
string "Passphrase for WPA2"
default "ThisistheRIOTporttoESP"
help
This string defines the passphrase as plain text, which is used for
the AP during WPA2 authentication. It can be up to 64 characters long.

endif # KCONFIG_MODULE_ESP_WIFI
12 changes: 6 additions & 6 deletions cpu/esp32/esp-wifi/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ USEMODULE += esp_wifi

Furthermore, the following configuration parameters have to be defined:

Configuration Parameter | Description
------------------------|------------
ESP_WIFI_SSID | SSID of the AP to be used.
ESP_WIFI_PASS | Passphrase used for the AP as clear text (max. 64 chars).
ESP_WIFI_STACKSIZE | Stack size used for the WiFi netdev driver thread.
Configuration Parameter | Description
--------------------------|------------
#CONFIG_ESP_WIFI_SSID | SSID of the AP to be used.
#CONFIG_ESP_WIFI_PASS | Passphrase used for the AP as clear text (max. 64 chars).
#CONFIG_ESP_WIFI_STACKSIZE| Stack size used for the WiFi netdev driver thread.

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
line, e.g.:

```
USEMODULE=esp_wifi \
CFLAGS='-DESP_WIFI_SSID=\"MySSID\" -DESP_WIFI_PASS=\"MyPassphrase\"' \
CFLAGS='-DCONFIG_ESP_WIFI_SSID=\"MySSID\" -DCONFIG_ESP_WIFI_PASS=\"MyPassphrase\"' \
make -C examples/gnrc_networking BOARD=...
```

Expand Down
16 changes: 8 additions & 8 deletions cpu/esp32/esp-wifi/esp_wifi_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static unsigned int rx_buf_write = 0;
static unsigned int rx_buf_read = 0;

/* device thread stack */
static char _esp_wifi_stack[ESP_WIFI_STACKSIZE];
static char _esp_wifi_stack[CONFIG_ESP_WIFI_STACKSIZE];

extern esp_err_t esp_system_event_add_handler (system_event_cb_t handler,
void *arg);
Expand Down Expand Up @@ -291,8 +291,8 @@ static esp_err_t IRAM_ATTR _esp_system_event_handler(void *ctx, system_event_t *
/* we use predefined station configuration */
static wifi_config_t wifi_config_sta = {
.sta = {
.ssid = ESP_WIFI_SSID,
.password = ESP_WIFI_PASS,
.ssid = CONFIG_ESP_WIFI_SSID,
.password = CONFIG_ESP_WIFI_PASS,
.bssid_set = 0,
.channel = 0,
.scan_method = WIFI_ALL_CHANNEL_SCAN,
Expand Down Expand Up @@ -578,14 +578,14 @@ void auto_init_esp_wifi (void)

esp_wifi_setup(&_esp_wifi_dev);
_esp_wifi_dev.netif = gnrc_netif_ethernet_create(_esp_wifi_stack,
ESP_WIFI_STACKSIZE,
CONFIG_ESP_WIFI_STACKSIZE,
#ifdef MODULE_ESP_NOW
ESP_WIFI_PRIO - 1,
CONFIG_ESP_WIFI_PRIO - 1,
#else
ESP_WIFI_PRIO,
CONFIG_ESP_WIFI_PRIO,
#endif
"esp-wifi",
(netdev_t *)&_esp_wifi_dev);
"esp-wifi",
(netdev_t *)&_esp_wifi_dev);
}

#endif /* MODULE_ESP_WIFI */
Expand Down
56 changes: 48 additions & 8 deletions cpu/esp32/esp-wifi/esp_wifi_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,77 @@

#if defined(MODULE_ESP_WIFI) || defined(DOXYGEN)

/**
* @name Legacy definitions of default configuration parameters
* @{
*/

/**
* @brief Legacy definition for compatibility reasons.
* #ESP_WIFI_STACKSIZE is deprecated, please use #CONFIG_ESP_WIFI_STACKSIZE
* instead.
*/
#ifndef ESP_WIFI_STACKSIZE
#define ESP_WIFI_STACKSIZE (THREAD_STACKSIZE_DEFAULT)
#endif

/**
* @brief Legacy definition for compatibility reasons.
* #ESP_WIFI_PRIO is deprecated, please use #CONFIG_ESP_WIFI_PRIO instead.
*/
#ifndef ESP_WIFI_PRIO
#define ESP_WIFI_PRIO (GNRC_NETIF_PRIO)
#endif

/**
* @brief Legacy definition for compatibility reasons.
* #ESP_WIFI_SSID is deprecated, please use #CONFIG_ESP_WIFI_SSID instead.
*/
#ifndef ESP_WIFI_SSID
#define ESP_WIFI_SSID "RIOT_AP"
#endif

/**
* @brief Legacy definition for compatibility reasons.
* #ESP_WIFI_PASS is deprecated, please use #CONFIG_ESP_WIFI_PASS instead.
*/
#ifndef ESP_WIFI_PASS
#define ESP_WIFI_PASS "ThisistheRIOTporttoESP"
#endif

/**
* @name Set default configuration parameters for the ESP WiFi netdev driver
* @{
*/

/** @} */

/**
* @brief The size of the stack used for the ESP WIFI netdev driver thread.
*/
#ifndef ESP_WIFI_STACKSIZE
#define ESP_WIFI_STACKSIZE (THREAD_STACKSIZE_DEFAULT)
#ifndef CONFIG_ESP_WIFI_STACKSIZE
#define CONFIG_ESP_WIFI_STACKSIZE ESP_WIFI_STACKSIZE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Namespace

#endif

/**
* @brief The priority of the ESP WiFi netdev driver thread. Should not be changed.
*/
#ifndef ESP_WIFI_PRIO
#define ESP_WIFI_PRIO (GNRC_NETIF_PRIO)
#ifndef CONFIG_ESP_WIFI_PRIO
#define CONFIG_ESP_WIFI_PRIO ESP_WIFI_PRIO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Namespace

#endif

/**
* @brief SSID of the AP to be used.
*/
#ifndef ESP_WIFI_SSID
#define ESP_WIFI_SSID "RIOT_AP"
#ifndef CONFIG_ESP_WIFI_SSID
#define CONFIG_ESP_WIFI_SSID ESP_WIFI_SSID
#endif

/**
* @brief Passphrase used for the AP as clear text (max. 64 chars).
*/
#ifndef ESP_WIFI_PASS
#define ESP_WIFI_PASS "ThisistheRIOTporttoESP"
#ifndef CONFIG_ESP_WIFI_PASS
#define CONFIG_ESP_WIFI_PASS ESP_WIFI_PASS
#endif

/**@}*/
Expand Down
10 changes: 8 additions & 2 deletions cpu/esp32/include/sdk_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,16 @@ extern "C" {
#include "board.h"

/**
* @brief Defines the CPU frequency [values = 2, 40, 80, 160 and 240]
* @brief Defines the CPU frequency [values = 80, 160 and 240]
*/
#ifndef CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ 80
#if defined(CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ_240)
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ (240)
#elif defined(CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ_160)
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ (160)
#else
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ (80)
#endif
#endif

/**
Expand Down
31 changes: 31 additions & 0 deletions cpu/esp8266/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright (c) 2020 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.
#

menuconfig KCONFIG_CPU_ESP8266
bool "Configure ESP8266 CPU"
depends on MODULE_ESP_ESP8266
help
Configure ESP8266 CPU via Kconfig.

if KCONFIG_CPU_ESP8266

choice ESP8266_CPU_FREQUENCY
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

bool "CPU frequency"
default ESP8266_CPU_FREQUENCY_80MHZ
help
Defines the CPU frequency.

config ESP8266_CPU_FREQUENCY_80MHZ
bool "80 MHz"
config ESP8266_CPU_FREQUENCY_160MHZ
bool "160 MHz"
endchoice

rsource "esp-wifi/Kconfig"
rsource "$(RIOTBASE)/cpu/esp_common/esp-now/Kconfig"

endif # ESP8266 settings
2 changes: 2 additions & 0 deletions cpu/esp8266/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ endif
export TARGET_ARCH ?= xtensa-esp8266-elf

# ESP8266 pseudomodules
PSEUDOMODULES += esp_esp8266
PSEUDOMODULES += esp_gdb
PSEUDOMODULES += esp_log_colored
PSEUDOMODULES += esp_log_tagged
Expand All @@ -82,6 +83,7 @@ PSEUDOMODULES += esp_spiffs
PSEUDOMODULES += esp_wifi_any

USEMODULE += esp_common
USEMODULE += esp_esp8266
USEMODULE += esp_freertos
USEMODULE += esp_idf
USEMODULE += esp_idf_esp8266
Expand Down
Loading