From eecd5efec5f08f192cb51ccbd298bd061bb8baab Mon Sep 17 00:00:00 2001 From: xiehang Date: Thu, 12 Dec 2019 15:04:02 +0800 Subject: [PATCH] esp_wifi: Put some rx code to iram --- components/esp32/CMakeLists.txt | 7 +++++++ components/esp32/Kconfig | 9 +++++++++ components/esp32/component.mk | 7 +++++++ components/esp32/ld/esp32.common.ld | 2 ++ components/esp32/ld/wifi_rx_iram_noopt/wifi_rx_iram.ld | 2 ++ components/esp32/ld/wifi_rx_iram_opt/wifi_rx_iram.ld | 4 ++++ components/esp32/lib | 2 +- tools/unit-test-app/configs/psram | 1 + tools/unit-test-app/configs/psram_2 | 1 + 9 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 components/esp32/ld/wifi_rx_iram_noopt/wifi_rx_iram.ld create mode 100644 components/esp32/ld/wifi_rx_iram_opt/wifi_rx_iram.ld diff --git a/components/esp32/CMakeLists.txt b/components/esp32/CMakeLists.txt index 4e70777cf..571aec972 100644 --- a/components/esp32/CMakeLists.txt +++ b/components/esp32/CMakeLists.txt @@ -80,6 +80,13 @@ else() target_link_libraries(esp32 "-L ${CMAKE_CURRENT_SOURCE_DIR}/ld/wifi_iram_noopt") endif() + # Add a different linker search path depending on WiFi RX optimisations + if (CONFIG_ESP32_WIFI_RX_IRAM_OPT) + target_link_libraries(esp32 "-L ${CMAKE_CURRENT_SOURCE_DIR}/ld/wifi_rx_iram_opt") + else() + target_link_libraries(esp32 "-L ${CMAKE_CURRENT_SOURCE_DIR}/ld/wifi_rx_iram_noopt") + endif() + if(NOT CONFIG_NO_BLOBS) target_link_libraries(esp32 coexist core espnow mesh net80211 phy pp rtc smartconfig wpa2 wpa wps) endif() diff --git a/components/esp32/Kconfig b/components/esp32/Kconfig index 197a34a72..5a93a4ae2 100644 --- a/components/esp32/Kconfig +++ b/components/esp32/Kconfig @@ -1282,11 +1282,20 @@ config ESP32_WIFI_SOFTAP_BEACON_MAX_LEN config ESP32_WIFI_IRAM_OPT bool "WiFi IRAM speed optimization" + default n if (BT_ENABLED && SPIRAM_SUPPORT) default y help Select this option to place frequently called Wi-Fi library functions in IRAM. When this option is disabled, more than 10Kbytes of IRAM memory will be saved but Wi-Fi throughput will be reduced. +config ESP32_WIFI_RX_IRAM_OPT + bool "WiFi RX IRAM speed optimization" + default n if (BT_ENABLED && SPIRAM_SUPPORT) + default y + help + Select this option to place frequently called Wi-Fi library RX functions in IRAM.When this option is disabled, + more than 17Kbytes of IRAM memory will be saved but Wi-Fi performance will be reduced. + config ESP32_WIFI_MGMT_SBUF_NUM int "WiFi mgmt short buffer number" range 6 32 diff --git a/components/esp32/component.mk b/components/esp32/component.mk index 74c2466bc..c88de4f47 100644 --- a/components/esp32/component.mk +++ b/components/esp32/component.mk @@ -25,6 +25,13 @@ else COMPONENT_ADD_LDFLAGS += -L $(COMPONENT_PATH)/ld/wifi_iram_noopt endif +# Add a different linker search path depending on WiFi RX optimisations +ifdef CONFIG_ESP32_WIFI_RX_IRAM_OPT +COMPONENT_ADD_LDFLAGS += -L $(COMPONENT_PATH)/ld/wifi_rx_iram_opt +else +COMPONENT_ADD_LDFLAGS += -L $(COMPONENT_PATH)/ld/wifi_rx_iram_noopt +endif + #Force pure functions from libgcc.a to be linked from ROM LINKER_SCRIPTS += esp32.rom.libgcc.ld diff --git a/components/esp32/ld/esp32.common.ld b/components/esp32/ld/esp32.common.ld index 179b1abdc..a4b4a3039 100644 --- a/components/esp32/ld/esp32.common.ld +++ b/components/esp32/ld/esp32.common.ld @@ -160,6 +160,7 @@ SECTIONS *libesp32.a:panic.*(.literal .text .literal.* .text.*) *libesp32.a:core_dump.*(.literal .text .literal.* .text.*) INCLUDE wifi_iram.ld + INCLUDE wifi_rx_iram.ld *libapp_trace.a:(.literal .text .literal.* .text.*) *libxtensa-debug-module.a:eri.*(.literal .text .literal.* .text.*) *librtc.a:(.literal .text .literal.* .text.*) @@ -328,6 +329,7 @@ SECTIONS *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) *(.irom0.text) /* catch stray ICACHE_RODATA_ATTR */ *(.wifi0iram .wifi0iram.*) /* catch stray WIFI_IRAM_ATTR */ + *(.wifirxiram .wifirxiram.*) /* catch stray WIFI_RX_IRAM_ATTR */ *(.fini.literal) *(.fini) *(.gnu.version) diff --git a/components/esp32/ld/wifi_rx_iram_noopt/wifi_rx_iram.ld b/components/esp32/ld/wifi_rx_iram_noopt/wifi_rx_iram.ld new file mode 100644 index 000000000..eb5ba4824 --- /dev/null +++ b/components/esp32/ld/wifi_rx_iram_noopt/wifi_rx_iram.ld @@ -0,0 +1,2 @@ +/* This snippet does nothing, if WiFi RX IRAM optimisations + are disabled. */ diff --git a/components/esp32/ld/wifi_rx_iram_opt/wifi_rx_iram.ld b/components/esp32/ld/wifi_rx_iram_opt/wifi_rx_iram.ld new file mode 100644 index 000000000..09c3fd2f3 --- /dev/null +++ b/components/esp32/ld/wifi_rx_iram_opt/wifi_rx_iram.ld @@ -0,0 +1,4 @@ +/* Link WiFi library .wifi0iram sections to IRAM + if this snippet is included */ +*libnet80211.a:( .wifirxiram .wifirxiram.*) +*libpp.a:( .wifirxiram .wifirxiram.*) diff --git a/components/esp32/lib b/components/esp32/lib index c8c149c65..2ae41bf68 160000 --- a/components/esp32/lib +++ b/components/esp32/lib @@ -1 +1 @@ -Subproject commit c8c149c65bbac86a612b0a9e5c3c584291f0d0d8 +Subproject commit 2ae41bf681e69d1ff527dcf7d2d8537095c00139 diff --git a/tools/unit-test-app/configs/psram b/tools/unit-test-app/configs/psram index 541bff574..f5f6c30d6 100644 --- a/tools/unit-test-app/configs/psram +++ b/tools/unit-test-app/configs/psram @@ -1,3 +1,4 @@ TEST_EXCLUDE_COMPONENTS=libsodium bt app_update driver esp32 spi_flash CONFIG_SPIRAM_SUPPORT=y CONFIG_SPIRAM_BANKSWITCH_ENABLE=n +CONFIG_ESP32_WIFI_RX_IRAM_OPT=n diff --git a/tools/unit-test-app/configs/psram_2 b/tools/unit-test-app/configs/psram_2 index 4173606df..ee5f14262 100644 --- a/tools/unit-test-app/configs/psram_2 +++ b/tools/unit-test-app/configs/psram_2 @@ -1,3 +1,4 @@ TEST_COMPONENTS=driver esp32 spi_flash CONFIG_SPIRAM_SUPPORT=y CONFIG_SPIRAM_BANKSWITCH_ENABLE=n +CONFIG_ESP32_WIFI_RX_IRAM_OPT=n