From 97e3c0fec4f21bf932fb4ab47a15302c603ac860 Mon Sep 17 00:00:00 2001 From: Tian Hao Date: Wed, 18 Jan 2017 20:05:26 +0800 Subject: [PATCH 1/4] kconfig: move PHY-related settings into new menu - PHY options must be shown when either WIFI or BT is enabled. - Add clarification that TX power option applies to WiFi only. --- components/esp32/Kconfig | 42 +++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/components/esp32/Kconfig b/components/esp32/Kconfig index 8bbd6d032e..5db28b6bea 100644 --- a/components/esp32/Kconfig +++ b/components/esp32/Kconfig @@ -1,4 +1,4 @@ -menu "ESP32-specific config" +menu "ESP32-specific" choice ESP32_DEFAULT_CPU_FREQ_MHZ prompt "CPU frequency" @@ -490,9 +490,27 @@ config SW_COEXIST_ENABLE Recommended for heavy traffic scenarios. Both coexistence configuration options are automatically managed, no user intervention is required. + +config ESP32_WIFI_RX_BUFFER_NUM + int "Max number of WiFi RX buffers" + depends on WIFI_ENABLED + range 2 25 + default 25 + help + Set the number of WiFi rx buffers. Each buffer takes approximately 1.6KB of RAM. + Larger number for higher throughput but more memory. Smaller number for lower + throughput but less memory. + +config PHY_ENABLED + bool + default y if WIFI_ENABLED || BT_ENABLED + +menu PHY + visible if PHY_ENABLED + config ESP32_PHY_AUTO_INIT bool "Initialize PHY in startup code" - depends on WIFI_ENABLED + depends on PHY_ENABLED default y help If enabled, PHY will be initialized in startup code, before @@ -507,7 +525,7 @@ config ESP32_PHY_AUTO_INIT config ESP32_PHY_INIT_DATA_IN_PARTITION bool "Use a partition to store PHY init data" - depends on WIFI_ENABLED + depends on PHY_ENABLED default n help If enabled, PHY init data will be loaded from a partition. @@ -523,20 +541,12 @@ config ESP32_PHY_INIT_DATA_IN_PARTITION If unsure, choose 'n'. config ESP32_PHY_MAX_TX_POWER - int "Max TX power (dBm)" + int "Max WiFi TX power (dBm)" range 0 20 default 20 - depends on WIFI_ENABLED + depends on PHY_ENABLED && WIFI_ENABLED help - Set maximum transmit power. Actual transmit power for high + Set maximum transmit power for WiFi radio. Actual transmit power for high data rates may be lower than this setting. - -config ESP32_WIFI_RX_BUFFER_NUM - int "Max number of WiFi RX buffers" - depends on WIFI_ENABLED - range 2 25 - default 25 - help - Set the number of WiFi rx buffers. Each buffer takes approximately 1.6KB of RAM. - Larger number for higher throughput but more memory. Smaller number for lower - throughput but less memory. + +endmenu From efbd2805e296a02929c299bc9091a2daae60592b Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 19 Jan 2017 00:32:10 +0800 Subject: [PATCH 2/4] ethernet: improve kconfig option descriptions Also limit suggested EMAC task priority range to 22, as the top priority should be used only by IPC tasks. --- components/ethernet/Kconfig | 41 ++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/components/ethernet/Kconfig b/components/ethernet/Kconfig index 0ea94eaafd..663871f2a0 100644 --- a/components/ethernet/Kconfig +++ b/components/ethernet/Kconfig @@ -5,30 +5,47 @@ menuconfig ETHERNET Select this option to enable ethernet driver and show the submenu with ethernet features. config DMA_RX_BUF_NUM - int "DMA Rx Buf Num" - default 10 - depends on ETHERNET - help - Dma rx buf num ,can not be 0 . - -config DMA_TX_BUF_NUM - int "DMA Tx Buf Num" + int "Number of DMA RX buffers" + range 1 10 default 10 depends on ETHERNET help - Dma tx Buf num ,can not be 0. + Number of DMA receive buffers. Each buffer is 1600 bytes. + Buffers are allocated statically. + Larger number of buffers increases throughput. + +config DMA_TX_BUF_NUM + int "Number of DMA RX buffers" + range 1 10 + default 10 + depends on ETHERNET + help + Number of DMA transmit buffers. Each buffer is 1600 bytes. + Buffers are allocated statically. + Larger number of buffers increases throughput. config EMAC_L2_TO_L3_RX_BUF_MODE - bool "L2 To L3 RX BUF COPY MODE" + bool "Enable copy between Layer2 and Layer3" default n depends on ETHERNET help - Receive Buf user copy mode or pointer mode. + If this options is selected, a copy of each received buffer will be created when + passing it from the Ethernet MAC (L2) to the IP stack (L3). Otherwise, IP stack + will receive pointers to the DMA buffers used by Ethernet MAC. + + When Ethernet MAC doesn't have any unused buffers left, it will drop incomming + packets (flow control may help with this problem, to some extent). + + The buffers for the IP stack are allocated from the heap, so the total number of + receive buffers is limited by the available heap size, if this option is selected. + + If unsure, choose n. config EMAC_TASK_PRIORITY int "EMAC_TASK_PRIORITY" default 20 + range 3 22 depends on ETHERNET help - Emac task priority ,suggest 3 ~ 23. + Ethernet MAC task priority. From 9a8a82e857920ba57811795f15aba3c55b1a4380 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 19 Jan 2017 11:18:44 +1100 Subject: [PATCH 3/4] phyinit: Use PHY config to enable, don't need phy_get_romfunc_addr to init --- components/esp32/component.mk | 8 +++----- components/esp32/cpu_freq.c | 2 -- components/esp32/phy.h | 3 +-- components/esp32/phy_init.c | 7 +++---- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/components/esp32/component.mk b/components/esp32/component.mk index e1cd2c6524..a8109a0f5e 100644 --- a/components/esp32/component.mk +++ b/components/esp32/component.mk @@ -3,16 +3,14 @@ # COMPONENT_SRCDIRS := . hwcrypto -LIBS := core rtc phy -ifdef CONFIG_BT_ENABLED -LIBS += coexist +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 := $(sort $(LIBS)) # de-duplicate, we can handle different orders here - LINKER_SCRIPTS += esp32.common.ld esp32.rom.ld esp32.peripherals.ld ifeq ("$(CONFIG_NEWLIB_NANO_FORMAT)","y") diff --git a/components/esp32/cpu_freq.c b/components/esp32/cpu_freq.c index 7618f147af..f5ccd13df7 100644 --- a/components/esp32/cpu_freq.c +++ b/components/esp32/cpu_freq.c @@ -17,7 +17,6 @@ #include "rom/ets_sys.h" #include "rom/uart.h" #include "sdkconfig.h" -#include "phy.h" #include "rtc.h" #include "soc/soc.h" #include "soc/rtc_cntl_reg.h" @@ -32,7 +31,6 @@ void esp_set_cpu_freq(void) { uint32_t freq_mhz = CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ; - phy_get_romfunc_addr(); // freq will be changed to 40MHz in rtc_init_lite, // wait uart tx finish, otherwise some uart output will be lost diff --git a/components/esp32/phy.h b/components/esp32/phy.h index 81990f2e36..c0affb36ef 100644 --- a/components/esp32/phy.h +++ b/components/esp32/phy.h @@ -25,8 +25,7 @@ extern "C" { */ /** - * @brief Initialize function pointer table in PHY library. - * @note This function should be called before register_chipv7_phy. + * @brief Return ROM function pointer table from PHY library. */ void phy_get_romfunc_addr(void); diff --git a/components/esp32/phy_init.c b/components/esp32/phy_init.c index 07a455d501..5b130eaf7a 100644 --- a/components/esp32/phy_init.c +++ b/components/esp32/phy_init.c @@ -27,7 +27,7 @@ #include "nvs.h" #include "sdkconfig.h" -#ifdef CONFIG_WIFI_ENABLED +#ifdef CONFIG_PHY_ENABLED #include "phy.h" #include "phy_init_data.h" @@ -39,8 +39,7 @@ esp_err_t esp_phy_init(const esp_phy_init_data_t* init_data, { assert(init_data); assert(calibration_data); - // Initialize PHY pointer table - phy_get_romfunc_addr(); + REG_SET_BIT(DPORT_CORE_RST_EN_REG, DPORT_MAC_RST); REG_CLR_BIT(DPORT_CORE_RST_EN_REG, DPORT_MAC_RST); // Enable WiFi peripheral clock @@ -221,4 +220,4 @@ static esp_err_t store_cal_data_to_nvs_handle(nvs_handle handle, return err; } -#endif // CONFIG_WIFI_ENABLED +#endif // CONFIG_PHY_ENABLED From b1df4c47f98e0b5082146543e362c8e849be9d22 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 19 Jan 2017 10:58:09 +0800 Subject: [PATCH 4/4] kconfig: define ESP32_PHY_MAX_TX_POWER if PHY_ENABLED ESP32_PHY_MAX_TX_POWER option is only meaningful for WiFi, so previous change made it depend on WIFI_ENABLED. However if WiFi is not enabled, but BT is, this option becomes undefined which breaks phy_init_data generation. This change turns ESP32_PHY_MAX_TX_POWER into a hidden parameter, which depends on PHY_ENABLED. New user-visible parameter, ESP32_PHY_MAX_WIFI_TX_POWER is introduced which depends on WIFI_ENABLED and is used as default value for ESP32_PHY_MAX_TX_POWER if WIFI_ENABLED is set. Otherwise ESP32_PHY_MAX_WIFI_TX_POWER is set to 20. --- components/esp32/Kconfig | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/components/esp32/Kconfig b/components/esp32/Kconfig index 5db28b6bea..c6e4cc7e22 100644 --- a/components/esp32/Kconfig +++ b/components/esp32/Kconfig @@ -539,8 +539,8 @@ config ESP32_PHY_INIT_DATA_IN_PARTITION into the application binary. If unsure, choose 'n'. - -config ESP32_PHY_MAX_TX_POWER + +config ESP32_PHY_MAX_WIFI_TX_POWER int "Max WiFi TX power (dBm)" range 0 20 default 20 @@ -548,5 +548,11 @@ config ESP32_PHY_MAX_TX_POWER 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 + endmenu