diff --git a/src/platform/bouffalolab/BL702L/BUILD.gn b/src/platform/bouffalolab/BL702L/BUILD.gn index fff0d1cd60a0c6..0063397a6b3cc4 100644 --- a/src/platform/bouffalolab/BL702L/BUILD.gn +++ b/src/platform/bouffalolab/BL702L/BUILD.gn @@ -75,7 +75,6 @@ static_library("BL702L") { import("${bouffalolab_iot_sdk_build_root}/bl702l/bl_iot_sdk.gni") public_deps += [ "${bouffalolab_iot_sdk_build_root}/bl702l:bl_iot_sdk", - "${bouffalolab_iot_sdk_build_root}/bl702l:mbedtls", ] sources += [ diff --git a/src/platform/bouffalolab/BL702L/args.gni b/src/platform/bouffalolab/BL702L/args.gni index f20cf817d2a2bc..5066ecfee7650e 100644 --- a/src/platform/bouffalolab/BL702L/args.gni +++ b/src/platform/bouffalolab/BL702L/args.gni @@ -22,7 +22,7 @@ chip_device_platform = "bl702l" riscv_platform_config = "${bouffalolab_iot_sdk_build_root}/common/rsicv.gni" -mbedtls_target = "${bouffalolab_iot_sdk_build_root}/bl702l:mbedtls" +mbedtls_target = "${bouffalolab_iot_sdk_build_root}/bl702l:bl_iot_sdk" chip_inet_config_enable_ipv4 = false chip_inet_config_enable_tcp_endpoint = false diff --git a/src/platform/bouffalolab/BL702L/bl702l-chip-mbedtls-config.h b/src/platform/bouffalolab/BL702L/bl702l-chip-mbedtls-config.h index 813afa6bed1dd0..95f231df8e5483 100644 --- a/src/platform/bouffalolab/BL702L/bl702l-chip-mbedtls-config.h +++ b/src/platform/bouffalolab/BL702L/bl702l-chip-mbedtls-config.h @@ -123,6 +123,10 @@ #include MBEDTLS_USER_CONFIG_FILE #endif +#define MBEDTLS_AES_ALT 1 +#define MBEDTLS_ECP_ALT 1 +#define MBEDTLS_USE_HW 1 + #include "mbedtls/check_config.h" #endif /* MBEDTLS_CONFIG_H */ diff --git a/third_party/bouffalolab/bl702l/BUILD.gn b/third_party/bouffalolab/bl702l/BUILD.gn index a1fb496c0a4d34..24f60f589bdeeb 100644 --- a/third_party/bouffalolab/bl702l/BUILD.gn +++ b/third_party/bouffalolab/bl702l/BUILD.gn @@ -23,15 +23,6 @@ declare_args() { assert(bl_iot_sdk_target != "", "bl_iot_sdk_target must be specified") -config("bl702l_mbedtls_config") { - defines = [ "MBEDTLS_CONFIG_FILE=\"bl702l-chip-mbedtls-config.h\"" ] -} - -mbedtls_target("mbedtls") { - public_configs = [ ":bl702l_mbedtls_config" ] - include_dirs = [ "${chip_root}/src/platform/bouffalolab/BL702L" ] -} - group("bl_iot_sdk") { public_deps = [ bl_iot_sdk_target ] } diff --git a/third_party/bouffalolab/bl702l/bl_iot_sdk.gni b/third_party/bouffalolab/bl702l/bl_iot_sdk.gni index 3f5a609c665bcf..2672bd71becf92 100644 --- a/third_party/bouffalolab/bl702l/bl_iot_sdk.gni +++ b/third_party/bouffalolab/bl702l/bl_iot_sdk.gni @@ -574,12 +574,91 @@ template("bl_iot_sdk") { ] public_deps = [ - "${bouffalolab_iot_sdk_build_root}/bl702l:mbedtls", "${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils", "${openthread_root}/src/core:libopenthread_core_headers", ] } + config("${sdk_target_name}_config_mbedtls") { + include_dirs = [ + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/include", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/port", + "${chip_root}/src/platform/bouffalolab/BL702L", + ] + + defines = [ "MBEDTLS_CONFIG_FILE=\"bl702l-chip-mbedtls-config.h\"" ] + } + + source_set("${sdk_target_name}_mbedtls") { + include_dirs = + [ "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library" ] + + sources = [ + "${bl_iot_sdk_root}/components/security/mbedtls_lts/port/hw_acc/aes_alt.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/port/hw_acc/bignum_hw.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/port/hw_acc/ecp_alt.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/port/hw_acc/ecp_curves_alt.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/port/hw_acc/hw_common.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/port/hw_acc/hw_common.h", + #"${bl_iot_sdk_root}/components/security/mbedtls_lts/port/hw_acc/sha1_alt.c", + #"${bl_iot_sdk_root}/components/security/mbedtls_lts/port/hw_acc/sha256_alt.c", + ] + + sources += [ + "${bl_iot_sdk_root}/components/security/mbedtls_lts/port/bignum_ext.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/port/hw_entropy_poll.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/port/mbedtls_port_mem.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/port/net_sockets.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/port/pkparse.c", + ] + + sources += [ + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/aes.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/asn1parse.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/asn1write.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/base64.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/bignum.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/ccm.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/cipher.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/cipher_wrap.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/cmac.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/constant_time.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/ctr_drbg.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/ecdh.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/ecdsa.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/ecp.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/ecp_curves.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/entropy.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/hkdf.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/hmac_drbg.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/md.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/oid.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/pem.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/pk.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/pk_wrap.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/pkcs5.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/pkwrite.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/platform.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/platform_util.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/sha256.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/sha512.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/x509_create.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/x509write_csr.c", + ] + cflags_c = [ + "-Wno-sign-compare", + "-Wno-implicit-function-declaration", + ] + configs += [ + ":${sdk_target_name}_config_BSP_Driver", + ":${sdk_target_name}_config_hosal", + ":${sdk_target_name}_config_bl702l_rom_a0", + ] + public_configs = [ + ":${sdk_target_name}_config", + ":${sdk_target_name}_config_mbedtls", + ] + } group(sdk_target_name) { public_deps = [ @@ -592,6 +671,7 @@ template("bl_iot_sdk") { ":${sdk_target_name}_sys", ":${sdk_target_name}_utils", ":${sdk_target_name}_ble", + ":${sdk_target_name}_mbedtls", ] public_configs = [ ":${sdk_target_name}_config_BSP_Driver",