Skip to content

Commit

Permalink
fix compile error
Browse files Browse the repository at this point in the history
  • Loading branch information
wy-hh committed Aug 30, 2023
1 parent ecefed1 commit 5ca5359
Show file tree
Hide file tree
Showing 20 changed files with 133 additions and 72 deletions.
21 changes: 1 addition & 20 deletions examples/lighting-app/bouffalolab/bl702/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import("${chip_root}/src/platform/bouffalolab/common/args.gni")

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

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

if (chip_enable_pw_rpc) {
import("//build_overrides/pigweed.gni")
import("$dir_pw_build/target_types.gni")
Expand Down Expand Up @@ -73,12 +71,6 @@ bl_iot_sdk("sdk") {
"${chip_root}/src/platform/bouffalolab/common",
]

if (chip_enable_wifi || chip_enable_ethernet) {
include_dirs += [
"${examples_plat_dir}/bl702/lwipopts",
]
}

freertos_config = "${examples_plat_dir}/bl702/FreeRTOSConfig.h"

defines = [
Expand All @@ -100,7 +92,6 @@ bl_iot_sdk("sdk") {

defines += [
"CHIP_DEVICE_CONFIG_ENABLE_ETHERNET=${chip_enable_ethernet}",
"ENABLE_OPENTHREAD_BORDER_ROUTER=${enable_openthread_border_router}"
]

if (enable_psram) {
Expand Down Expand Up @@ -206,13 +197,9 @@ bouffalolab_executable("lighting_app") {
"${examples_plat_dir}/common/route_hook/bl_route_hook.c",
"${examples_plat_dir}/common/route_hook/bl_route_table.c",
]

if (enable_openthread_border_router) {
defines += [ "CHIP_DEVICE_CONFIG_THREAD_FTD=1" ]
}
}

if (chip_enable_openthread || enable_openthread_border_router) {
if (chip_enable_openthread) {
deps += [
"${chip_root}/third_party/openthread/platforms:libopenthread-platform",
"${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils",
Expand Down Expand Up @@ -292,12 +279,6 @@ bouffalolab_executable("lighting_app") {
"${chip_root}/examples/shell/shell_common/include",
]

if (enable_openthread_border_router) {
sources += [
"${examples_plat_dir}/common/shell/cli_otc.cpp",
]
}

deps += [ "${chip_root}/examples/shell/shell_common:shell_common" ]
}

Expand Down
1 change: 0 additions & 1 deletion examples/lighting-app/bouffalolab/common/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#include <easyflash.h>

extern "C" {
#include "board.h"
#include <bl_gpio.h>
#include <hal_gpio.h>
#include <hosal_gpio.h>
Expand Down
6 changes: 1 addition & 5 deletions examples/platform/bouffalolab/common/plat/plat.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,4 @@ extern "C" void platform_port_init(void);
void appError(int err);
void platform_port_init(void);

#endif

#if ENABLE_OPENTHREAD_BORDER_ROUTER && CONFIG_ENABLE_CHIP_SHELL
extern void cli_otc_init(void);
#endif
#endif
1 change: 0 additions & 1 deletion scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,6 @@ def BuildBouffalolabTarget():
TargetPart('BL706DK',
board=BouffalolabBoard.BL706DK, module_type="BL706C-22"),
TargetPart('BL704LDK', board=BouffalolabBoard.BL704LDK, module_type="BL704L"),
TargetPart('BL704L-DVK', board=BouffalolabBoard.BL704L_DVK, module_type="BL704L"),
])

# Apps
Expand Down
11 changes: 5 additions & 6 deletions scripts/build/builders/bouffalolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class BouffalolabBoard(Enum):
XT_ZB6_DevKit = auto()
BL706_NIGHT_LIGHT = auto()
BL706DK = auto()
BL704LDK = auto()
BL704L_DVK = auto()

def GnArgName(self):
Expand All @@ -69,8 +68,6 @@ def GnArgName(self):
return 'BL706DK'
elif self == BouffalolabBoard.BL704LDK:
return 'BL704LDK'
elif self == BouffalolabBoard.BL704L_DVK:
return 'BL704L-DVK'
else:
raise_exception('Unknown board #: %r' % self)

Expand Down Expand Up @@ -113,6 +110,7 @@ def __init__(self,

self.argsOpt = []
self.chip_name = bouffalo_chip
self.enable_frame_ptr = enable_frame_ptr

openthread_project_core_config_file = None
toolchain = os.path.join(root, os.path.split(os.path.realpath(__file__))[0], '../../../config/bouffalolab/toolchain')
Expand Down Expand Up @@ -145,8 +143,6 @@ def __init__(self,

elif bouffalo_chip == "bl702l":

if board == BouffalolabBoard.BL704L_DVK:
raise_exception('Board bl704l-dvk renames to bl704ldk.')
if enable_ethernet or enable_wifi:
raise_exception('SoC %s doesn\'t support connectivity Ethernet/Wi-Fi currently.' % bouffalo_chip)

Expand Down Expand Up @@ -236,7 +232,10 @@ def print_enviroment_error(self):
logging.fatal('*' * 80)

def GnBuildArgs(self):
return self.argsOpt
if self.enable_frame_ptr:
return self.argsOpt + ["debug_output_file=\"{}\"".format(os.path.join(self.output_dir, '%s.out' % self.app.AppNamePrefix(self.chip_name)))]
else:
return self.argsOpt

def build_outputs(self):
items = {
Expand Down
5 changes: 3 additions & 2 deletions scripts/flashing/bouffalolab_firmware_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,13 @@ def get_boot_image(self, config_path, boot2_image):

return boot_image_guess

def get_dts_file(self, config_path, xtal_value, chip_name):
def get_dts_file(self, config_path, xtal_value):

for root, dirs, files in os.walk(config_path, topdown=False):
for name in files:
if name.find(xtal_value) >= 0:
return os.path.join(config_path, name)

return None

def verify(self):
Expand Down Expand Up @@ -248,7 +249,7 @@ def actions(self):
print(dts_path, xtal_value)
if not dts_path and xtal_value:
chip_config_path = os.path.join(tool_path, "chips", chip_name, "device_tree")
dts_path = self.get_dts_file(chip_config_path, xtal_value, chip_name)
dts_path = self.get_dts_file(chip_config_path, xtal_value)
arguments.append("--dts")
arguments.append(dts_path)

Expand Down
2 changes: 1 addition & 1 deletion src/lib/shell/streamer_bouffalolab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/**
* @file
* Source implementation of an input / output stream for bl702 targets.
* Source implementation of an input / output stream for Bouffalo Lab targets.
*/

#include <lib/shell/Engine.h>
Expand Down
92 changes: 92 additions & 0 deletions src/platform/bouffalolab/BL602/NetworkCommissioningDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,101 @@ bool BLWiFiDriver::WiFiNetworkIterator::Next(Network & item)
item.connected = true;
}
}

return true;
}

void NetworkEventHandler(const ChipDeviceEvent * event, intptr_t arg)
{
if (!(DeviceEventType::IsPlatformSpecific(event->Type) && DeviceEventType::IsPublic(event->Type))) {
return;
}

switch (event->Type) {
case kWiFiOnInitDone:
break;
case kWiFiOnScanDone:
BLWiFiDriver::GetInstance().OnScanWiFiNetworkDone();
break;
case kWiFiOnConnected:
BLWiFiDriver::GetInstance().OnNetworkStatusChange();
break;
case kGotIpAddress:
ConnectivityMgrImpl().ChangeWiFiStationState(ConnectivityManagerImpl::kWiFiStationState_Connected);
ConnectivityMgrImpl().OnConnectivityChanged(deviceInterface_getNetif());
break;
case kGotIpv6Address:
ConnectivityMgrImpl().ChangeWiFiStationState(ConnectivityManagerImpl::kWiFiStationState_Connected);
ConnectivityMgrImpl().OnConnectivityChanged(deviceInterface_getNetif());
break;
case kWiFiOnDisconnected:
if (ConnectivityManager::kWiFiStationState_Connecting == ConnectivityMgrImpl().GetWiFiStationState())
{
ConnectivityMgrImpl().ChangeWiFiStationState(ConnectivityManager::kWiFiStationState_Connecting_Failed);
}
break;
default:
ChipLogProgress(DeviceLayer, "Undefined network commission event type %x.\r\n", event->Type);
break;
}
}

static wifi_conf_t conf = {
.country_code = "CN",
};

extern "C" void wifi_event_handler(uint32_t code)
{
ChipDeviceEvent event;

memset(&event, 0, sizeof(ChipDeviceEvent));

switch (code) {
case CODE_WIFI_ON_INIT_DONE:
wifi_mgmr_start_background(&conf);
break;
case CODE_WIFI_ON_SCAN_DONE:
event.Type = kWiFiOnScanDone;
PlatformMgr().PostEventOrDie(&event);
break;
case CODE_WIFI_ON_CONNECTED:
event.Type = kWiFiOnConnected;
PlatformMgr().PostEventOrDie(&event);
break;
case CODE_WIFI_ON_GOT_IP:
event.Type = kGotIpAddress;
PlatformMgr().PostEventOrDie(&event);
break;
case CODE_WIFI_ON_DISCONNECT:
event.Type = kWiFiOnDisconnected;
PlatformMgr().PostEventOrDie(&event);
break;
default:
ChipLogProgress(DeviceLayer, "[APP] [EVT] Unknown code %lu \r\n", code);
}
}

extern "C" void network_netif_ext_callback(struct netif* nif, netif_nsc_reason_t reason, const netif_ext_callback_args_t* args)
{
ChipDeviceEvent event;

memset(&event, 0, sizeof(ChipDeviceEvent));

if ((LWIP_NSC_IPV6_ADDR_STATE_CHANGED & reason) && args) {

if (args->ipv6_addr_state_changed.addr_index >= LWIP_IPV6_NUM_ADDRESSES ||
ip6_addr_islinklocal(netif_ip6_addr(nif, args->ipv6_addr_state_changed.addr_index))) {
return;
}

if (netif_ip6_addr_state(nif, args->ipv6_addr_state_changed.addr_index) != args->ipv6_addr_state_changed.old_state &&
ip6_addr_ispreferred(netif_ip6_addr_state(nif, args->ipv6_addr_state_changed.addr_index))) {
event.Type = kGotIpv6Address;
PlatformMgr().PostEventOrDie(&event);
}
}
}

} // namespace NetworkCommissioning
} // namespace DeviceLayer
} // namespace chip
4 changes: 0 additions & 4 deletions src/platform/bouffalolab/BL702/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ import("${chip_root}/src/platform/bouffalolab/common/args.gni")
assert(chip_device_platform == "bl702")
assert(chip_enable_factory_data == false)

if (enable_openthread_border_router) {
assert(chip_enable_openthread==false)
}

if (chip_enable_openthread) {
import("//build_overrides/openthread.gni")
}
Expand Down
11 changes: 1 addition & 10 deletions src/platform/bouffalolab/BL702/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,11 @@
#include <platform/bouffalolab/BL702/wifi_mgmr_portable.h>
#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI

#if CHIP_DEVICE_CONFIG_ENABLE_THREAD || ENABLE_OPENTHREAD_BORDER_ROUTER
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
#include <openthread_port.h>
#include <utils_list.h>
#endif

#if ENABLE_OPENTHREAD_BORDER_ROUTER
#include <openthread/thread.h>

#include <openthread/dataset.h>
#include <openthread/dataset_ftd.h>
#include <openthread/ip6.h>
#include <openthread_br.h>
#endif

#if CHIP_DEVICE_CONFIG_ENABLE_ETHERNET
#include <platform/bouffalolab/BL702/EthernetInterface.h>
#endif // CHIP_DEVICE_CONFIG_ENABLE_ETHERNET
Expand Down
2 changes: 1 addition & 1 deletion src/platform/bouffalolab/common/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#endif

extern "C" {
#if CHIP_DEVICE_LAYER_TARGET_BL702L || CHIP_DEVICE_LAYER_TARGET_BL616
#if CHIP_DEVICE_LAYER_TARGET_BL702L
#include <btble_lib_api.h>
#else
#include <ble_lib_api.h>
Expand Down
1 change: 1 addition & 0 deletions src/platform/bouffalolab/common/Logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <task.h>
#if CHIP_DEVICE_LAYER_TARGET_BL602 || CHIP_DEVICE_LAYER_TARGET_BL702 || CHIP_DEVICE_LAYER_TARGET_BL702L
#include <utils_log.h>
#endif

namespace chip {
namespace Logging {
Expand Down
7 changes: 4 additions & 3 deletions src/platform/bouffalolab/common/OTAImageProcessorImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@
#include <app/clusters/ota-requestor/OTADownloader.h>
#include <app/clusters/ota-requestor/OTARequestorInterface.h>

#include "OTAImageProcessorImpl.h"
#if CHIP_DEVICE_LAYER_TARGET_BL602 || CHIP_DEVICE_LAYER_TARGET_BL702 || CHIP_DEVICE_LAYER_TARGET_BL702L
extern "C" {
#include <hal_sys.h>
#include <hosal_ota.h>
#endif

void hal_reboot (void);
extern void hal_reboot (void);
}

#include "OTAImageProcessorImpl.h"

using namespace chip::System;

namespace chip {
Expand Down Expand Up @@ -201,7 +203,6 @@ void OTAImageProcessorImpl::HandleProcessBlock(intptr_t context)
ByteSpan block = imageProcessor->mBlock;
if (imageProcessor->mHeaderParser.IsInitialized())
{

error = imageProcessor->mHeaderParser.AccumulateAndDecode(block, header);
if (CHIP_ERROR_BUFFER_TOO_SMALL == error)
{
Expand Down
6 changes: 2 additions & 4 deletions src/platform/bouffalolab/common/PlatformManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,11 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener
friend PlatformManager & PlatformMgr(void);
friend PlatformManagerImpl & PlatformMgrImpl(void);
friend class Internal::BLEManagerImpl;

CHIP_ERROR _PostEvent(const ChipDeviceEvent * event);

#if CHIP_DEVICE_LAYER_TARGET_BL602 && CHIP_DEVICE_CONFIG_ENABLE_WIFI
friend void OnWiFiPlatformEvent(input_event_t * event, void * private_data);
#endif

CHIP_ERROR _PostEvent(const ChipDeviceEvent * event);
System::Clock::Timestamp mStartTime = System::Clock::kZero;

static PlatformManagerImpl sInstance;
Expand All @@ -91,7 +89,7 @@ inline PlatformManager & PlatformMgr(void)
* Returns the platform-specific implementation of the PlatformManager singleton object.
*
* Chip applications can use this to gain access to features of the PlatformManager
* that are specific to the ESP32 platform.
* that are specific to the Bouffalo Lab platform.
*/
inline PlatformManagerImpl & PlatformMgrImpl(void)
{
Expand Down
Loading

0 comments on commit 5ca5359

Please sign in to comment.