Skip to content

Commit

Permalink
[Bouffalolab] Add build option to enable rotating device id (#27906)
Browse files Browse the repository at this point in the history
* add option to enable rotating device id

* add more files for mbedtls for bl702

* fix restyle and test data
  • Loading branch information
wy-hh authored Jul 14, 2023
1 parent 4655314 commit c6462e2
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 8 deletions.
1 change: 1 addition & 0 deletions scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ def BuildBouffalolabTarget():
target.AppendModifier('115200', baudrate=115200)
target.AppendModifier('rpc', enable_rpcs=True)
target.AppendModifier('cdc', enable_cdc=True)
target.AppendModifier('rotating_device_id', enable_rotating_device_id=True)

return target

Expand Down
7 changes: 6 additions & 1 deletion scripts/build/builders/bouffalolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def __init__(self,
module_type: str = "BL706C-22",
baudrate=2000000,
enable_shell: bool = False,
enable_cdc: bool = False
enable_cdc: bool = False,
enable_rotating_device_id: bool = False
):

if 'BL602' == module_type:
Expand Down Expand Up @@ -125,6 +126,10 @@ def __init__(self,
elif enable_shell:
self.argsOpt.append('chip_build_libshell=true')

if enable_rotating_device_id:
self.argsOpt.append('chip_enable_additional_data_advertising=true')
self.argsOpt.append('chip_enable_rotating_device_id=true')

try:
self.argsOpt.append('bouffalolab_sdk_root="%s"' % os.environ['BOUFFALOLAB_SDK_ROOT'])
except KeyError as err:
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/testdata/all_targets_linux_x64.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ameba-amebad-{all-clusters,all-clusters-minimal,light,light-switch,pigweed}
asr-{asr582x,asr595x}-{all-clusters,all-clusters-minimal,lighting,light-switch,lock,bridge,temperature-measurement,thermostat,ota-requestor}[-ota][-shell][-no_logging][-factory][-rotating_id]
android-{arm,arm64,x86,x64,androidstudio-arm,androidstudio-arm64,androidstudio-x86,androidstudio-x64}-{chip-tool,chip-test,tv-server,tv-casting-app,java-matter-controller}[-no-debug]
bouffalolab-{bl602-iot-matter-v1,bl602-iot-dvk-3s,bl602-night-light,xt-zb6-devkit,bl706-iot-dvk,bl706-night-light,bl704l-dvk}-light[-shell][-115200][-rpc][-cdc]
bouffalolab-{bl602-iot-matter-v1,bl602-iot-dvk-3s,bl602-night-light,xt-zb6-devkit,bl706-iot-dvk,bl706-night-light,bl704l-dvk}-light[-shell][-115200][-rpc][-cdc][-rotating_device_id]
cc32xx-lock
ti-cc13x2x7_26x2x7-{lighting,lock,pump,pump-controller}[-mtd]
ti-cc13x4_26x4-{all-clusters,lighting,lock,pump,pump-controller}[-mtd][-ftd]
Expand Down
2 changes: 0 additions & 2 deletions src/platform/bouffalolab/BL602/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ lwip_platform = "bl602"

chip_inet_config_enable_ipv4 = true

chip_enable_rotating_device_id = false

chip_build_tests = false
chip_inet_config_enable_dns_resolver = false
chip_inet_config_enable_tun_endpoint = false
Expand Down
6 changes: 4 additions & 2 deletions src/platform/bouffalolab/common/BLConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ class BLConfig
static constexpr const char * kConfigKey_ActiveLocale = ("active-locale");
static constexpr const char * kConfigKey_Breadcrumb = ("breadcrumb");
static constexpr const char * kConfigKey_GroupKeyIndex = ("group-key-index");
static constexpr const char * kBLConfigKey_wifissid = ("blConfig_wifi-ssid");
static constexpr const char * kBLConfigKey_wifipassword = ("blConfig_wifi-pwd");
static constexpr const char * kConfigKey_LifeTimeCounter = ("life-time-counter");

static constexpr const char * kBLConfigKey_wifissid = ("blConfig_wifi-ssid");
static constexpr const char * kBLConfigKey_wifipassword = ("blConfig_wifi-pwd");

/** Counter Keys, diagnostic information */
static constexpr const char * kCounterKey_RebootCount = ("reboot-count");
Expand Down
1 change: 1 addition & 0 deletions src/platform/bouffalolab/common/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <lib/support/CHIPMemString.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/logging/CHIPLogging.h>
#include <platform/DeviceInstanceInfoProvider.h>
#include <platform/internal/BLEManager.h>
#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING
#include <setup_payload/AdditionalDataPayloadGenerator.h>
Expand Down
2 changes: 1 addition & 1 deletion src/platform/bouffalolab/common/CHIPPlatformConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#define CHIP_CONFIG_PERSISTED_STORAGE_ENC_MSG_CNTR_ID 1
#define CHIP_CONFIG_PERSISTED_STORAGE_MAX_KEY_LENGTH 2

#define CHIP_CONFIG_LIFETIIME_PERSISTED_COUNTER_KEY 0x01
#define CHIP_CONFIG_LIFETIIME_PERSISTED_COUNTER_KEY BLConfig::kConfigKey_LifeTimeCounter

// ==================== Security Adaptations ====================
//#define CHIP_CONFIG_SHA256_CONTEXT_SIZE sizeof(bl_sha_ctx_t)
Expand Down
5 changes: 4 additions & 1 deletion src/platform/bouffalolab/common/FactoryDataProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,10 @@ CHIP_ERROR FactoryDataProvider::GetRotatingDeviceIdUniqueId(MutableByteSpan & un
#else
constexpr uint8_t uniqueId[] = CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID;

uniqueIdSpan = MutableByteSpan((uint8_t *) uniqueId, sizeof(uniqueId));
VerifyOrReturnValue(uniqueIdSpan.size() >= sizeof(uniqueId), CHIP_ERROR_INVALID_ARGUMENT);

memcpy(uniqueIdSpan.data(), uniqueId, sizeof(uniqueId));
uniqueIdSpan.reduce_size(sizeof(uniqueId));

return CHIP_NO_ERROR;
#endif
Expand Down
2 changes: 2 additions & 0 deletions third_party/bouffalolab/bl702/bl_iot_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,9 @@ template("bl_iot_sdk") {
"${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.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/x509_create.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/x509_crt.c",
"${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/x509write_csr.c",
]

Expand Down

0 comments on commit c6462e2

Please sign in to comment.