Skip to content

Commit 2a47aee

Browse files
jczhang777wy-hhrestyled-commits
authored
[BL602] Update Bouffa Lab sdk repo (#22106)
* [BL602] Update bl602 sdk and impl. Adjust the directory structure, once again the subsequent addition of other types of chips * [BL602] Fix pwm led * [BL602] Update diagnosis and enable async log * Restyled by whitespace * Restyled by clang-format * Restyled by gn * [BL602] Update submodule * [BL602] Fix compile error * [BL602] Fix compile error * Restyled by gn * Restyled by whitespace * Restyled by clang-format * [BL602] Delete unused code * [BL602] Delete unused code Co-authored-by: wyhong <[email protected]> Co-authored-by: Restyled.io <[email protected]>
1 parent c3e355a commit 2a47aee

31 files changed

+1780
-100
lines changed

.gitmodules

+5-5
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,6 @@
233233
url = https://github.com/TexasInstruments/cc13xx_cc26xx_sdk.git
234234
branch = main
235235
platforms = cc13x2_26x2
236-
[submodule "third_party/bouffalolab/bl602"]
237-
path = third_party/bouffalolab/bl602_sdk/repo
238-
url = https://github.com/bouffalolab/bl_iot_sdk_matter.git
239-
branch = bl602_release
240-
platforms = bl602
241236
[submodule "third_party/ti_simplelink_sdk/repo_cc32xx"]
242237
path = third_party/ti_simplelink_sdk/repo_cc32xx
243238
url = https://github.com/TexasInstruments/cc32xx_open_sdk.git
@@ -273,3 +268,8 @@
273268
[submodule "third_party/boringssl/repo/src"]
274269
path = third_party/boringssl/repo/src
275270
url = https://github.com/google/boringssl.git
271+
[submodule "boufalolab_repo"]
272+
path = third_party/bouffalolab/repo
273+
url = https://github.com/bouffalolab/bl_iot_sdk.git
274+
branch = master
275+
platforms = bl602

build/toolchain/riscv_gcc/riscv_toolchain.gni

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import("${build_root}/toolchain/gcc_toolchain.gni")
1919

2020
template("riscv_toolchain") {
2121
gcc_toolchain(target_name) {
22-
_tool_name_root = "${root_build_dir}/../../third_party/bouffalolab/bl602_sdk/repo/toolchain/riscv/Linux/bin/riscv64-unknown-elf-"
22+
_tool_name_root = "${root_build_dir}/../../third_party/bouffalolab/repo/toolchain/riscv/Linux/bin/riscv64-unknown-elf-"
2323
ar = _tool_name_root + "ar"
2424
cc = _tool_name_root + "gcc"
2525
cxx = _tool_name_root + "g++"

build_overrides/bl602_sdk.gni

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414

1515
declare_args() {
1616
# Root directory for bl602 SDK build files.
17-
bl602_sdk_build_root = "//third_party/bouffalolab/bl602_sdk"
17+
bl602_sdk_build_root = "//third_party/bouffalolab/bl602"
1818
}

config/bouffalolab/bl602/lib/pw_rpc/BUILD.gn

+11
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ import("//build_overrides/chip.gni")
1616
import("//build_overrides/pigweed.gni")
1717
import("$dir_pw_build/target_types.gni")
1818

19+
config("pw_string_config") {
20+
defines = [
21+
"_GLIBCXX_USE_C99_MATH_TR1",
22+
"_LDBL_EQ_DBL",
23+
]
24+
}
25+
26+
pw_source_set("pw_string_dep") {
27+
public_configs = [ ":pw_string_config" ]
28+
}
29+
1930
static_library("pw_rpc") {
2031
output_name = "libPwRpc"
2132

config/bouffalolab/bl602/lib/pw_rpc/pw_rpc.gni

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ pw_sys_io_BACKEND =
2121
"${chip_root}/examples/platform/bouffalolab/bl602/pw_sys_io:pw_sys_io_bl602"
2222
pw_span_ENABLE_STD_SPAN_POLYFILL = false
2323

24+
pw_string_CONFIG =
25+
"${chip_root}/config/bouffalolab/bl602/lib/pw_rpc:pw_string_dep"
26+
2427
pw_build_LINK_DEPS = [
2528
"$dir_pw_assert:impl",
2629
"$dir_pw_log:impl",

examples/build_overrides/bl602_sdk.gni

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
declare_args() {
1616
# Root directory for bl602 SDK.
1717
bl602_sdk_build_root =
18-
"//third_party/connectedhomeip/third_party/bouffalolab/bl602_sdk"
18+
"//third_party/connectedhomeip/third_party/bouffalolab/bl602"
1919
}

examples/lighting-app/bouffalolab/bl602/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ The steps in this document were validated on Ubuntu 18.04 and 20.04.
6464
commands:
6565
6666
```
67-
cd third_party/bouffalolab/bl602_sdk/repo/tools/flash_tool
67+
cd third_party/bouffalolab/repo/tools/flash_tool
6868
6969
./bflb_iot_tool-ubuntu18 --chipname=BL602 --baudrate=115200 --port=/dev/ttyACM0 --pt=chips/bl602/partition/partition_cfg_4M.toml --dts=chips/bl602/device_tree/bl_factory_params_IoTKitA_40M.dts --firmware=../../../../../../out/bl602-light/chip-bl602-lighting-example.bin
7070
```

examples/lighting-app/bouffalolab/bl602/include/CHIPDeviceManager.h

+5-8
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
* activities within the CHIP stack. This is a singleton object.
2525
*/
2626

27-
#ifndef CHIP_LOCK_DEVICEMANAGER_H_
28-
#define CHIP_LOCK_DEVICEMANAGER_H_
27+
#pragma once
2928

3029
#include <lib/core/CHIPCore.h>
3130
#include <lib/core/CHIPError.h>
@@ -58,7 +57,7 @@ class DLL_EXPORT CHIPDeviceManagerCallbacks
5857
* @param event ChipDeviceEvent that occurred
5958
* @param arg arguments specific to the event, if any
6059
*/
61-
virtual void DeviceEventCallback(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg);
60+
void DeviceEventCallback(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg);
6261
/**
6362
* @brief
6463
* Called after an attribute has been changed
@@ -71,10 +70,10 @@ class DLL_EXPORT CHIPDeviceManagerCallbacks
7170
* @param size size of the attribute
7271
* @param value pointer to the new value
7372
*/
74-
virtual void PostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId,
75-
uint8_t type, uint16_t size, uint8_t * value)
73+
void PostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId,
74+
uint8_t type, uint16_t size, uint8_t * value)
7675
{}
77-
virtual ~CHIPDeviceManagerCallbacks() {}
76+
// virtual ~CHIPDeviceManagerCallbacks();
7877
};
7978

8079
/**
@@ -120,5 +119,3 @@ class DLL_EXPORT CHIPDeviceManager
120119

121120
} // namespace DeviceManager
122121
} // namespace chip
123-
124-
#endif /* CHIP_LOCK_DEVICEMANAGER_H_ */

examples/lighting-app/bouffalolab/bl602/src/AppTask.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ BDXDownloader gDownloader;
9292
OTAImageProcessorImpl gImageProcessor;
9393

9494
AppTask AppTask::sAppTask;
95-
static DeviceCallbacks EchoCallbacks;
95+
// static DeviceCallbacks EchoCallbacks;
9696

9797
CHIP_ERROR AppTask::StartAppTask()
9898
{
@@ -153,7 +153,6 @@ CHIP_ERROR AppTask::Init()
153153
PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE));
154154

155155
InitButtons();
156-
157156
#if PW_RPC_ENABLED
158157
chip::rpc::Init();
159158
#endif
@@ -168,6 +167,7 @@ void AppTask::AppTaskMain(void * pvParameter)
168167
CHIP_ERROR err;
169168

170169
log_info("App Task entered\r\n");
170+
log_async_init();
171171
enable_async_log();
172172

173173
err = sWiFiNetworkCommissioningInstance.Init();

examples/lighting-app/bouffalolab/bl602/src/CHIPDeviceManager.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <stdlib.h>
2626

2727
#include "CHIPDeviceManager.h"
28+
#include "DeviceCallbacks.h"
2829
#include <app/ConcreteAttributePath.h>
2930
#include <app/util/basic-types.h>
3031
#include <lib/support/CHIPMem.h>
@@ -42,7 +43,8 @@ using namespace ::chip::DeviceLayer;
4243

4344
void CHIPDeviceManager::CommonDeviceEventHandler(const ChipDeviceEvent * event, intptr_t arg)
4445
{
45-
CHIPDeviceManagerCallbacks * cb = reinterpret_cast<CHIPDeviceManagerCallbacks *>(arg);
46+
// CHIPDeviceManagerCallbacks * cb = reinterpret_cast<CHIPDeviceManagerCallbacks *>(arg);
47+
DeviceCallbacks * cb = reinterpret_cast<DeviceCallbacks *>(arg);
4648
if (cb != nullptr)
4749
{
4850
cb->DeviceEventCallback(event, reinterpret_cast<intptr_t>(cb));

examples/platform/bouffalolab/bl602/InitPlatform.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ void InitPlatform(void)
285285
hal_button_module_init(8, 1000, 4800, 5000);
286286
Platform_Light_Init();
287287
aos_register_event_filter(EV_KEY, event_cb_key_event, NULL);
288+
wifi_td_diagnosis_init();
288289
}
289290

290291
#ifdef __cplusplus

examples/platform/bouffalolab/bl602/ldscripts/flash_rom.ld

+4-4
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ SECTIONS
166166
PROVIDE( _data_run = ADDR(.data) );
167167
PROVIDE( _data_run_end = ADDR(.data) + SIZEOF(.data));
168168

169-
*(.tcm_code)
170-
*(.tcm_const)
171-
*(.sclock_rlt_code)
172-
*(.sclock_rlt_const)
169+
*(.tcm_code*)
170+
*(.tcm_const*)
171+
*(.sclock_rlt_code*)
172+
*(.sclock_rlt_const*)
173173
*(.data .data.*)
174174
*(.gnu.linkonce.d.*)
175175

scripts/examples/gn_bl602_example.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ shift
3838
OUTPUT_DIR=$1
3939
shift
4040

41-
export BL_IOT_SDK_PATH="$MATTER_ROOT"/third_party/bouffalolab/bl602_sdk/repo
41+
export BL_IOT_SDK_PATH="$MATTER_ROOT"/third_party/bouffalolab/repo
4242

4343
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
4444
export PATH="$BL_IOT_SDK_PATH/toolchain/riscv/Linux/bin:$PATH"

src/platform/bouffalolab/BL602/ConfigurationManagerImpl.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg)
216216
CHIP_ERROR err;
217217

218218
ChipLogProgress(DeviceLayer, "Performing factory reset");
219-
ef_port_erase_all();
220219
ChipLogProgress(DeviceLayer, "System restarting");
221220
hal_reboot();
222221
}

src/platform/bouffalolab/BL602/ConnectivityManagerImpl.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
#include <task.h>
5050

5151
#include <lwip/netifapi.h>
52-
#include <mdns_server.h>
5352
#include <wifi_mgmr_ext.h>
5453

5554
#include <FreeRTOS.h>

src/platform/bouffalolab/BL602/DiagnosticDataProviderImpl.cpp

+55-12
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
extern "C" {
3232
#include <bl602_hal/bl_sys.h>
33+
#include <bl60x_fw_api.h>
3334
#include <bl_efuse.h>
3435
#include <bl_main.h>
3536
#include <wifi_mgmr.h>
@@ -204,8 +205,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiBssId(ByteSpan & BssId)
204205
{
205206
static uint8_t macAddress[kMaxHardwareAddrSize];
206207

207-
wifi_mgmr_get_bssid(macAddress);
208-
BssId = ByteSpan(macAddress, 6);
208+
memcpy(macAddress, wifiMgmr.wifi_mgmr_stat_info.bssid, kMaxHardwareAddrSize);
209209

210210
return CHIP_NO_ERROR;
211211
}
@@ -214,8 +214,8 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiSecurityType(uint8_t & securityTyp
214214
{
215215
int authmode;
216216

217-
authmode = mgmr_get_security_type();
218-
securityType = MapAuthModeToSecurityType(authmode);
217+
// authmode = mgmr_get_security_type();
218+
// securityType = MapAuthModeToSecurityType(authmode);
219219
return CHIP_NO_ERROR;
220220
}
221221

@@ -229,21 +229,28 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiChannelNumber(uint16_t & channelNu
229229
{
230230
channelNumber = 0;
231231

232-
channelNumber = mgmr_get_current_channel_num();
232+
// channelNumber = mgmr_get_current_channel_num();
233233

234234
return CHIP_NO_ERROR;
235235
}
236236

237237
CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiRssi(int8_t & rssi)
238238
{
239-
rssi = mgmr_get_rssi();
239+
// rssi = mgmr_get_rssi();
240240

241241
return CHIP_NO_ERROR;
242242
}
243243

244244
CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiBeaconLostCount(uint32_t & beaconLostCount)
245245
{
246-
beaconLostCount = wifi_mgmr_beacon_loss_cnt();
246+
wifi_diagnosis_info_t * info;
247+
248+
info = bl_diagnosis_get();
249+
if (info)
250+
{
251+
beaconLostCount = info->beacon_loss;
252+
}
253+
247254
return CHIP_NO_ERROR;
248255
}
249256

@@ -255,25 +262,53 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiCurrentMaxRate(uint64_t & currentM
255262

256263
CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketMulticastRxCount(uint32_t & packetMulticastRxCount)
257264
{
258-
packetMulticastRxCount = wifi_mgmr_tx_multicast_cnt_get();
265+
wifi_diagnosis_info_t * info;
266+
267+
info = bl_diagnosis_get();
268+
if (info)
269+
{
270+
packetMulticastRxCount = info->multicast_recv;
271+
}
272+
259273
return CHIP_NO_ERROR;
260274
}
261275

262276
CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketMulticastTxCount(uint32_t & packetMulticastTxCount)
263277
{
264-
packetMulticastTxCount = wifi_mgmr_tx_multicast_cnt_get();
278+
wifi_diagnosis_info_t * info;
279+
280+
info = bl_diagnosis_get();
281+
if (info)
282+
{
283+
packetMulticastTxCount = info->multicast_send;
284+
}
285+
265286
return CHIP_NO_ERROR;
266287
}
267288

268289
CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketUnicastRxCount(uint32_t & packetUnicastRxCount)
269290
{
270-
packetUnicastRxCount = wifi_mgmr_rx_unicast_cnt_get();
291+
wifi_diagnosis_info_t * info;
292+
293+
info = bl_diagnosis_get();
294+
if (info)
295+
{
296+
packetUnicastRxCount = info->unicast_recv;
297+
}
298+
271299
return CHIP_NO_ERROR;
272300
}
273301

274302
CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketUnicastTxCount(uint32_t & packetUnicastTxCount)
275303
{
276-
packetUnicastTxCount = wifi_mgmr_tx_unicast_cnt_get();
304+
wifi_diagnosis_info_t * info;
305+
306+
info = bl_diagnosis_get();
307+
if (info)
308+
{
309+
packetUnicastTxCount = info->multicast_send;
310+
}
311+
277312
return CHIP_NO_ERROR;
278313
}
279314

@@ -290,9 +325,17 @@ CHIP_ERROR DiagnosticDataProviderImpl::ResetWiFiNetworkDiagnosticsCounts()
290325

291326
CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiBeaconRxCount(uint32_t & beaconRxCount)
292327
{
293-
beaconRxCount = wifi_mgmr_beacon_recv_cnt();
328+
wifi_diagnosis_info_t * info;
329+
330+
info = bl_diagnosis_get();
331+
if (info)
332+
{
333+
beaconRxCount = info->beacon_recv;
334+
}
335+
294336
return CHIP_NO_ERROR;
295337
}
296338

297339
} // namespace DeviceLayer
340+
wifi_diagnosis_info_t * info;
298341
} // namespace chip

src/platform/bouffalolab/BL602/NetworkCommissioningDriver.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <wifi_mgmr.h>
2626
#include <wifi_mgmr_api.h>
2727
#include <wifi_mgmr_ext.h>
28+
#include <wifi_mgmr_portable.h>
2829

2930
#include <limits>
3031
#include <stdint.h>
@@ -230,7 +231,7 @@ CHIP_ERROR BLWiFiDriver::StartScanWiFiNetworks(ByteSpan ssid)
230231
{
231232
memset(WiFiSSIDStr, 0, sizeof(WiFiSSIDStr));
232233
memcpy(WiFiSSIDStr, ssid.data(), ssid.size());
233-
err = (CHIP_ERROR) wifi_mgmr_scan_adv(NULL, NULL, NULL, 0, WiFiSSIDStr);
234+
err = (CHIP_ERROR) wifi_mgmr_scan_adv(NULL, NULL, NULL, 0, NULL, WiFiSSIDStr, 1, 0);
234235
scan_type = 1;
235236
}
236237
else
@@ -247,7 +248,7 @@ CHIP_ERROR BLWiFiDriver::StartScanWiFiNetworks(ByteSpan ssid)
247248

248249
void BLWiFiDriver::OnScanWiFiNetworkDone()
249250
{
250-
int ap_num;
251+
int ap_num = 0;
251252

252253
ap_num = wifi_mgmr_get_scan_ap_num();
253254
if (!ap_num)

src/platform/bouffalolab/BL602/PlatformManagerImpl.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
#include <tcpip.h>
4444
#include <wifi_mgmr_ext.h>
4545

46+
extern "C" {
47+
#include <bl_sec.h>
48+
}
49+
4650
namespace chip {
4751
namespace DeviceLayer {
4852

@@ -149,9 +153,9 @@ static void WifiStaConnected(void)
149153
}
150154

151155
memset(ap_ssid, 0, sizeof(ap_ssid));
152-
wifi_mgmr_sta_ssid_get(ap_ssid);
153-
wifi_mgmr_ap_item_t * ap_info = mgmr_get_ap_info_handle();
154-
wifi_mgmr_get_scan_result_filter(ap_info, ap_ssid);
156+
// wifi_mgmr_sta_ssid_get(ap_ssid);
157+
// wifi_mgmr_ap_item_t * ap_info = mgmr_get_ap_info_handle();
158+
// wifi_mgmr_get_scan_result_filter(ap_info, ap_ssid);
155159

156160
ConnectivityMgrImpl().ChangeWiFiStationState(ConnectivityManagerImpl::kWiFiStationState_Connected);
157161
ConnectivityMgrImpl().WifiStationStateChange();

0 commit comments

Comments
 (0)