Skip to content

Commit

Permalink
add bl706 wifi support
Browse files Browse the repository at this point in the history
  • Loading branch information
wy-hh committed Jul 27, 2023
1 parent 426be96 commit db6901b
Show file tree
Hide file tree
Showing 27 changed files with 1,156 additions and 63 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/examples-bouffalolab.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target bouffalolab-bl602-iot-matter-v1-light \
--target bouffalolab-bl602-night-light-light \
--target bouffalolab-bl602-iot-matter-v1-light-115200-rpc \
build \
--copy-artifacts-to out/artifacts \
Expand All @@ -64,7 +64,7 @@ jobs:
run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
bl602 bl602 lighting-app \
out/artifacts/bouffalolab-bl602-iot-matter-v1-light/chip-bl602-lighting-example.out \
out/artifacts/bouffalolab-bl602-night-light-light/chip-bl602-lighting-example.out \
/tmp/bloat_reports/
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
bl602 bl602+rpc lighting-app \
Expand All @@ -77,7 +77,9 @@ jobs:
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target bouffalolab-xt-zb6-devkit-light \
--target bouffalolab-bl706-night-light-light \
--target bouffalolab-bl706-eth-light \
--target bouffalolab-bl706-wifi-light \
--target bouffalolab-xt-zb6-devkit-light-115200-rpc \
build \
--copy-artifacts-to out/artifacts \
Expand All @@ -86,7 +88,15 @@ jobs:
run: |
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
bl702 bl702 lighting-app \
out/artifacts/bouffalolab-xt-zb6-devkit-light/chip-bl702-lighting-example.out \
out/artifacts/bouffalolab-bl706-night-light-light/chip-bl702-lighting-example.out \
/tmp/bloat_reports/
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
bl702 bl706-eth lighting-app \
out/artifacts/bouffalolab-bl706-eth-light/chip-bl702-lighting-example.out \
/tmp/bloat_reports/
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
bl702 bl706-wifi lighting-app \
out/artifacts/bouffalolab-bl706-wifi-light/chip-bl702-lighting-example.out \
/tmp/bloat_reports/
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
bl702 bl702+rpc lighting-app \
Expand Down
1 change: 1 addition & 0 deletions examples/lighting-app/bouffalolab/bl602/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import("${bouffalolab_iot_sdk_build_root}/common/bouffalolab_executable.gni")
import("${build_root}/config/defaults.gni")
import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")
import("${chip_root}/src/platform/device.gni")
import("${chip_root}/src/platform/bouffalolab/common/args.gni")

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

Expand Down
6 changes: 0 additions & 6 deletions examples/lighting-app/bouffalolab/bl602/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,3 @@
#define CHIP_SYSTEM_CRYPTO_HEADER_RESERVE_SIZE 128

#define CHIP_BLE_DEVICE_NAME "MatterLight"

/** Please contact Bouffalo Lab for how to use factory data provider */
// #define CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE 1
// uncomment out the following macro to use factory test data
// when CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE sets to 1
// #define CONFIG_BOUFFALOLAB_FACTORY_DATA_TEST
3 changes: 3 additions & 0 deletions examples/lighting-app/bouffalolab/bl702/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,11 @@ bouffalolab_executable("lighting_app") {
defines += [ "BL706_NIGHT_LIGHT" ]
} else if ("BL706-ETH" == board) {
defines += [ "BL706_ETHERNET" ]
} else if ("BL706-WIFI" == board) {
defines += [ "BL706_WIFI" ]
}


if (defined(enable_cdc_module) && enable_cdc_module) {
defines += [ "CFG_USB_CDC_ENABLE" ]
}
Expand Down
1 change: 1 addition & 0 deletions examples/platform/bouffalolab/common/plat/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ extern "C" {
#include <rom_lmac154_ext.h>
#endif

#include <uart.h>
#include "board.h"
#include <uart.h>
}
Expand Down
4 changes: 0 additions & 4 deletions examples/platform/bouffalolab/common/plat/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,6 @@ void ChipEventHandler(const ChipDeviceEvent * event, intptr_t arg)

CHIP_ERROR PlatformManagerImpl::PlatformInit(void)
{
#if CONFIG_ENABLE_CHIP_SHELL || PW_RPC_ENABLED
uartInit();
#endif

#if PW_RPC_ENABLED
PigweedLogger::pw_init();
#elif CONFIG_ENABLE_CHIP_SHELL
Expand Down
2 changes: 2 additions & 0 deletions scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,8 @@ def BuildBouffalolabTarget():
board=BouffalolabBoard.BL706_NIGHT_LIGHT, module_type="BL706C-22"),
TargetPart('BL706-ETH',
board=BouffalolabBoard.BL706_ETH, module_type="BL706C-22"),
TargetPart('BL706-WIFI',
board=BouffalolabBoard.BL706_WIFI, module_type="BL706C-22"),
TargetPart('BL704L-DVK', board=BouffalolabBoard.BL704L_DVK, module_type="BL704L"),
])

Expand Down
6 changes: 6 additions & 0 deletions scripts/build/builders/bouffalolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class BouffalolabBoard(Enum):
XT_ZB6_DevKit = auto()
BL706_NIGHT_LIGHT = auto()
BL706_ETH = auto()
BL706_WIFI = auto()
BL704L_DVK = auto()

def GnArgName(self):
Expand All @@ -60,6 +61,8 @@ def GnArgName(self):
return 'BL706-NIGHT-LIGHT'
elif self == BouffalolabBoard.BL706_ETH:
return 'BL706-ETH'
elif self == BouffalolabBoard.BL706_WIFI:
return 'BL706-WIFI'
elif self == BouffalolabBoard.BL704L_DVK:
return 'BL704L-DVK'
else:
Expand Down Expand Up @@ -120,6 +123,9 @@ def __init__(self,
self.argsOpt.append('chip_config_network_layer_ble=false')
self.argsOpt.append('chip_enable_openthread=false')
self.argsOpt.append('chip_enable_wifi=false')
elif board == BouffalolabBoard.BL706_WIFI:
self.argsOpt.append('chip_enable_openthread=false')
self.argsOpt.append('chip_enable_wifi=true')
else:
self.argsOpt.append('chip_enable_openthread=true')
self.argsOpt.append('chip_enable_wifi=false')
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,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]
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]
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]
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]
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
46 changes: 45 additions & 1 deletion scripts/examples/gn_bouffalolab_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ source "$MATTER_ROOT/scripts/activate.sh"
bl602_boards=("BL602-IoT-Matter-V1" "BL602-NIGHT-LIGHT")
bl602_module_type="BL602"

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

bl702l_boards=("BL704L-DVK")
bl702l_modules=("BL702L")
bl702l_module_type="BL704l"


print_help() {
bl602_boards_help=""
for board in "${bl602_boards[@]}"; do
Expand All @@ -39,6 +44,10 @@ print_help() {
for board in "${bl702_boards[@]}"; do
bl702_boards_help=$bl702_boards_help$board"\n "
done
bl702l_boards_help=""
for board in "${bl702l_boards[@]}"; do
bl702l_boards_help=$bl702l_boards_help$board"\n "
done

echo -e "Build script for Bouffalolab Matter examples
Format:
Expand All @@ -55,6 +64,7 @@ print_help() {
Currently Supported :
$bl602_boards_help
$bl702_boards_help
$bl702l_boards_help
<Build options> - optional noteworthy build options for Bouffalolab IOT Matter examples
chip_build_libshell
Enable libshell support. (Default false)
Expand Down Expand Up @@ -120,6 +130,9 @@ else
optArgs=board=\"$board_name\"" "$optArgs
optArgs=module_type=\"$bl602_module_type\"" "$optArgs
optArgs=baudrate=\"$baudrate\"" "$optArgs
optArgs=baudrate=\"$baudrate\"" "$optArgs
optArgs=chip_enable_openthread=false" "$optArgs
optArgs=chip_enable_wifi=true" "$optArgs

elif [[ "${bl702_boards[@]}" =~ "$board_name" ]]; then
bouffalo_chip="bl702"
Expand All @@ -136,6 +149,37 @@ else
fi

optArgs=baudrate=\"$baudrate\"" "$optArgs

if [[ "$board_name" == "BL706-ETH" ]]; then
optArgs=chip_config_network_layer_ble=false" "$optArgs
optArgs=chip_enable_openthread=false" "$optArgs
optArgs=chip_enable_wifi=false" "$optArgs
elif [[ "$board_name" == "BL706-WIFI" ]]; then
optArgs=chip_enable_openthread=false" "$optArgs
optArgs=chip_enable_wifi=true" "$optArgs
else
optArgs=chip_enable_openthread=true" "$optArgs
optArgs=chip_enable_wifi=false" "$optArgs
fi

elif [[ "${bl702l_boards[@]}" =~ "$board_name" ]]; then
bouffalo_chip="bl702l"

optArgs=board=\"$board_name\"" "$optArgs

if [[ "$module_type" != "" ]]; then
if [[ ! "${bl702l_modules[@]}" =~ "$module_type" ]]; then
echo "Module $module_type is not supported."
exit 1
fi

optArgs=module_type=\"$module_type\"" "$optArgs
fi

optArgs=baudrate=\"$baudrate\"" "$optArgs
optArgs=chip_enable_openthread=true" "$optArgs
optArgs=chip_enable_wifi=false" "$optArgs

else
echo "Board $board_name is not supported."
exit 1
Expand Down
23 changes: 17 additions & 6 deletions src/platform/bouffalolab/BL602/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import("//build_overrides/chip.gni")

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

import("${chip_root}/src/platform/bouffalolab/common/args.gni")

assert(chip_device_platform == "bl602")

static_library("BL602") {
Expand All @@ -30,34 +32,43 @@ static_library("BL602") {
]

common_sources = [
"${chip_root}/src/credentials/CHIPCert.h",
"${chip_root}/src/credentials/DeviceAttestationCredsProvider.h",
"../../FreeRTOS/SystemTimeSupport.cpp",
"../../SingletonConfigurationManager.cpp",
"../common/BLConfig.cpp",
"../common/ConfigurationManagerImpl.cpp",
"../common/ConnectivityManagerImpl.cpp",
"../common/DiagnosticDataProviderImpl.cpp",
"../common/FactoryDataProvider.cpp",
"../common/FactoryDataProvider.h",
"../common/KeyValueStoreManagerImpl.cpp",
"../common/Logging.cpp",
"../common/PlatformManagerImpl.cpp",
]

if (chip_enable_ota_requestor) {
sources += [
common_sources += [
"../common/OTAImageProcessorImpl.cpp",
"../common/OTAImageProcessorImpl.h",
]
}

if (chip_enable_ble) {
sources += [
common_sources += [
"../common/BLEManagerImpl.cpp",
"../common/BLEManagerImpl.h",
]
}

if (chip_enable_factory_data || chip_enable_factory_data_test) {
if (chip_enable_factory_data) {
defines = [ "CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE" ]
}
common_sources += [
"${chip_root}/src/credentials/CHIPCert.h",
"${chip_root}/src/credentials/DeviceAttestationCredsProvider.h",
"../common/FactoryDataProvider.cpp",
"../common/FactoryDataProvider.h",
]
}

sources += common_sources

deps = [ "${chip_root}/src/lib/dnssd:platform_header" ]
Expand Down
8 changes: 4 additions & 4 deletions src/platform/bouffalolab/BL602/NetworkCommissioningDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ CHIP_ERROR BLWiFiDriver::Init(NetworkStatusChangeCallback * networkStatusChangeC
size_t ssidLen = 0;
size_t credentialsLen = 0;

err = PersistedStorage::KeyValueStoreMgr().Get(BLConfig::kBLConfigKey_wifissid, mSavedNetwork.credentials,
err = PersistedStorage::KeyValueStoreMgr().Get(BLConfig::kConfigKey_WiFiSSID, mSavedNetwork.credentials,
sizeof(mSavedNetwork.credentials), &credentialsLen);
SuccessOrExit(err);
err = PersistedStorage::KeyValueStoreMgr().Get(BLConfig::kBLConfigKey_wifipassword, mSavedNetwork.ssid,
err = PersistedStorage::KeyValueStoreMgr().Get(BLConfig::kConfigKey_WiFiPassword, mSavedNetwork.ssid,
sizeof(mSavedNetwork.ssid), &ssidLen);
SuccessOrExit(err);

Expand Down Expand Up @@ -78,8 +78,8 @@ CHIP_ERROR BLWiFiDriver::CommitConfiguration()
{
ChipLogProgress(NetworkProvisioning, "BLWiFiDriver::CommitConfiguration");
ReturnErrorOnFailure(
PersistedStorage::KeyValueStoreMgr().Put(BLConfig::kBLConfigKey_wifissid, mStagingNetwork.ssid, mStagingNetwork.ssidLen));
ReturnErrorOnFailure(PersistedStorage::KeyValueStoreMgr().Put(BLConfig::kBLConfigKey_wifipassword, mStagingNetwork.credentials,
PersistedStorage::KeyValueStoreMgr().Put(BLConfig::kConfigKey_WiFiSSID, mStagingNetwork.ssid, mStagingNetwork.ssidLen));
ReturnErrorOnFailure(PersistedStorage::KeyValueStoreMgr().Put(BLConfig::kConfigKey_WiFiPassword, mStagingNetwork.credentials,
mStagingNetwork.credentialsLen));
mSavedNetwork = mStagingNetwork;
return CHIP_NO_ERROR;
Expand Down
3 changes: 1 addition & 2 deletions src/platform/bouffalolab/BL602/NetworkCommissioningDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
namespace chip {
namespace DeviceLayer {
namespace NetworkCommissioning {
// #if CHIP_DEVICE_CONFIG_ENABLE_WIFI

namespace {
constexpr uint8_t kMaxWiFiNetworks = 1;
constexpr uint8_t kWiFiScanNetworksTimeOutSeconds = 10;
Expand Down Expand Up @@ -134,7 +134,6 @@ class BLWiFiDriver final : public WiFiDriver
NetworkStatusChangeCallback * mpStatusChangeCallback = nullptr;
int32_t mLastDisconnectedReason;
};
// #endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI

} // namespace NetworkCommissioning
} // namespace DeviceLayer
Expand Down
36 changes: 27 additions & 9 deletions src/platform/bouffalolab/BL702/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import("//build_overrides/chip.gni")

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

import("${chip_root}/src/platform/bouffalolab/common/args.gni")

assert(chip_device_platform == "bl702")
assert(false == (chip_enable_wifi && chip_enable_openthread),
"Not support Wi-Fi and Thread together")
Expand All @@ -41,30 +43,46 @@ static_library("BL702") {
"../common/KeyValueStoreManagerImpl.cpp",
"../common/Logging.cpp",
"../common/PlatformManagerImpl.cpp",

# "${chip_root}/src/credentials/CHIPCert.h",
# "${chip_root}/src/credentials/DeviceAttestationCredsProvider.h",

# "../common/FactoryDataProvider.cpp",
# "../common/FactoryDataProvider.h",
]

if (chip_enable_ota_requestor) {
sources += [
common_sources += [
"../common/OTAImageProcessorImpl.cpp",
"../common/OTAImageProcessorImpl.h",
]
}

if (chip_enable_ble) {
sources += [
common_sources += [
"../common/BLEManagerImpl.cpp",
"../common/BLEManagerImpl.h",
]
}

if (chip_enable_factory_data || chip_enable_factory_data_test) {
if (chip_enable_factory_data) {
defines = [ "CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE" ]
}
common_sources += [
"${chip_root}/src/credentials/CHIPCert.h",
"${chip_root}/src/credentials/DeviceAttestationCredsProvider.h",
"../common/FactoryDataProvider.cpp",
"../common/FactoryDataProvider.h",
]
}

sources += common_sources

if (chip_enable_openthread) {
if (chip_enable_wifi) {
sources += [
"ConfigurationManagerImpl.cpp",
"WiFiInterface.c",
"ConnectivityManagerImpl.cpp",
"NetworkCommissioningDriver.cpp"
]

deps = [ "${chip_root}/src/lib/dnssd:platform_header" ]
} else if (chip_enable_openthread) {
# needed for MTD/FTD

import("//build_overrides/bouffalolab_iot_sdk.gni")
Expand Down
Loading

0 comments on commit db6901b

Please sign in to comment.