diff --git a/examples/lighting-app/bouffalolab/bl702l/BUILD.gn b/examples/lighting-app/bouffalolab/bl702l/BUILD.gn index a3f4e3120e8092..b3e6f809b6ba38 100644 --- a/examples/lighting-app/bouffalolab/bl702l/BUILD.gn +++ b/examples/lighting-app/bouffalolab/bl702l/BUILD.gn @@ -98,7 +98,7 @@ bl_iot_sdk("sdk") { } chip_data_model("bouffalolab-lighting") { - zap_file = "${example_dir}/data_model/lighting-app-wifi.zap" + zap_file = "${example_dir}/data_model/lighting-app-thread.zap" zap_pregenerated_dir = "${chip_root}/zzz_generated/lighting-app/zap-generated" is_server = true diff --git a/examples/platform/bouffalolab/common/plat/platform.cpp b/examples/platform/bouffalolab/common/plat/platform.cpp index ea6548327847b1..329e3eee49f262 100644 --- a/examples/platform/bouffalolab/common/plat/platform.cpp +++ b/examples/platform/bouffalolab/common/plat/platform.cpp @@ -165,6 +165,18 @@ void ChipEventHandler(const ChipDeviceEvent * event, intptr_t arg) } } +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD +void LockOpenThreadTask(void) +{ + chip::DeviceLayer::ThreadStackMgr().LockThreadStack(); +} + +void UnlockOpenThreadTask(void) +{ + chip::DeviceLayer::ThreadStackMgr().UnlockThreadStack(); +} +#endif + CHIP_ERROR PlatformManagerImpl::PlatformInit(void) { chip::RendezvousInformationFlags rendezvousMode(chip::RendezvousInformationFlag::kOnNetwork); @@ -235,6 +247,14 @@ CHIP_ERROR PlatformManagerImpl::PlatformInit(void) static CommonCaseDeviceServerInitParams initParams; (void) initParams.InitializeStaticResourcesBeforeServerInit(); +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams; + nativeParams.lockCb = LockOpenThreadTask; + nativeParams.unlockCb = UnlockOpenThreadTask; + nativeParams.openThreadInstancePtr = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance(); + initParams.endpointNativeParams = static_cast(&nativeParams); +#endif + ReturnLogErrorOnFailure(chip::Server::GetInstance().Init(initParams)); gExampleDeviceInfoProvider.SetStorageDelegate(&chip::Server::GetInstance().GetPersistentStorage()); diff --git a/scripts/build/builders/bouffalolab.py b/scripts/build/builders/bouffalolab.py index c4d4fc10f12ccd..1b661bff045c07 100644 --- a/scripts/build/builders/bouffalolab.py +++ b/scripts/build/builders/bouffalolab.py @@ -166,6 +166,8 @@ def __init__(self, self.argsOpt.append(f'chip_inet_config_enable_ipv4={str(enable_ethernet or enable_wifi).lower()}') if enable_thread: + self.argsOpt.append('chip_system_config_use_open_thread_inet_endpoints=true') + self.argsOpt.append('chip_with_lwip=false') self.argsOpt.append(f'openthread_project_core_config_file="{bouffalo_chip}-openthread-core-bl-config.h"') if not use_matter_openthread: self.argsOpt.append( diff --git a/src/platform/bouffalolab/BL702/BUILD.gn b/src/platform/bouffalolab/BL702/BUILD.gn index 8582019df301e7..831f0d27679e21 100644 --- a/src/platform/bouffalolab/BL702/BUILD.gn +++ b/src/platform/bouffalolab/BL702/BUILD.gn @@ -115,4 +115,7 @@ static_library("BL702") { deps += [ "${chip_root}/src/credentials:credentials_header" ] public_deps = [ "${chip_root}/src/platform:platform_base" ] + + public_configs = + [ "${chip_root}/src/lib/address_resolve:default_address_resolve_config" ] } diff --git a/src/platform/bouffalolab/BL702/PlatformManagerImpl.cpp b/src/platform/bouffalolab/BL702/PlatformManagerImpl.cpp index a9c532d93f69ce..ae68f9c680795c 100644 --- a/src/platform/bouffalolab/BL702/PlatformManagerImpl.cpp +++ b/src/platform/bouffalolab/BL702/PlatformManagerImpl.cpp @@ -23,7 +23,10 @@ #include #include +#if CHIP_SYSTEM_CONFIG_USE_LWIP #include +#endif + #if CHIP_DEVICE_CONFIG_ENABLE_WIFI #include #endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI @@ -62,8 +65,10 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) CHIP_ERROR err; TaskHandle_t backup_eventLoopTask; +#if CHIP_SYSTEM_CONFIG_USE_LWIP // Initialize LwIP. tcpip_init(NULL, NULL); +#endif #if CHIP_DEVICE_CONFIG_ENABLE_THREAD otRadio_opt_t opt; diff --git a/src/platform/bouffalolab/BL702/ThreadStackManagerImpl.cpp b/src/platform/bouffalolab/BL702/ThreadStackManagerImpl.cpp index 3b9e0313a5b66f..784dfa396cd371 100644 --- a/src/platform/bouffalolab/BL702/ThreadStackManagerImpl.cpp +++ b/src/platform/bouffalolab/BL702/ThreadStackManagerImpl.cpp @@ -17,16 +17,16 @@ #include -#include -#include - #include #include -#include +#include +#include #include +#include + #include #include @@ -51,7 +51,7 @@ CHIP_ERROR ThreadStackManagerImpl::InitThreadStack(otInstance * otInst) // Initialize the generic implementation base classes. err = GenericThreadStackManagerImpl_FreeRTOS::DoInit(); SuccessOrExit(err); - err = GenericThreadStackManagerImpl_OpenThread_LwIP::DoInit(otInstanceInitSingle()); + err = GenericThreadStackManagerImpl_OpenThread::DoInit(otInst); SuccessOrExit(err); mbedtls_platform_set_calloc_free(pvPortCalloc, vPortFree); diff --git a/src/platform/bouffalolab/BL702L/BUILD.gn b/src/platform/bouffalolab/BL702L/BUILD.gn index 547b9c695730c5..d4e077d5922802 100644 --- a/src/platform/bouffalolab/BL702L/BUILD.gn +++ b/src/platform/bouffalolab/BL702L/BUILD.gn @@ -92,4 +92,7 @@ static_library("BL702L") { deps += [ "${chip_root}/src/credentials:credentials_header" ] public_deps = [ "${chip_root}/src/platform:platform_base" ] + + public_configs = + [ "${chip_root}/src/lib/address_resolve:default_address_resolve_config" ] } diff --git a/src/platform/bouffalolab/BL702L/DiagnosticDataProviderImpl.cpp b/src/platform/bouffalolab/BL702L/DiagnosticDataProviderImpl.cpp index fcd805ebfccf65..5dcc64a52927f1 100644 --- a/src/platform/bouffalolab/BL702L/DiagnosticDataProviderImpl.cpp +++ b/src/platform/bouffalolab/BL702L/DiagnosticDataProviderImpl.cpp @@ -21,8 +21,7 @@ #include #include -#include "FreeRTOS.h" -#include +#include extern "C" { #include diff --git a/src/platform/bouffalolab/BL702L/PlatformManagerImpl.cpp b/src/platform/bouffalolab/BL702L/PlatformManagerImpl.cpp index ef9adadc941d8c..d72c1090064968 100644 --- a/src/platform/bouffalolab/BL702L/PlatformManagerImpl.cpp +++ b/src/platform/bouffalolab/BL702L/PlatformManagerImpl.cpp @@ -24,7 +24,9 @@ #include #include +#if CHIP_SYSTEM_CONFIG_USE_LWIP #include +#endif extern "C" { #include @@ -68,8 +70,10 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) ReturnErrorOnFailure(System::Clock::InitClock_RealTime()); +#if CHIP_SYSTEM_CONFIG_USE_LWIP // Initialize LwIP. tcpip_init(NULL, NULL); +#endif err = chip::Crypto::add_entropy_source(app_entropy_source, NULL, 16); SuccessOrExit(err); diff --git a/src/platform/bouffalolab/BL702L/ThreadStackManagerImpl.cpp b/src/platform/bouffalolab/BL702L/ThreadStackManagerImpl.cpp index e2ceec4e40219f..bc6a558b20f6c2 100644 --- a/src/platform/bouffalolab/BL702L/ThreadStackManagerImpl.cpp +++ b/src/platform/bouffalolab/BL702L/ThreadStackManagerImpl.cpp @@ -17,12 +17,14 @@ #include -#include -#include - #include #include +#include +#include + +#include + #include #include @@ -54,7 +56,7 @@ CHIP_ERROR ThreadStackManagerImpl::InitThreadStack(otInstance * otInst) // Initialize the generic implementation base classes. err = GenericThreadStackManagerImpl_FreeRTOS::DoInit(); SuccessOrExit(err); - err = GenericThreadStackManagerImpl_OpenThread_LwIP::DoInit(otInst); + err = GenericThreadStackManagerImpl_OpenThread::DoInit(otInst); SuccessOrExit(err); mbedtls_platform_set_calloc_free(pvPortCalloc, vPortFree); diff --git a/src/platform/bouffalolab/common/BLConfig.cpp b/src/platform/bouffalolab/common/BLConfig.cpp index 818c64069b71df..bac1580f9f7c19 100644 --- a/src/platform/bouffalolab/common/BLConfig.cpp +++ b/src/platform/bouffalolab/common/BLConfig.cpp @@ -26,12 +26,13 @@ namespace Internal { void BLConfig::Init(void) { + env_node_obj node; + easyflash_init(); ef_load_env_cache(); - if (ef_get_env(kBLKey_factoryResetFlag)) + if (ef_get_env_obj(kBLKey_factoryResetFlag, &node)) { - ef_print_env_cb([](env_node_obj_t env, void * arg1, void * arg2) { if (ENV_WRITE == env->status) { diff --git a/src/platform/bouffalolab/common/SystemPlatformConfig.h b/src/platform/bouffalolab/common/SystemPlatformConfig.h index 0441601762ced5..c42b2671f84b48 100644 --- a/src/platform/bouffalolab/common/SystemPlatformConfig.h +++ b/src/platform/bouffalolab/common/SystemPlatformConfig.h @@ -30,5 +30,9 @@ struct ChipDeviceEvent; #define CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_TIME 1 #define CHIP_SYSTEM_CONFIG_EVENT_OBJECT_TYPE const struct ::chip::DeviceLayer::ChipDeviceEvent * +#if CHIP_ENABLE_OPENTHREAD +#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8 +#endif + // #define CHIP_CONFIG_SHA256_CONTEXT_SIZE sizeof(bl_sha_ctx_t) #define CHIP_CONFIG_SHA256_CONTEXT_SIZE ((7 + 1 + 5 + 18 + 16 + 16 + 7) * sizeof(unsigned int)) diff --git a/src/platform/bouffalolab/common/ThreadStackManagerImpl.h b/src/platform/bouffalolab/common/ThreadStackManagerImpl.h index dc69f270e17c93..462d2de76ac32d 100644 --- a/src/platform/bouffalolab/common/ThreadStackManagerImpl.h +++ b/src/platform/bouffalolab/common/ThreadStackManagerImpl.h @@ -17,13 +17,10 @@ #pragma once -#include -#include - #include #include - -#include +#include +#include extern "C" void otSysEventSignalPending(void); extern "C" void otrLock(void); @@ -41,7 +38,7 @@ class ThreadStackManagerImpl; * using the Bouffalolab SDK and the OpenThread stack. */ class ThreadStackManagerImpl final : public ThreadStackManager, - public Internal::GenericThreadStackManagerImpl_OpenThread_LwIP, + public Internal::GenericThreadStackManagerImpl_OpenThread, public Internal::GenericThreadStackManagerImpl_FreeRTOS { // Allow the ThreadStackManager interface class to delegate method calls to diff --git a/src/system/BUILD.gn b/src/system/BUILD.gn index 86e02725e261c6..283e3b7c49bcbd 100644 --- a/src/system/BUILD.gn +++ b/src/system/BUILD.gn @@ -68,6 +68,10 @@ if (chip_device_platform == "cc13x2_26x2") { import("//build_overrides/mt793x_sdk.gni") } else if (chip_device_platform == "stm32") { import("//build_overrides/stm32_sdk.gni") +} else if (chip_device_platform == "bl702") { + import("//build_overrides/bouffalolab_iot_sdk.gni") +} else if (chip_device_platform == "bl702l") { + import("//build_overrides/bouffalolab_iot_sdk.gni") } buildconfig_header("system_buildconfig") { @@ -192,6 +196,12 @@ source_set("system_config_header") { if (chip_device_platform == "stm32") { public_deps += [ "${stm32_sdk_build_root}:stm32_sdk" ] } + if (chip_device_platform == "bl702") { + public_deps += [ "${bouffalolab_iot_sdk_build_root}/bl702:bl_iot_sdk" ] + } + if (chip_device_platform == "bl702l") { + public_deps += [ "${bouffalolab_iot_sdk_build_root}/bl702l:bl_iot_sdk" ] + } # Add platform here as needed. } diff --git a/third_party/bouffalolab/bl702/bl_iot_sdk.gni b/third_party/bouffalolab/bl702/bl_iot_sdk.gni index 41f4c7fb7310a0..f7c26e44c0dbbc 100644 --- a/third_party/bouffalolab/bl702/bl_iot_sdk.gni +++ b/third_party/bouffalolab/bl702/bl_iot_sdk.gni @@ -403,6 +403,10 @@ template("bl_iot_sdk") { "${bl_iot_sdk_root}/components/stage/blfdt/inc", "${bl_iot_sdk_root}/components/stage/cli/cli/include", ] + + if (defined(invoker.enable_cdc_module) && invoker.enable_cdc_module) { + cflags_cc = [ "-Wno-shadow" ] + } } source_set("${sdk_target_name}_stage") {