Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BL602] Update Bouffa Lab sdk repo #22106

Merged
merged 23 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,6 @@
url = https://github.com/TexasInstruments/cc13xx_cc26xx_sdk.git
branch = main
platforms = cc13x2_26x2
[submodule "third_party/bouffalolab/bl602"]
path = third_party/bouffalolab/bl602_sdk/repo
url = https://github.com/bouffalolab/bl_iot_sdk_matter.git
branch = bl602_release
platforms = bl602
[submodule "third_party/ti_simplelink_sdk/repo_cc32xx"]
path = third_party/ti_simplelink_sdk/repo_cc32xx
url = https://github.com/TexasInstruments/cc32xx_open_sdk.git
Expand Down Expand Up @@ -273,3 +268,8 @@
[submodule "third_party/boringssl/repo/src"]
path = third_party/boringssl/repo/src
url = https://github.com/google/boringssl.git
[submodule "boufalolab_repo"]
path = third_party/bouffalolab/repo
url = https://github.com/bouffalolab/bl_iot_sdk.git
branch = master
platforms = bl602
2 changes: 1 addition & 1 deletion build/toolchain/riscv_gcc/riscv_toolchain.gni
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import("${build_root}/toolchain/gcc_toolchain.gni")

template("riscv_toolchain") {
gcc_toolchain(target_name) {
_tool_name_root = "${root_build_dir}/../../third_party/bouffalolab/bl602_sdk/repo/toolchain/riscv/Linux/bin/riscv64-unknown-elf-"
_tool_name_root = "${root_build_dir}/../../third_party/bouffalolab/repo/toolchain/riscv/Linux/bin/riscv64-unknown-elf-"
ar = _tool_name_root + "ar"
cc = _tool_name_root + "gcc"
cxx = _tool_name_root + "g++"
Expand Down
2 changes: 1 addition & 1 deletion build_overrides/bl602_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@

declare_args() {
# Root directory for bl602 SDK build files.
bl602_sdk_build_root = "//third_party/bouffalolab/bl602_sdk"
bl602_sdk_build_root = "//third_party/bouffalolab/bl602"
}
11 changes: 11 additions & 0 deletions config/bouffalolab/bl602/lib/pw_rpc/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ import("//build_overrides/chip.gni")
import("//build_overrides/pigweed.gni")
import("$dir_pw_build/target_types.gni")

config("pw_string_config") {
defines = [
"_GLIBCXX_USE_C99_MATH_TR1",
"_LDBL_EQ_DBL",
]
}

pw_source_set("pw_string_dep") {
public_configs = [ ":pw_string_config" ]
}

static_library("pw_rpc") {
output_name = "libPwRpc"

Expand Down
3 changes: 3 additions & 0 deletions config/bouffalolab/bl602/lib/pw_rpc/pw_rpc.gni
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ pw_sys_io_BACKEND =
"${chip_root}/examples/platform/bouffalolab/bl602/pw_sys_io:pw_sys_io_bl602"
pw_span_ENABLE_STD_SPAN_POLYFILL = false

pw_string_CONFIG =
"${chip_root}/config/bouffalolab/bl602/lib/pw_rpc:pw_string_dep"

pw_build_LINK_DEPS = [
"$dir_pw_assert:impl",
"$dir_pw_log:impl",
Expand Down
2 changes: 1 addition & 1 deletion examples/build_overrides/bl602_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
declare_args() {
# Root directory for bl602 SDK.
bl602_sdk_build_root =
"//third_party/connectedhomeip/third_party/bouffalolab/bl602_sdk"
"//third_party/connectedhomeip/third_party/bouffalolab/bl602"
}
2 changes: 1 addition & 1 deletion examples/lighting-app/bouffalolab/bl602/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ The steps in this document were validated on Ubuntu 18.04 and 20.04.
commands:

```
cd third_party/bouffalolab/bl602_sdk/repo/tools/flash_tool
cd third_party/bouffalolab/repo/tools/flash_tool

./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
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
* activities within the CHIP stack. This is a singleton object.
*/

#ifndef CHIP_LOCK_DEVICEMANAGER_H_
#define CHIP_LOCK_DEVICEMANAGER_H_
#pragma once

#include <lib/core/CHIPCore.h>
#include <lib/core/CHIPError.h>
Expand Down Expand Up @@ -58,7 +57,7 @@ class DLL_EXPORT CHIPDeviceManagerCallbacks
* @param event ChipDeviceEvent that occurred
* @param arg arguments specific to the event, if any
*/
virtual void DeviceEventCallback(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg);
void DeviceEventCallback(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg);
/**
* @brief
* Called after an attribute has been changed
Expand All @@ -71,10 +70,10 @@ class DLL_EXPORT CHIPDeviceManagerCallbacks
* @param size size of the attribute
* @param value pointer to the new value
*/
virtual void PostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId,
uint8_t type, uint16_t size, uint8_t * value)
void PostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId,
uint8_t type, uint16_t size, uint8_t * value)
{}
virtual ~CHIPDeviceManagerCallbacks() {}
// virtual ~CHIPDeviceManagerCallbacks();
};

/**
Expand Down Expand Up @@ -120,5 +119,3 @@ class DLL_EXPORT CHIPDeviceManager

} // namespace DeviceManager
} // namespace chip

#endif /* CHIP_LOCK_DEVICEMANAGER_H_ */
4 changes: 2 additions & 2 deletions examples/lighting-app/bouffalolab/bl602/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ BDXDownloader gDownloader;
OTAImageProcessorImpl gImageProcessor;

AppTask AppTask::sAppTask;
static DeviceCallbacks EchoCallbacks;
// static DeviceCallbacks EchoCallbacks;

CHIP_ERROR AppTask::StartAppTask()
{
Expand Down Expand Up @@ -153,7 +153,6 @@ CHIP_ERROR AppTask::Init()
PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE));

InitButtons();

#if PW_RPC_ENABLED
chip::rpc::Init();
#endif
Expand All @@ -168,6 +167,7 @@ void AppTask::AppTaskMain(void * pvParameter)
CHIP_ERROR err;

log_info("App Task entered\r\n");
log_async_init();
enable_async_log();

err = sWiFiNetworkCommissioningInstance.Init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <stdlib.h>

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

void CHIPDeviceManager::CommonDeviceEventHandler(const ChipDeviceEvent * event, intptr_t arg)
{
CHIPDeviceManagerCallbacks * cb = reinterpret_cast<CHIPDeviceManagerCallbacks *>(arg);
// CHIPDeviceManagerCallbacks * cb = reinterpret_cast<CHIPDeviceManagerCallbacks *>(arg);
DeviceCallbacks * cb = reinterpret_cast<DeviceCallbacks *>(arg);
if (cb != nullptr)
{
cb->DeviceEventCallback(event, reinterpret_cast<intptr_t>(cb));
Expand Down
1 change: 1 addition & 0 deletions examples/platform/bouffalolab/bl602/InitPlatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ void InitPlatform(void)
hal_button_module_init(8, 1000, 4800, 5000);
Platform_Light_Init();
aos_register_event_filter(EV_KEY, event_cb_key_event, NULL);
wifi_td_diagnosis_init();
}

#ifdef __cplusplus
Expand Down
8 changes: 4 additions & 4 deletions examples/platform/bouffalolab/bl602/ldscripts/flash_rom.ld
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ SECTIONS
PROVIDE( _data_run = ADDR(.data) );
PROVIDE( _data_run_end = ADDR(.data) + SIZEOF(.data));

*(.tcm_code)
*(.tcm_const)
*(.sclock_rlt_code)
*(.sclock_rlt_const)
*(.tcm_code*)
*(.tcm_const*)
*(.sclock_rlt_code*)
*(.sclock_rlt_const*)
*(.data .data.*)
*(.gnu.linkonce.d.*)

Expand Down
2 changes: 1 addition & 1 deletion scripts/examples/gn_bl602_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ shift
OUTPUT_DIR=$1
shift

export BL_IOT_SDK_PATH="$MATTER_ROOT"/third_party/bouffalolab/bl602_sdk/repo
export BL_IOT_SDK_PATH="$MATTER_ROOT"/third_party/bouffalolab/repo

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
export PATH="$BL_IOT_SDK_PATH/toolchain/riscv/Linux/bin:$PATH"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg)
CHIP_ERROR err;

ChipLogProgress(DeviceLayer, "Performing factory reset");
ef_port_erase_all();
ChipLogProgress(DeviceLayer, "System restarting");
hal_reboot();
}
Expand Down
1 change: 0 additions & 1 deletion src/platform/bouffalolab/BL602/ConnectivityManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
#include <task.h>

#include <lwip/netifapi.h>
#include <mdns_server.h>
#include <wifi_mgmr_ext.h>

#include <FreeRTOS.h>
Expand Down
67 changes: 55 additions & 12 deletions src/platform/bouffalolab/BL602/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

extern "C" {
#include <bl602_hal/bl_sys.h>
#include <bl60x_fw_api.h>
#include <bl_efuse.h>
#include <bl_main.h>
#include <wifi_mgmr.h>
Expand Down Expand Up @@ -204,8 +205,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiBssId(ByteSpan & BssId)
{
static uint8_t macAddress[kMaxHardwareAddrSize];

wifi_mgmr_get_bssid(macAddress);
BssId = ByteSpan(macAddress, 6);
memcpy(macAddress, wifiMgmr.wifi_mgmr_stat_info.bssid, kMaxHardwareAddrSize);

return CHIP_NO_ERROR;
}
Expand All @@ -214,8 +214,8 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiSecurityType(uint8_t & securityTyp
{
int authmode;

authmode = mgmr_get_security_type();
securityType = MapAuthModeToSecurityType(authmode);
// authmode = mgmr_get_security_type();
// securityType = MapAuthModeToSecurityType(authmode);
return CHIP_NO_ERROR;
}

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

channelNumber = mgmr_get_current_channel_num();
// channelNumber = mgmr_get_current_channel_num();

return CHIP_NO_ERROR;
}

CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiRssi(int8_t & rssi)
{
rssi = mgmr_get_rssi();
// rssi = mgmr_get_rssi();

return CHIP_NO_ERROR;
}

CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiBeaconLostCount(uint32_t & beaconLostCount)
{
beaconLostCount = wifi_mgmr_beacon_loss_cnt();
wifi_diagnosis_info_t * info;

info = bl_diagnosis_get();
if (info)
{
beaconLostCount = info->beacon_loss;
}

return CHIP_NO_ERROR;
}

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

CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketMulticastRxCount(uint32_t & packetMulticastRxCount)
{
packetMulticastRxCount = wifi_mgmr_tx_multicast_cnt_get();
wifi_diagnosis_info_t * info;

info = bl_diagnosis_get();
if (info)
{
packetMulticastRxCount = info->multicast_recv;
}

return CHIP_NO_ERROR;
}

CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketMulticastTxCount(uint32_t & packetMulticastTxCount)
{
packetMulticastTxCount = wifi_mgmr_tx_multicast_cnt_get();
wifi_diagnosis_info_t * info;

info = bl_diagnosis_get();
if (info)
{
packetMulticastTxCount = info->multicast_send;
}

return CHIP_NO_ERROR;
}

CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketUnicastRxCount(uint32_t & packetUnicastRxCount)
{
packetUnicastRxCount = wifi_mgmr_rx_unicast_cnt_get();
wifi_diagnosis_info_t * info;

info = bl_diagnosis_get();
if (info)
{
packetUnicastRxCount = info->unicast_recv;
}

return CHIP_NO_ERROR;
}

CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketUnicastTxCount(uint32_t & packetUnicastTxCount)
{
packetUnicastTxCount = wifi_mgmr_tx_unicast_cnt_get();
wifi_diagnosis_info_t * info;

info = bl_diagnosis_get();
if (info)
{
packetUnicastTxCount = info->multicast_send;
}

return CHIP_NO_ERROR;
}

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

CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiBeaconRxCount(uint32_t & beaconRxCount)
{
beaconRxCount = wifi_mgmr_beacon_recv_cnt();
wifi_diagnosis_info_t * info;

info = bl_diagnosis_get();
if (info)
{
beaconRxCount = info->beacon_recv;
}

return CHIP_NO_ERROR;
}

} // namespace DeviceLayer
wifi_diagnosis_info_t * info;
} // namespace chip
5 changes: 3 additions & 2 deletions src/platform/bouffalolab/BL602/NetworkCommissioningDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <wifi_mgmr.h>
#include <wifi_mgmr_api.h>
#include <wifi_mgmr_ext.h>
#include <wifi_mgmr_portable.h>

#include <limits>
#include <stdint.h>
Expand Down Expand Up @@ -230,7 +231,7 @@ CHIP_ERROR BLWiFiDriver::StartScanWiFiNetworks(ByteSpan ssid)
{
memset(WiFiSSIDStr, 0, sizeof(WiFiSSIDStr));
memcpy(WiFiSSIDStr, ssid.data(), ssid.size());
err = (CHIP_ERROR) wifi_mgmr_scan_adv(NULL, NULL, NULL, 0, WiFiSSIDStr);
err = (CHIP_ERROR) wifi_mgmr_scan_adv(NULL, NULL, NULL, 0, NULL, WiFiSSIDStr, 1, 0);
scan_type = 1;
}
else
Expand All @@ -247,7 +248,7 @@ CHIP_ERROR BLWiFiDriver::StartScanWiFiNetworks(ByteSpan ssid)

void BLWiFiDriver::OnScanWiFiNetworkDone()
{
int ap_num;
int ap_num = 0;

ap_num = wifi_mgmr_get_scan_ap_num();
if (!ap_num)
Expand Down
10 changes: 7 additions & 3 deletions src/platform/bouffalolab/BL602/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
#include <tcpip.h>
#include <wifi_mgmr_ext.h>

extern "C" {
#include <bl_sec.h>
}

namespace chip {
namespace DeviceLayer {

Expand Down Expand Up @@ -149,9 +153,9 @@ static void WifiStaConnected(void)
}

memset(ap_ssid, 0, sizeof(ap_ssid));
wifi_mgmr_sta_ssid_get(ap_ssid);
wifi_mgmr_ap_item_t * ap_info = mgmr_get_ap_info_handle();
wifi_mgmr_get_scan_result_filter(ap_info, ap_ssid);
// wifi_mgmr_sta_ssid_get(ap_ssid);
// wifi_mgmr_ap_item_t * ap_info = mgmr_get_ap_info_handle();
// wifi_mgmr_get_scan_result_filter(ap_info, ap_ssid);

ConnectivityMgrImpl().ChangeWiFiStationState(ConnectivityManagerImpl::kWiFiStationState_Connected);
ConnectivityMgrImpl().WifiStationStateChange();
Expand Down
Loading