From 34a26ed6328aa445c420308cbc851b9eb27bcbfa Mon Sep 17 00:00:00 2001 From: Sarvesh Bodakhe Date: Thu, 25 Jan 2024 12:01:21 +0530 Subject: [PATCH 1/6] fix(wifi): Avoid dereferencing a dangling function pointer in WPS supplicant Avoid dereferencing a dangling function pointer in 'eap_server_sm_deinit()'. This issue arises when hostap unregisteres EAP methods before it removes the server state machine for station. --- components/wpa_supplicant/src/ap/wps_hostapd.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/components/wpa_supplicant/src/ap/wps_hostapd.c b/components/wpa_supplicant/src/ap/wps_hostapd.c index 3210438f9430..a2b7ecc6ddbe 100644 --- a/components/wpa_supplicant/src/ap/wps_hostapd.c +++ b/components/wpa_supplicant/src/ap/wps_hostapd.c @@ -321,6 +321,14 @@ int hostapd_init_wps(struct hostapd_data *hapd, struct wps_data *wps_data, struc return -1; } +#ifdef ESP_SUPPLICANT +static int ap_sta_server_sm_deinit(struct hostapd_data *hapd, + struct sta_info *sta, void *ctx) +{ + ieee802_1x_free_station(hapd, sta); + return 0; +} +#endif /* ESP_SUPPLICANT */ void hostapd_deinit_wps(struct hostapd_data *hapd) { @@ -332,6 +340,11 @@ void hostapd_deinit_wps(struct hostapd_data *hapd) } wps_registrar_deinit(hapd->wps->registrar); hapd->wps->registrar = NULL; + +#ifdef ESP_SUPPLICANT + ap_for_each_sta(hapd, ap_sta_server_sm_deinit, NULL); +#endif /* ESP_SUPPLICANT */ + eap_server_unregister_methods(); hapd->wps = NULL; hostapd_wps_clear_ies(hapd, 1); From 691997af91b2b54e2711bcd7007f2766e00b3657 Mon Sep 17 00:00:00 2001 From: Sarvesh Bodakhe Date: Thu, 25 Jan 2024 15:42:01 +0530 Subject: [PATCH 2/6] fix(wpa_supplicant): Improve execution flow for WPS registrar public APIs Make sure that WPS registrar public APIs do not modify supplicant data in application task context. Execute API functionlity in eloop context to prevent protential race conditions. --- .../esp_supplicant/src/esp_hostpad_wps.c | 220 +++++++++++++----- .../esp_supplicant/src/esp_wps.c | 11 +- .../esp_supplicant/src/esp_wps_i.h | 15 +- 3 files changed, 173 insertions(+), 73 deletions(-) diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_hostpad_wps.c b/components/wpa_supplicant/esp_supplicant/src/esp_hostpad_wps.c index 84a8177dc640..869deccc6e4a 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_hostpad_wps.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_hostpad_wps.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -26,12 +26,15 @@ #include "ap/hostapd.h" #include "ap/ap_config.h" #include "ap/wps_hostapd.h" +#include "utils/eloop.h" extern struct wps_sm *gWpsSm; extern void *s_wps_api_lock; extern void *s_wps_api_sem; extern bool s_wps_enabled; +static int wps_reg_eloop_post_block(uint32_t sig, void *arg); + static int wifi_ap_wps_init(const esp_wps_config_t *config) { struct wps_sm *sm = NULL; @@ -138,41 +141,8 @@ int wifi_ap_wps_deinit(void) return ESP_OK; } -int wifi_ap_wps_enable_internal(const esp_wps_config_t *config) -{ - int ret = 0; - - wpa_printf(MSG_DEBUG, "ESP WPS crypto initialize!"); - if (config->wps_type == WPS_TYPE_DISABLE) { - wpa_printf(MSG_ERROR, "wps enable: invalid wps type"); - return ESP_ERR_WIFI_WPS_TYPE; - } - - wpa_printf(MSG_DEBUG, "Set factory information."); - ret = wps_set_factory_info(config); - if (ret != 0) { - return ret; - } - - wpa_printf(MSG_INFO, "wifi_wps_enable"); - - wps_set_type(config->wps_type); - wps_set_status(WPS_STATUS_DISABLE); - - ret = wifi_ap_wps_init(config); - - if (ret != 0) { - wps_set_type(WPS_STATUS_DISABLE); - wps_set_status(WPS_STATUS_DISABLE); - return ESP_FAIL; - } - - return ESP_OK; -} - -int esp_wifi_ap_wps_enable(const esp_wps_config_t *config) +static int wifi_ap_wps_enable_internal(const esp_wps_config_t *config) { - int ret = ESP_OK; struct wps_sm *sm = gWpsSm; wifi_mode_t mode = WIFI_MODE_NULL; @@ -181,7 +151,11 @@ int esp_wifi_ap_wps_enable(const esp_wps_config_t *config) return ESP_ERR_WIFI_STATE; } - ret = esp_wifi_get_mode(&mode); + if (esp_wifi_get_mode(&mode) != ESP_OK) { + wpa_printf(MSG_ERROR, "wps enable: unable to get current wifi mode"); + return ESP_FAIL; + } + if (mode != WIFI_MODE_AP && mode != WIFI_MODE_APSTA) { wpa_printf(MSG_ERROR, "wps enable: mode=%d does not include AP", mode); return ESP_ERR_WIFI_MODE; @@ -192,58 +166,106 @@ int esp_wifi_ap_wps_enable(const esp_wps_config_t *config) return ESP_ERR_WIFI_MODE; } - API_MUTEX_TAKE(); if (s_wps_enabled) { if (sm && os_memcmp(sm->identity, WSC_ID_ENROLLEE, sm->identity_len) == 0) { wpa_printf(MSG_ERROR, "wps enable: wps enrollee already enabled cannot enable wpsreg"); - ret = ESP_ERR_WIFI_MODE; + return ESP_ERR_WIFI_MODE; } else { wpa_printf(MSG_DEBUG, "wps enable: already enabled"); - ret = ESP_OK; + return ESP_OK; } - API_MUTEX_GIVE(); - return ret; } - ret = wifi_ap_wps_enable_internal(config); + if (config->wps_type == WPS_TYPE_DISABLE) { + wpa_printf(MSG_ERROR, "wps enable: invalid wps type"); + return ESP_ERR_WIFI_WPS_TYPE; + } + + wpa_printf(MSG_DEBUG, "Set factory information."); + if (wps_set_factory_info(config) != ESP_OK) { + return ESP_FAIL; + } + + + if (wps_set_type(config->wps_type) != ESP_OK) { + goto _err; + } + + if (wps_set_status(WPS_STATUS_DISABLE) != ESP_OK) { + goto _err; + } + + if (wifi_ap_wps_init(config) != ESP_OK) { + goto _err; + } + + wpa_printf(MSG_INFO, "wifi_wps_enable"); s_wps_enabled = true; + return ESP_OK; + +_err: + wpa_printf(MSG_ERROR, "failure in wifi_wps_enable"); + wps_set_type(WPS_TYPE_DISABLE); + wps_set_status(WPS_STATUS_DISABLE); + + return ESP_FAIL; +} + +int esp_wifi_ap_wps_enable(const esp_wps_config_t *config) +{ + int ret = ESP_OK; + + API_MUTEX_TAKE(); + ret = wps_reg_eloop_post_block(SIG_WPS_REG_ENABLE, (void *) config); API_MUTEX_GIVE(); return ret; } -int esp_wifi_ap_wps_disable(void) +static int wifi_ap_wps_disable_internal(void) { - int ret = 0; struct wps_sm *sm = gWpsSm; if (sm && os_memcmp(sm->identity, WSC_ID_ENROLLEE, sm->identity_len) == 0) { return ESP_ERR_WIFI_MODE; } - API_MUTEX_TAKE(); - if (!s_wps_enabled) { wpa_printf(MSG_DEBUG, "wps disable: already disabled"); - API_MUTEX_GIVE(); return ESP_OK; } wpa_printf(MSG_INFO, "wifi_wps_disable"); - wps_set_type(WPS_TYPE_DISABLE); - wps_set_status(WPS_STATUS_DISABLE); + if (wps_set_type(WPS_TYPE_DISABLE) != ESP_OK) { + goto _err; + } - wifi_ap_wps_deinit(); + if (wps_set_status(WPS_STATUS_DISABLE) != ESP_OK) { + goto _err; + } - if (ESP_OK != ret) { - wpa_printf(MSG_ERROR, "wps disable: failed to disable wps, ret=%d", ret); + if (wifi_ap_wps_deinit() != ESP_OK) { + goto _err; } + s_wps_enabled = false; - API_MUTEX_GIVE(); return ESP_OK; + +_err: + wpa_printf(MSG_ERROR, "wps disable: failed to disable wps"); + return ESP_FAIL; } -int esp_wifi_ap_wps_start(const unsigned char *pin) +int esp_wifi_ap_wps_disable(void) +{ + int ret = ESP_FAIL; + API_MUTEX_TAKE(); + ret = wps_reg_eloop_post_block(SIG_WPS_REG_DISABLE, NULL); + API_MUTEX_GIVE(); + return ret; +} + +static int wifi_ap_wps_start_internal(const unsigned char *pin) { wifi_mode_t mode = WIFI_MODE_NULL; @@ -253,7 +275,6 @@ int esp_wifi_ap_wps_start(const unsigned char *pin) return ESP_ERR_WIFI_MODE; } - API_MUTEX_TAKE(); if (!s_wps_enabled) { wpa_printf(MSG_ERROR, "wps start: wps not enabled"); @@ -261,29 +282,100 @@ int esp_wifi_ap_wps_start(const unsigned char *pin) return ESP_ERR_WIFI_WPS_SM; } - if (wps_get_type() == WPS_TYPE_DISABLE || (wps_get_status() != WPS_STATUS_DISABLE && wps_get_status() != WPS_STATUS_SCANNING)) { - wpa_printf(MSG_ERROR, "wps start: wps_get_type=%d wps_get_status=%d", wps_get_type(), wps_get_status()); - API_MUTEX_GIVE(); + if (wps_get_type() == WPS_TYPE_DISABLE || + (wps_get_status() != WPS_STATUS_DISABLE && + wps_get_status() != WPS_STATUS_SCANNING)) { + wpa_printf(MSG_ERROR, "wps start: wps_get_type=%d wps_get_status=%d", + wps_get_type(), wps_get_status()); return ESP_ERR_WIFI_WPS_TYPE; } if (esp_wifi_get_user_init_flag_internal() == 0) { - wpa_printf(MSG_ERROR, "wps start: esp_wifi_get_user_init_flag_internal=%d", esp_wifi_get_user_init_flag_internal()); - API_MUTEX_GIVE(); + wpa_printf(MSG_ERROR, "wps start: esp_wifi_get_user_init_flag_internal=%d", + esp_wifi_get_user_init_flag_internal()); return ESP_ERR_WIFI_STATE; } if (!pin) { pin = gWpsSm->wps->dev_password; } + /* TODO ideally SoftAP mode should also do a single scan in PBC mode * however softAP scanning is not available at the moment */ - wps_set_status(WPS_STATUS_PENDING); + if (wps_set_status(WPS_STATUS_PENDING) != ESP_OK) { + return ESP_FAIL; + } if (wps_get_type() == WPS_TYPE_PBC) { - hostapd_wps_button_pushed(hostapd_get_hapd_data(), NULL); + if (hostapd_wps_button_pushed(hostapd_get_hapd_data(), NULL) != ESP_OK) { + return ESP_FAIL; + } } else if (wps_get_type() == WPS_TYPE_PIN) { - hostapd_wps_add_pin(hostapd_get_hapd_data(), pin); + if (hostapd_wps_add_pin(hostapd_get_hapd_data(), pin) != ESP_OK) { + return ESP_FAIL; + } } - API_MUTEX_GIVE(); return ESP_OK; } + +int esp_wifi_ap_wps_start(const unsigned char *pin) +{ + int ret = ESP_FAIL; + API_MUTEX_TAKE(); + ret = wps_reg_eloop_post_block(SIG_WPS_REG_START, (void *)pin); + API_MUTEX_GIVE(); + return ret; +} + +static void wps_reg_eloop_handler(void *eloop_ctx, void *user_ctx) +{ + int ret = ESP_FAIL; + enum wps_reg_sig_type *sig = (enum wps_reg_sig_type *) eloop_ctx; + wps_ioctl_param_t *param = (wps_ioctl_param_t *) user_ctx; + + switch(*sig) { + case SIG_WPS_REG_ENABLE: + esp_wps_config_t *config = (esp_wps_config_t *)param->arg; + ret = wifi_ap_wps_enable_internal(config); + break; + case SIG_WPS_REG_START: + unsigned char *pin = (unsigned char *)param->arg; + ret = wifi_ap_wps_start_internal((const unsigned char *)pin); + break; + case SIG_WPS_REG_DISABLE: + ret = wifi_ap_wps_disable_internal(); + break; + default: + wpa_printf(MSG_WARNING, "%s(): invalid signal type=%d", __func__, *sig); + ret = ESP_FAIL; + break; + } + + param->ret = ret; + os_semphr_give(s_wps_api_sem); +} + +static int wps_reg_eloop_post_block(uint32_t sig, void *arg) +{ + int ret = ESP_FAIL; + wps_ioctl_param_t param; + param.ret = ESP_FAIL; + param.arg = arg; + + if (s_wps_api_sem == NULL) { + s_wps_api_sem = os_semphr_create(1, 0); + if (s_wps_api_sem == NULL) { + wpa_printf(MSG_ERROR, "%s(): failed to create WPA API semaphore", __func__); + return ESP_ERR_NO_MEM; + } + } + + eloop_register_timeout(0, 0, wps_reg_eloop_handler, (void *)&sig, (void *)¶m); + + if (TRUE == os_semphr_take(s_wps_api_sem, OS_BLOCK)) { + ret = param.ret; + } else { + ret = ESP_FAIL; + } + + return ret; +} diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wps.c b/components/wpa_supplicant/esp_supplicant/src/esp_wps.c index 51f743e16362..05680bd11572 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wps.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wps.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -33,8 +33,8 @@ const char *wps_model_number = CONFIG_IDF_TARGET; -void *s_wps_api_lock = NULL; /* Used in WPS public API only, never be freed */ -void *s_wps_api_sem = NULL; /* Sync semaphore used between WPS publi API caller task and WPS task */ +void *s_wps_api_lock = NULL; /* Used in WPS/WPS-REG public API only, never be freed */ +void *s_wps_api_sem = NULL; /* Sync semaphore used between WPS/WPS-REG public API caller task and WPS task, never be freed */ bool s_wps_enabled = false; #ifdef USE_WPS_TASK struct wps_rx_param { @@ -45,11 +45,6 @@ struct wps_rx_param { }; static STAILQ_HEAD(,wps_rx_param) s_wps_rxq; -typedef struct { - void *arg; - int ret; /* return value */ -} wps_ioctl_param_t; - static void *s_wps_task_hdl = NULL; static void *s_wps_queue = NULL; static void *s_wps_data_lock = NULL; diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wps_i.h b/components/wpa_supplicant/esp_supplicant/src/esp_wps_i.h index 8b0f87cc4866..ca527ff24e07 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wps_i.h +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wps_i.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -27,6 +27,19 @@ enum wps_sig_type { SIG_WPS_NUM, //10 }; #endif + +enum wps_reg_sig_type { + SIG_WPS_REG_ENABLE = 1, //1 + SIG_WPS_REG_DISABLE, //2 + SIG_WPS_REG_START, //3 + SIG_WPS_REG_MAX, //4 +}; + +typedef struct { + void *arg; + int ret; /* return value */ +} wps_ioctl_param_t; + #ifdef ESP_SUPPLICANT enum wps_sm_state{ WAIT_START, From b4a8bd20408cb087929a451dffcb55c5284f7074 Mon Sep 17 00:00:00 2001 From: Armando Date: Fri, 15 Mar 2024 15:45:29 +0800 Subject: [PATCH 3/6] bugfix(cache): don't allow M2C direction ESP_CACHE_MSYNC_FLAG_UNALIGNED --- components/esp_mm/esp_cache.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/esp_mm/esp_cache.c b/components/esp_mm/esp_cache.c index 4b8fbf20b685..129281f16a11 100644 --- a/components/esp_mm/esp_cache.c +++ b/components/esp_mm/esp_cache.c @@ -59,6 +59,10 @@ esp_err_t esp_cache_msync(void *addr, size_t size, int flags) if (flags & ESP_CACHE_MSYNC_FLAG_DIR_M2C) { ESP_EARLY_LOGV(TAG, "M2C DIR"); + if (flags & ESP_CACHE_MSYNC_FLAG_UNALIGNED) { + ESP_RETURN_ON_FALSE_ISR(false, ESP_ERR_INVALID_ARG, TAG, "M2C direction doesn't allow ESP_CACHE_MSYNC_FLAG_UNALIGNED"); + } + esp_os_enter_critical_safe(&s_spinlock); //Add preload feature / flag here, IDF-7800 valid = cache_hal_invalidate_addr(vaddr, size); From 5f32741958c239976653bf385e0f4dc5c3e1c956 Mon Sep 17 00:00:00 2001 From: muhaidong Date: Mon, 4 Mar 2024 20:37:39 +0800 Subject: [PATCH 4/6] fix(wifi): fix some wifi bugs 230325 1. limit the number of sub amsdu 2. fix recycle cache sub amsdu eb issue 3. update api esp_wifi_sta_get_rssi docs --- components/esp_wifi/include/esp_wifi.h | 8 +++++--- components/esp_wifi/lib | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/components/esp_wifi/include/esp_wifi.h b/components/esp_wifi/include/esp_wifi.h index e4ea220cf7ee..a268ad8ada77 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -398,6 +398,7 @@ esp_err_t esp_wifi_restore(void); * - ESP_OK: succeed * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start + * - ESP_ERR_WIFI_MODE: WiFi mode error * - ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong * - ESP_ERR_WIFI_SSID: SSID of AP which station connects is invalid */ @@ -1458,9 +1459,10 @@ esp_err_t esp_wifi_sta_get_negotiated_phymode(wifi_phy_mode_t *phymode); esp_err_t esp_wifi_set_dynamic_cs(bool enabled); /** - * @brief Get the rssi info after station connected to AP + * @brief Get the rssi information of AP to which the device is associated with * - * @attention This API should be called after station connected to AP. + * @attention 1. This API should be called after station connected to AP. + * @attention 2. Use this API only in WIFI_MODE_STA or WIFI_MODE_APSTA mode. * * @param rssi store the rssi info received from last beacon. * diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 0e0ccbb3ed7a..25e4696bc346 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 0e0ccbb3ed7afa066a2935a0a3a6bcd65740d2f5 +Subproject commit 25e4696bc346576c48d76f9e0c7cf1e6d3de909e From 1be59d080a70d8db32852791b5fc9a8f443807ae Mon Sep 17 00:00:00 2001 From: Jiang Guang Ming Date: Wed, 7 Feb 2024 15:32:46 +0800 Subject: [PATCH 5/6] fix(esp_rom): Update esp32p4lp rom ld files --- .../esp_rom/esp32p4/ld/esp32p4lp.rom.ld | 68 +++++++++++++------ 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/components/esp_rom/esp32p4/ld/esp32p4lp.rom.ld b/components/esp_rom/esp32p4/ld/esp32p4lp.rom.ld index 00f951caea73..ad9dbf3971be 100644 --- a/components/esp_rom/esp32p4/ld/esp32p4lp.rom.ld +++ b/components/esp_rom/esp32p4/ld/esp32p4lp.rom.ld @@ -1,12 +1,12 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ /* ROM function interface esp32p4lp.rom.ld for esp32p4lp * * - * Generated from ./target/esp32p4lp/interface-esp32p4lp.yml md5sum 0751c805e21bd23f11b74dcc1f7e8007 + * Generated from ./target/esp32p4lp/interface-esp32p4lp.yml md5sum f827caf806e9f4faec384ffbde44b380 * * Compatible with ROM where ECO version equal or greater to 0. * @@ -20,16 +20,40 @@ /* Functions */ rtc_get_reset_reason = 0x50100098; rtc_get_wakeup_cause = 0x5010009c; -ets_printf = 0x501000a0; -ets_install_putc1 = 0x501000a4; -ets_install_uart_printf = 0x501000a8; -ets_delay_us = 0x501000ac; -uart_tx_one_char = 0x501000b0; -uart_tx_flush = 0x501000b4; -uart_tx_wait_idle = 0x501000b8; -uartAttach = 0x501000bc; -Uart_Init = 0x501000c0; -GetUartDevice = 0x501000c4; +pmu_enable_unhold_pads = 0x501000a0; +ets_printf = 0x501000a4; +ets_install_putc1 = 0x501000a8; +ets_install_uart_printf = 0x501000ac; +ets_delay_us = 0x501000b0; +uart_tx_one_char = 0x501000b4; +uart_tx_flush = 0x501000b8; +uart_tx_wait_idle = 0x501000bc; +uartAttach = 0x501000c0; +Uart_Init = 0x501000c4; +GetUartDevice = 0x501000c8; + + +/*************************************** + Group gpio + ***************************************/ + +/* Functions */ +gpio_set_output_level = 0x501000cc; +gpio_get_input_level = 0x501000d0; +gpio_matrix_in = 0x501000d4; +gpio_matrix_out = 0x501000d8; +gpio_bypass_matrix_in = 0x501000dc; +gpio_output_disable = 0x501000e0; +gpio_output_enable = 0x501000e4; +gpio_pad_input_disable = 0x501000e8; +gpio_pad_input_enable = 0x501000ec; +gpio_pad_pulldown = 0x501000f0; +gpio_pad_pullup = 0x501000f4; +gpio_pad_select_gpio = 0x501000f8; +gpio_pad_set_drv = 0x501000fc; +gpio_pad_unhold = 0x50100100; +gpio_pad_hold = 0x50100104; +gpio_lppad_select_mux = 0x50100108; /*************************************** @@ -37,10 +61,10 @@ GetUartDevice = 0x501000c4; ***************************************/ /* Functions */ -crc32_le = 0x501000c8; -crc16_le = 0x501000cc; -crc8_le = 0x501000d0; -esp_crc8 = 0x501000d4; +crc32_le = 0x5010010c; +crc16_le = 0x50100110; +crc8_le = 0x50100114; +esp_crc8 = 0x50100118; /*************************************** @@ -48,9 +72,9 @@ esp_crc8 = 0x501000d4; ***************************************/ /* Functions */ -ets_intr_lock = 0x501000d8; -ets_intr_unlock = 0x501000dc; -PROVIDE( intr_handler_set = 0x501000e0 ); -ets_isr_attach = 0x501000e4; -ets_isr_mask = 0x501000e8; -ets_isr_unmask = 0x501000ec; +ets_intr_lock = 0x5010011c; +ets_intr_unlock = 0x50100120; +PROVIDE( intr_handler_set = 0x50100124 ); +ets_isr_attach = 0x50100128; +ets_isr_mask = 0x5010012c; +ets_isr_unmask = 0x50100130; From 120cb89c566d0de3e29dfd091c8f5d654ea2ce68 Mon Sep 17 00:00:00 2001 From: "nilesh.kale" Date: Tue, 20 Feb 2024 16:19:51 +0530 Subject: [PATCH 6/6] fix(esp_hw_support): update hmac toggle method due to discrepency in ROM code Need to update the HMAC enable/disable method due to discrepancy in ROM code across different targets for the esp_hmac_disable() API. --- components/esp_hw_support/esp_hmac.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/components/esp_hw_support/esp_hmac.c b/components/esp_hw_support/esp_hmac.c index f79899b97d37..34df0aac4ea9 100644 --- a/components/esp_hw_support/esp_hmac.c +++ b/components/esp_hw_support/esp_hmac.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -187,7 +187,9 @@ esp_err_t esp_hmac_jtag_enable(hmac_key_id_t key_id, const uint8_t *token) ESP_LOGD(TAG, "HMAC computation in downstream mode is completed."); - ets_hmac_disable(); + HMAC_RCC_ATOMIC() { + hmac_ll_enable_bus_clock(false); + } esp_crypto_hmac_lock_release(); @@ -197,9 +199,17 @@ esp_err_t esp_hmac_jtag_enable(hmac_key_id_t key_id, const uint8_t *token) esp_err_t esp_hmac_jtag_disable() { esp_crypto_hmac_lock_acquire(); - ets_hmac_enable(); + + HMAC_RCC_ATOMIC() { + hmac_ll_enable_bus_clock(true); + } + REG_WRITE(HMAC_SET_INVALIDATE_JTAG_REG, 1); - ets_hmac_disable(); + + HMAC_RCC_ATOMIC() { + hmac_ll_enable_bus_clock(false); + } + esp_crypto_hmac_lock_release(); ESP_LOGD(TAG, "Invalidate JTAG result register. JTAG disabled."); @@ -234,7 +244,6 @@ esp_err_t esp_hmac_calculate(hmac_key_id_t key_id, } else { return ESP_OK; } - } esp_err_t esp_hmac_jtag_enable(hmac_key_id_t key_id, const uint8_t *token)