Merge branch 'change/ecdsa_does_not_use_mpi_esp32h2_eco5_v5.4' into 'release/v5.4'

The ECDSA module of ESP32-H2 ECO5 does not use the MPI module (v5.4)

See merge request espressif/esp-idf!41219
This commit is contained in:
Mahavir Jain
2025-08-18 14:02:43 +05:30
5 changed files with 44 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@@ -46,6 +46,9 @@ static _lock_t s_crypto_ecc_lock;
#ifdef SOC_ECDSA_SUPPORTED #ifdef SOC_ECDSA_SUPPORTED
/* Lock for ECDSA peripheral */ /* Lock for ECDSA peripheral */
static _lock_t s_crypto_ecdsa_lock; static _lock_t s_crypto_ecdsa_lock;
#if SOC_ECDSA_USES_MPI
#include "hal/ecdsa_ll.h"
#endif /* SOC_ECDSA_USES_MPI */
#endif /* SOC_ECDSA_SUPPORTED */ #endif /* SOC_ECDSA_SUPPORTED */
#ifdef SOC_KEY_MANAGER_SUPPORTED #ifdef SOC_KEY_MANAGER_SUPPORTED
@@ -137,14 +140,18 @@ void esp_crypto_ecdsa_lock_acquire(void)
_lock_acquire(&s_crypto_ecdsa_lock); _lock_acquire(&s_crypto_ecdsa_lock);
esp_crypto_ecc_lock_acquire(); esp_crypto_ecc_lock_acquire();
#ifdef SOC_ECDSA_USES_MPI #ifdef SOC_ECDSA_USES_MPI
if (ecdsa_ll_is_mpi_required()) {
esp_crypto_mpi_lock_acquire(); esp_crypto_mpi_lock_acquire();
}
#endif /* SOC_ECDSA_USES_MPI */ #endif /* SOC_ECDSA_USES_MPI */
} }
void esp_crypto_ecdsa_lock_release(void) void esp_crypto_ecdsa_lock_release(void)
{ {
#ifdef SOC_ECDSA_USES_MPI #ifdef SOC_ECDSA_USES_MPI
if (ecdsa_ll_is_mpi_required()) {
esp_crypto_mpi_lock_release(); esp_crypto_mpi_lock_release();
}
#endif /* SOC_ECDSA_USES_MPI */ #endif /* SOC_ECDSA_USES_MPI */
esp_crypto_ecc_lock_release(); esp_crypto_ecc_lock_release();
_lock_release(&s_crypto_ecdsa_lock); _lock_release(&s_crypto_ecdsa_lock);

View File

@@ -418,6 +418,14 @@ static inline bool ecdsa_ll_is_deterministic_mode_supported(void)
return ESP_CHIP_REV_ABOVE(efuse_hal_chip_revision(), 102); return ESP_CHIP_REV_ABOVE(efuse_hal_chip_revision(), 102);
} }
/**
* @brief Check if the ECDSA peripheral uses MPI module's memory
*/
static inline bool ecdsa_ll_is_mpi_required(void)
{
return !ESP_CHIP_REV_ABOVE(efuse_hal_chip_revision(), 102);
}
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -440,6 +440,14 @@ static inline bool ecdsa_ll_is_deterministic_mode_supported(void)
return true; return true;
} }
/**
* @brief Check if the ECDSA peripheral uses MPI module's memory
*/
static inline bool ecdsa_ll_is_mpi_required(void)
{
return true; // TODO: IDF-13523
}
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -45,19 +45,23 @@ static void ecdsa_enable_and_reset(void)
} }
#ifdef SOC_ECDSA_USES_MPI #ifdef SOC_ECDSA_USES_MPI
if (ecdsa_ll_is_mpi_required()) {
MPI_RCC_ATOMIC() { MPI_RCC_ATOMIC() {
mpi_ll_enable_bus_clock(true); mpi_ll_enable_bus_clock(true);
mpi_ll_reset_register(); mpi_ll_reset_register();
} }
}
#endif #endif
} }
static void ecdsa_disable(void) static void ecdsa_disable(void)
{ {
#ifdef SOC_ECDSA_USES_MPI #ifdef SOC_ECDSA_USES_MPI
if (ecdsa_ll_is_mpi_required()) {
MPI_RCC_ATOMIC() { MPI_RCC_ATOMIC() {
mpi_ll_enable_bus_clock(false); mpi_ll_enable_bus_clock(false);
} }
}
#endif #endif
ECC_RCC_ATOMIC() { ECC_RCC_ATOMIC() {

View File

@@ -70,10 +70,12 @@ static void esp_ecdsa_acquire_hardware(void)
/* We need to reset the MPI peripheral because ECDSA peripheral /* We need to reset the MPI peripheral because ECDSA peripheral
* of some targets use the MPI peripheral as well. * of some targets use the MPI peripheral as well.
*/ */
if (ecdsa_ll_is_mpi_required()) {
MPI_RCC_ATOMIC() { MPI_RCC_ATOMIC() {
mpi_ll_enable_bus_clock(true); mpi_ll_enable_bus_clock(true);
mpi_ll_reset_register(); mpi_ll_reset_register();
} }
}
#endif /* SOC_ECDSA_USES_MPI */ #endif /* SOC_ECDSA_USES_MPI */
} }
@@ -89,9 +91,11 @@ static void esp_ecdsa_release_hardware(void)
} }
#ifdef SOC_ECDSA_USES_MPI #ifdef SOC_ECDSA_USES_MPI
if (ecdsa_ll_is_mpi_required()) {
MPI_RCC_ATOMIC() { MPI_RCC_ATOMIC() {
mpi_ll_enable_bus_clock(false); mpi_ll_enable_bus_clock(false);
} }
}
#endif /* SOC_ECDSA_USES_MPI */ #endif /* SOC_ECDSA_USES_MPI */
esp_crypto_ecdsa_lock_release(); esp_crypto_ecdsa_lock_release();