From 3afa52bb884e8a721423d9d3f55dc48830498d80 Mon Sep 17 00:00:00 2001 From: "nilesh.kale" Date: Tue, 16 Jan 2024 14:40:09 +0530 Subject: [PATCH] fix(esp_hw_support): fix API esp_hmac_disable_jtag() to disable JTAG After ets_hmac_disable(), invalidating JTAG register process is ineffective. So, added call to enable hmac begore invalidating JTAG REG. And similarly disabled it after invalidation. --- components/esp_hw_support/port/esp32c3/esp_hmac.c | 4 ++-- components/esp_hw_support/port/esp32h2/esp_hmac.c | 6 +++--- components/esp_hw_support/port/esp32s2/esp_hmac.c | 4 ++-- components/esp_hw_support/port/esp32s3/esp_hmac.c | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/components/esp_hw_support/port/esp32c3/esp_hmac.c b/components/esp_hw_support/port/esp32c3/esp_hmac.c index 0c85d7429c..423fb92990 100644 --- a/components/esp_hw_support/port/esp32c3/esp_hmac.c +++ b/components/esp_hw_support/port/esp32c3/esp_hmac.c @@ -169,9 +169,9 @@ 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(); REG_SET_BIT(HMAC_SET_INVALIDATE_JTAG_REG, HMAC_INVALIDATE_JTAG); - + ets_hmac_disable(); esp_crypto_hmac_lock_release(); ESP_LOGD(TAG, "Invalidate JTAG result register. JTAG disabled."); diff --git a/components/esp_hw_support/port/esp32h2/esp_hmac.c b/components/esp_hw_support/port/esp32h2/esp_hmac.c index 84340d8164..c20e1b26c6 100644 --- a/components/esp_hw_support/port/esp32h2/esp_hmac.c +++ b/components/esp_hw_support/port/esp32h2/esp_hmac.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -169,9 +169,9 @@ 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(); REG_SET_BIT(HMAC_SET_INVALIDATE_JTAG_REG, HMAC_INVALIDATE_JTAG); - + ets_hmac_disable(); esp_crypto_hmac_lock_release(); ESP_LOGD(TAG, "Invalidate JTAG result register. JTAG disabled."); diff --git a/components/esp_hw_support/port/esp32s2/esp_hmac.c b/components/esp_hw_support/port/esp32s2/esp_hmac.c index 328ccbd90d..2939b77a9a 100644 --- a/components/esp_hw_support/port/esp32s2/esp_hmac.c +++ b/components/esp_hw_support/port/esp32s2/esp_hmac.c @@ -88,9 +88,9 @@ 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_dma_lock_acquire(); - + ets_hmac_enable(); REG_WRITE(HMAC_SET_INVALIDATE_JTAG_REG, 1); - + ets_hmac_disable(); esp_crypto_dma_lock_release(); ESP_LOGD(TAG, "Invalidate JTAG result register. JTAG disabled."); diff --git a/components/esp_hw_support/port/esp32s3/esp_hmac.c b/components/esp_hw_support/port/esp32s3/esp_hmac.c index 73c3193a8d..e2f5cee16d 100644 --- a/components/esp_hw_support/port/esp32s3/esp_hmac.c +++ b/components/esp_hw_support/port/esp32s3/esp_hmac.c @@ -170,9 +170,9 @@ 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(); REG_SET_BIT(HMAC_SET_INVALIDATE_JTAG_REG, HMAC_INVALIDATE_JTAG); - + ets_hmac_disable(); esp_crypto_hmac_lock_release(); ESP_LOGD(TAG, "Invalidate JTAG result register. JTAG disabled.");