From c10a3021ae61d2649bab1bec7e0976472519e888 Mon Sep 17 00:00:00 2001 From: Zhao Wei Liang Date: Wed, 31 Dec 2025 21:13:30 +0800 Subject: [PATCH] fix(ble): fixed build error on ESP32-C6 (cherry picked from commit a16a56fdbe43af03ddbad1b7cb1e44c39f26ec04) Co-authored-by: zhaoweiliang --- components/bt/controller/esp32c2/bt.c | 4 +++- components/bt/controller/esp32c6/bt.c | 4 +++- components/bt/controller/esp32h2/bt.c | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/components/bt/controller/esp32c2/bt.c b/components/bt/controller/esp32c2/bt.c index 104503d8e25..41149cd8e51 100644 --- a/components/bt/controller/esp32c2/bt.c +++ b/components/bt/controller/esp32c2/bt.c @@ -1466,12 +1466,13 @@ static mbedtls_ecp_keypair keypair; #include "tinycrypt/ecc_dh.h" +#if CONFIG_BT_CONTROLLER_ONLY /* Used by uECC to get random data */ static int ecc_rand_func(uint8_t *dst, unsigned int len) { int offset_cnt = 0; uint8_t *u8ptr = dst; - uint64_t random_64 = 0; + uint64_t random64 = 0; while(len > 0) { random64 = (uint64_t)esp_random(); @@ -1485,6 +1486,7 @@ static int ecc_rand_func(uint8_t *dst, unsigned int len) return 1; } +#endif // CONFIG_BT_CONTROLLER_ONLY #endif // CONFIG_BT_LE_SM_SC #endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS diff --git a/components/bt/controller/esp32c6/bt.c b/components/bt/controller/esp32c6/bt.c index de8d8f51fcc..018f06ff6f1 100644 --- a/components/bt/controller/esp32c6/bt.c +++ b/components/bt/controller/esp32c6/bt.c @@ -1677,12 +1677,13 @@ static mbedtls_ecp_keypair keypair; #include "tinycrypt/cmac_mode.h" #include "tinycrypt/ecc_dh.h" +#if CONFIG_BT_CONTROLLER_ONLY /* Used by uECC to get random data */ static int ecc_rand_func(uint8_t *dst, unsigned int len) { int offset_cnt = 0; uint8_t *u8ptr = dst; - uint64_t random_64 = 0; + uint64_t random64 = 0; while(len > 0) { random64 = (uint64_t)esp_random(); @@ -1695,6 +1696,7 @@ static int ecc_rand_func(uint8_t *dst, unsigned int len) return 1; } +#endif // CONFIG_BT_CONTROLLER_ONLY #endif // CONFIG_BT_LE_SM_SC #endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS diff --git a/components/bt/controller/esp32h2/bt.c b/components/bt/controller/esp32h2/bt.c index c51cd40c951..eb0371fe896 100644 --- a/components/bt/controller/esp32h2/bt.c +++ b/components/bt/controller/esp32h2/bt.c @@ -1628,12 +1628,13 @@ static mbedtls_ecp_keypair keypair; #include "tinycrypt/cmac_mode.h" #include "tinycrypt/ecc_dh.h" +#if CONFIG_BT_CONTROLLER_ONLY /* Used by uECC to get random data */ static int ecc_rand_func(uint8_t *dst, unsigned int len) { int offset_cnt = 0; uint8_t *u8ptr = dst; - uint64_t random_64 = 0; + uint64_t random64 = 0; while(len > 0) { random64 = (uint64_t)esp_random(); @@ -1646,6 +1647,7 @@ static int ecc_rand_func(uint8_t *dst, unsigned int len) return 1; } +#endif // CONFIG_BT_CONTROLLER_ONLY #endif // CONFIG_BT_LE_SM_SC #endif // CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS