Skip to content

Commit d078ae8

Browse files
wy-hhpull[bot]
authored andcommitted
[Bouffalolab] Add BL706 Wi-Fi support (#28320)
* add bl706 wifi support * fix restyle * add bl706 wifi support * fix restyle * update codes according review suggestions * fix restyle * remove common_sources * fix restyle
1 parent 704d16d commit d078ae8

30 files changed

+1160
-78
lines changed

.github/workflows/examples-bouffalolab.yaml

+14-4
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
run: |
5656
./scripts/run_in_build_env.sh \
5757
"./scripts/build/build_examples.py \
58-
--target bouffalolab-bl602-iot-matter-v1-light \
58+
--target bouffalolab-bl602-night-light-light \
5959
--target bouffalolab-bl602-iot-matter-v1-light-115200-rpc \
6060
build \
6161
--copy-artifacts-to out/artifacts \
@@ -64,7 +64,7 @@ jobs:
6464
run: |
6565
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
6666
bl602 bl602 lighting-app \
67-
out/artifacts/bouffalolab-bl602-iot-matter-v1-light/chip-bl602-lighting-example.out \
67+
out/artifacts/bouffalolab-bl602-night-light-light/chip-bl602-lighting-example.out \
6868
/tmp/bloat_reports/
6969
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
7070
bl602 bl602+rpc lighting-app \
@@ -77,7 +77,9 @@ jobs:
7777
run: |
7878
./scripts/run_in_build_env.sh \
7979
"./scripts/build/build_examples.py \
80-
--target bouffalolab-xt-zb6-devkit-light \
80+
--target bouffalolab-bl706-night-light-light \
81+
--target bouffalolab-bl706-eth-light \
82+
--target bouffalolab-bl706-wifi-light \
8183
--target bouffalolab-xt-zb6-devkit-light-115200-rpc \
8284
build \
8385
--copy-artifacts-to out/artifacts \
@@ -86,7 +88,15 @@ jobs:
8688
run: |
8789
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
8890
bl702 bl702 lighting-app \
89-
out/artifacts/bouffalolab-xt-zb6-devkit-light/chip-bl702-lighting-example.out \
91+
out/artifacts/bouffalolab-bl706-night-light-light/chip-bl702-lighting-example.out \
92+
/tmp/bloat_reports/
93+
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
94+
bl702 bl706-eth lighting-app \
95+
out/artifacts/bouffalolab-bl706-eth-light/chip-bl702-lighting-example.out \
96+
/tmp/bloat_reports/
97+
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
98+
bl702 bl706-wifi lighting-app \
99+
out/artifacts/bouffalolab-bl706-wifi-light/chip-bl702-lighting-example.out \
90100
/tmp/bloat_reports/
91101
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
92102
bl702 bl702+rpc lighting-app \

examples/lighting-app/bouffalolab/bl602/BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import("${bouffalolab_iot_sdk_build_root}/bl602/bl_iot_sdk.gni")
2020
import("${bouffalolab_iot_sdk_build_root}/common/bouffalolab_executable.gni")
2121
import("${build_root}/config/defaults.gni")
2222
import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
23+
import("${chip_root}/src/platform/bouffalolab/common/args.gni")
2324
import("${chip_root}/src/platform/device.gni")
2425

2526
import("${chip_root}/src/app/chip_data_model.gni")

examples/lighting-app/bouffalolab/bl602/CHIPProjectConfig.h

-6
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,3 @@
126126
#define CHIP_SYSTEM_CRYPTO_HEADER_RESERVE_SIZE 128
127127

128128
#define CHIP_BLE_DEVICE_NAME "MatterLight"
129-
130-
/** Please contact Bouffalo Lab for how to use factory data provider */
131-
// #define CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE 1
132-
// uncomment out the following macro to use factory test data
133-
// when CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE sets to 1
134-
// #define CONFIG_BOUFFALOLAB_FACTORY_DATA_TEST

examples/lighting-app/bouffalolab/bl702/BUILD.gn

+2
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ bouffalolab_executable("lighting_app") {
136136
defines += [ "BL706_NIGHT_LIGHT" ]
137137
} else if ("BL706-ETH" == board) {
138138
defines += [ "BL706_ETHERNET" ]
139+
} else if ("BL706-WIFI" == board) {
140+
defines += [ "BL706_WIFI" ]
139141
}
140142

141143
if (defined(enable_cdc_module) && enable_cdc_module) {

examples/platform/bouffalolab/common/plat/platform.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,6 @@ void ChipEventHandler(const ChipDeviceEvent * event, intptr_t arg)
166166

167167
CHIP_ERROR PlatformManagerImpl::PlatformInit(void)
168168
{
169-
#if CONFIG_ENABLE_CHIP_SHELL || PW_RPC_ENABLED
170-
uartInit();
171-
#endif
172-
173169
#if PW_RPC_ENABLED
174170
PigweedLogger::pw_init();
175171
#elif CONFIG_ENABLE_CHIP_SHELL

scripts/build/build/targets.py

+2
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,8 @@ def BuildBouffalolabTarget():
602602
board=BouffalolabBoard.BL706_NIGHT_LIGHT, module_type="BL706C-22"),
603603
TargetPart('BL706-ETH',
604604
board=BouffalolabBoard.BL706_ETH, module_type="BL706C-22"),
605+
TargetPart('BL706-WIFI',
606+
board=BouffalolabBoard.BL706_WIFI, module_type="BL706C-22"),
605607
TargetPart('BL704L-DVK', board=BouffalolabBoard.BL704L_DVK, module_type="BL704L"),
606608
])
607609

scripts/build/builders/bouffalolab.py

+6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class BouffalolabBoard(Enum):
4747
XT_ZB6_DevKit = auto()
4848
BL706_NIGHT_LIGHT = auto()
4949
BL706_ETH = auto()
50+
BL706_WIFI = auto()
5051
BL704L_DVK = auto()
5152

5253
def GnArgName(self):
@@ -60,6 +61,8 @@ def GnArgName(self):
6061
return 'BL706-NIGHT-LIGHT'
6162
elif self == BouffalolabBoard.BL706_ETH:
6263
return 'BL706-ETH'
64+
elif self == BouffalolabBoard.BL706_WIFI:
65+
return 'BL706-WIFI'
6366
elif self == BouffalolabBoard.BL704L_DVK:
6467
return 'BL704L-DVK'
6568
else:
@@ -120,6 +123,9 @@ def __init__(self,
120123
self.argsOpt.append('chip_config_network_layer_ble=false')
121124
self.argsOpt.append('chip_enable_openthread=false')
122125
self.argsOpt.append('chip_enable_wifi=false')
126+
elif board == BouffalolabBoard.BL706_WIFI:
127+
self.argsOpt.append('chip_enable_openthread=false')
128+
self.argsOpt.append('chip_enable_wifi=true')
123129
else:
124130
self.argsOpt.append('chip_enable_openthread=true')
125131
self.argsOpt.append('chip_enable_wifi=false')

scripts/build/testdata/all_targets_linux_x64.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ameba-amebad-{all-clusters,all-clusters-minimal,light,light-switch,pigweed}
22
asr-{asr582x,asr595x,asr550x}-{all-clusters,all-clusters-minimal,lighting,light-switch,lock,bridge,temperature-measurement,thermostat,ota-requestor,dishwasher}[-ota][-shell][-no_logging][-factory][-rotating_id][-rio]
33
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,virtual-device-app}[-no-debug]
4-
bouffalolab-{bl602-iot-matter-v1,bl602-night-light,xt-zb6-devkit,bl706-night-light,bl706-eth,bl704l-dvk}-light[-shell][-115200][-rpc][-cdc][-resetcnt][-rotating_device_id]
4+
bouffalolab-{bl602-iot-matter-v1,bl602-night-light,xt-zb6-devkit,bl706-night-light,bl706-eth,bl706-wifi,bl704l-dvk}-light[-shell][-115200][-rpc][-cdc][-resetcnt][-rotating_device_id]
55
cc32xx-lock
66
ti-cc13x2x7_26x2x7-{lighting,lock,pump,pump-controller}[-mtd]
77
ti-cc13x4_26x4-{all-clusters,lighting,lock,pump,pump-controller}[-mtd][-ftd]

scripts/examples/gn_bouffalolab_example.sh

+44-1
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ source "$MATTER_ROOT/scripts/activate.sh"
2626
bl602_boards=("BL602-IoT-Matter-V1" "BL602-NIGHT-LIGHT")
2727
bl602_module_type="BL602"
2828

29-
bl702_boards=("XT-ZB6-DevKit" "BL706-IoT-DVK" "BL706-NIGHT-LIGHT")
29+
bl702_boards=("XT-ZB6-DevKit" "BL706-NIGHT-LIGHT" "BL706-ETH" "BL706-WIFI")
3030
bl702_modules=("BL702" "BL706C-22")
3131
bl702_module_type="BL706C-22"
3232

33+
bl702l_boards=("BL704L-DVK")
34+
bl702l_modules=("BL702L")
35+
bl702l_module_type="BL704l"
36+
3337
print_help() {
3438
bl602_boards_help=""
3539
for board in "${bl602_boards[@]}"; do
@@ -39,6 +43,10 @@ print_help() {
3943
for board in "${bl702_boards[@]}"; do
4044
bl702_boards_help=$bl702_boards_help$board"\n "
4145
done
46+
bl702l_boards_help=""
47+
for board in "${bl702l_boards[@]}"; do
48+
bl702l_boards_help=$bl702l_boards_help$board"\n "
49+
done
4250

4351
echo -e "Build script for Bouffalolab Matter examples
4452
Format:
@@ -55,6 +63,7 @@ print_help() {
5563
Currently Supported :
5664
$bl602_boards_help
5765
$bl702_boards_help
66+
$bl702l_boards_help
5867
<Build options> - optional noteworthy build options for Bouffalolab IOT Matter examples
5968
chip_build_libshell
6069
Enable libshell support. (Default false)
@@ -120,6 +129,9 @@ else
120129
optArgs=board=\"$board_name\"" "$optArgs
121130
optArgs=module_type=\"$bl602_module_type\"" "$optArgs
122131
optArgs=baudrate=\"$baudrate\"" "$optArgs
132+
optArgs=baudrate=\"$baudrate\"" "$optArgs
133+
optArgs=chip_enable_openthread=false" "$optArgs
134+
optArgs=chip_enable_wifi=true" "$optArgs
123135

124136
elif [[ "${bl702_boards[@]}" =~ "$board_name" ]]; then
125137
bouffalo_chip="bl702"
@@ -136,6 +148,37 @@ else
136148
fi
137149

138150
optArgs=baudrate=\"$baudrate\"" "$optArgs
151+
152+
if [[ "$board_name" == "BL706-ETH" ]]; then
153+
optArgs=chip_config_network_layer_ble=false" "$optArgs
154+
optArgs=chip_enable_openthread=false" "$optArgs
155+
optArgs=chip_enable_wifi=false" "$optArgs
156+
elif [[ "$board_name" == "BL706-WIFI" ]]; then
157+
optArgs=chip_enable_openthread=false" "$optArgs
158+
optArgs=chip_enable_wifi=true" "$optArgs
159+
else
160+
optArgs=chip_enable_openthread=true" "$optArgs
161+
optArgs=chip_enable_wifi=false" "$optArgs
162+
fi
163+
164+
elif [[ "${bl702l_boards[@]}" =~ "$board_name" ]]; then
165+
bouffalo_chip="bl702l"
166+
167+
optArgs=board=\"$board_name\"" "$optArgs
168+
169+
if [[ "$module_type" != "" ]]; then
170+
if [[ ! "${bl702l_modules[@]}" =~ "$module_type" ]]; then
171+
echo "Module $module_type is not supported."
172+
exit 1
173+
fi
174+
175+
optArgs=module_type=\"$module_type\"" "$optArgs
176+
fi
177+
178+
optArgs=baudrate=\"$baudrate\"" "$optArgs
179+
optArgs=chip_enable_openthread=true" "$optArgs
180+
optArgs=chip_enable_wifi=false" "$optArgs
181+
139182
else
140183
echo "Board $board_name is not supported."
141184
exit 1

src/credentials/BUILD.gn

+7
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ source_set("build_time_header") {
4242
deps = [ ":gen_build_time_header" ]
4343
}
4444

45+
source_set("credentials_header") {
46+
sources = [
47+
"CHIPCert.h",
48+
"DeviceAttestationCredsProvider.h",
49+
]
50+
}
51+
4552
static_library("credentials") {
4653
output_name = "libCredentials"
4754

src/platform/bouffalolab/BL602/BUILD.gn

+16-7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import("//build_overrides/chip.gni")
1717

1818
import("${chip_root}/src/platform/device.gni")
1919

20+
import("${chip_root}/src/platform/bouffalolab/common/args.gni")
21+
2022
assert(chip_device_platform == "bl602")
2123

2224
static_library("BL602") {
@@ -29,17 +31,13 @@ static_library("BL602") {
2931
"wifi_mgmr_portable.c",
3032
]
3133

32-
common_sources = [
33-
"${chip_root}/src/credentials/CHIPCert.h",
34-
"${chip_root}/src/credentials/DeviceAttestationCredsProvider.h",
34+
sources += [
3535
"../../FreeRTOS/SystemTimeSupport.cpp",
3636
"../../SingletonConfigurationManager.cpp",
3737
"../common/BLConfig.cpp",
3838
"../common/ConfigurationManagerImpl.cpp",
3939
"../common/ConnectivityManagerImpl.cpp",
4040
"../common/DiagnosticDataProviderImpl.cpp",
41-
"../common/FactoryDataProvider.cpp",
42-
"../common/FactoryDataProvider.h",
4341
"../common/KeyValueStoreManagerImpl.cpp",
4442
"../common/Logging.cpp",
4543
"../common/PlatformManagerImpl.cpp",
@@ -58,8 +56,19 @@ static_library("BL602") {
5856
"../common/BLEManagerImpl.h",
5957
]
6058
}
61-
sources += common_sources
6259

63-
deps = [ "${chip_root}/src/lib/dnssd:platform_header" ]
60+
defines =
61+
[ "CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE=${chip_enable_factory_data}" ]
62+
if (chip_enable_factory_data || chip_enable_factory_data_test) {
63+
sources += [
64+
"../common/FactoryDataProvider.cpp",
65+
"../common/FactoryDataProvider.h",
66+
]
67+
}
68+
69+
deps = [
70+
"${chip_root}/src/credentials:credentials_header",
71+
"${chip_root}/src/lib/dnssd:platform_header",
72+
]
6473
public_deps = [ "${chip_root}/src/platform:platform_base" ]
6574
}

src/platform/bouffalolab/BL602/NetworkCommissioningDriver.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ CHIP_ERROR BLWiFiDriver::Init(NetworkStatusChangeCallback * networkStatusChangeC
4444
size_t ssidLen = 0;
4545
size_t credentialsLen = 0;
4646

47-
err = PersistedStorage::KeyValueStoreMgr().Get(BLConfig::kBLConfigKey_wifissid, mSavedNetwork.credentials,
47+
err = PersistedStorage::KeyValueStoreMgr().Get(BLConfig::kConfigKey_WiFiSSID, mSavedNetwork.credentials,
4848
sizeof(mSavedNetwork.credentials), &credentialsLen);
4949
SuccessOrExit(err);
50-
err = PersistedStorage::KeyValueStoreMgr().Get(BLConfig::kBLConfigKey_wifipassword, mSavedNetwork.ssid,
50+
err = PersistedStorage::KeyValueStoreMgr().Get(BLConfig::kConfigKey_WiFiPassword, mSavedNetwork.ssid,
5151
sizeof(mSavedNetwork.ssid), &ssidLen);
5252
SuccessOrExit(err);
5353

@@ -78,8 +78,8 @@ CHIP_ERROR BLWiFiDriver::CommitConfiguration()
7878
{
7979
ChipLogProgress(NetworkProvisioning, "BLWiFiDriver::CommitConfiguration");
8080
ReturnErrorOnFailure(
81-
PersistedStorage::KeyValueStoreMgr().Put(BLConfig::kBLConfigKey_wifissid, mStagingNetwork.ssid, mStagingNetwork.ssidLen));
82-
ReturnErrorOnFailure(PersistedStorage::KeyValueStoreMgr().Put(BLConfig::kBLConfigKey_wifipassword, mStagingNetwork.credentials,
81+
PersistedStorage::KeyValueStoreMgr().Put(BLConfig::kConfigKey_WiFiSSID, mStagingNetwork.ssid, mStagingNetwork.ssidLen));
82+
ReturnErrorOnFailure(PersistedStorage::KeyValueStoreMgr().Put(BLConfig::kConfigKey_WiFiPassword, mStagingNetwork.credentials,
8383
mStagingNetwork.credentialsLen));
8484
mSavedNetwork = mStagingNetwork;
8585
return CHIP_NO_ERROR;

src/platform/bouffalolab/BL602/NetworkCommissioningDriver.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
namespace chip {
2323
namespace DeviceLayer {
2424
namespace NetworkCommissioning {
25-
// #if CHIP_DEVICE_CONFIG_ENABLE_WIFI
25+
2626
namespace {
2727
constexpr uint8_t kMaxWiFiNetworks = 1;
2828
constexpr uint8_t kWiFiScanNetworksTimeOutSeconds = 10;
@@ -134,7 +134,6 @@ class BLWiFiDriver final : public WiFiDriver
134134
NetworkStatusChangeCallback * mpStatusChangeCallback = nullptr;
135135
int32_t mLastDisconnectedReason;
136136
};
137-
// #endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI
138137

139138
} // namespace NetworkCommissioning
140139
} // namespace DeviceLayer

src/platform/bouffalolab/BL702/BUILD.gn

+23-9
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import("//build_overrides/chip.gni")
1717

1818
import("${chip_root}/src/platform/device.gni")
1919

20+
import("${chip_root}/src/platform/bouffalolab/common/args.gni")
21+
2022
assert(chip_device_platform == "bl702")
2123
assert(false == (chip_enable_wifi && chip_enable_openthread),
2224
"Not support Wi-Fi and Thread together")
@@ -31,7 +33,7 @@ static_library("BL702") {
3133
"PlatformManagerImpl.cpp",
3234
]
3335

34-
common_sources = [
36+
sources += [
3537
"../../FreeRTOS/SystemTimeSupport.cpp",
3638
"../../SingletonConfigurationManager.cpp",
3739
"../common/BLConfig.cpp",
@@ -41,12 +43,6 @@ static_library("BL702") {
4143
"../common/KeyValueStoreManagerImpl.cpp",
4244
"../common/Logging.cpp",
4345
"../common/PlatformManagerImpl.cpp",
44-
45-
# "${chip_root}/src/credentials/CHIPCert.h",
46-
# "${chip_root}/src/credentials/DeviceAttestationCredsProvider.h",
47-
48-
# "../common/FactoryDataProvider.cpp",
49-
# "../common/FactoryDataProvider.h",
5046
]
5147

5248
if (chip_enable_ota_requestor) {
@@ -62,9 +58,26 @@ static_library("BL702") {
6258
"../common/BLEManagerImpl.h",
6359
]
6460
}
65-
sources += common_sources
6661

67-
if (chip_enable_openthread) {
62+
defines =
63+
[ "CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE=${chip_enable_factory_data}" ]
64+
if (chip_enable_factory_data || chip_enable_factory_data_test) {
65+
sources += [
66+
"../common/FactoryDataProvider.cpp",
67+
"../common/FactoryDataProvider.h",
68+
]
69+
}
70+
71+
if (chip_enable_wifi) {
72+
sources += [
73+
"ConfigurationManagerImpl.cpp",
74+
"ConnectivityManagerImpl.cpp",
75+
"NetworkCommissioningDriver.cpp",
76+
"WiFiInterface.c",
77+
]
78+
79+
deps = [ "${chip_root}/src/lib/dnssd:platform_header" ]
80+
} else if (chip_enable_openthread) {
6881
# needed for MTD/FTD
6982

7083
import("//build_overrides/bouffalolab_iot_sdk.gni")
@@ -94,5 +107,6 @@ static_library("BL702") {
94107
deps = [ "${chip_root}/src/lib/dnssd:platform_header" ]
95108
}
96109

110+
deps += [ "${chip_root}/src/credentials:credentials_header" ]
97111
public_deps = [ "${chip_root}/src/platform:platform_base" ]
98112
}

0 commit comments

Comments
 (0)