From 8063b93497bade8f32d89dea6037533181710f90 Mon Sep 17 00:00:00 2001 From: Kedar Sovani Date: Tue, 15 Aug 2017 14:10:57 +0530 Subject: [PATCH 1/8] wifi_lib: Update to the change in the wifi_lib repository --- components/esp32/lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp32/lib b/components/esp32/lib index e8d8e908f..6fda89666 160000 --- a/components/esp32/lib +++ b/components/esp32/lib @@ -1 +1 @@ -Subproject commit e8d8e908fb37c4d9e8a3f23e63f6b34f5178e24a +Subproject commit 6fda896660d001dd6d4aec5bae2a294a757d4276 From 55a6aca355b7be2a148c755caebb0b4ffd495045 Mon Sep 17 00:00:00 2001 From: Kedar Sovani Date: Mon, 7 Aug 2017 10:35:36 +0530 Subject: [PATCH 2/8] wifi: Map esp_wifi_init() to esp_wifi_init_internal() Follow-on patches will include additional functionality in esp_wifi_init() --- components/esp32/event_default_handlers.c | 5 +++++ components/esp32/include/esp_wifi_internal.h | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/components/esp32/event_default_handlers.c b/components/esp32/event_default_handlers.c index 04a74f59d..118277656 100644 --- a/components/esp32/event_default_handlers.c +++ b/components/esp32/event_default_handlers.c @@ -408,3 +408,8 @@ esp_err_t esp_event_process_default(system_event_t *event) } return ESP_OK; } + +esp_err_t esp_wifi_init(wifi_init_config_t *config) +{ + return esp_wifi_init_internal(config); +} diff --git a/components/esp32/include/esp_wifi_internal.h b/components/esp32/include/esp_wifi_internal.h index 09813bfa1..e86d60f7f 100644 --- a/components/esp32/include/esp_wifi_internal.h +++ b/components/esp32/include/esp_wifi_internal.h @@ -40,6 +40,20 @@ extern "C" { #endif +/** + * @brief Initialize Wi-Fi Driver + * Alloc resource for WiFi driver, such as WiFi control structure, RX/TX buffer, + * WiFi NVS structure among others. + * + * @param config provide WiFi init configuration + * + * @return + * - ESP_OK: succeed + * - ESP_ERR_WIFI_NO_MEM: out of memory + * - others: refer to error code esp_err.h + */ +esp_err_t esp_wifi_init_internal(wifi_init_config_t *config); + /** * @brief get whether the wifi driver is allowed to transmit data or not * From a41b1a9d1f7bce52dd42deb3b67d507d41e262b6 Mon Sep 17 00:00:00 2001 From: Kedar Sovani Date: Mon, 7 Aug 2017 15:57:58 +0530 Subject: [PATCH 3/8] esp32: Register event handlers on the esp_wifi_init() call --- components/esp32/event_default_handlers.c | 30 ++++++++++++----------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/components/esp32/event_default_handlers.c b/components/esp32/event_default_handlers.c index 118277656..fa32d2cbc 100644 --- a/components/esp32/event_default_handlers.c +++ b/components/esp32/event_default_handlers.c @@ -47,7 +47,6 @@ do{\ typedef esp_err_t (*system_event_handler_t)(system_event_t *e); -#ifdef CONFIG_WIFI_ENABLED static esp_err_t system_event_ap_start_handle_default(system_event_t *event); static esp_err_t system_event_ap_stop_handle_default(system_event_t *event); static esp_err_t system_event_sta_start_handle_default(system_event_t *event); @@ -55,7 +54,6 @@ static esp_err_t system_event_sta_stop_handle_default(system_event_t *event); static esp_err_t system_event_sta_connected_handle_default(system_event_t *event); static esp_err_t system_event_sta_disconnected_handle_default(system_event_t *event); static esp_err_t system_event_sta_got_ip_default(system_event_t *event); -#endif #ifdef CONFIG_ETHERNET static esp_err_t system_event_eth_start_handle_default(system_event_t *event); @@ -68,27 +66,25 @@ static esp_err_t system_event_eth_disconnected_handle_default(system_event_t *ev Any entry in this table which is disabled by config will have a NULL handler. */ -static const system_event_handler_t default_event_handlers[SYSTEM_EVENT_MAX] = { -#ifdef CONFIG_WIFI_ENABLED +static system_event_handler_t default_event_handlers[SYSTEM_EVENT_MAX] = { [SYSTEM_EVENT_WIFI_READY] = NULL, [SYSTEM_EVENT_SCAN_DONE] = NULL, - [SYSTEM_EVENT_STA_START] = system_event_sta_start_handle_default, - [SYSTEM_EVENT_STA_STOP] = system_event_sta_stop_handle_default, - [SYSTEM_EVENT_STA_CONNECTED] = system_event_sta_connected_handle_default, - [SYSTEM_EVENT_STA_DISCONNECTED] = system_event_sta_disconnected_handle_default, + [SYSTEM_EVENT_STA_START] = NULL, + [SYSTEM_EVENT_STA_STOP] = NULL, + [SYSTEM_EVENT_STA_CONNECTED] = NULL, + [SYSTEM_EVENT_STA_DISCONNECTED] = NULL, [SYSTEM_EVENT_STA_AUTHMODE_CHANGE] = NULL, - [SYSTEM_EVENT_STA_GOT_IP] = system_event_sta_got_ip_default, + [SYSTEM_EVENT_STA_GOT_IP] = NULL, [SYSTEM_EVENT_STA_WPS_ER_SUCCESS] = NULL, [SYSTEM_EVENT_STA_WPS_ER_FAILED] = NULL, [SYSTEM_EVENT_STA_WPS_ER_TIMEOUT] = NULL, [SYSTEM_EVENT_STA_WPS_ER_PIN] = NULL, - [SYSTEM_EVENT_AP_START] = system_event_ap_start_handle_default, - [SYSTEM_EVENT_AP_STOP] = system_event_ap_stop_handle_default, + [SYSTEM_EVENT_AP_START] = NULL, + [SYSTEM_EVENT_AP_STOP] = NULL, [SYSTEM_EVENT_AP_STACONNECTED] = NULL, [SYSTEM_EVENT_AP_STADISCONNECTED] = NULL, [SYSTEM_EVENT_AP_PROBEREQRECVED] = NULL, [SYSTEM_EVENT_AP_STA_GOT_IP6] = NULL, -#endif #ifdef CONFIG_ETHERNET [SYSTEM_EVENT_ETH_START] = system_event_eth_start_handle_default, [SYSTEM_EVENT_ETH_STOP] = system_event_eth_stop_handle_default, @@ -156,7 +152,6 @@ esp_err_t system_event_eth_disconnected_handle_default(system_event_t *event) } #endif -#ifdef CONFIG_WIFI_ENABLED static esp_err_t system_event_sta_got_ip_default(system_event_t *event) { WIFI_API_CALL_CHECK("esp_wifi_internal_set_sta_ip", esp_wifi_internal_set_sta_ip(), ESP_OK); @@ -250,7 +245,6 @@ esp_err_t system_event_sta_disconnected_handle_default(system_event_t *event) WIFI_API_CALL_CHECK("esp_wifi_internal_reg_rxcb", esp_wifi_internal_reg_rxcb(ESP_IF_WIFI_STA, NULL), ESP_OK); return ESP_OK; } -#endif static esp_err_t esp_system_event_debug(system_event_t *event) { @@ -411,5 +405,13 @@ esp_err_t esp_event_process_default(system_event_t *event) esp_err_t esp_wifi_init(wifi_init_config_t *config) { + default_event_handlers[SYSTEM_EVENT_STA_START] = system_event_sta_start_handle_default; + default_event_handlers[SYSTEM_EVENT_STA_STOP] = system_event_sta_stop_handle_default; + default_event_handlers[SYSTEM_EVENT_STA_CONNECTED] = system_event_sta_connected_handle_default; + default_event_handlers[SYSTEM_EVENT_STA_DISCONNECTED] = system_event_sta_disconnected_handle_default; + default_event_handlers[SYSTEM_EVENT_STA_GOT_IP] = system_event_sta_got_ip_default; + default_event_handlers[SYSTEM_EVENT_AP_START] = system_event_ap_start_handle_default; + default_event_handlers[SYSTEM_EVENT_AP_STOP] = system_event_ap_stop_handle_default; + return esp_wifi_init_internal(config); } From 159e7e81b45eb4afdbdfa939053df6415eb1903a Mon Sep 17 00:00:00 2001 From: Kedar Sovani Date: Mon, 7 Aug 2017 16:00:46 +0530 Subject: [PATCH 4/8] esp32: Make 'restart' function independent of Wi-Fi Restart being a lower-layer system-level function, needn't depend on the higher level Wi-Fi libraries. This also enables us to get rid of one more WIFI_ENABLED ifdef check --- components/esp32/event_default_handlers.c | 2 ++ components/esp32/include/esp_system.h | 9 +++++++ components/esp32/system_api.c | 30 ++++++++++++++--------- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/components/esp32/event_default_handlers.c b/components/esp32/event_default_handlers.c index fa32d2cbc..34a0ddcb4 100644 --- a/components/esp32/event_default_handlers.c +++ b/components/esp32/event_default_handlers.c @@ -23,6 +23,7 @@ #include "esp_event_loop.h" #include "esp_task.h" #include "esp_eth.h" +#include "esp_system.h" #include "rom/ets_sys.h" @@ -413,5 +414,6 @@ esp_err_t esp_wifi_init(wifi_init_config_t *config) default_event_handlers[SYSTEM_EVENT_AP_START] = system_event_ap_start_handle_default; default_event_handlers[SYSTEM_EVENT_AP_STOP] = system_event_ap_stop_handle_default; + esp_register_shutdown_handler((shutdown_handler_t)esp_wifi_stop); return esp_wifi_init_internal(config); } diff --git a/components/esp32/include/esp_system.h b/components/esp32/include/esp_system.h index 3921dfb8d..c2064fd49 100644 --- a/components/esp32/include/esp_system.h +++ b/components/esp32/include/esp_system.h @@ -49,6 +49,15 @@ void system_init(void) __attribute__ ((deprecated)); */ void system_restore(void) __attribute__ ((deprecated)); +typedef void (*shutdown_handler_t)(void); +/** + * @brief Register shutdown handler + * + * This function allows you to register a handler that gets invoked before a + * systematic shutdown of the chip. + */ +esp_err_t esp_register_shutdown_handler(shutdown_handler_t handle); + /** * @brief Restart PRO and APP CPUs. * diff --git a/components/esp32/system_api.c b/components/esp32/system_api.c index 1b541f1cb..145b0532a 100644 --- a/components/esp32/system_api.c +++ b/components/esp32/system_api.c @@ -39,6 +39,9 @@ static const char* TAG = "system_api"; static uint8_t base_mac_addr[6] = { 0 }; +#define SHUTDOWN_HANDLERS_NO 2 +static shutdown_handler_t shutdown_handlers[SHUTDOWN_HANDLERS_NO]; + void system_init() { } @@ -227,23 +230,28 @@ esp_err_t esp_read_mac(uint8_t* mac, esp_mac_type_t type) return ESP_OK; } -void esp_restart_noos() __attribute__ ((noreturn)); - -/* Dummy function to be used instead of esp_wifi_stop if WiFi stack is not - * linked in (even though CONFIG_WIFI_ENABLED is set). - */ -esp_err_t wifi_stop_noop() +esp_err_t esp_register_shutdown_handler(shutdown_handler_t handler) { - return ESP_OK; + int i; + for (i = 0; i < SHUTDOWN_HANDLERS_NO; i++) { + if (shutdown_handlers[i] == NULL) { + shutdown_handlers[i] = handler; + return ESP_OK; + } + } + return ESP_FAIL; } -esp_err_t esp_wifi_stop(void) __attribute((weak, alias("wifi_stop_noop"))); +void esp_restart_noos() __attribute__ ((noreturn)); void IRAM_ATTR esp_restart(void) { -#ifdef CONFIG_WIFI_ENABLED - esp_wifi_stop(); -#endif + int i; + for (i = 0; i < SHUTDOWN_HANDLERS_NO; i++) { + if (shutdown_handlers[i]) { + shutdown_handlers[i](); + } + } // Disable scheduler on this core. vTaskSuspendAll(); From a24130b390e4f4e53e38f21402021d12526deba1 Mon Sep 17 00:00:00 2001 From: Kedar Sovani Date: Tue, 8 Aug 2017 10:18:14 +0530 Subject: [PATCH 5/8] tcpip_adapter: Decompose tcpip_adapter_start() into interface specification options Since only the used interface's start function gets called, it pulls in only the functions that are required in the current application, thereby saving footprint. --- components/esp32/event_default_handlers.c | 6 +-- .../tcpip_adapter/include/tcpip_adapter.h | 39 +++++++++++++++---- components/tcpip_adapter/tcpip_adapter_lwip.c | 39 ++++++++++++------- 3 files changed, 59 insertions(+), 25 deletions(-) diff --git a/components/esp32/event_default_handlers.c b/components/esp32/event_default_handlers.c index 34a0ddcb4..d08fe43e7 100644 --- a/components/esp32/event_default_handlers.c +++ b/components/esp32/event_default_handlers.c @@ -103,7 +103,7 @@ esp_err_t system_event_eth_start_handle_default(system_event_t *event) esp_eth_get_mac(eth_mac); tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, ð_ip); - tcpip_adapter_start(TCPIP_ADAPTER_IF_ETH, eth_mac, ð_ip); + tcpip_adapter_eth_start(eth_mac, ð_ip); return ESP_OK; } @@ -174,7 +174,7 @@ esp_err_t system_event_ap_start_handle_default(system_event_t *event) WIFI_API_CALL_CHECK("esp_wifi_mac_get", esp_wifi_get_mac(ESP_IF_WIFI_AP, ap_mac), ESP_OK); tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_AP, &ap_ip); - tcpip_adapter_start(TCPIP_ADAPTER_IF_AP, ap_mac, &ap_ip); + tcpip_adapter_ap_start(ap_mac, &ap_ip); return ESP_OK; } @@ -195,7 +195,7 @@ esp_err_t system_event_sta_start_handle_default(system_event_t *event) WIFI_API_CALL_CHECK("esp_wifi_mac_get", esp_wifi_get_mac(ESP_IF_WIFI_STA, sta_mac), ESP_OK); tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &sta_ip); - tcpip_adapter_start(TCPIP_ADAPTER_IF_STA, sta_mac, &sta_ip); + tcpip_adapter_sta_start(sta_mac, &sta_ip); return ESP_OK; } diff --git a/components/tcpip_adapter/include/tcpip_adapter.h b/components/tcpip_adapter/include/tcpip_adapter.h index f1a0a9e2f..6d99b4a81 100644 --- a/components/tcpip_adapter/include/tcpip_adapter.h +++ b/components/tcpip_adapter/include/tcpip_adapter.h @@ -177,13 +177,8 @@ typedef struct tcpip_adapter_api_msg_s { void tcpip_adapter_init(void); /** - * @brief Start an interface with specific MAC and IP + * @brief Start the ethernet interface with specific MAC and IP * - * softAP or station interface will be initialized, connect WiFi stack with TCPIP stack. - * - * For softAP interface, DHCP server will be started automatically. - * - * @param[in] tcpip_if: the interface which we will start * @param[in] mac: set MAC address of this interface * @param[in] ip_info: set IP address of this interface * @@ -191,7 +186,37 @@ void tcpip_adapter_init(void); * ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS * ESP_ERR_NO_MEM */ -esp_err_t tcpip_adapter_start(tcpip_adapter_if_t tcpip_if, uint8_t *mac, tcpip_adapter_ip_info_t *ip_info); +esp_err_t tcpip_adapter_eth_start(uint8_t *mac, tcpip_adapter_ip_info_t *ip_info); + +/** + * @brief Start the Wi-Fi station interface with specific MAC and IP + * + * Station interface will be initialized, connect WiFi stack with TCPIP stack. + * + * @param[in] mac: set MAC address of this interface + * @param[in] ip_info: set IP address of this interface + * + * @return ESP_OK + * ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS + * ESP_ERR_NO_MEM + */ +esp_err_t tcpip_adapter_sta_start(uint8_t *mac, tcpip_adapter_ip_info_t *ip_info); + +/** + * @brief Start the Wi-Fi AP interface with specific MAC and IP + * + * softAP interface will be initialized, connect WiFi stack with TCPIP stack. + * + * DHCP server will be started automatically. + * + * @param[in] mac: set MAC address of this interface + * @param[in] ip_info: set IP address of this interface + * + * @return ESP_OK + * ESP_ERR_TCPIP_ADAPTER_INVALID_PARAMS + * ESP_ERR_NO_MEM + */ +esp_err_t tcpip_adapter_ap_start(uint8_t *mac, tcpip_adapter_ip_info_t *ip_info); /** * @brief Stop an interface diff --git a/components/tcpip_adapter/tcpip_adapter_lwip.c b/components/tcpip_adapter/tcpip_adapter_lwip.c index 37be2bd44..372c6d3ee 100644 --- a/components/tcpip_adapter/tcpip_adapter_lwip.c +++ b/components/tcpip_adapter/tcpip_adapter_lwip.c @@ -40,6 +40,7 @@ static struct netif *esp_netif[TCPIP_ADAPTER_IF_MAX]; static tcpip_adapter_ip_info_t esp_ip[TCPIP_ADAPTER_IF_MAX]; static tcpip_adapter_ip6_info_t esp_ip6[TCPIP_ADAPTER_IF_MAX]; +static netif_init_fn esp_netif_init_fn[TCPIP_ADAPTER_IF_MAX]; static tcpip_adapter_dhcp_status_t dhcps_status = TCPIP_ADAPTER_DHCP_INIT; static tcpip_adapter_dhcp_status_t dhcpc_status[TCPIP_ADAPTER_IF_MAX] = {TCPIP_ADAPTER_DHCP_INIT}; @@ -96,22 +97,12 @@ void tcpip_adapter_init(void) } } -static netif_init_fn tcpip_if_to_netif_init_fn(tcpip_adapter_if_t tcpip_if) +static inline netif_init_fn tcpip_if_to_netif_init_fn(tcpip_adapter_if_t tcpip_if) { - switch(tcpip_if) { -#ifdef CONFIG_WIFI_ENABLED - case TCPIP_ADAPTER_IF_AP: - return wlanif_init_ap; - case TCPIP_ADAPTER_IF_STA: - return wlanif_init_sta; -#endif -#ifdef CONFIG_ETHERNET - case TCPIP_ADAPTER_IF_ETH: - return ethernetif_init; -#endif - default: - return NULL; - } + if (tcpip_if < TCPIP_ADAPTER_IF_MAX) + return esp_netif_init_fn[tcpip_if]; + else + return NULL; } static int tcpip_adapter_ipc_check(tcpip_adapter_api_msg_t *msg) @@ -181,6 +172,24 @@ esp_err_t tcpip_adapter_start(tcpip_adapter_if_t tcpip_if, uint8_t *mac, tcpip_a return ESP_OK; } +esp_err_t tcpip_adapter_eth_start(uint8_t *mac, tcpip_adapter_ip_info_t *ip_info) +{ + esp_netif_init_fn[TCPIP_ADAPTER_IF_ETH] = ethernetif_init; + return tcpip_adapter_start(TCPIP_ADAPTER_IF_ETH, mac, ip_info); +} + +esp_err_t tcpip_adapter_sta_start(uint8_t *mac, tcpip_adapter_ip_info_t *ip_info) +{ + esp_netif_init_fn[TCPIP_ADAPTER_IF_STA] = wlanif_init_sta; + return tcpip_adapter_start(TCPIP_ADAPTER_IF_STA, mac, ip_info); +} + +esp_err_t tcpip_adapter_ap_start(uint8_t *mac, tcpip_adapter_ip_info_t *ip_info) +{ + esp_netif_init_fn[TCPIP_ADAPTER_IF_AP] = wlanif_init_ap; + return tcpip_adapter_start(TCPIP_ADAPTER_IF_AP, mac, ip_info); +} + static esp_err_t tcpip_adapter_start_api(tcpip_adapter_api_msg_t * msg) { return tcpip_adapter_start(msg->tcpip_if, msg->mac, msg->ip_info); From ba8cd58b080a5eae017eae10cea86fd0cd30ae03 Mon Sep 17 00:00:00 2001 From: Kedar Sovani Date: Tue, 8 Aug 2017 10:23:52 +0530 Subject: [PATCH 6/8] kconfig: Remove Wi-Fi on/off as a menuconfig option This is no longer required since the functions automatically get pulled in based on the usage. A quick summary of footprint comparisions before and after these set of patches is shown below: Hello-World: (simplified for readability) old Total image size:~ 104902 bytes (.bin may be padded larger) old Total image size:~ 105254 bytes (.bin may be padded larger) Per-archive contributions to ELF file: Archive File DRAM .data & .bss IRAM Flash code & rodata Total old libesp32.a 1973 177 4445 3939 2267 12801 new libesp32.a 1973 185 4473 3939 2267 12837 new libnvs_flash.a 0 92 0 274 8 374 new libstdc++.a 0 0 0 24 0 24 For some reason, nvs_flash.a (~400bytes) gets pulled in (particularly the nvs_flash_init() function). Power-Save: (simplified for readability) old Total image size:~ 421347 bytes (.bin may be padded larger) old Total image size:~ 421235 bytes (.bin may be padded larger) old libtcpip_adapter.a 0 81 0 1947 115 2143 new libtcpip_adapter.a 0 69 0 1897 115 2081 The size actually shrinks a bit, since the AP interface function doesn't get pulled in. --- components/esp32/Kconfig | 29 ++++------------------------- components/esp32/component.mk | 8 +------- components/esp32/include/esp_wifi.h | 5 +---- components/esp32/phy_init.c | 2 -- components/freertos/Kconfig | 3 +-- 5 files changed, 7 insertions(+), 40 deletions(-) diff --git a/components/esp32/Kconfig b/components/esp32/Kconfig index bf92ba159..4cdf01000 100644 --- a/components/esp32/Kconfig +++ b/components/esp32/Kconfig @@ -560,15 +560,11 @@ config ESP32_XTAL_FREQ endmenu -menuconfig WIFI_ENABLED - bool "WiFi" - default y - help - Select this option to enable WiFi stack and show the submenu with WiFi configuration choices. +menu Wi-Fi config SW_COEXIST_ENABLE bool "Software controls WiFi/Bluetooth coexistence" - depends on WIFI_ENABLED && BT_ENABLED + depends on BT_ENABLED default n help If enabled, WiFi & Bluetooth coexistence is controlled by software rather than hardware. @@ -578,7 +574,6 @@ config SW_COEXIST_ENABLE config ESP32_WIFI_STATIC_RX_BUFFER_NUM int "Max number of WiFi static RX buffers" - depends on WIFI_ENABLED range 2 25 default 10 help @@ -590,7 +585,6 @@ config ESP32_WIFI_STATIC_RX_BUFFER_NUM config ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM int "Max number of WiFi dynamic RX buffers" - depends on WIFI_ENABLED range 0 128 default 32 help @@ -606,7 +600,6 @@ config ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM choice ESP32_WIFI_TX_BUFFER prompt "Type of WiFi TX buffers" - depends on WIFI_ENABLED default ESP32_WIFI_DYNAMIC_TX_BUFFER help Select type of WiFi tx buffers and show the submenu with the number of WiFi tx buffers choice. @@ -626,13 +619,11 @@ endchoice config ESP32_WIFI_TX_BUFFER_TYPE int - depends on WIFI_ENABLED default 0 if ESP32_WIFI_STATIC_TX_BUFFER default 1 if ESP32_WIFI_DYNAMIC_TX_BUFFER config ESP32_WIFI_STATIC_TX_BUFFER_NUM int "Max number of WiFi static TX buffers" - depends on WIFI_ENABLED depends on ESP32_WIFI_STATIC_TX_BUFFER range 16 64 default 32 @@ -646,7 +637,6 @@ config ESP32_WIFI_STATIC_TX_BUFFER_NUM config ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM int "Max number of WiFi dynamic TX buffers" - depends on WIFI_ENABLED depends on ESP32_WIFI_DYNAMIC_TX_BUFFER range 16 64 default 32 @@ -659,7 +649,6 @@ config ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM config ESP32_WIFI_AMPDU_ENABLED bool "WiFi AMPDU" - depends on WIFI_ENABLED default y help Select this option to enable AMPDU feature @@ -689,21 +678,14 @@ config ESP32_WIFI_RX_BA_WIN config ESP32_WIFI_NVS_ENABLED bool "WiFi NVS flash" - depends on WIFI_ENABLED default y help Select this option to enable WiFi NVS flash -config PHY_ENABLED - bool - default y if WIFI_ENABLED || BT_ENABLED - menu PHY - visible if PHY_ENABLED config ESP32_PHY_CALIBRATION_AND_DATA_STORAGE bool "Do phy calibration and store calibration data in NVS" - depends on PHY_ENABLED default y help If this option is enabled, NVS will be initialized and calibration data will be loaded from there. @@ -714,7 +696,6 @@ config ESP32_PHY_CALIBRATION_AND_DATA_STORAGE config ESP32_PHY_INIT_DATA_IN_PARTITION bool "Use a partition to store PHY init data" - depends on PHY_ENABLED default n help If enabled, PHY init data will be loaded from a partition. @@ -733,15 +714,13 @@ config ESP32_PHY_MAX_WIFI_TX_POWER int "Max WiFi TX power (dBm)" range 0 20 default 20 - depends on PHY_ENABLED && WIFI_ENABLED help Set maximum transmit power for WiFi radio. Actual transmit power for high data rates may be lower than this setting. config ESP32_PHY_MAX_TX_POWER int - depends on PHY_ENABLED - default 20 if !WIFI_ENABLED - default ESP32_PHY_MAX_WIFI_TX_POWER if WIFI_ENABLED + default ESP32_PHY_MAX_WIFI_TX_POWER endmenu +endmenu \ No newline at end of file diff --git a/components/esp32/component.mk b/components/esp32/component.mk index 8a06c9cd6..ee8e5c579 100644 --- a/components/esp32/component.mk +++ b/components/esp32/component.mk @@ -7,13 +7,7 @@ CFLAGS += -DBOOTLOADER_BUILD #endif COMPONENT_SRCDIRS := . hwcrypto -LIBS := core rtc -ifdef CONFIG_PHY_ENABLED # BT || WIFI -LIBS += phy coexist -endif -ifdef CONFIG_WIFI_ENABLED -LIBS += net80211 pp wpa smartconfig coexist wps wpa2 -endif +LIBS := core rtc net80211 pp wpa smartconfig coexist wps wpa2 phy coexist LINKER_SCRIPTS += esp32.common.ld esp32.rom.ld esp32.peripherals.ld diff --git a/components/esp32/include/esp_wifi.h b/components/esp32/include/esp_wifi.h index b6450c7fa..58b1146e1 100755 --- a/components/esp32/include/esp_wifi.h +++ b/components/esp32/include/esp_wifi.h @@ -144,7 +144,7 @@ typedef struct { extern const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs; #define WIFI_INIT_CONFIG_MAGIC 0x1F2F3F4F -#ifdef CONFIG_WIFI_ENABLED + #define WIFI_INIT_CONFIG_DEFAULT() { \ .event_handler = &esp_event_send, \ .wpa_crypto_funcs = g_wifi_default_wpa_crypto_funcs, \ @@ -160,9 +160,6 @@ extern const wpa_crypto_funcs_t g_wifi_default_wpa_crypto_funcs; .rx_ba_win = CONFIG_ESP32_WIFI_RX_BA_WIN,\ .magic = WIFI_INIT_CONFIG_MAGIC\ }; -#else -#define WIFI_INIT_CONFIG_DEFAULT() {0}; _Static_assert(0, "please enable wifi in menuconfig to use esp_wifi.h"); -#endif /** * @brief Init WiFi diff --git a/components/esp32/phy_init.c b/components/esp32/phy_init.c index 5a007ce5d..f92f58abe 100644 --- a/components/esp32/phy_init.c +++ b/components/esp32/phy_init.c @@ -32,7 +32,6 @@ #include "nvs_flash.h" #include "sdkconfig.h" -#ifdef CONFIG_PHY_ENABLED #include "phy.h" #include "phy_init_data.h" #include "esp_coexist.h" @@ -298,4 +297,3 @@ void esp_phy_load_cal_and_init(void) free(cal_data); // PHY maintains a copy of calibration data, so we can free this } -#endif // CONFIG_PHY_ENABLED diff --git a/components/freertos/Kconfig b/components/freertos/Kconfig index 8ff5000d6..d2f6ca8f7 100644 --- a/components/freertos/Kconfig +++ b/components/freertos/Kconfig @@ -96,8 +96,7 @@ config FREERTOS_WATCHPOINT_END_OF_STACK config FREERTOS_THREAD_LOCAL_STORAGE_POINTERS int "Number of thread local storage pointers" - range 0 256 if !(WIFI_ENABLED || ETHERNET) - range 1 256 if WIFI_ENABLED || ETHERNET + range 1 256 default 1 help FreeRTOS has the ability to store per-thread pointers in the task From 6405d6f874689fb6285c76dea5a98f3667eb0aaa Mon Sep 17 00:00:00 2001 From: Kedar Sovani Date: Thu, 10 Aug 2017 10:46:36 +0530 Subject: [PATCH 7/8] kconfig: Add an option for skipping binary blobs --- components/esp32/Kconfig | 8 ++++++++ components/esp32/component.mk | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/components/esp32/Kconfig b/components/esp32/Kconfig index 4cdf01000..c5d410f76 100644 --- a/components/esp32/Kconfig +++ b/components/esp32/Kconfig @@ -560,6 +560,14 @@ config ESP32_XTAL_FREQ endmenu +config NO_BLOBS + bool "No Binary Blobs" + depends on !BT_ENABLED + default n + help + If enabled, this disables the linking of binary libraries in the application build. Note + that after enabling this Wi-Fi/Bluetooth will not work. + menu Wi-Fi config SW_COEXIST_ENABLE diff --git a/components/esp32/component.mk b/components/esp32/component.mk index ee8e5c579..32876da0e 100644 --- a/components/esp32/component.mk +++ b/components/esp32/component.mk @@ -7,7 +7,9 @@ CFLAGS += -DBOOTLOADER_BUILD #endif COMPONENT_SRCDIRS := . hwcrypto -LIBS := core rtc net80211 pp wpa smartconfig coexist wps wpa2 phy coexist +ifndef CONFIG_NO_BLOBS +LIBS := core rtc net80211 pp wpa smartconfig coexist wps wpa2 phy +endif LINKER_SCRIPTS += esp32.common.ld esp32.rom.ld esp32.peripherals.ld From 63c738de4c04790cccd5752cd2807bd332366da3 Mon Sep 17 00:00:00 2001 From: Kedar Sovani Date: Tue, 15 Aug 2017 14:47:53 +0530 Subject: [PATCH 8/8] sdkconfig: Remove rest of the references to WIFI_ENABLED --- examples/bluetooth/gatt_client/sdkconfig.defaults | 3 +-- examples/bluetooth/gatt_security_server/sdkconfig.defaults | 3 +-- examples/bluetooth/gatt_server/sdkconfig.defaults | 3 +-- examples/ethernet/ethernet/sdkconfig.defaults | 1 - examples/get-started/blink/sdkconfig.defaults | 4 ++-- tools/unit-test-app/sdkconfig | 1 - 6 files changed, 5 insertions(+), 10 deletions(-) diff --git a/examples/bluetooth/gatt_client/sdkconfig.defaults b/examples/bluetooth/gatt_client/sdkconfig.defaults index 9d51df5ee..14f5546ff 100644 --- a/examples/bluetooth/gatt_client/sdkconfig.defaults +++ b/examples/bluetooth/gatt_client/sdkconfig.defaults @@ -1,4 +1,3 @@ # Override some defaults so BT stack is enabled -# and WiFi disabled by default in this example +# by default in this example CONFIG_BT_ENABLED=y -CONFIG_WIFI_ENABLED=n diff --git a/examples/bluetooth/gatt_security_server/sdkconfig.defaults b/examples/bluetooth/gatt_security_server/sdkconfig.defaults index 9d51df5ee..14f5546ff 100644 --- a/examples/bluetooth/gatt_security_server/sdkconfig.defaults +++ b/examples/bluetooth/gatt_security_server/sdkconfig.defaults @@ -1,4 +1,3 @@ # Override some defaults so BT stack is enabled -# and WiFi disabled by default in this example +# by default in this example CONFIG_BT_ENABLED=y -CONFIG_WIFI_ENABLED=n diff --git a/examples/bluetooth/gatt_server/sdkconfig.defaults b/examples/bluetooth/gatt_server/sdkconfig.defaults index 9d51df5ee..14f5546ff 100644 --- a/examples/bluetooth/gatt_server/sdkconfig.defaults +++ b/examples/bluetooth/gatt_server/sdkconfig.defaults @@ -1,4 +1,3 @@ # Override some defaults so BT stack is enabled -# and WiFi disabled by default in this example +# by default in this example CONFIG_BT_ENABLED=y -CONFIG_WIFI_ENABLED=n diff --git a/examples/ethernet/ethernet/sdkconfig.defaults b/examples/ethernet/ethernet/sdkconfig.defaults index b4f4c3c1c..62a7778f1 100644 --- a/examples/ethernet/ethernet/sdkconfig.defaults +++ b/examples/ethernet/ethernet/sdkconfig.defaults @@ -1,2 +1 @@ -# CONFIG_WIFI_ENABLED is not set CONFIG_ETHERNET=y diff --git a/examples/get-started/blink/sdkconfig.defaults b/examples/get-started/blink/sdkconfig.defaults index 8c618fb9b..8fa2136f6 100644 --- a/examples/get-started/blink/sdkconfig.defaults +++ b/examples/get-started/blink/sdkconfig.defaults @@ -1,2 +1,2 @@ -# Disable WiFi stack by default -CONFIG_WIFI_ENABLED=n +# + diff --git a/tools/unit-test-app/sdkconfig b/tools/unit-test-app/sdkconfig index 43ffa272b..9aa13bc2a 100644 --- a/tools/unit-test-app/sdkconfig +++ b/tools/unit-test-app/sdkconfig @@ -174,7 +174,6 @@ CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY=0 # CONFIG_ESP32_XTAL_FREQ_26 is not set CONFIG_ESP32_XTAL_FREQ_AUTO=y CONFIG_ESP32_XTAL_FREQ=0 -CONFIG_WIFI_ENABLED=y CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=0 # CONFIG_ESP32_WIFI_STATIC_TX_BUFFER is not set