From 3d481f375d1460bd295a4e2547cc767d57d506fc Mon Sep 17 00:00:00 2001 From: Dieter Van der Meulen <87530904+dvdm-qorvo@users.noreply.github.com> Date: Thu, 8 Jun 2023 23:48:40 +0200 Subject: [PATCH] [QPG] QPG SDK feature updates (#27151) * [QPG] Enable ACL extension attribute for light and lock application * [QPG] Use FactoryDataProvider to validate vid and pid in otaheader validation * [QPG] Do not initialize KVS twice; cleanup around OTA requestor init * [QPG] integrate build of libFactoryData * [QPG] Update version + fix in DoorLock state after boot * Restyled by gn * Move to updated qpg libs * [QPG] Increase timeout for Matter SDK library --------- Co-authored-by: Brecht Van Cauwenberghe Co-authored-by: lucicop Co-authored-by: Thomas Langewouters Co-authored-by: Restyled.io --- .github/workflows/examples-qpg.yaml | 2 +- examples/lighting-app/qpg/BUILD.gn | 2 ++ .../qpg/include/CHIPProjectConfig.h | 4 +-- examples/lighting-app/qpg/zap/light.matter | 2 ++ examples/lighting-app/qpg/zap/light.zap | 5 +-- examples/lock-app/qpg/BUILD.gn | 2 ++ .../lock-app/qpg/include/CHIPProjectConfig.h | 4 +-- examples/lock-app/qpg/src/AppTask.cpp | 21 +++++++++--- examples/lock-app/qpg/zap/lock.matter | 2 ++ examples/lock-app/qpg/zap/lock.zap | 5 +-- examples/platform/qpg/app/main.cpp | 17 +++------- examples/platform/qpg/ota/ota.cpp | 17 ++++++++-- third_party/qpg_sdk/BUILD.gn | 32 +++++++++++++++++++ third_party/qpg_sdk/repo | 2 +- 14 files changed, 88 insertions(+), 29 deletions(-) diff --git a/.github/workflows/examples-qpg.yaml b/.github/workflows/examples-qpg.yaml index 9bd263a684a82b..bf97acb89b13ba 100644 --- a/.github/workflows/examples-qpg.yaml +++ b/.github/workflows/examples-qpg.yaml @@ -95,7 +95,7 @@ jobs: --copy-artifacts-to out/artifacts \ " - name: Build Matter SDK library - timeout-minutes: 5 + timeout-minutes: 10 run: | config/qpg/chip-gn/build.sh diff --git a/examples/lighting-app/qpg/BUILD.gn b/examples/lighting-app/qpg/BUILD.gn index b165b116a84473..361021fc21dcdc 100644 --- a/examples/lighting-app/qpg/BUILD.gn +++ b/examples/lighting-app/qpg/BUILD.gn @@ -73,6 +73,8 @@ qpg_executable("lighting_app") { "${chip_root}/third_party/openthread/platforms:libopenthread-platform", "${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils", "${chip_root}/third_party/qpg_sdk:qpg_light_factorydata_lib", + "${chip_root}/third_party/qpg_sdk:qpg_light_factorydata_lib", + "${chip_root}/third_party/qpg_sdk:qpg_light_firmwaredata_lib", ] if (chip_openthread_ftd) { diff --git a/examples/lighting-app/qpg/include/CHIPProjectConfig.h b/examples/lighting-app/qpg/include/CHIPProjectConfig.h index f5f8d12be7797f..61dc9fdebc86af 100644 --- a/examples/lighting-app/qpg/include/CHIPProjectConfig.h +++ b/examples/lighting-app/qpg/include/CHIPProjectConfig.h @@ -42,7 +42,7 @@ * A uint32_t identifying the software version running on the device. */ #ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION -#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0002 +#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0003 #endif /** @@ -53,7 +53,7 @@ * {MAJOR_VERSION}.0d{MINOR_VERSION} */ #ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING -#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "1.0" +#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "1.1" #endif /** * CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE diff --git a/examples/lighting-app/qpg/zap/light.matter b/examples/lighting-app/qpg/zap/light.matter index 4ca38a58c4d353..41c986eb8e0584 100644 --- a/examples/lighting-app/qpg/zap/light.matter +++ b/examples/lighting-app/qpg/zap/light.matter @@ -384,6 +384,7 @@ server cluster AccessControl = 31 { } attribute access(read: administer, write: administer) AccessControlEntryStruct acl[] = 0; + attribute access(read: administer, write: administer) AccessControlExtensionStruct extension[] = 1; readonly attribute int16u subjectsPerAccessControlEntry = 2; readonly attribute int16u targetsPerAccessControlEntry = 3; readonly attribute int16u accessControlEntriesPerFabric = 4; @@ -1738,6 +1739,7 @@ endpoint 0 { emits event AccessControlEntryChanged; emits event AccessControlExtensionChanged; callback attribute acl; + callback attribute extension; callback attribute subjectsPerAccessControlEntry default = 4; callback attribute targetsPerAccessControlEntry default = 3; callback attribute accessControlEntriesPerFabric default = 4; diff --git a/examples/lighting-app/qpg/zap/light.zap b/examples/lighting-app/qpg/zap/light.zap index 4ecc61cd8a1a02..36583b33122d79 100644 --- a/examples/lighting-app/qpg/zap/light.zap +++ b/examples/lighting-app/qpg/zap/light.zap @@ -1088,7 +1088,7 @@ "mfgCode": null, "side": "server", "type": "array", - "included": 0, + "included": 1, "storageOption": "External", "singleton": 0, "bounded": 0, @@ -10281,5 +10281,6 @@ "endpointVersion": 1, "deviceIdentifier": 269 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/lock-app/qpg/BUILD.gn b/examples/lock-app/qpg/BUILD.gn index 03d657ac5a0023..c8edc51a72545a 100644 --- a/examples/lock-app/qpg/BUILD.gn +++ b/examples/lock-app/qpg/BUILD.gn @@ -70,6 +70,8 @@ qpg_executable("lock_app") { "${chip_root}/third_party/openthread/platforms:libopenthread-platform", "${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils", "${chip_root}/third_party/qpg_sdk:qpg_lock_factorydata_lib", + "${chip_root}/third_party/qpg_sdk:qpg_lock_factorydata_lib", + "${chip_root}/third_party/qpg_sdk:qpg_lock_firmwaredata_lib", ] if (chip_openthread_ftd) { diff --git a/examples/lock-app/qpg/include/CHIPProjectConfig.h b/examples/lock-app/qpg/include/CHIPProjectConfig.h index 802aa5b2a1f2f3..4989ed2f85051d 100644 --- a/examples/lock-app/qpg/include/CHIPProjectConfig.h +++ b/examples/lock-app/qpg/include/CHIPProjectConfig.h @@ -42,7 +42,7 @@ * A uint32_t identifying the software version running on the device. */ #ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION -#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0002 +#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0003 #endif /** @@ -53,7 +53,7 @@ * {MAJOR_VERSION}.0d{MINOR_VERSION} */ #ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING -#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "1.0" +#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "1.1" #endif /** * CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE diff --git a/examples/lock-app/qpg/src/AppTask.cpp b/examples/lock-app/qpg/src/AppTask.cpp index 616e7d231482f3..3466d8c4a4c395 100644 --- a/examples/lock-app/qpg/src/AppTask.cpp +++ b/examples/lock-app/qpg/src/AppTask.cpp @@ -585,13 +585,24 @@ void AppTask::UpdateClusterState(void) auto newValue = BoltLockMgr().IsUnlocked() ? DoorLock::DlLockState::kUnlocked : DoorLock::DlLockState::kLocked; SystemLayer().ScheduleLambda([newValue] { - ChipLogProgress(NotSpecified, "UpdateClusterState"); + chip::app::DataModel::Nullable currentLockState; + chip::app::Clusters::DoorLock::Attributes::LockState::Get(QPG_LOCK_ENDPOINT_ID, currentLockState); - EmberAfStatus status = DoorLock::Attributes::LockState::Set(QPG_LOCK_ENDPOINT_ID, newValue); - - if (status != EMBER_ZCL_STATUS_SUCCESS) + if (currentLockState.IsNull()) + { + EmberAfStatus status = DoorLock::Attributes::LockState::Set(QPG_LOCK_ENDPOINT_ID, newValue); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: updating DoorLock %x", status); + } + } + else { - ChipLogError(NotSpecified, "ERR: updating DoorLock %x", status); + ChipLogProgress(NotSpecified, "Updating LockState attribute"); + if (!DoorLockServer::Instance().SetLockState(QPG_LOCK_ENDPOINT_ID, newValue)) + { + ChipLogError(NotSpecified, "ERR: updating DoorLock"); + } } }); } diff --git a/examples/lock-app/qpg/zap/lock.matter b/examples/lock-app/qpg/zap/lock.matter index 2062ba0e7026a9..de2de89c0cc739 100644 --- a/examples/lock-app/qpg/zap/lock.matter +++ b/examples/lock-app/qpg/zap/lock.matter @@ -218,6 +218,7 @@ server cluster AccessControl = 31 { } attribute access(read: administer, write: administer) AccessControlEntryStruct acl[] = 0; + attribute access(read: administer, write: administer) AccessControlExtensionStruct extension[] = 1; readonly attribute int16u subjectsPerAccessControlEntry = 2; readonly attribute int16u targetsPerAccessControlEntry = 3; readonly attribute int16u accessControlEntriesPerFabric = 4; @@ -1872,6 +1873,7 @@ endpoint 0 { emits event AccessControlEntryChanged; emits event AccessControlExtensionChanged; callback attribute acl; + callback attribute extension; callback attribute subjectsPerAccessControlEntry default = 4; callback attribute targetsPerAccessControlEntry default = 3; callback attribute accessControlEntriesPerFabric default = 4; diff --git a/examples/lock-app/qpg/zap/lock.zap b/examples/lock-app/qpg/zap/lock.zap index 0f707b688c4af8..dc5430fff2a297 100644 --- a/examples/lock-app/qpg/zap/lock.zap +++ b/examples/lock-app/qpg/zap/lock.zap @@ -836,7 +836,7 @@ "mfgCode": null, "side": "server", "type": "array", - "included": 0, + "included": 1, "storageOption": "External", "singleton": 0, "bounded": 0, @@ -9399,5 +9399,6 @@ "endpointVersion": 1, "deviceIdentifier": 10 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/platform/qpg/app/main.cpp b/examples/platform/qpg/app/main.cpp index c05c0b626e4b75..bc3b28e230efe8 100644 --- a/examples/platform/qpg/app/main.cpp +++ b/examples/platform/qpg/app/main.cpp @@ -81,13 +81,6 @@ constexpr int extDiscTimeoutSecs = 20; CHIP_ERROR CHIP_Init(void); -#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR -void InitOTARequestorHandler(void) -{ - InitializeOTARequestor(); -} -#endif - void Application_Init(void) { CHIP_ERROR error; @@ -96,13 +89,13 @@ void Application_Init(void) GP_CLEARBOX_TESTING_APPLICATION_INIT_HOOK; #endif - /* Initialize IO */ - qvIO_Init(); - #if defined(GP_APP_DIVERSITY_POWERCYCLECOUNTING) gpAppFramework_Reset_Init(); #endif + /* Initialize IO */ + qvIO_Init(); + /* Initialize CHIP stack */ error = CHIP_Init(); if (error != CHIP_NO_ERROR) @@ -137,7 +130,7 @@ void ChipEventHandler(const ChipDeviceEvent * aEvent, intptr_t /* arg */) { case DeviceEventType::kDnssdInitialized: #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR - InitOTARequestorHandler(); + InitializeOTARequestor(); #endif break; default: @@ -199,7 +192,7 @@ CHIP_ERROR CHIP_Init(void) qvIO_EnableSleep(true); #elif CHIP_DEVICE_CONFIG_THREAD_FTD ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router); - qvIO_EnableSleep(false); + qvIO_EnableSleep(true); #else ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice); qvIO_EnableSleep(false); diff --git a/examples/platform/qpg/ota/ota.cpp b/examples/platform/qpg/ota/ota.cpp index b37a62d3ab1d76..97fbee3ea38055 100644 --- a/examples/platform/qpg/ota/ota.cpp +++ b/examples/platform/qpg/ota/ota.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include using namespace chip; @@ -52,9 +53,21 @@ OTAImageProcessorImpl gImageProcessor; bool OtaHeaderValidationCb(qvCHIP_Ota_ImageHeader_t imageHeader) { + + uint16_t vendorId = 0; + uint16_t productId = 0; + + if (GetDeviceInstanceInfoProvider()->GetVendorId(vendorId) != CHIP_NO_ERROR) + { + return false; + } + if (GetDeviceInstanceInfoProvider()->GetProductId(productId) != CHIP_NO_ERROR) + { + return false; + } + // Check that the image matches vendor and product ID and that the version is higher than what we currently have - if (imageHeader.vendorId != CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID || - imageHeader.productId != CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID || + if (imageHeader.vendorId != vendorId || imageHeader.productId != productId || imageHeader.softwareVersion <= CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION) { return false; diff --git a/third_party/qpg_sdk/BUILD.gn b/third_party/qpg_sdk/BUILD.gn index 4d10e71fc00704..671804cfa586d3 100755 --- a/third_party/qpg_sdk/BUILD.gn +++ b/third_party/qpg_sdk/BUILD.gn @@ -226,3 +226,35 @@ config("qpg_retain_factorydata") { "-Wl,-u_binary_factory_data_start", ] } + +qpg_make_build("qpg_light_firmwaredata") { + make_sources = [ "${qpg_sdk_root}/Tools/FactoryData" ] + make_output = [ "${target_gen_dir}/${qpg_sdk_lib_dir}/FirmwareData_light/libFirmwareData_light.a" ] + make_args = [ + "-f", + rebase_path(qpg_sdk_root, root_build_dir) + + "/Libraries/Qorvo/FactoryData/Makefile.FirmwareData_light", + "WORKDIR=" + rebase_path(target_gen_dir, root_build_dir) + + "/${qpg_sdk_lib_dir}/FirmwareData_light", + ] +} +static_library("qpg_light_firmwaredata_lib") { + deps = [ "${chip_root}/third_party/qpg_sdk:qpg_light_firmwaredata" ] + libs = [ "${target_gen_dir}/${qpg_sdk_lib_dir}/FirmwareData_light/libFirmwareData_light.a" ] +} + +qpg_make_build("qpg_lock_firmwaredata") { + make_sources = [ "${qpg_sdk_root}/Tools/FactoryData" ] + make_output = [ "${target_gen_dir}/${qpg_sdk_lib_dir}/FirmwareData_lock/libFirmwareData_lock.a" ] + make_args = [ + "-f", + rebase_path(qpg_sdk_root, root_build_dir) + + "/Libraries/Qorvo/FactoryData/Makefile.FirmwareData_lock", + "WORKDIR=" + rebase_path(target_gen_dir, root_build_dir) + + "/${qpg_sdk_lib_dir}/FirmwareData_lock", + ] +} +static_library("qpg_lock_firmwaredata_lib") { + deps = [ "${chip_root}/third_party/qpg_sdk:qpg_lock_firmwaredata" ] + libs = [ "${target_gen_dir}/${qpg_sdk_lib_dir}/FirmwareData_lock/libFirmwareData_lock.a" ] +} diff --git a/third_party/qpg_sdk/repo b/third_party/qpg_sdk/repo index cacb7eb95985f9..6c3303e5155912 160000 --- a/third_party/qpg_sdk/repo +++ b/third_party/qpg_sdk/repo @@ -1 +1 @@ -Subproject commit cacb7eb95985f9b81359d839cd25468fb3b1aec1 +Subproject commit 6c3303e51559123a76d9e93ef902d57fc8302c32