From 0169728ddddfec2a3c88f142fbdb86c2cb976c2c 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 + 8 files changed, 33 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 68cdd9359..c4f13bed1 100644 --- a/components/esp32/CMakeLists.txt +++ b/components/esp32/CMakeLists.txt @@ -77,6 +77,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 59c44f366..66b158cba 100644 --- a/components/esp32/Kconfig +++ b/components/esp32/Kconfig @@ -1098,11 +1098,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 7beae4250..93528a2b1 100644 --- a/components/esp32/component.mk +++ b/components/esp32/component.mk @@ -20,6 +20,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 6700efeff..2fac1cd64 100644 --- a/components/esp32/ld/esp32.common.ld +++ b/components/esp32/ld/esp32.common.ld @@ -102,6 +102,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.*) @@ -240,6 +241,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 deea532dc..f5b9bcb0d 160000 --- a/components/esp32/lib +++ b/components/esp32/lib @@ -1 +1 @@ -Subproject commit deea532dc8e532f30154193df7ac4087f7d4ab55 +Subproject commit f5b9bcb0d0f9b3052e4aeb6407916b97dbe7be4e diff --git a/tools/unit-test-app/configs/psram b/tools/unit-test-app/configs/psram index dc74b5a2d..a46eaf423 100644 --- a/tools/unit-test-app/configs/psram +++ b/tools/unit-test-app/configs/psram @@ -1,2 +1,3 @@ EXCLUDE_COMPONENTS=libsodium bt CONFIG_SPIRAM_SUPPORT=y +CONFIG_ESP32_WIFI_RX_IRAM_OPT=n