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

Conversation

gschorcht
Copy link
Contributor

Contribution description

This PR adds Kconfig for ESP32 and ESP8266 CPUs as well as the ESP netdev drivers esp_wifi
and esp_now.

Testing procedure

Use examples/gnrc_networking with commands

USEMODULE='esp_wifi esp_now' make BOARD=esp32-wroom-32 -C examples/gnrc_networking menuconfig
USEMODULE='esp_wifi esp_now' make BOARD=esp8266-esp-12x -C examples/gnrc_networking menuconfig

to configure both CPUs and try to compile them afterwards.

Issues/PRs references

Part of issue #12888

@gschorcht gschorcht added Area: cpu Area: CPU/MCU ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ESP Platform: This PR/issue effects ESP-based platforms TF: Config Marks issues and PRs related to the work of the Configuration Task Force Type: new feature The issue requests / The PR implemements a new feature for RIOT labels Jan 15, 2020
@gschorcht
Copy link
Contributor Author

Just force-pushed typo and whitespace fixes for static tests.

Copy link
Contributor

@leandrolanzieri leandrolanzieri left a comment

Choose a reason for hiding this comment

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

Some initial comments. Regarding the macro renaming: I think it's better if we start to keep the CONFIG_ namespace for macros generated via Kconfig, that way at a glance you can tell where this is coming from.

Also, take a look at this regarding the translation of choices:

RIOT/sys/usb/Kconfig

Lines 30 to 43 in 27764fe

choice
bool "USB specification version"
config USB_SPEC_BCDVERSION_2_0
bool "USB v2.0"
help
The peripheral acts as an USB version 2.0 device.
config USB_SPEC_BCDVERSION_1_1
bool "USB v1.1"
help
The peripheral acts as an USB version 1.1 device.
endchoice

RIOT/sys/include/usb.h

Lines 94 to 102 in 27764fe

#ifndef CONFIG_USB_SPEC_BCDVERSION
#if defined(CONFIG_USB_SPEC_BCDVERSION_1_1)
#define CONFIG_USB_SPEC_BCDVERSION 0x0110
#elif defined(CONFIG_USB_SPEC_BCDVERSION_2_0)
#define CONFIG_USB_SPEC_BCDVERSION 0x0200
#else
#define CONFIG_USB_SPEC_BCDVERSION 0x0200
#endif
#endif

Lastly, I know that these are CPU-specific configurations for the ESP, but having the WiFi and ESP-NOW options under CPU seems a bit off from the user perspective when using menuconfig.

cpu/esp32/Kconfig Outdated Show resolved Hide resolved
@@ -21,6 +21,64 @@

#if defined(MODULE_ESP_NOW) || defined(DOXYGEN)

/**
* @name Legacy definitions of default configuration parameters
* @{
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add the @deprecated note and a deprecation release (2020.10?)

bool "Configure ESP-NOW netdev"
depends on MODULE_ESP_NOW
help
Configure ESP-NOW netdev when module esp_now is used.
Copy link
Contributor

Choose a reason for hiding this comment

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

This only shows up when esp_now module is used, so there is no need to clarify that on the help string.

@@ -30,42 +88,42 @@
* @brief The size of the stack used for the ESP-NOW netdev driver thread.
* @ingroup cpu_esp_common_conf
*/
#ifndef ESP_NOW_STACKSIZE
#define ESP_NOW_STACKSIZE (THREAD_STACKSIZE_DEFAULT)
#ifndef CONFIG_ESP_NOW_STACKSIZE
Copy link
Contributor

Choose a reason for hiding this comment

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

This macro is not generated by Kconfig, I think it's better that we try to keep the CONFIG_ namespace for those

Copy link
Contributor Author

@gschorcht gschorcht Jan 16, 2020

Choose a reason for hiding this comment

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

I decided to rename it for two reasons:

  1. I wished the stack size would be configurable, but I couldn't find an usable approach til now. The option has to be an int which doesn't allow a default like THREAD_STACKSIZE_DEFAULT. Maybe, I will add a combination of a bool option for using the default and an int option for specifying a different value.

  2. I wanted to avoid naming inconsistencies from the users point of view in documentations where you have tables like

    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
    CONFIG_ESP_WIFI_STACKSIZE Stack size used for the WiFi netdev driver

    I wanted to avoid tables like the following:

    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
    ESP_WIFI_STACKSIZE Stack size used for the WiFi netdev driver

Therefore, I decided to name everything that is configurable by user also at command line in same way.

#ifndef ESP_NOW_KEY
#define ESP_NOW_KEY (NULL)
#ifndef CONFIG_ESP_NOW_KEY
#define CONFIG_ESP_NOW_KEY ESP_NOW_KEY
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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The configuration of the key with Kconfig is a problem. The option would have to be either 0 or a 64 character array. I have no idea how to realize it with Kconfig. I renamed it to CONFIG_ just for naming consistency.

@@ -0,0 +1,29 @@
# Copyright (c) 2020 Gunar Schorcht
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to have the exact same Kconfig for esp8266 and esp32 in different places, instead of having one in esp_common like the ESP-NOW?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, when RIOT was ported to both platforms, the ESP8266 SDK required an implementation of esp_wifi that was completely different from that for ESP32.

With the new ESP8266 SDK and the complete reimplementation of the RIOT port on ESP8266 in PR #11108, a new esp_wifi module was introduced for ESP8266 that is almost the same as for ESP32. That's why there is already PR #12955 which will do a complete code deduplication. Module esp_wifi will then be moved to esp_common completely.

But before PR #12955 is merged, we have to do it in both implementations 😟 I wished PR #12955 would be merged soon, doing everything twice is quite nerving.

Copy link
Contributor

Choose a reason for hiding this comment

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

But, we can just place this file in cpu/esp_common/Kconfig.wifi and source it from both right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But, we can just place this file in cpu/esp_common/Kconfig.wifi and source it from both right?

Yes, this should be possible.

#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

#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

#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

#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

@gschorcht
Copy link
Contributor Author

Lastly, I know that these are CPU-specific configurations for the ESP, but having the WiFi and ESP-NOW options under CPU seems a bit off from the user perspective when using menuconfig.

What whould be a better place from your point of view?

@leandrolanzieri
Copy link
Contributor

What whould be a better place from your point of view?

I would expect to see this maybe in System > Networking > WiFi.

One thing that can be done is to have generic 'WiFi' symbols (e.g. CONFIG_WIFI_SSID) that can be translated to esp-specific parameters. Something similar like LoRaMAC has now with the keys

@gschorcht
Copy link
Contributor Author

What whould be a better place from your point of view?

I would expect to see this maybe in System > Networking > WiFi.

Hm 🤔 ok. Maybe there should be a further menu Network Devices and then WiFi and ESP-NOW?

`System > Networking > Network Devices > WiFi`
`System > Networking > Network Devices > ESP-NOW`

One thing that can be done is to have generic 'WiFi' symbols (e.g. CONFIG_WIFI_SSID)

As long a there is no other WiFi netdev driver I would leave the symbols as they are. OK?

@leandrolanzieri
Copy link
Contributor

As long a there is no other WiFi netdev driver I would leave the symbols as they are. OK?

The problem with having the ESP specific symbols is that then you need to source a file that is placed in cpu/... from a file that is in sys/net/..., which may seem odd as we are trying to follow the same structure as we have for modules.

@gschorcht
Copy link
Contributor Author

As long a there is no other WiFi netdev driver I would leave the symbols as they are. OK?

The problem with having the ESP specific symbols is that then you need to source a file that is placed in cpu/... from a file that is in sys/net/..., which may seem odd as we are trying to follow the same structure as we have for modules.

Yeah, that was the reason why I placed them in CPU section. Having ESP-WiFi in Networking and ESP-NOW in CPU section would be even more odd because ESP-NOW is nothing else than the WiFi interface that uses IEEE 802.11 Action Frames. So if we place ESPs network devices in Networking, the user would expect all of them there.

@gschorcht
Copy link
Contributor Author

Something similar like LoRaMAC has now with the keys

I couldn't find Kconfig for LoRaMAC. I found sys/net/gnrc/link_layer/lorawan/Kconfig, but in this example all symbols are also called GNRC_LORAWAN_*.

@fjmolinas fjmolinas added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jan 17, 2020
@leandrolanzieri
Copy link
Contributor

I couldn't find Kconfig for LoRaMAC.

Sorry, I was just referring to the fact that they have generic LORAMAC_ macros that are used both by the Semtech package and GNRC LoRaWAN.


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.


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

@leandrolanzieri
Copy link
Contributor

leandrolanzieri commented Jan 17, 2020

As long a there is no other WiFi netdev driver I would leave the symbols as they are. OK?

The problem with having the ESP specific symbols is that then you need to source a file that is placed in cpu/... from a file that is in sys/net/..., which may seem odd as we are trying to follow the same structure as we have for modules.

Yeah, that was the reason why I placed them in CPU section. Having ESP-WiFi in Networking and ESP-NOW in CPU section would be even more odd because ESP-NOW is nothing else than the WiFi interface that uses IEEE 802.11 Action Frames. So if we place ESPs network devices in Networking, the user would expect all of them there.

We could place ESP-NOW there as well

@leandrolanzieri
Copy link
Contributor

Thus it's time to change the ESP-specific ESP_WIFI_* configurations to more general WIFI_* definitions. We should change it first before we expose the configuration in Kconfig.

That's good, and would be more in the direction of one of my proposals above, in order to have the WiFi parameters in a more generic place.

Ok, I'll be tagging this for next release then. Thanks for the quick response!

@leandrolanzieri leandrolanzieri added this to the Release 2020.07 milestone Apr 3, 2020
@leandrolanzieri leandrolanzieri added the Area: Kconfig Area: Kconfig integration label Apr 3, 2020
@miri64
Copy link
Member

miri64 commented Jun 25, 2020

@leandrolanzieri @gschorcht still valid?

@gschorcht
Copy link
Contributor Author

gschorcht commented Jun 25, 2020

Because of PR #13754, it is time to change the ESP specific WiFi configuration to a more general one. This must be done first. Then we can expose the configurations via Kconfig. I would say, that it nothing we can realize with this release.

@fjmolinas
Copy link
Contributor

#13754 is in now, maybe @leandrolanzieri can help rework this one now

@leandrolanzieri
Copy link
Contributor

@gschorcht any plans on moving forward with this one?

@gschorcht
Copy link
Contributor Author

@gschorcht any plans on moving forward with this one?

Unfortunately not, I could not work on my RIOT contributions in the last months, because of other tasks related to the Corona online summer semester and the upcoming winter semester, which will be online again 😟 There are a number of open RIOT contributions just waiting to be completed. But I just don't have time to finish them and contribute at the moment.

@fjmolinas
Copy link
Contributor

@leandrolanzieri @gschorcht esp is one of the main items on the to-do list for Kconfig, is it interesting to revive this PR?

@leandrolanzieri
Copy link
Contributor

@leandrolanzieri @gschorcht esp is one of the main items on the to-do list for Kconfig, is it interesting to revive this PR?

Sure, I'm currently working on the modelling of the esp modules (minus networking), adding the configurations as well would be nice.

@gschorcht
Copy link
Contributor Author

Sure, I'm currently working on the modelling of the esp modules (minus networking)

@leandrolanzieri Is your modelling esp modules something different or will you provide a new PR which makes this one obsolete?

@leandrolanzieri
Copy link
Contributor

Sure, I'm currently working on the modelling of the esp modules (minus networking)

@leandrolanzieri Is your modelling esp modules something different or will you provide a new PR which makes this one obsolete?

It is something different, I will be providing a different PR (similar to #16929), but it does not make this one obsolete, as this adds configurations, not modules.

@gschorcht
Copy link
Contributor Author

@leandrolanzieri Is your modelling esp modules something different or will you provide a new PR which makes this one obsolete?

It is something different, I will be providing a different PR (similar to #16929), but it does not make this one obsolete, as this adds configurations, not modules.

So my first task would be to rebase this PR.

@leandrolanzieri
Copy link
Contributor

It is something different, I will be providing a different PR

@gschorcht see #17232

@gschorcht
Copy link
Contributor Author

gschorcht commented Dec 11, 2021

@leandrolanzieri Now were PR #17232 is merged, I would like to resume my work on the Kconfig for ESP network devices. I think this PR has to be reworked completely. Therefore, I would like to clarify the following questions before

  1. We have now a category Drivers -> Network Device Drivers where there are already network device drivers. I would add ESP network devices there?
  2. I would like to leave the configuration parameters like ESP_WIFI_* as documented to keep the compatibility with existing applications at user side. I would use the more general symbols CONFIG_WIFI_* in Kconfig and would map them as follows:
    #ifndef ESP_WIFI_SSID
    #ifdef CONFIG_WIFI_SSID
    #define ESP_WIFI_SSID    CONFIG_WIFI_SSID
    #else
    #define ESP_WIFI_SSID    "RIOT_AP"
    #endif
    #endif
    Would that be ok?
  3. How can I enable GNRC in Kconfig for tests? I have seen in
    menu "GNRC Network stack"
    depends on USEMODULE_GNRC
    that Kconfig for GNRC depends on USEMODULE_GNRC, but how can I enable it an required submodules? According to the documentation USEMODULE_ is generated by Kconfig from USEMODULE += gnrc. But it works neither at command line nor in Makefiles.

@stale
Copy link

stale bot commented Jul 10, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions.

@stale stale bot added the State: stale State: The issue / PR has no activity for >185 days label Jul 10, 2022
@stale stale bot closed this Aug 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: cpu Area: CPU/MCU ports Area: Kconfig Area: Kconfig integration CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ESP Platform: This PR/issue effects ESP-based platforms State: stale State: The issue / PR has no activity for >185 days TF: Config Marks issues and PRs related to the work of the Configuration Task Force Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants