diff --git a/cpu/esp32/esp-idf/Kconfig b/cpu/esp32/esp-idf/Kconfig new file mode 100644 index 0000000000..d74711087f --- /dev/null +++ b/cpu/esp32/esp-idf/Kconfig @@ -0,0 +1,29 @@ +# Copyright (c) 2021 HAW Hamburg +# 2022 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 MODULE_ESP_IDF + bool + depends on TEST_KCONFIG + depends on HAS_ARCH_ESP32 + default y + select MODULE_ESP_IDF_COMMON + select MODULE_ESP_IDF_SPI_FLASH if MODULE_MTD + help + Espressif IoT Development Framework. + +rsource "common/Kconfig" +rsource "efuse/Kconfig" +rsource "eth/Kconfig" +rsource "event/Kconfig" +rsource "gpio/Kconfig" +rsource "heap/Kconfig" +rsource "nvs_flash/Kconfig" +rsource "spi_flash/Kconfig" +rsource "spi_ram/Kconfig" +rsource "wifi/Kconfig" +rsource "wpa_supplicant/Kconfig" diff --git a/cpu/esp32/esp-idf/Makefile b/cpu/esp32/esp-idf/Makefile new file mode 100644 index 0000000000..89fee49322 --- /dev/null +++ b/cpu/esp32/esp-idf/Makefile @@ -0,0 +1,47 @@ +MODULE=esp_idf + +# Add a list of subdirectories, that should also be built: + +DIRS += common + +ifneq (,$(filter esp_idf_efuse,$(USEMODULE))) + DIRS += efuse +endif + +ifneq (,$(filter esp_idf_eth,$(USEMODULE))) + DIRS += eth +endif + +ifneq (,$(filter esp_idf_event,$(USEMODULE))) + DIRS += event +endif + +ifneq (,$(filter esp_idf_gpio,$(USEMODULE))) + DIRS += gpio +endif + +ifneq (,$(filter esp_idf_heap,$(USEMODULE))) + DIRS += heap +endif + +ifneq (,$(filter esp_idf_nvs_flash,$(USEMODULE))) + DIRS += nvs_flash +endif + +ifneq (,$(filter esp_idf_spi_flash,$(USEMODULE))) + DIRS += spi_flash +endif + +ifneq (,$(filter esp_idf_spi_ram,$(USEMODULE))) + DIRS += spi_ram +endif + +ifneq (,$(filter esp_idf_wifi,$(USEMODULE))) + DIRS += wifi +endif + +ifneq (,$(filter esp_idf_wpa_supplicant,$(USEMODULE))) + DIRS += wpa_supplicant +endif + +include $(RIOTBASE)/Makefile.base diff --git a/cpu/esp32/esp-idf/common/Kconfig b/cpu/esp32/esp-idf/common/Kconfig new file mode 100644 index 0000000000..a8c0a73959 --- /dev/null +++ b/cpu/esp32/esp-idf/common/Kconfig @@ -0,0 +1,14 @@ +# Copyright (c) 2022 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 MODULE_ESP_IDF_COMMON + bool + depends on TEST_KCONFIG + depends on MODULE_ESP_IDF + help + Common ESP-IDF code required for the RIOT port regardless of + additional modules. diff --git a/cpu/esp32/esp-idf/common/Makefile b/cpu/esp32/esp-idf/common/Makefile new file mode 100644 index 0000000000..80e3c7a74d --- /dev/null +++ b/cpu/esp32/esp-idf/common/Makefile @@ -0,0 +1,36 @@ +MODULE = esp_idf_common + +# source files required from ESP-IDF in any case, regardless of additional modules +ESP32_SDK_SRC = \ + components/driver/periph_ctrl.c \ + components/esp_hw_support/cpu_util.c \ + components/esp_hw_support/sleep_modes.c \ + components/esp_hw_support/port/$(CPU)/rtc_sleep.c \ + components/esp_hw_support/esp_clk.c \ + components/esp_hw_support/port/$(CPU)/rtc_clk.c \ + components/esp_hw_support/port/$(CPU)/rtc_clk_init.c \ + components/esp_hw_support/port/$(CPU)/rtc_init.c \ + components/esp_hw_support/port/$(CPU)/rtc_time.c \ + components/esp_hw_support/port/$(CPU)/rtc_wdt.c \ + components/esp_hw_support/regi2c_ctrl.c \ + components/esp_pm/pm_impl.c \ + components/esp_system/esp_err.c \ + components/esp_system/esp_system.c \ + components/esp_system/port/soc/$(CPU)/clk.c \ + components/esp_system/port/soc/$(CPU)/reset_reason.c \ + components/esp_system/system_time.c \ + components/hal/mpu_hal.c \ + components/hal/wdt_hal_iram.c \ + components/newlib/port/esp_time_impl.c \ + components/soc/$(CPU)/rtc_io_periph.c \ + components/spi_flash/cache_utils.c \ + components/esp_timer/src/esp_timer.c \ + components/esp_timer/src/esp_timer_impl_frc_legacy.c \ + # + +include $(RIOTBASE)/Makefile.base + +ESP32_SDK_BIN = $(BINDIR)/$(MODULE) + +include ../esp_idf.mk +include ../esp_idf_cflags.mk diff --git a/cpu/esp32/esp-idf/efuse/Kconfig b/cpu/esp32/esp-idf/efuse/Kconfig new file mode 100644 index 0000000000..0e36c16baa --- /dev/null +++ b/cpu/esp32/esp-idf/efuse/Kconfig @@ -0,0 +1,15 @@ +# Copyright (c) 2022 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 MODULE_ESP_IDF_EFUSE + bool + depends on TEST_KCONFIG + depends on MODULE_ESP_IDF + help + ESP-IDF code for accessing eFuse bits of ESP32 SoCs, as required for + accessing the MAC addresses of network devices or accessing the + external SPI RAM. diff --git a/cpu/esp32/esp-idf/efuse/Makefile b/cpu/esp32/esp-idf/efuse/Makefile new file mode 100644 index 0000000000..92a0d1d617 --- /dev/null +++ b/cpu/esp32/esp-idf/efuse/Makefile @@ -0,0 +1,29 @@ +MODULE = esp_idf_efuse + +# source files to be compiled for this module +ESP32_SDK_SRC = \ + components/efuse/$(CPU)/esp_efuse_fields.c \ + components/efuse/$(CPU)/esp_efuse_table.c \ + components/efuse/$(CPU)/esp_efuse_utility.c \ + components/efuse/src/esp_efuse_api.c \ + components/efuse/src/esp_efuse_utility.c \ + components/esp_hw_support/mac_addr.c \ + # + +ifneq (,$(filter esp32,$(CPU))) + ESP32_SDK_SRC += components/efuse/src/esp_efuse_api_key_esp32.c +else + ESP32_SDK_SRC += components/efuse/src/esp_efuse_api_key_esp32xx.c +endif + +# additional include pathes required by this module +INCLUDES += -I$(ESP32_SDK_DIR)/components/efuse/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/efuse/private_include +INCLUDES += -I$(ESP32_SDK_DIR)/components/efuse/$(CPU)/private_include + +include $(RIOTBASE)/Makefile.base + +ESP32_SDK_BIN = $(BINDIR)/$(MODULE) + +include ../esp_idf.mk +include ../esp_idf_cflags.mk diff --git a/cpu/esp32/esp-idf/esp_idf.mk b/cpu/esp32/esp-idf/esp_idf.mk new file mode 100644 index 0000000000..9f32cf23c6 --- /dev/null +++ b/cpu/esp32/esp-idf/esp_idf.mk @@ -0,0 +1,73 @@ +# common definitions for all ESP-IDF modules + +INCLUDES += -I$(ESP32_SDK_DIR)/components/bootloader_support/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/driver/esp32/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/driver/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/efuse/esp32/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_common/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_hw_support/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_hw_support/include/soc +INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_hw_support/port/esp32 +INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_hw_support/port/esp32/private_include +INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_ipc/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_pm/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_rom/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_rom/include/esp32 +INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_system/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_system/port/public_compat +INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_timer/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_timer/private_include +INCLUDES += -I$(ESP32_SDK_DIR)/components/hal/esp32/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/hal/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/hal/platform_port/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/heap/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/log/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/newlib/priv_include +INCLUDES += -I$(ESP32_SDK_DIR)/components/soc/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/soc/esp32/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/spi_flash/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/xtensa/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/xtensa/esp32/include + +SRC := $(addprefix $(ESP32_SDK_DIR)/,$(ESP32_SDK_SRC)) +SRCXX := $(addprefix $(ESP32_SDK_DIR)/,$(ESP32_SDK_SRCXX)) + +OBJC_LTO := $(ESP32_SDK_SRC:%.c=$(ESP32_SDK_BIN)/%.o) +OBJC_NOLTO := $(ESP32_SDK_SRC_NOLTO:%.c=$(ESP32_SDK_BIN)/%.o) +OBJC := $(OBJC_NOLTO) $(OBJC_LTO) +OBJCXX := $(ESP32_SDK_SRCXX:%.$(SRCXXEXT)=$(ESP32_SDK_BIN)/%.o) +ASMOBJ := $(ESP32_SDK_ASMSRC:%.s=$(ESP32_SDK_BIN)/%.o) + +OBJ := $(OBJC) $(OBJCXX) $(ASMOBJ) $(ASSMOBJ) $(GENOBJC) +DEP := $(OBJC:.o=.d) $(OBJCXX:.o=.d) $(ASSMOBJ:.o=.d) + +$(MODULE).module compile-commands $(OBJ): | $(BINDIR)/$(MODULE)/ + +$(MODULE).module: $(OBJ) $(ESP32_LD_DST) \ + $(if $(OBJECTS_TO_REMOVE),$(MODULE).cleanup) | $(DIRS:%=ALL--%) + +$(OBJC): $(BINDIR)/$(MODULE)/%.o: $(ESP32_SDK_DIR)/%.c $(OBJ_DEPS) \ + | $(if $(SHOULD_RUN_KCONFIG),$(KCONFIG_GENERATED_AUTOCONF_HEADER_C)) + $(Q)mkdir -p $(dir $@) + $(Q)$(CCACHE) $(CC) \ + -DRIOT_FILE_RELATIVE=\"$(patsubst $(RIOTBASE)/%,%,$(abspath $<))\" \ + -DRIOT_FILE_NOPATH=\"$(notdir $<)\" \ + $(CFLAGS) $(INCLUDES) -MQ '$@' -MD -MP -c $(abspath $<) -o $@ +ifneq (,$(SHOULD_RUN_KCONFIG)) + $(Q)$(FIXDEP) $(@:.o=.d) $@ $(KCONFIG_SYNC_DIR) > $(@:.o=.tmp) + $(Q)mv $(@:.o=.tmp) $(@:.o=.d) +endif + +$(OBJCXX): $(BINDIR)/$(MODULE)/%.o: $(ESP32_SDK_DIR)/%.$(SRCXXEXT) $(OBJ_DEPS) \ + | $(if $(SHOULD_RUN_KCONFIG),$(KCONFIG_GENERATED_AUTOCONF_HEADER_C)) + $(Q)mkdir -p $(dir $@) + $(Q)$(CCACHE) $(CXX) \ + -DRIOT_FILE_RELATIVE=\"$(patsubst $(RIOTBASE)/%,%,$(abspath $<))\" \ + -DRIOT_FILE_NOPATH=\"$(notdir $<)\" \ + $(CXXFLAGS) $(CXXINCLUDES) $(INCLUDES) -MQ '$@' -MD -MP -c $(abspath $<) -o $@ +ifneq (,$(SHOULD_RUN_KCONFIG)) + $(Q)$(FIXDEP) $(@:.o=.d) $@ $(KCONFIG_SYNC_DIR) > $(@:.o=.tmp) + $(Q)mv $(@:.o=.tmp) $(@:.o=.d) +endif + +-include $(DEP) diff --git a/cpu/esp32/esp-idf/esp_idf_cflags.mk b/cpu/esp32/esp-idf/esp_idf_cflags.mk new file mode 100644 index 0000000000..74e1006644 --- /dev/null +++ b/cpu/esp32/esp-idf/esp_idf_cflags.mk @@ -0,0 +1,26 @@ +# common definitions for all ESP-IDF modules + +# shortcuts used by ESP-IDF +CFLAGS += -Dasm=__asm +CFLAGS += -Dtypeof=__typeof__ + +# required for esp_wifi (components/spi_flash/esp32/spi_flash_rom_patch.c) +# required for esp_idf_heap (components/heap/heap_caps_init.c) +# required for esp_idf_wpa_supplicant +CFLAGS += -Wno-sign-compare + +# required by esp_idf_heap (components/heap/heap_caps.c) +# required for esp_idf_wpa_supplicant +CFLAGS += -Wno-implicit-function-declaration + +# required for esp_wifi (components/esp_event/esp_event.c) +CFLAGS += -Wno-old-style-declaration + +# required for esp-wifi (components/efuse/esp32/esp_efuse_utility.c) +# required for esp_idf_heap (components/heap/multi_heap.c) +# required for esp_idf_wpa_supplicant +CFLAGS += -Wno-old-style-definition + +# vendor code contains casts that increase alignment requirements. Let's hope +# those are false positives. +CFLAGS += -Wno-cast-align diff --git a/cpu/esp32/esp-idf/esp_idf_support.c b/cpu/esp32/esp-idf/esp_idf_support.c new file mode 100644 index 0000000000..44747cefa6 --- /dev/null +++ b/cpu/esp32/esp-idf/esp_idf_support.c @@ -0,0 +1,176 @@ +/* + * Copyright (C) 2022 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 cpu_esp32 + * @{ + * + * @file + * @brief Functions required for ESP-IDF compatibility + * + * @author Gunar Schorcht + * + * @} + */ + +#include + +#include "esp_common.h" +#include "log.h" +#include "syscalls.h" + +#include "esp_attr.h" +#include "esp_log.h" + +#define ENABLE_DEBUG 0 +#include "debug.h" + +#if IS_USED(MODULE_ESP_WIFI_ANY) || IS_USED(MODULE_ESP_ETH) +#include "esp_event_base.h" + +ESP_EVENT_DEFINE_BASE(IP_EVENT); +#endif + +/* Global variables required by ESP-IDF */ +uint8_t *g_wpa_anonymous_identity; +int g_wpa_anonymous_identity_len; + +uint8_t *g_wpa_username; +int g_wpa_username_len; + +uint8_t *g_wpa_password; +int g_wpa_password_len; + +uint8_t *g_wpa_new_password; +int g_wpa_new_password_len; + +const uint8_t *g_wpa_client_cert; +int g_wpa_client_cert_len; + +const uint8_t *g_wpa_private_key; +int g_wpa_private_key_len; + +const uint8_t *g_wpa_private_key_passwd; +int g_wpa_private_key_passwd_len; + +const uint8_t *g_wpa_ca_cert; +int g_wpa_ca_cert_len; + +char *g_wpa_ttls_phase2_type; +bool g_wpa_suiteb_certification; + +/* + * provided by: /path/to/esp-idf/components/log/log_freertos.c + */ +uint32_t IRAM_ATTR esp_log_timestamp(void) +{ + return system_get_time() / USEC_PER_MSEC; +} + +typedef struct { + const char *tag; + unsigned level; +} esp_log_level_entry_t; + +static esp_log_level_entry_t _log_levels[] = { + { .tag = "wifi", .level = LOG_INFO }, + { .tag = "*", .level = LOG_DEBUG }, +}; + +static char _printf_buf[PRINTF_BUFSIZ]; + +/* + * provided by: /path/to/esp-idf/component/log/log.c + */ +void IRAM_ATTR esp_log_write(esp_log_level_t level, + const char* tag, const char* format, ...) +{ + va_list list; + va_start(list, format); + esp_log_writev(level, tag, format, list); + va_end(list); +} + +/* + * provided by: /path/to/esp-idf/component/log/log.c + */ +void IRAM_ATTR esp_log_writev(esp_log_level_t level, + const char *tag, + const char *format, + va_list args) +{ + /* + * We use the log level set for the given tag instead of using + * the given log level. + */ + esp_log_level_t act_level = LOG_DEBUG; + size_t i; + for (i = 0; i < ARRAY_SIZE(_log_levels); i++) { + if (strcmp(tag, _log_levels[i].tag) == 0) { + act_level = _log_levels[i].level; + break; + } + } + + /* If we didn't find an entry for the tag, we use the log level for "*" */ + if (i == ARRAY_SIZE(_log_levels)) { + act_level = _log_levels[ARRAY_SIZE(_log_levels)-1].level; + } + + /* Return if the log output has not the required level */ + if ((unsigned)act_level > CONFIG_LOG_DEFAULT_LEVEL) { + return; + } + + /* + * The format of log output from ESP SDK libraries is "X (s) t: message\n" + * where X is the log level, d the system time in milliseconds and t the + * tag. To be able to enable these additional information by module + * `esp_log_tagged`, we have to separate these information from the + * message here. + */ + const char* msg = (strchr (format, ':') + 2); + + va_list arglist; + va_copy(arglist, args); + + /* remove time and tag argument from argument list */ + va_arg(arglist, unsigned); + va_arg(arglist, const char*); + vsnprintf(_printf_buf, PRINTF_BUFSIZ, msg, arglist); + va_end(arglist); + + switch (act_level) { + case LOG_NONE : return; + case LOG_ERROR : LOG_TAG_ERROR (tag, "%s", _printf_buf); break; + case LOG_WARNING: LOG_TAG_WARNING(tag, "%s", _printf_buf); break; + case LOG_INFO : LOG_TAG_INFO (tag, "%s", _printf_buf); break; + case LOG_DEBUG : LOG_TAG_DEBUG (tag, "%s", _printf_buf); break; + case LOG_ALL : LOG_TAG_ALL (tag, "%s", _printf_buf); break; + } +} + +/* + * provided by: /path/to/esp-idf/component/log/log.c + */ +void esp_log_level_set(const char* tag, esp_log_level_t level) +{ + size_t i; + for (i = 0; i < ARRAY_SIZE(_log_levels); i++) { + if (strcmp(tag, _log_levels[i].tag) == 0) { + break; + } + } + + if (i == ARRAY_SIZE(_log_levels)) { + LOG_DEBUG("Tag for setting log level not found\n"); + return; + } + + _log_levels[i].level = level; +} diff --git a/cpu/esp32/esp-idf/eth/Kconfig b/cpu/esp32/esp-idf/eth/Kconfig new file mode 100644 index 0000000000..90a571c963 --- /dev/null +++ b/cpu/esp32/esp-idf/eth/Kconfig @@ -0,0 +1,14 @@ +# Copyright (c) 2021 HAW Hamburg +# 2022 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 MODULE_ESP_IDF_ETH + bool + depends on TEST_KCONFIG + depends on MODULE_ESP_IDF + help + ESP-IDF code required for the Ethernet network device. diff --git a/cpu/esp32/esp-idf/eth/Makefile b/cpu/esp32/esp-idf/eth/Makefile new file mode 100644 index 0000000000..1eeb9aa80b --- /dev/null +++ b/cpu/esp32/esp-idf/eth/Makefile @@ -0,0 +1,22 @@ +MODULE = esp_idf_eth + +# source files to be compiled for this module +ESP32_SDK_SRC = \ + components/esp_eth/src/esp_eth.c \ + components/esp_eth/src/esp_eth_mac_esp.c \ + components/esp_eth/src/esp_eth_netif_glue.c \ + components/esp_eth/src/esp_eth_phy.c \ + components/esp_eth/src/esp_eth_phy_dp83848.c \ + components/esp_eth/src/esp_eth_phy_ip101.c \ + components/esp_eth/src/esp_eth_phy_ksz80xx.c \ + components/esp_eth/src/esp_eth_phy_lan87xx.c \ + components/esp_eth/src/esp_eth_phy_rtl8201.c \ + components/hal/emac_hal.c \ + # + +include $(RIOTBASE)/Makefile.base + +ESP32_SDK_BIN = $(BINDIR)/$(MODULE) + +include ../esp_idf.mk +include ../esp_idf_cflags.mk diff --git a/cpu/esp32/esp-idf/event/Kconfig b/cpu/esp32/esp-idf/event/Kconfig new file mode 100644 index 0000000000..8ff5523d7f --- /dev/null +++ b/cpu/esp32/esp-idf/event/Kconfig @@ -0,0 +1,13 @@ +# Copyright (c) 2022 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 MODULE_ESP_IDF_EVENT + bool + depends on TEST_KCONFIG + depends on MODULE_ESP_IDF + help + ESP-IDF code for event handling as required for network devices. diff --git a/cpu/esp32/esp-idf/event/Makefile b/cpu/esp32/esp-idf/event/Makefile new file mode 100644 index 0000000000..22cd77e8a4 --- /dev/null +++ b/cpu/esp32/esp-idf/event/Makefile @@ -0,0 +1,18 @@ +MODULE = esp_idf_event + +# source files to be compiled for this module +ESP32_SDK_SRC = \ + components/esp_event/default_event_loop.c \ + components/esp_event/esp_event.c \ + # + +# additional include pathes required by this module +INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_event/private_include +INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_event/include + +include $(RIOTBASE)/Makefile.base + +ESP32_SDK_BIN = $(BINDIR)/$(MODULE) + +include ../esp_idf.mk +include ../esp_idf_cflags.mk diff --git a/cpu/esp32/esp-idf/gpio/Kconfig b/cpu/esp32/esp-idf/gpio/Kconfig new file mode 100644 index 0000000000..89cbea1320 --- /dev/null +++ b/cpu/esp32/esp-idf/gpio/Kconfig @@ -0,0 +1,13 @@ +# Copyright (c) 2022 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 MODULE_ESP_IDF_GPIO + bool + depends on TEST_KCONFIG + depends on MODULE_ESP_IDF + help + ESP-IDF code for peripheral GPIO. diff --git a/cpu/esp32/esp-idf/gpio/Makefile b/cpu/esp32/esp-idf/gpio/Makefile new file mode 100644 index 0000000000..d0b5d0a233 --- /dev/null +++ b/cpu/esp32/esp-idf/gpio/Makefile @@ -0,0 +1,14 @@ +MODULE = esp_idf_gpio + +# source files to be compiled for this module +ESP32_SDK_SRC = \ + components/driver/gpio.c \ + components/soc/$(CPU)/gpio_periph.c \ + # + +include $(RIOTBASE)/Makefile.base + +ESP32_SDK_BIN = $(BINDIR)/$(MODULE) + +include ../esp_idf.mk +include ../esp_idf_cflags.mk diff --git a/cpu/esp32/esp-idf/heap/Kconfig b/cpu/esp32/esp-idf/heap/Kconfig new file mode 100644 index 0000000000..d67264f68a --- /dev/null +++ b/cpu/esp32/esp-idf/heap/Kconfig @@ -0,0 +1,16 @@ +# Copyright (c) 2021 HAW Hamburg +# 2022 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 MODULE_ESP_IDF_HEAP + bool + depends on TEST_KCONFIG + depends on MODULE_ESP_IDF + select PACKAGE_TLSF + help + ESP-IDF heap library. This library is required if external SPI RAM + or the WiFi interface is used. diff --git a/cpu/esp32/esp-idf/heap/Makefile b/cpu/esp32/esp-idf/heap/Makefile new file mode 100644 index 0000000000..b76e013e2a --- /dev/null +++ b/cpu/esp32/esp-idf/heap/Makefile @@ -0,0 +1,34 @@ +MODULE = esp_idf_heap + +# source files to be compiled for this module +ESP32_SDK_SRC = \ + components/heap/heap_caps.c \ + components/heap/heap_caps_init.c \ + components/heap/heap_task_info.c \ + components/heap/heap_trace_standalone.c \ + components/heap/multi_heap.c \ + components/heap/multi_heap_poisoning.c \ + components/heap/port/$(CPU)/memory_layout.c \ + components/heap/port/memory_layout_utils.c \ + # + +# We don't use ESP-IDF TLSF at all to prevent colissions. It doesn't seem to do +# something special with the exception of heap poisoning which isn't configured +# by default. +# ifeq (,$(filter tlsf,$(USEPKG))) +# ESP32_SDK_SRC += components/heap/heap_tlsf.c +# endif + +# additional include pathes required by this module +INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_rom/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_system/include + +include $(RIOTBASE)/Makefile.base + +ESP32_SDK_BIN = $(BINDIR)/$(MODULE) + +include ../esp_idf.mk +include ../esp_idf_cflags.mk + +# set by default +CFLAGS += -DMULTI_HEAP_FREERTOS diff --git a/cpu/esp32/esp-idf/include/log/esp_log.h b/cpu/esp32/esp-idf/include/log/esp_log.h new file mode 100644 index 0000000000..f673b932f9 --- /dev/null +++ b/cpu/esp32/esp-idf/include/log/esp_log.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2022 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 cpu_esp32 + * @{ + * + * @file + * @brief Wrapper for source code compatibility of ESP-IDF log with RIOT's log module + * + * @author Gunar Schorcht + * @} + */ + +#ifndef LOG_ESP_LOG_H +#define LOG_ESP_LOG_H + +#ifndef DOXYGEN /* Hide implementation details from doxygen */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include_next "esp_log.h" + +#if defined(RIOT_VERSION) + +#include "esp_common.h" + +#ifndef LOG_LOCAL_LEVEL +#define LOG_LOCAL_LEVEL LOG_LEVEL +#endif + +#define ESP_LOG_LEVEL(level, tag, format, ...) \ + do { \ + if ((esp_log_level_t)level==ESP_LOG_ERROR ) { \ + LOG_TAG(level, E, tag, format, ##__VA_ARGS__); \ + } \ + else if ((esp_log_level_t)level==ESP_LOG_WARN ) { \ + LOG_TAG(level, W, tag, format, ##__VA_ARGS__); \ + } \ + else if ((esp_log_level_t)level==ESP_LOG_INFO ) { \ + LOG_TAG(level, I, tag, format, ##__VA_ARGS__); \ + } \ + else if ((esp_log_level_t)level==ESP_LOG_DEBUG ) { \ + LOG_TAG(level, D, tag, format, ##__VA_ARGS__); \ + } \ + else if ((esp_log_level_t)level==ESP_LOG_VERBOSE ) { \ + LOG_TAG(level, V, tag, format, ##__VA_ARGS__); \ + } \ + } while (0) + +#define ESP_LOG_LEVEL_LOCAL(level, tag, format, ...) \ + do { \ + if ( LOG_LOCAL_LEVEL >= level ) { \ + ESP_LOG_LEVEL(level, tag, format, ##__VA_ARGS__); \ + } \ + } while (0) + +#endif /* defined(RIOT_VERSION) */ + +#ifdef __cplusplus +} +#endif + +#endif /* DOXYGEN */ +#endif /* LOG_ESP_LOG_H */ diff --git a/cpu/esp32/include/sdk_conf.h b/cpu/esp32/esp-idf/include/sdkconfig.h similarity index 58% rename from cpu/esp32/include/sdk_conf.h rename to cpu/esp32/esp-idf/include/sdkconfig.h index 29c8c6d6d5..89acb45605 100644 --- a/cpu/esp32/include/sdk_conf.h +++ b/cpu/esp32/esp-idf/include/sdkconfig.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Gunar Schorcht + * Copyright (C) 2022 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 @@ -19,8 +19,8 @@ * @author Gunar Schorcht */ -#ifndef SDK_CONF_H -#define SDK_CONF_H +#ifndef SDKCONFIG_H +#define SDKCONFIG_H #ifndef DOXYGEN @@ -34,7 +34,7 @@ extern "C" { * Determined with `git describe --tags` in `$ESP32_SDK_DIR` */ #if !defined(IDF_VER) || DOXYGEN -#include "esp32_idf_version.h" +#include "esp_idf_ver.h" #endif /** @@ -76,6 +76,7 @@ extern "C" { * can be overridden by an application specific configuration. */ #define CONFIG_CONSOLE_UART_NUM 0 +#define CONFIG_ESP_CONSOLE_UART_NUM CONFIG_CONSOLE_UART_NUM #ifndef CONFIG_CONSOLE_UART_BAUDRATE #define CONFIG_CONSOLE_UART_BAUDRATE STDIO_UART_BAUDRATE @@ -104,18 +105,29 @@ extern "C" { /** * System specific configuration (DO NOT CHANGE) */ -#define CONFIG_TRACEMEM_RESERVE_DRAM 0 -#define CONFIG_ULP_COPROC_RESERVE_MEM 0 - -#define CONFIG_SYSTEM_EVENT_QUEUE_SIZE 32 -#define CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE 2048 -#define CONFIG_NUMBER_OF_UNIVERSAL_MAC_ADDRESS 4 - #ifdef MODULE_NEWLIB_NANO #define CONFIG_NEWLIB_NANO_FORMAT 1 #endif + +#define CONFIG_TRACEMEM_RESERVE_DRAM 0 +#define CONFIG_ULP_COPROC_RESERVE_MEM 0 + +#define CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE 32 +#define CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE 2560 +#define CONFIG_NUMBER_OF_UNIVERSAL_MAC_ADDRESS 4 + #define CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY 2000 +#define CONFIG_ESP_TIMER_INTERRUPT_LEVEL 1 +#define CONFIG_ESP_TIMER_TASK_STACK_SIZE 3584 +#define CONFIG_ESP_TIMER_IMPL_FRC2 1 +#define CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER 1 + +#define CONFIG_APP_BUILD_USE_FLASH_SECTIONS 1 +#define CONFIG_EFUSE_MAX_BLK_LEN 192 + +#define CONFIG_PARTITION_TABLE_OFFSET 0x8000 + /** * Bluetooth configuration (DO NOT CHANGE) */ @@ -126,19 +138,29 @@ extern "C" { * SPI RAM configuration (DO NOT CHANGE) */ #ifdef MODULE_ESP_SPI_RAM -#define CONFIG_SPIRAM_SUPPORT 1 -#else -#define CONFIG_SPIRAM_SUPPORT 0 -#endif -#define CONFIG_SPIRAM_SPEED_40M 1 -#define CONFIG_SPIRAM_SIZE 4194304 +#define CONFIG_SOC_SPIRAM_SUPPORTED 1 +#define CONFIG_ESP32_SPIRAM_SUPPORT 1 +#define CONFIG_D0WD_PSRAM_CLK_IO 17 +#define CONFIG_D0WD_PSRAM_CS_IO 16 +#define CONFIG_D2WD_PSRAM_CLK_IO 9 +#define CONFIG_D2WD_PSRAM_CS_IO 10 +#define CONFIG_PICO_PSRAM_CS_IO 10 +#define CONFIG_SPIRAM_SUPPORT CONFIG_ESP32_SPIRAM_SUPPORT +#define CONFIG_SPIRAM 1 +#define CONFIG_SPIRAM_BANKSWITCH_ENABLE 1 +#define CONFIG_SPIRAM_BANKSWITCH_RESERVE 8 #define CONFIG_SPIRAM_BOOT_INIT 1 -#define CONFIG_SPIRAM_USE_MALLOC 1 -#define CONFIG_SPIRAM_TYPE_ESPPSRAM32 1 -#define CONFIG_SPIRAM_MEMTEST 1 #define CONFIG_SPIRAM_CACHE_WORKAROUND 1 +#define CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_MEMW 1 #define CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL 16384 #define CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL 32768 +#define CONFIG_SPIRAM_MEMTEST 1 +#define CONFIG_SPIRAM_SIZE -1 +#define CONFIG_SPIRAM_SPEED_40M 1 +#define CONFIG_SPIRAM_SPIWP_SD3_PIN 7 +#define CONFIG_SPIRAM_TYPE_AUTO 1 +#define CONFIG_SPIRAM_USE_MALLOC 0 /* using malloc requires QStaticQueue */ +#endif /** * SPI Flash driver configuration (DO NOT CHANGE) @@ -148,9 +170,16 @@ extern "C" { /** * Ethernet driver configuration (DO NOT CHANGE) */ -#define CONFIG_DMA_RX_BUF_NUM 10 -#define CONFIG_DMA_TX_BUF_NUM 10 -#define CONFIG_EMAC_TASK_PRIORITY 20 +#ifdef MODULE_ESP_ETH +#define CONFIG_ETH_ENABLED 1 +#endif +#define CONFIG_ETH_USE_ESP32_EMAC 1 +#define CONFIG_ETH_PHY_INTERFACE_RMII 1 +#define CONFIG_ETH_RMII_CLK_INPUT 1 +#define CONFIG_ETH_RMII_CLK_IN_GPIO 0 +#define CONFIG_ETH_DMA_BUFFER_SIZE 512 +#define CONFIG_ETH_DMA_RX_BUFFER_NUM 10 +#define CONFIG_ETH_DMA_TX_BUFFER_NUM 10 /** * Serial flasher config (DO NOT CHANGE) @@ -169,34 +198,49 @@ extern "C" { /** * Wi-Fi driver configuration (DO NOT CHANGE) */ -#define CONFIG_ESP32_WIFI_TX_BUFFER_TYPE 1 -#define CONFIG_ESP32_WIFI_STATIC_TX_BUFFER 0 -#define CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER 1 -#define CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM 20 +#ifdef MODULE_ESP_WIFI_ANY +#define CONFIG_ESP32_WIFI_ENABLED 1 +#endif +#if defined(MODULE_ESP_WIFI_AP) || defined(MODULE_ESP_NOW) +#define CONFIG_ESP_WIFI_SOFTAP_SUPPORT 1 +#endif #define CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM 10 -#define CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM 20 +#define CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM 32 +#define CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER 1 +#define CONFIG_ESP32_WIFI_TX_BUFFER_TYPE 1 +#define CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM 32 +#define CONFIG_ESP32_WIFI_CACHE_TX_BUFFER_NUM 32 /* required when CONFIG_SPIRAM_USE_MALLOC=0 */ #define CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED 1 -#define CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED 1 #define CONFIG_ESP32_WIFI_TX_BA_WIN 6 +#define CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED 1 #define CONFIG_ESP32_WIFI_RX_BA_WIN 6 -#define CONFIG_ESP32_WIFI_CSI_ENABLED 0 -#define CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0 1 -#define CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1 0 #if MODULE_ESP_IDF_NVS_ENABLED #define CONFIG_ESP32_WIFI_NVS_ENABLED 1 #endif +#define CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0 1 +#define CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN 752 +#define CONFIG_ESP32_WIFI_MGMT_SBUF_NUM 32 +#define CONFIG_ESP32_WIFI_IRAM_OPT 1 +#define CONFIG_ESP32_WIFI_RX_IRAM_OPT 1 +#define CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE 1 /** * PHY configuration */ -#define CONFIG_ESP32_PHY_MAX_TX_POWER 20 -#define CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER 20 -#define CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION 0 - #if MODULE_ESP_IDF_NVS_ENABLED -#define CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE 1 +#define CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE 1 #endif +#define CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION 0 +#define CONFIG_ESP_PHY_MAX_TX_POWER 20 +#define CONFIG_ESP_PHY_MAX_WIFI_TX_POWER 20 +#define CONFIG_ESP_PHY_REDUCE_TX_POWER 1 + +#define CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE +#define CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER CONFIG_ESP_PHY_MAX_WIFI_TX_POWER +#define CONFIG_ESP32_REDUCE_PHY_TX_POWER CONFIG_ESP_PHY_REDUCE_TX_POWER +#define CONFIG_REDUCE_PHY_TX_POWER CONFIG_ESP_PHY_REDUCE_TX_POWER + /** * EMAC driver configuration (DO NOT CHANGE) */ @@ -207,5 +251,5 @@ extern "C" { #endif #endif /* DOXYGEN */ -#endif /* SDK_CONF_H */ +#endif /* SDKCONFIG_H */ /** @} */ diff --git a/cpu/esp32/esp-idf/nvs_flash/Kconfig b/cpu/esp32/esp-idf/nvs_flash/Kconfig new file mode 100644 index 0000000000..09c88c5aa2 --- /dev/null +++ b/cpu/esp32/esp-idf/nvs_flash/Kconfig @@ -0,0 +1,16 @@ +# Copyright (c) 2021 HAW Hamburg +# +# 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 MODULE_ESP_IDF_NVS_FLASH + bool + depends on TEST_KCONFIG + depends on MODULE_ESP_IDF + select MODULE_CPP + select MODULE_MTD + help + ESP-IDF non-volatile storage library. This library is required if + the WiFi interface is used. diff --git a/cpu/esp32/esp-idf/nvs_flash/Makefile b/cpu/esp32/esp-idf/nvs_flash/Makefile new file mode 100644 index 0000000000..111ed1c542 --- /dev/null +++ b/cpu/esp32/esp-idf/nvs_flash/Makefile @@ -0,0 +1,30 @@ +MODULE = esp_idf_nvs_flash + +# source files to be compiled for this module +ESP32_SDK_SRCXX = \ + components/nvs_flash/src/nvs_api.cpp \ + components/nvs_flash/src/nvs_cxx_api.cpp \ + components/nvs_flash/src/nvs_handle_locked.cpp \ + components/nvs_flash/src/nvs_handle_simple.cpp \ + components/nvs_flash/src/nvs_item_hash_list.cpp \ + components/nvs_flash/src/nvs_page.cpp \ + components/nvs_flash/src/nvs_pagemanager.cpp \ + components/nvs_flash/src/nvs_partition.cpp \ + components/nvs_flash/src/nvs_partition_lookup.cpp \ + components/nvs_flash/src/nvs_partition_manager.cpp \ + components/nvs_flash/src/nvs_storage.cpp \ + components/nvs_flash/src/nvs_types.cpp \ + # + +# additional include pathes required by this module +INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_rom/include + +include $(RIOTBASE)/Makefile.base + +ESP32_SDK_BIN = $(BINDIR)/$(MODULE) + +include ../esp_idf.mk + +# vendor code contains casts that increase alignment requirements. Let's hope +# those are false positives. +CFLAGS += -Wno-cast-align diff --git a/cpu/esp32/esp-idf/spi_flash/Kconfig b/cpu/esp32/esp-idf/spi_flash/Kconfig new file mode 100644 index 0000000000..a27e1876d3 --- /dev/null +++ b/cpu/esp32/esp-idf/spi_flash/Kconfig @@ -0,0 +1,13 @@ +# Copyright (c) 2022 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 MODULE_ESP_IDF_SPI_FLASH + bool + depends on TEST_KCONFIG + depends on MODULE_ESP_IDF + help + ESP-IDF code for accessing external SPI Flash. diff --git a/cpu/esp32/esp-idf/spi_flash/Makefile b/cpu/esp32/esp-idf/spi_flash/Makefile new file mode 100644 index 0000000000..de77e18bd4 --- /dev/null +++ b/cpu/esp32/esp-idf/spi_flash/Makefile @@ -0,0 +1,23 @@ +MODULE = esp_idf_spi_flash + +# source files to be compiled for this module +ESP32_SDK_SRC = \ + components/bootloader_support/src/bootloader_common.c \ + components/bootloader_support/src/bootloader_efuse_$(CPU).c \ + components/bootloader_support/src/bootloader_flash_config_$(CPU).c \ + components/driver/spi_common.c \ + components/soc/$(CPU)/spi_periph.c \ + components/spi_flash/$(CPU)/spi_flash_rom_patch.c \ + components/spi_flash/flash_ops.c \ + # + +# additional include pathes required by this module +INCLUDES += -I$(ESP32_SDK_DIR)/components/bootloader_support/include_bootloader +INCLUDES += -I$(ESP32_SDK_DIR)/components/spi_flash/include/spi_flash + +include $(RIOTBASE)/Makefile.base + +ESP32_SDK_BIN = $(BINDIR)/$(MODULE) + +include ../esp_idf.mk +include ../esp_idf_cflags.mk diff --git a/cpu/esp32/esp-idf/spi_ram/Kconfig b/cpu/esp32/esp-idf/spi_ram/Kconfig new file mode 100644 index 0000000000..3c0118e984 --- /dev/null +++ b/cpu/esp32/esp-idf/spi_ram/Kconfig @@ -0,0 +1,13 @@ +# Copyright (c) 2022 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 MODULE_ESP_IDF_SPI_RAM + bool + depends on TEST_KCONFIG + depends on MODULE_ESP_IDF + help + ESP-IDF code for accessing external SPI RAM. diff --git a/cpu/esp32/esp-idf/spi_ram/Makefile b/cpu/esp32/esp-idf/spi_ram/Makefile new file mode 100644 index 0000000000..fe25153d86 --- /dev/null +++ b/cpu/esp32/esp-idf/spi_ram/Makefile @@ -0,0 +1,18 @@ +MODULE = esp_idf_spi_ram + +# source files to be compiled for this module +ESP32_SDK_SRC = \ + components/esp_hw_support/port/$(CPU)/spiram.c \ + components/esp_hw_support/port/$(CPU)/spiram_psram.c \ + components/esp_hw_support/port/$(CPU)/cache_sram_mmu.c \ + # + +# additional include pathes required by this module +INCLUDES += -I$(ESP32_SDK_DIR)/components/soc/$(CPU)/include + +include $(RIOTBASE)/Makefile.base + +ESP32_SDK_BIN = $(BINDIR)/$(MODULE) + +include ../esp_idf.mk +include ../esp_idf_cflags.mk diff --git a/cpu/esp32/esp-idf/wifi/Kconfig b/cpu/esp32/esp-idf/wifi/Kconfig new file mode 100644 index 0000000000..7609e8dbe9 --- /dev/null +++ b/cpu/esp32/esp-idf/wifi/Kconfig @@ -0,0 +1,13 @@ +# Copyright (c) 2022 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 MODULE_ESP_IDF_WIFI + bool + depends on TEST_KCONFIG + depends on MODULE_ESP_IDF + help + ESP-IDF code required for accessing the WiFi interface. diff --git a/cpu/esp32/esp-idf/wifi/Makefile b/cpu/esp32/esp-idf/wifi/Makefile new file mode 100644 index 0000000000..a2759bc42d --- /dev/null +++ b/cpu/esp32/esp-idf/wifi/Makefile @@ -0,0 +1,27 @@ +MODULE = esp_idf_wifi + +# source files to be compiled for this module +ESP32_SDK_SRC = \ + components/driver/adc_common.c \ + components/driver/rtc_module.c \ + components/esp_event/event_send.c \ + components/esp_hw_support/hw_random.c \ + components/esp_hw_support/port/$(CPU)/dport_access.c \ + components/esp_phy/src/phy_init.c \ + components/esp_wifi/$(CPU)/esp_adapter.c \ + components/esp_wifi/src/wifi_init.c \ + # + +# additional include pathes required by this module +INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_phy/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/esp_phy/$(CPU)/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/tcpip_adapter/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/wpa_supplicant/port/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/wpa_supplicant/esp_supplicant/include + +include $(RIOTBASE)/Makefile.base + +ESP32_SDK_BIN = $(BINDIR)/$(MODULE) + +include ../esp_idf.mk +include ../esp_idf_cflags.mk diff --git a/cpu/esp32/esp-idf/wpa_supplicant/Kconfig b/cpu/esp32/esp-idf/wpa_supplicant/Kconfig new file mode 100644 index 0000000000..b3c5908218 --- /dev/null +++ b/cpu/esp32/esp-idf/wpa_supplicant/Kconfig @@ -0,0 +1,14 @@ +# Copyright (c) 2021 HAW Hamburg +# 2022 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 MODULE_ESP_IDF_WPA_SUPPLICANT + bool + depends on TEST_KCONFIG + depends on MODULE_ESP_IDF + help + ESP-IDF WPA supplicant. diff --git a/cpu/esp32/esp-idf/wpa_supplicant/Makefile b/cpu/esp32/esp-idf/wpa_supplicant/Makefile new file mode 100644 index 0000000000..0927bf5a2c --- /dev/null +++ b/cpu/esp32/esp-idf/wpa_supplicant/Makefile @@ -0,0 +1,146 @@ +MODULE = esp_idf_wpa_supplicant + +# source file list to be compiled as configured in component.mk +ESP32_SDK_SRC = \ + components/wpa_supplicant/esp_supplicant/src/esp_dpp.c \ + components/wpa_supplicant/esp_supplicant/src/esp_hostap.c \ + components/wpa_supplicant/esp_supplicant/src/esp_wpa2.c \ + components/wpa_supplicant/esp_supplicant/src/esp_wpa3.c \ + components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c \ + components/wpa_supplicant/esp_supplicant/src/esp_wpas_glue.c \ + components/wpa_supplicant/esp_supplicant/src/esp_wps.c \ + components/wpa_supplicant/port/os_xtensa.c \ + components/wpa_supplicant/src/ap/ap_config.c \ + components/wpa_supplicant/src/ap/ieee802_1x.c \ + components/wpa_supplicant/src/ap/wpa_auth.c \ + components/wpa_supplicant/src/ap/wpa_auth_ie.c \ + components/wpa_supplicant/src/common/dpp.c \ + components/wpa_supplicant/src/common/sae.c \ + components/wpa_supplicant/src/common/wpa_common.c \ + components/wpa_supplicant/src/crypto/aes-cbc.c \ + components/wpa_supplicant/src/crypto/aes-ccm.c \ + components/wpa_supplicant/src/crypto/aes-ctr.c \ + components/wpa_supplicant/src/crypto/aes-gcm.c \ + components/wpa_supplicant/src/crypto/aes-internal.c \ + components/wpa_supplicant/src/crypto/aes-internal-dec.c \ + components/wpa_supplicant/src/crypto/aes-internal-enc.c \ + components/wpa_supplicant/src/crypto/aes-omac1.c \ + components/wpa_supplicant/src/crypto/aes-siv.c \ + components/wpa_supplicant/src/crypto/aes-unwrap.c \ + components/wpa_supplicant/src/crypto/aes-wrap.c \ + components/wpa_supplicant/src/crypto/ccmp.c \ + components/wpa_supplicant/src/crypto/crypto_internal.c \ + components/wpa_supplicant/src/crypto/crypto_internal-cipher.c \ + components/wpa_supplicant/src/crypto/crypto_internal-modexp.c \ + components/wpa_supplicant/src/crypto/crypto_internal-rsa.c \ + components/wpa_supplicant/src/crypto/crypto_ops.c \ + components/wpa_supplicant/src/crypto/des-internal.c \ + components/wpa_supplicant/src/crypto/dh_group5.c \ + components/wpa_supplicant/src/crypto/dh_groups.c \ + components/wpa_supplicant/src/crypto/md4-internal.c \ + components/wpa_supplicant/src/crypto/md5.c \ + components/wpa_supplicant/src/crypto/md5-internal.c \ + components/wpa_supplicant/src/crypto/ms_funcs.c \ + components/wpa_supplicant/src/crypto/rc4.c \ + components/wpa_supplicant/src/crypto/sha1.c \ + components/wpa_supplicant/src/crypto/sha1-internal.c \ + components/wpa_supplicant/src/crypto/sha1-pbkdf2.c \ + components/wpa_supplicant/src/crypto/sha1-prf.c \ + components/wpa_supplicant/src/crypto/sha1-tlsprf.c \ + components/wpa_supplicant/src/crypto/sha256.c \ + components/wpa_supplicant/src/crypto/sha256-internal.c \ + components/wpa_supplicant/src/crypto/sha256-kdf.c \ + components/wpa_supplicant/src/crypto/sha256-prf.c \ + components/wpa_supplicant/src/crypto/sha256-tlsprf.c \ + components/wpa_supplicant/src/crypto/sha384-internal.c \ + components/wpa_supplicant/src/crypto/sha384-prf.c \ + components/wpa_supplicant/src/crypto/sha384-tlsprf.c \ + components/wpa_supplicant/src/crypto/sha512-internal.c \ + components/wpa_supplicant/src/eap_peer/chap.c \ + components/wpa_supplicant/src/eap_peer/eap.c \ + components/wpa_supplicant/src/eap_peer/eap_common.c \ + components/wpa_supplicant/src/eap_peer/eap_mschapv2.c \ + components/wpa_supplicant/src/eap_peer/eap_peap.c \ + components/wpa_supplicant/src/eap_peer/eap_peap_common.c \ + components/wpa_supplicant/src/eap_peer/eap_tls.c \ + components/wpa_supplicant/src/eap_peer/eap_tls_common.c \ + components/wpa_supplicant/src/eap_peer/eap_ttls.c \ + components/wpa_supplicant/src/eap_peer/mschapv2.c \ + components/wpa_supplicant/src/rsn_supp/pmksa_cache.c \ + components/wpa_supplicant/src/rsn_supp/wpa.c \ + components/wpa_supplicant/src/rsn_supp/wpa_ie.c \ + components/wpa_supplicant/src/tls/asn1.c \ + components/wpa_supplicant/src/tls/bignum.c \ + components/wpa_supplicant/src/tls/pkcs1.c \ + components/wpa_supplicant/src/tls/pkcs5.c \ + components/wpa_supplicant/src/tls/pkcs8.c \ + components/wpa_supplicant/src/tls/rsa.c \ + components/wpa_supplicant/src/tls/tls_internal.c \ + components/wpa_supplicant/src/tls/tlsv1_client.c \ + components/wpa_supplicant/src/tls/tlsv1_client_read.c \ + components/wpa_supplicant/src/tls/tlsv1_client_write.c \ + components/wpa_supplicant/src/tls/tlsv1_common.c \ + components/wpa_supplicant/src/tls/tlsv1_cred.c \ + components/wpa_supplicant/src/tls/tlsv1_record.c \ + components/wpa_supplicant/src/tls/tlsv1_server.c \ + components/wpa_supplicant/src/tls/tlsv1_server_read.c \ + components/wpa_supplicant/src/tls/tlsv1_server_write.c \ + components/wpa_supplicant/src/tls/x509v3.c \ + components/wpa_supplicant/src/utils/base64.c \ + components/wpa_supplicant/src/utils/bitfield.c \ + components/wpa_supplicant/src/utils/common.c \ + components/wpa_supplicant/src/utils/ext_password.c \ + components/wpa_supplicant/src/utils/json.c \ + components/wpa_supplicant/src/utils/uuid.c \ + components/wpa_supplicant/src/utils/wpabuf.c \ + components/wpa_supplicant/src/utils/wpa_debug.c \ + components/wpa_supplicant/src/wps/wps_attr_build.c \ + components/wpa_supplicant/src/wps/wps_attr_parse.c \ + components/wpa_supplicant/src/wps/wps_attr_process.c \ + components/wpa_supplicant/src/wps/wps.c \ + components/wpa_supplicant/src/wps/wps_common.c \ + components/wpa_supplicant/src/wps/wps_dev_attr.c \ + components/wpa_supplicant/src/wps/wps_enrollee.c \ + components/wpa_supplicant/src/wps/wps_registrar.c \ + components/wpa_supplicant/src/wps/wps_validate.c \ + # + +# additional include pathes required by this module +INCLUDES += -I$(ESP32_SDK_DIR)/components/wpa_supplicant/esp_supplicant/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/wpa_supplicant/esp_supplicant/src +INCLUDES += -I$(ESP32_SDK_DIR)/components/wpa_supplicant/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/wpa_supplicant/port/include +INCLUDES += -I$(ESP32_SDK_DIR)/components/wpa_supplicant/src +INCLUDES += -I$(ESP32_SDK_DIR)/components/wpa_supplicant/src/utils + +include $(RIOTBASE)/Makefile.base + +ESP32_SDK_BIN = $(BINDIR)/$(MODULE) + +# definitions for wpa_supplicant from components/wpa_supplicant/component.mk +CFLAGS += -D__ets__ +CFLAGS += -DCONFIG_DPP +CFLAGS += -DCONFIG_ECC +CFLAGS += -DCONFIG_IEEE80211W +CFLAGS += -DCONFIG_SHA256 +CFLAGS += -DCONFIG_WNM +CFLAGS += -DCONFIG_WPS_PIN +CFLAGS += -DCONFIG_WPS2 +CFLAGS += -DEAP_MSCHAPv2 +CFLAGS += -DEAP_PEAP +CFLAGS += -DEAP_PEER_METHOD +CFLAGS += -DEAP_TLS +CFLAGS += -DEAP_TTLS +CFLAGS += -DESP_SUPPLICANT +CFLAGS += -DESP32_WORKAROUND +CFLAGS += -DESPRESSIF_USE +CFLAGS += -DIEEE8021X_EAPOL +CFLAGS += -DUSE_WPA2_TASK +CFLAGS += -DUSE_WPS_TASK +CFLAGS += -Wno-strict-aliasing +CFLAGS += -Wno-format-nonliteral +CFLAGS += -Wno-format-security +CFLAGS += -std=gnu99 + +include ../esp_idf.mk +include ../esp_idf_cflags.mk