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 1 commit
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
Prev Previous commit
Next Next commit
[BL602] Update diagnosis and enable async log
  • Loading branch information
jczhang777 committed Aug 24, 2022
commit 6f2f254f82150a70b027aa906849631098c26902
5 changes: 3 additions & 2 deletions examples/lighting-app/bouffalolab/bl602/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include <platform/internal/CHIPDeviceLayerInternal.h>

#include <InitPlatform.h>
//#include <async_log.h>
#include <async_log.h>
#include <bl_sys_ota.h>
#include <easyflash.h>
#include <hal_sys.h>
Expand Down Expand Up @@ -167,7 +167,8 @@ void AppTask::AppTaskMain(void * pvParameter)
CHIP_ERROR err;

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

err = sWiFiNetworkCommissioningInstance.Init();
if (CHIP_NO_ERROR != err)
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
60 changes: 51 additions & 9 deletions src/platform/bouffalolab/BL602/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ extern "C" {
#include <bl_main.h>
#include <wifi_mgmr.h>
#include <wifi_mgmr_ext.h>
#include <bl60x_fw_api.h>
}

extern uint8_t _heap_size;
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 Down Expand Up @@ -243,7 +243,14 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiRssi(int8_t & rssi)

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,16 @@ 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
} // namespace chip
wifi_diagnosis_info_t *info;} // namespace chip
13 changes: 9 additions & 4 deletions third_party/bouffalolab/bl602/bl602_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ template("bl602_sdk") {
"${bl602_sdk_root}/components/utils/include/",
"${bl602_sdk_root}/components/platform/soc/bl602/bl602_std/bl602_std/StdDriver/Inc/",
"${bl602_sdk_root}/components/platform/hosal/bl602_hal/",
"${bl602_sdk_root}/components/utils/async_log/",

#bl602 portable
"${chip_root}/third_party/bouffalolab/bl602/portable",

# rebase add
"${bl602_sdk_root}/components/network/wifi_hosal/include",
Expand Down Expand Up @@ -246,6 +248,7 @@ template("bl602_sdk") {
#include defines
"OS_USING_FREERTOS",
"BL602_MATTER_SUPPORT",
"TD_DIAGNOSIS_STA",

]

Expand Down Expand Up @@ -494,9 +497,7 @@ template("bl602_sdk") {
"${bl602_sdk_root}/components/platform/hosal/bl602_hal/hosal_dma.c",
"${bl602_sdk_root}/components/platform/hosal/bl602_hal/hosal_pwm.c",
"${bl602_sdk_root}/components/platform/hosal/bl602_hal/hosal_uart.c",
"${bl602_sdk_root}/components/platform/soc/bl602/bl602/bfl_main.c",
"${bl602_sdk_root}/components/platform/soc/bl602/bl602/evb/src/boot/gcc/start.S",
"${bl602_sdk_root}/components/platform/soc/bl602/bl602/evb/src/debug.c",
"${bl602_sdk_root}/components/platform/soc/bl602/bl602/evb/src/strntoumax.c",
"${bl602_sdk_root}/components/platform/soc/bl602/bl602_std/bl602_std/Common/platform_print/platform_device.c",
"${bl602_sdk_root}/components/platform/soc/bl602/bl602_std/bl602_std/StdDriver/Src/bl602_dma.c",
Expand Down Expand Up @@ -544,7 +545,6 @@ template("bl602_sdk") {
"${bl602_sdk_root}/components/sys/bloop/looprt/src/looprt.c",
"${bl602_sdk_root}/components/sys/bloop/loopset/src/loopset_led.c",
"${bl602_sdk_root}/components/sys/bltime/bl_sys_time.c",
#"${bl602_sdk_root}/components/utils/async_log/async_log.c",
"${bl602_sdk_root}/components/utils/src/utils_crc.c",
"${bl602_sdk_root}/components/utils/src/utils_dns.c",
"${bl602_sdk_root}/components/utils/src/utils_hmac_sha1_fast.c",
Expand All @@ -565,6 +565,11 @@ template("bl602_sdk") {
"${bl602_sdk_root}/components/platform/hosal/sec_common/bl_sec_aes.c",
"${bl602_sdk_root}/components/security/blcrypto_suite/src/blcrypto_suite_supplicant_api.c",

#bl602 portable
"${chip_root}/third_party/bouffalolab/bl602/portable/debug.c",
"${chip_root}/third_party/bouffalolab/bl602/portable/async_log.c",
"${chip_root}/third_party/bouffalolab/bl602/portable/bfl_main.c",

#wap_supplicant
"${bl602_sdk_root}/components/security/wpa_supplicant/port/os_bl.c",
"${bl602_sdk_root}/components/security/wpa_supplicant/src/ap/ap_config.c",
Expand Down
86 changes: 86 additions & 0 deletions third_party/bouffalolab/bl602/portable/async_log.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#include <stdio.h>

#include <FreeRTOS.h>
#include <task.h>
#include <semphr.h>
#include <stream_buffer.h>

#define STREAM_BUFF_SIZE 512

StreamBufferHandle_t xStreamBuffer;
static int enable_async_log_flag = 0;

typedef void (*pop_callback)(void*, void* src, const uint16_t len);

int uring_fifo_init()
{
xStreamBuffer = xStreamBufferCreate(STREAM_BUFF_SIZE, 1);

if (xStreamBuffer == NULL) {
return -1;
}

return 0;
}

int async_log_push(const void* buf, const uint16_t len)
{
int xBytesSent;

const TickType_t xBlockTime = pdMS_TO_TICKS(10);
xBytesSent = xStreamBufferSend(xStreamBuffer, (void *)buf, len, 0);

if (xBytesSent != len) {
return -1;
}
}

int async_log_pop_cb(pop_callback cb, void* cb_arg)
{
char tmp_buf[256];
size_t rcv_size = 0;

rcv_size = xStreamBufferReceive(xStreamBuffer, (void *)tmp_buf, sizeof(tmp_buf), portMAX_DELAY);

if (cb != NULL) {
cb(cb_arg, tmp_buf, (uint16_t)rcv_size);
}

return 0;
}
static void log_handler(void* para, void* log_text, const uint16_t log_len)
{
if ((log_text != NULL) && log_len > 0) {
puts(log_text);
}
}

static void log_routine(void* para)
{
while (1) {
async_log_pop_cb(log_handler, NULL);
}
}

void log_async_init(void)
{
int ret;

TaskHandle_t async_log_task;
ret = uring_fifo_init();
if (ret < 0) {
puts("stream buff init fail.\r\n");
}

xTaskCreate(log_routine, (char*)"async_log", 1024, NULL, 15, &async_log_task);
}

int async_log(void)
{
return enable_async_log_flag;
}

void enable_async_log(void)
{
enable_async_log_flag = 1;
}
17 changes: 17 additions & 0 deletions third_party/bouffalolab/bl602/portable/async_log.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef __ASYNC_LOT_H_
#define __ASYNC_LOT_H_

#ifdef __cplusplus
extern "C" {
#endif


int async_log_push(const void* buf, const uint16_t len);
void log_async_init(void);
void enable_async_log(void);
int async_log(void);

#ifdef __cplusplus
}
#endif
#endif
Loading