Merge branch 'bugfix/fix_esp32c5_coexist_hw_timer_issue' into 'master'

bugfix/fix esp32c5 coexist hw timer issue, xtal frequency issue, coexist reconnect policy issue, memory leakage issue

Closes WIFIBUG-833 and WIFIBUG-851

See merge request espressif/esp-idf!33933
This commit is contained in:
Xu Xiao
2024-10-16 11:12:37 +08:00
14 changed files with 122 additions and 49 deletions

View File

@@ -152,6 +152,11 @@ static int esp_coexist_debug_matrix_init_wrapper(int evt, int sig, bool rev)
#endif
}
static IRAM_ATTR int esp_coex_common_xtal_freq_get_wrapper(void)
{
return rtc_clk_xtal_freq_get();
}
coex_adapter_funcs_t g_coex_adapter_funcs = {
._version = COEX_ADAPTER_VERSION,
._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper,
@@ -172,5 +177,6 @@ coex_adapter_funcs_t g_coex_adapter_funcs = {
._timer_setfn = esp_coex_common_timer_setfn_wrapper,
._timer_arm_us = esp_coex_common_timer_arm_us_wrapper,
._debug_matrix_init = esp_coexist_debug_matrix_init_wrapper,
._xtal_freq_get = esp_coex_common_xtal_freq_get_wrapper,
._magic = COEX_ADAPTER_MAGIC,
};

View File

@@ -151,6 +151,11 @@ static int esp_coexist_debug_matrix_init_wrapper(int evt, int sig, bool rev)
#endif
}
static IRAM_ATTR int esp_coex_common_xtal_freq_get_wrapper(void)
{
return rtc_clk_xtal_freq_get();
}
coex_adapter_funcs_t g_coex_adapter_funcs = {
._version = COEX_ADAPTER_VERSION,
._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper,
@@ -170,5 +175,6 @@ coex_adapter_funcs_t g_coex_adapter_funcs = {
._timer_setfn = esp_coex_common_timer_setfn_wrapper,
._timer_arm_us = esp_coex_common_timer_arm_us_wrapper,
._debug_matrix_init = esp_coexist_debug_matrix_init_wrapper,
._xtal_freq_get = esp_coex_common_xtal_freq_get_wrapper,
._magic = COEX_ADAPTER_MAGIC,
};

View File

@@ -152,6 +152,11 @@ static int esp_coexist_debug_matrix_init_wrapper(int evt, int sig, bool rev)
#endif
}
static IRAM_ATTR int esp_coex_common_xtal_freq_get_wrapper(void)
{
return rtc_clk_xtal_freq_get();
}
coex_adapter_funcs_t g_coex_adapter_funcs = {
._version = COEX_ADAPTER_VERSION,
._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper,
@@ -171,5 +176,6 @@ coex_adapter_funcs_t g_coex_adapter_funcs = {
._timer_setfn = esp_coex_common_timer_setfn_wrapper,
._timer_arm_us = esp_coex_common_timer_arm_us_wrapper,
._debug_matrix_init = esp_coexist_debug_matrix_init_wrapper,
._xtal_freq_get = esp_coex_common_xtal_freq_get_wrapper,
._magic = COEX_ADAPTER_MAGIC,
};

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -152,6 +152,11 @@ static int esp_coexist_debug_matrix_init_wrapper(int evt, int sig, bool rev)
#endif
}
static IRAM_ATTR int esp_coex_common_xtal_freq_get_wrapper(void)
{
return rtc_clk_xtal_freq_get();
}
coex_adapter_funcs_t g_coex_adapter_funcs = {
._version = COEX_ADAPTER_VERSION,
._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper,
@@ -171,5 +176,6 @@ coex_adapter_funcs_t g_coex_adapter_funcs = {
._timer_setfn = esp_coex_common_timer_setfn_wrapper,
._timer_arm_us = esp_coex_common_timer_arm_us_wrapper,
._debug_matrix_init = esp_coexist_debug_matrix_init_wrapper,
._xtal_freq_get = esp_coex_common_xtal_freq_get_wrapper,
._magic = COEX_ADAPTER_MAGIC,
};

View File

@@ -144,6 +144,11 @@ static int esp_coexist_debug_matrix_init_wrapper(int evt, int sig, bool rev)
#endif
}
static IRAM_ATTR int esp_coex_common_xtal_freq_get_wrapper(void)
{
return rtc_clk_xtal_freq_get();
}
coex_adapter_funcs_t g_coex_adapter_funcs = {
._version = COEX_ADAPTER_VERSION,
._task_yield_from_isr = esp_coex_common_task_yield_from_isr_wrapper,
@@ -163,5 +168,6 @@ coex_adapter_funcs_t g_coex_adapter_funcs = {
._timer_setfn = esp_coex_common_timer_setfn_wrapper,
._timer_arm_us = esp_coex_common_timer_arm_us_wrapper,
._debug_matrix_init = esp_coexist_debug_matrix_init_wrapper,
._xtal_freq_get = esp_coex_common_xtal_freq_get_wrapper,
._magic = COEX_ADAPTER_MAGIC,
};

View File

@@ -47,6 +47,7 @@ typedef struct {
void (* _timer_setfn)(void *ptimer, void *pfunction, void *parg);
void (* _timer_arm_us)(void *ptimer, uint32_t us, bool repeat);
int (* _debug_matrix_init)(int event, int signal, bool rev);
int (* _xtal_freq_get)(void);
int32_t _magic;
} coex_adapter_funcs_t;

View File

@@ -108,7 +108,7 @@ typedef enum {
#endif
/* wifi callback -> debug */
void wifi_set_gpio_debug_cb(void (* cb)(int, int));
void wifi_set_gpio_debug_cb(void (* cb)(int, coex_gpio_debug_sig_t));
int wifi_gpio_debug_max_event_get(void);
/* functions to check if in ROM */
@@ -128,9 +128,10 @@ void pm_check_state(void);
void pm_tx_null_data_done_process(void);
void pm_start(void);
void pm_stop(void);
void pm_disconnected_wake(void);
/* coex callback -> debug */
void coex_set_gpio_debug_cb(void (*cb)(int, int));
void coex_set_gpio_debug_cb(void (*cb)(int, coex_gpio_debug_sig_t));
int coex_gpio_debug_max_event_get(void);
esp_err_t coex_gpio_debug_matrix_init(void);
@@ -142,4 +143,10 @@ void wifi_bind_io_to_evt(uint8_t io_idx, uint8_t evt);
void coex_bind_io_to_evt(uint8_t io_idx, uint8_t evt);
void diagram_bind_io_to_evt(void);
/* coex -> debug
* configure single gpio debug event */
esp_err_t coex_gpio_debug_matrix_config(int event);
/* debug -> internal use */
esp_err_t esp_coexist_gpio_debug_matrix_config(int event);
#endif

View File

@@ -13,37 +13,20 @@
#include "esp_attr.h"
#include "esp_log.h"
#if CONFIG_IDF_TARGET_ESP32
#include "esp32/rom/gpio.h"
#include "esp32/rom/ets_sys.h"
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
#include "esp32s2/rom/gpio.h"
#include "esp32s2/rom/ets_sys.h"
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
#include "esp32c3/rom/gpio.h"
#include "esp32c3/rom/ets_sys.h"
#elif defined(CONFIG_IDF_TARGET_ESP32C2)
#include "esp32c2/rom/gpio.h"
#include "esp32c2/rom/ets_sys.h"
#elif defined(CONFIG_IDF_TARGET_ESP32C6)
#include "esp32c6/rom/gpio.h"
#include "esp32c6/rom/ets_sys.h"
#elif defined(CONFIG_IDF_TARGET_ESP32C5)
#include "esp32c5/rom/gpio.h"
#include "esp32c5/rom/ets_sys.h"
#elif defined(CONFIG_IDF_TARGET_ESP32C61)
#include "esp32c61/rom/gpio.h"
#include "esp32c61/rom/ets_sys.h"
#endif
#include "rom/gpio.h"
#include "rom/ets_sys.h"
#include "driver/gpio.h"
#include "soc/gpio_sig_map.h"
#include "esp_rom_gpio.h"
#include "soc/soc.h"
#if SOC_MODEM_CLOCK_IS_INDEPENDENT
#include "esp_private/esp_modem_clock.h"
#endif
#if CONFIG_ESP_COEX_GPIO_DEBUG
static char* TAG = "coexist debug";
__attribute__((weak)) void wifi_set_gpio_debug_cb(void (* cb)(int, int))
__attribute__((weak)) void wifi_set_gpio_debug_cb(void (* cb)(int, coex_gpio_debug_sig_t))
{
ESP_LOGW(TAG, "Not support: %s", __FUNCTION__);
}
@@ -53,7 +36,7 @@ __attribute__((weak)) int wifi_gpio_debug_max_event_get(void)
return 0;
}
__attribute__((weak)) void coex_set_gpio_debug_cb(void (*cb)(int, int))
__attribute__((weak)) void coex_set_gpio_debug_cb(void (*cb)(int, coex_gpio_debug_sig_t))
{
ESP_LOGW(TAG, "Not support: %s", __FUNCTION__);
}
@@ -207,6 +190,18 @@ esp_err_t esp_coexist_debug_matrix_init(int evt, int sig, bool rev)
return ESP_OK;
}
esp_err_t esp_coexist_gpio_debug_matrix_config(int event)
{
#if SOC_MODEM_CLOCK_IS_INDEPENDENT
modem_clock_module_enable(PERIPH_COEX_MODULE);
#endif
esp_err_t ret = coex_gpio_debug_matrix_config(event);
#if SOC_MODEM_CLOCK_IS_INDEPENDENT
modem_clock_module_disable(PERIPH_COEX_MODULE);
#endif
return ret;
}
esp_err_t esp_coexist_debug_init(void)
{
if (check_funcs_in_rom()) {
@@ -270,8 +265,14 @@ esp_err_t esp_coexist_debug_init(void)
gpio_set_level(s_io_nums[i], false);
}
#if SOC_MODEM_CLOCK_IS_INDEPENDENT
modem_clock_module_enable(PERIPH_COEX_MODULE);
#endif
/* Init coexist hardware signal */
ESP_ERROR_CHECK(coex_gpio_debug_matrix_init());
#if SOC_MODEM_CLOCK_IS_INDEPENDENT
modem_clock_module_disable(PERIPH_COEX_MODULE);
#endif
return ESP_OK;
}

View File

@@ -32,40 +32,74 @@ case $IDF_TARGET in
esac
LIB_DIR=${IDF_TARGET}
ELF_FILE=test.elf
COEX_ELF_FILE=coex.elf
TEST_ELF_FILE=test.elf
FAILURES=0
function check_md5()
{
FILENAME=$1
SYMBOL=$2
${PREFIX}ld --unresolved-symbols=ignore-all --entry 0 -o ${ELF_FILE} \
-u ${SYMBOL} \
${IDF_PATH}/components/esp_coex/lib/${LIB_DIR}/*.a
GDB_COMMAND="printf \"%s\\n\", (const char*) ${SYMBOL}"
MD5_FROM_LIB=$(${PREFIX}gdb -n -batch ${ELF_FILE} -ex "${GDB_COMMAND}")
MD5_FROM_HEADER=$(md5sum ${FILENAME} | cut -c 1-7)
echo "Checking ${FILENAME}:"
echo " ${MD5_FROM_HEADER} - from header file"
echo " ${MD5_FROM_LIB} - from library"
if [ "${MD5_FROM_LIB}" != "${MD5_FROM_HEADER}" ]; then
if [ "$1" != "$2" ]; then
echo " error: MD5 mismatch!"
FAILURES=$(($FAILURES+1))
fi
}
function check_md5_file_lib()
{
FILENAME=$1
SYMBOL=$2
${PREFIX}ld --unresolved-symbols=ignore-all --entry 0 -o ${COEX_ELF_FILE} \
-u ${SYMBOL} \
${IDF_PATH}/components/esp_coex/lib/${LIB_DIR}/*.a
GDB_COMMAND="printf \"%s\\n\", (const char*) ${SYMBOL}"
MD5_FROM_LIB=$(${PREFIX}gdb -n -batch ${COEX_ELF_FILE} -ex "${GDB_COMMAND}")
MD5_FROM_HEADER=$(md5sum ${FILENAME} | cut -c 1-7)
echo "Checking ${FILENAME}:"
echo " ${MD5_FROM_HEADER} - from header file"
echo " ${MD5_FROM_LIB} - from library"
check_md5 ${MD5_FROM_HEADER} ${MD5_FROM_LIB}
}
function check_md5_libs()
{
COEX_SYMBOL=$1
TEST_SYMBOL=$2
TEST_PATH=$3
${PREFIX}ld --unresolved-symbols=ignore-all --entry 0 -o ${COEX_ELF_FILE} \
-u ${COEX_SYMBOL} \
${IDF_PATH}/components/esp_coex/lib/${LIB_DIR}/*.a
${PREFIX}ld --unresolved-symbols=ignore-all --entry 0 -o ${TEST_ELF_FILE} \
-u ${TEST_SYMBOL} \
${TEST_PATH}/*.a
COEX_GDB_COMMAND="printf \"%s\\n\", (const char*) ${COEX_SYMBOL}"
TEST_GDB_COMMAND="printf \"%s\\n\", (const char*) ${TEST_SYMBOL}"
COEX_MD5_FROM_LIB=$(${PREFIX}gdb -n -batch ${COEX_ELF_FILE} -ex "${COEX_GDB_COMMAND}")
TEST_MD5_FROM_LIB=$(${PREFIX}gdb -n -batch ${TEST_ELF_FILE} -ex "${TEST_GDB_COMMAND}")
echo "Checking ${TEST_PATH}/${TEST_SYMBOL} "
echo " ${COEX_MD5_FROM_LIB} - from coexist library"
echo " ${TEST_MD5_FROM_LIB} - from test library"
check_md5 ${COEX_MD5_FROM_LIB} ${TEST_MD5_FROM_LIB}
}
echo "Checking libraries for target ${IDF_TARGET}..."
check_md5 ${IDF_PATH}/components/esp_coex/include/private/esp_coexist_adapter.h g_coex_adapter_funcs_md5
check_md5_file_lib ${IDF_PATH}/components/esp_coex/include/private/esp_coexist_adapter.h g_coex_adapter_funcs_md5
case $IDF_TARGET in
esp32c6|esp32h2|esp32c5)
check_md5 ${IDF_PATH}/components/esp_coex/include/esp_coex_i154.h g_coex_i154_funcs_md5
check_md5_file_lib ${IDF_PATH}/components/esp_coex/include/esp_coex_i154.h g_coex_i154_funcs_md5
;;
esac
if [[ ! "$IDF_TARGET" =~ ^(esp32h2)$ ]]; then
check_md5_libs g_coex_basic_md5 g_wifi_coex_basic_md5 ${IDF_PATH}/components/esp_wifi/lib/${LIB_DIR}
fi
if [ $FAILURES -gt 0 ]; then
exit 1
fi

View File

@@ -1623,7 +1623,7 @@ dbg_lmac_rxtx_statis_dump = 0x40001e90;
dbg_lmac_hw_statis_dump = 0x40001e94;
dbg_lmac_diag_statis_dump = 0x40001e98;
dbg_lmac_ps_statis_dump = 0x40001e9c;
pp_timer_do_process = 0x40001ea0;
/*pp_timer_do_process = 0x40001ea0;*/
rcUpdateAMPDUParam = 0x40001ea4;
rcUpdatePhyMode = 0x40001ea8;
rcGetHighestRateIdx = 0x40001eac;

View File

@@ -222,7 +222,7 @@ pp_coex_tx_release = 0x40000f08;
ppAdd2AMPDUTail = 0x40000f0c;
ppDirectRecycleAmpdu = 0x40000f10;
ppRegressAmpdu = 0x40000f14;
pp_timer_do_process = 0x40000f18;
/*pp_timer_do_process = 0x40000f18;*/
rcGetAmpduSched = 0x40000f1c;
rcUpdateRxDone = 0x40000f20;
rc_get_trc = 0x40000f24;

View File

@@ -225,7 +225,7 @@ pp_coex_tx_release = 0x40000e7c;
ppAdd2AMPDUTail = 0x40000e80;
ppDirectRecycleAmpdu = 0x40000e84;
ppRegressAmpdu = 0x40000e88;
pp_timer_do_process = 0x40000e8c;
/*pp_timer_do_process = 0x40000e8c;*/
rcGetAmpduSched = 0x40000e90;
rcUpdateRxDone = 0x40000e94;
rc_get_trc = 0x40000e98;