From fce7322f79fd17689547166e59ac8c64f5a80504 Mon Sep 17 00:00:00 2001 From: Seth Rickard Date: Tue, 19 Apr 2022 15:42:03 +0000 Subject: [PATCH 01/14] add and process the OTA Image header --- .gitmodules | 1 + .../all-clusters-app/cc13x2x7_26x2x7/BUILD.gn | 15 +-- .../main/include/CHIPProjectConfig.h | 26 +---- examples/lock-app/cc13x2x7_26x2x7/BUILD.gn | 20 ++-- examples/lock-app/cc13x2x7_26x2x7/args.gni | 2 + .../lock-app/cc13x2x7_26x2x7/main/AppTask.cpp | 5 +- .../main/include/CHIPProjectConfig.h | 28 ++--- examples/pump-app/cc13x2x7_26x2x7/BUILD.gn | 15 +-- .../main/include/CHIPProjectConfig.h | 34 +----- .../cc13x2x7_26x2x7/BUILD.gn | 15 +-- .../main/include/CHIPProjectConfig.h | 34 +----- .../cc13x2_26x2/OTAImageProcessorImpl.cpp | 83 ++++++++------ .../cc13x2_26x2/OTAImageProcessorImpl.h | 6 + .../ti_simplelink_sdk/oad_merge_tool.py | 27 +++++ third_party/ti_simplelink_sdk/run_oad_tool.py | 55 ---------- .../ti_simplelink_executable.gni | 103 ++++++++++++++++-- .../ti_simplelink_sdk/ti_simplelink_sdk.gni | 3 + 17 files changed, 244 insertions(+), 228 deletions(-) create mode 100644 third_party/ti_simplelink_sdk/oad_merge_tool.py delete mode 100644 third_party/ti_simplelink_sdk/run_oad_tool.py diff --git a/.gitmodules b/.gitmodules index 7fadeb79ec8fcf..d2f35c99693d3a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -246,6 +246,7 @@ url = https://github.com/TexasInstruments/cc13xx_cc26xx_sdk.git branch = main platforms = cc13x2_26x2 + ignore = dirty [submodule "third_party/efr32_sdk/wiseconnect-wifi-bt-sdk"] path = third_party/efr32_sdk/wiseconnect-wifi-bt-sdk url = https://github.com/SiliconLabs/wiseconnect-wifi-bt-sdk diff --git a/examples/all-clusters-app/cc13x2x7_26x2x7/BUILD.gn b/examples/all-clusters-app/cc13x2x7_26x2x7/BUILD.gn index 7a74881a44d55d..46e8e9d0c9c7c1 100644 --- a/examples/all-clusters-app/cc13x2x7_26x2x7/BUILD.gn +++ b/examples/all-clusters-app/cc13x2x7_26x2x7/BUILD.gn @@ -26,17 +26,18 @@ import("${ti_simplelink_sdk_build_root}/ti_simplelink_sdk.gni") assert(current_os == "freertos") +declare_args() { + device_vid = "0xFFF1" + device_pid = "0x8006" + software_ver = "0x0001" + software_ver_str = "1.0d1" +} + project_dir = "${chip_root}/examples/all-clusters-app/cc13x2x7_26x2x7" ti_simplelink_sdk("sdk") { include_dirs = [ "${project_dir}/main/include" ] - - defines = [] - if (is_debug) { - defines += [ "BUILD_RELEASE=0" ] - } else { - defines += [ "BUILD_RELEASE=1" ] - } + public_configs = [ ":all-clusters-app_config" ] } ti_sysconfig("sysconfig") { diff --git a/examples/all-clusters-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h b/examples/all-clusters-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h index 5c62f09065ff40..a19157147c0093 100644 --- a/examples/all-clusters-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h +++ b/examples/all-clusters-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h @@ -47,20 +47,6 @@ */ #define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER "TEST_SN" -/** - * CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID - * - * 0xFFF1: Test vendor - */ -#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF1 - -/** - * CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID - * - * 0x8006: example lock app - */ -#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8006 - /** * CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION * @@ -72,15 +58,13 @@ #define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1 /** + * Values set by BUILD.gn: + * CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID + * CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING - * - * A string identifying the software version running on the device. - * CHIP currently expects the software version to be in the format - * {MAJOR_VERSION}.0d{MINOR_VERSION} + * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION */ -#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING -#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "1.0d1" -#endif + /** * CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE * diff --git a/examples/lock-app/cc13x2x7_26x2x7/BUILD.gn b/examples/lock-app/cc13x2x7_26x2x7/BUILD.gn index 2636803899e2ab..9c127522984b5c 100644 --- a/examples/lock-app/cc13x2x7_26x2x7/BUILD.gn +++ b/examples/lock-app/cc13x2x7_26x2x7/BUILD.gn @@ -26,17 +26,18 @@ import("${ti_simplelink_sdk_build_root}/ti_simplelink_sdk.gni") assert(current_os == "freertos") +declare_args() { + device_vid = "0xFFF1" + device_pid = "0x8006" + software_ver = "0x0001" + software_ver_str = "1.0d1" +} + project_dir = "${chip_root}/examples/lock-app/cc13x2x7_26x2x7" ti_simplelink_sdk("sdk") { include_dirs = [ "${project_dir}/main/include" ] - - defines = [] - if (is_debug) { - defines += [ "BUILD_RELEASE=0" ] - } else { - defines += [ "BUILD_RELEASE=1" ] - } + public_configs = [ ":lock_app_config" ] } ti_sysconfig("sysconfig") { @@ -79,6 +80,11 @@ ti_sysconfig("sysconfig") { ti_simplelink_executable("lock_app") { output_name = "chip-${ti_simplelink_board}-lock-example.out" + device_vid = device_vid + device_pid = device_pid + software_ver = software_ver + software_ver_str = software_ver_str + sources = [ "${project_dir}/main/AppTask.cpp", "${project_dir}/main/BoltLockManager.cpp", diff --git a/examples/lock-app/cc13x2x7_26x2x7/args.gni b/examples/lock-app/cc13x2x7_26x2x7/args.gni index 2b1db21d690d61..d0aac2a4b7ab2d 100644 --- a/examples/lock-app/cc13x2x7_26x2x7/args.gni +++ b/examples/lock-app/cc13x2x7_26x2x7/args.gni @@ -38,3 +38,5 @@ chip_config_network_layer_ble = true # Disable lock tracking, since our FreeRTOS configuration does not set # INCLUDE_xSemaphoreGetMutexHolder chip_stack_lock_tracking = "none" + +chip_openthread_ftd = true diff --git a/examples/lock-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/lock-app/cc13x2x7_26x2x7/main/AppTask.cpp index 35c474c6911010..ab0bf4047af4cb 100644 --- a/examples/lock-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/lock-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -129,8 +129,11 @@ int AppTask::Init() while (1) ; } - +#if CHIP_DEVICE_CONFIG_THREAD_FTD ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router); +#else + ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice); +#endif if (ret != CHIP_NO_ERROR) { PLAT_LOG("ConnectivityMgr().SetThreadDeviceType() failed"); diff --git a/examples/lock-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h b/examples/lock-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h index 5c62f09065ff40..082d0ec805cc49 100644 --- a/examples/lock-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h +++ b/examples/lock-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h @@ -47,20 +47,6 @@ */ #define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER "TEST_SN" -/** - * CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID - * - * 0xFFF1: Test vendor - */ -#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF1 - -/** - * CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID - * - * 0x8006: example lock app - */ -#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8006 - /** * CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION * @@ -69,18 +55,18 @@ * physical device, a change to its packaging, and/or a change to its marketing presentation. * This value is generally *not* incremented for device software versions. */ +#ifndef CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION #define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1 +#endif /** + * Values set by BUILD.gn: + * CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID + * CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING - * - * A string identifying the software version running on the device. - * CHIP currently expects the software version to be in the format - * {MAJOR_VERSION}.0d{MINOR_VERSION} + * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION */ -#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING -#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "1.0d1" -#endif + /** * CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE * diff --git a/examples/pump-app/cc13x2x7_26x2x7/BUILD.gn b/examples/pump-app/cc13x2x7_26x2x7/BUILD.gn index 7ee9db88c7a72e..61b4a5d0dfb023 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/BUILD.gn +++ b/examples/pump-app/cc13x2x7_26x2x7/BUILD.gn @@ -25,17 +25,18 @@ import("${ti_simplelink_sdk_build_root}/ti_simplelink_sdk.gni") assert(current_os == "freertos") +declare_args() { + device_vid = "0xFFF1" + device_pid = "0x800A" + software_ver = "0x0001" + software_ver_str = "1.0d1" +} + project_dir = "${chip_root}/examples/pump-app/cc13x2x7_26x2x7" ti_simplelink_sdk("sdk") { include_dirs = [ "${project_dir}/main/include" ] - - defines = [] - if (is_debug) { - defines += [ "BUILD_RELEASE=0" ] - } else { - defines += [ "BUILD_RELEASE=1" ] - } + public_configs = [ ":pump_app_config" ] } ti_sysconfig("sysconfig") { diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h b/examples/pump-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h index f94a7c4c0ac657..35eeeade2cb66d 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h +++ b/examples/pump-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h @@ -42,28 +42,6 @@ // Use a default pairing code if one hasn't been provisioned in flash. #define CHIP_DEVICE_CONFIG_USE_TEST_PAIRING_CODE "CHIPUS" -/** - * CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER - * - * Enables the use of a hard-coded default serial number if none - * is found in CHIP NV storage. - */ -#define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER "TEST_SN" - -/** - * CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID - * - * 0xFFF1: Test vendor. - */ -#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF1 - -/** - * CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID - * - * 0x8011: example pump-app - */ -#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x800A - /** * CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION * @@ -75,15 +53,13 @@ #define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1 /** + * Values set by BUILD.gn: + * CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID + * CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING - * - * A string identifying the software version running on the device. - * CHIP currently expects the software version to be in the format - * {MAJOR_VERSION}.0d{MINOR_VERSION} + * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION */ -#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING -#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "1.0d1" -#endif + /** * CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE * diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/BUILD.gn b/examples/pump-controller-app/cc13x2x7_26x2x7/BUILD.gn index fedefd4dcb5d5d..7f4b91d89f7e4b 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/BUILD.gn +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/BUILD.gn @@ -26,17 +26,18 @@ import("${ti_simplelink_sdk_build_root}/ti_simplelink_sdk.gni") assert(current_os == "freertos") +declare_args() { + device_vid = "0xFFF1" + device_pid = "0x8011" + software_ver = "0x0001" + software_ver_str = "1.0d1" +} + project_dir = "${chip_root}/examples/pump-controller-app/cc13x2x7_26x2x7" ti_simplelink_sdk("sdk") { include_dirs = [ "${project_dir}/main/include" ] - - defines = [] - if (is_debug) { - defines += [ "BUILD_RELEASE=0" ] - } else { - defines += [ "BUILD_RELEASE=1" ] - } + public_configs = [ ":pump_controller_app_config" ] } ti_sysconfig("sysconfig") { diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h index 0c216632b9d5e8..35eeeade2cb66d 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h @@ -42,28 +42,6 @@ // Use a default pairing code if one hasn't been provisioned in flash. #define CHIP_DEVICE_CONFIG_USE_TEST_PAIRING_CODE "CHIPUS" -/** - * CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER - * - * Enables the use of a hard-coded default serial number if none - * is found in CHIP NV storage. - */ -#define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER "TEST_SN" - -/** - * CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID - * - * 0xFFF1: Test vendor. - */ -#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF1 - -/** - * CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID - * - * 0x8009: example pump-controller-app - */ -#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8011 - /** * CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION * @@ -75,15 +53,13 @@ #define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1 /** + * Values set by BUILD.gn: + * CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID + * CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING - * - * A string identifying the software version running on the device. - * CHIP currently expects the software version to be in the format - * {MAJOR_VERSION}.0d{MINOR_VERSION} + * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION */ -#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING -#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "1.0d1" -#endif + /** * CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE * diff --git a/src/platform/cc13x2_26x2/OTAImageProcessorImpl.cpp b/src/platform/cc13x2_26x2/OTAImageProcessorImpl.cpp index d13b8b618f73fe..fd2fbe0c0d0dda 100644 --- a/src/platform/cc13x2_26x2/OTAImageProcessorImpl.cpp +++ b/src/platform/cc13x2_26x2/OTAImageProcessorImpl.cpp @@ -17,6 +17,8 @@ */ #include +#include +#include #include "OTAImageProcessorImpl.h" @@ -31,29 +33,32 @@ #include DeviceFamily_constructPath(driverlib/sys_ctrl.h) // clang-format on +using namespace chip::DeviceLayer; +using namespace chip::DeviceLayer::PersistedStorage; + namespace chip { CHIP_ERROR OTAImageProcessorImpl::PrepareDownload() { - DeviceLayer::PlatformMgr().ScheduleWork(HandlePrepareDownload, reinterpret_cast(this)); + PlatformMgr().ScheduleWork(HandlePrepareDownload, reinterpret_cast(this)); return CHIP_NO_ERROR; } CHIP_ERROR OTAImageProcessorImpl::Finalize() { - DeviceLayer::PlatformMgr().ScheduleWork(HandleFinalize, reinterpret_cast(this)); + PlatformMgr().ScheduleWork(HandleFinalize, reinterpret_cast(this)); return CHIP_NO_ERROR; } CHIP_ERROR OTAImageProcessorImpl::Apply() { - DeviceLayer::PlatformMgr().ScheduleWork(HandleApply, reinterpret_cast(this)); + PlatformMgr().ScheduleWork(HandleApply, reinterpret_cast(this)); return CHIP_NO_ERROR; } CHIP_ERROR OTAImageProcessorImpl::Abort() { - DeviceLayer::PlatformMgr().ScheduleWork(HandleAbort, reinterpret_cast(this)); + PlatformMgr().ScheduleWork(HandleAbort, reinterpret_cast(this)); return CHIP_NO_ERROR; } @@ -76,7 +81,7 @@ CHIP_ERROR OTAImageProcessorImpl::ProcessBlock(ByteSpan & block) ChipLogError(SoftwareUpdate, "Cannot set block data: %" CHIP_ERROR_FORMAT, err.Format()); } - DeviceLayer::PlatformMgr().ScheduleWork(HandleProcessBlock, reinterpret_cast(this)); + PlatformMgr().ScheduleWork(HandleProcessBlock, reinterpret_cast(this)); return CHIP_NO_ERROR; } @@ -92,24 +97,10 @@ CHIP_ERROR OTAImageProcessorImpl::ProcessBlock(ByteSpan & block) #define IMG_START (4 * EFL_SIZE_META) -static bool readExtFlashImgHeader(NVS_Handle handle, imgFixedHdr_t * header) +static bool readExtFlashImgHeader(NVS_Handle handle, imgFixedHdr_t * header, size_t otaHeaderLen) { int_fast16_t status; - status = NVS_read(handle, IMG_START, header, sizeof(header)); - return (status == NVS_STATUS_SUCCESS); -} - -static bool eraseExtFlashHeader(NVS_Handle handle) -{ - int_fast16_t status; - NVS_Attrs regionAttrs; - unsigned int sectors; - - NVS_getAttrs(handle, ®ionAttrs); - /* calculate the number of sectors to erase */ - sectors = (sizeof(imgFixedHdr_t) + (regionAttrs.sectorSize - 1)) / regionAttrs.sectorSize; - status = NVS_erase(handle, IMG_START, sectors * regionAttrs.sectorSize); - + status = NVS_read(handle, IMG_START + otaHeaderLen, header, sizeof(imgFixedHdr_t)); return (status == NVS_STATUS_SUCCESS); } @@ -131,17 +122,26 @@ static bool writeExtFlashImgPages(NVS_Handle handle, size_t bytesWritten, Mutabl status = NVS_erase(handle, IMG_START + (erasedSectors * sectorSize), (neededSectors - erasedSectors) * sectorSize); if (status != NVS_STATUS_SUCCESS) { + ChipLogError(SoftwareUpdate, "NVS_erase failed status: %d", status); return false; } } status = NVS_write(handle, IMG_START + bytesWritten, block.data(), block.size(), NVS_WRITE_POST_VERIFY); - return (status == NVS_STATUS_SUCCESS); + if (status != NVS_STATUS_SUCCESS) + { + ChipLogError(SoftwareUpdate, "NVS_write failed status: %d", status); + return false; + } + else + { + return true; + } } static bool readExtFlashMetaHeader(NVS_Handle handle, ExtImageInfo_t * header) { int_fast16_t status; - status = NVS_read(handle, EFL_ADDR_META, header, sizeof(header)); + status = NVS_read(handle, EFL_ADDR_META, header, sizeof(ExtImageInfo_t)); return (status == NVS_STATUS_SUCCESS); } @@ -166,7 +166,7 @@ static bool writeExtFlashMetaHeader(NVS_Handle handle, ExtImageInfo_t * header) { return false; } - status = NVS_write(handle, EFL_ADDR_META, header, sizeof(header), NVS_WRITE_POST_VERIFY); + status = NVS_write(handle, EFL_ADDR_META, header, sizeof(ExtImageInfo_t), NVS_WRITE_POST_VERIFY); return (status == NVS_STATUS_SUCCESS); } @@ -224,20 +224,20 @@ uint32_t crc_update(uint32_t crc, const void * data, size_t data_len) return crc & 0xffffffff; } -static bool validateExtFlashImage(NVS_Handle handle) +static bool validateExtFlashImage(NVS_Handle handle, size_t otaHeaderLen) { uint32_t crc; imgFixedHdr_t header; size_t addr, endAddr; - if (!readExtFlashImgHeader(handle, &header)) + if (!readExtFlashImgHeader(handle, &header, otaHeaderLen)) { return false; } /* CRC is calculated after the CRC element of the image header */ - addr = IMG_START + IMG_DATA_OFFSET; - endAddr = IMG_START + header.len; + addr = IMG_START + otaHeaderLen + IMG_DATA_OFFSET; + endAddr = IMG_START + otaHeaderLen + header.len; crc = 0xFFFFFFFF; @@ -301,19 +301,23 @@ void OTAImageProcessorImpl::HandleFinalize(intptr_t context) { ExtImageInfo_t header; auto * imageProcessor = reinterpret_cast(context); + const uint8_t extImgId[] = OAD_EFL_MAGIC; + if (imageProcessor == nullptr) { return; } - if (!readExtFlashImgHeader(imageProcessor->mNvsHandle, &(header.fixedHdr))) + if (!readExtFlashImgHeader(imageProcessor->mNvsHandle, &(header.fixedHdr), imageProcessor->mFixedOtaHeader.headerSize + sizeof(imageProcessor->mFixedOtaHeader))) { return; } - header.extFlAddr = IMG_START; + // offset in the size of the fixed and variable OTA image headers + memcpy(&(header.fixedHdr.imgID), extImgId, sizeof(header.fixedHdr.imgID)); + header.extFlAddr = IMG_START + imageProcessor->mFixedOtaHeader.headerSize + sizeof(imageProcessor->mFixedOtaHeader); header.counter = 0x0; - if (validateExtFlashImage(imageProcessor->mNvsHandle)) + if (validateExtFlashImage(imageProcessor->mNvsHandle, imageProcessor->mFixedOtaHeader.headerSize + sizeof(imageProcessor->mFixedOtaHeader))) { // only write the meta header if the crc check passes writeExtFlashMetaHeader(imageProcessor->mNvsHandle, &header); @@ -381,8 +385,23 @@ void OTAImageProcessorImpl::HandleProcessBlock(intptr_t context) return; } - // TODO: Process block header if any + /* Save the fixed size header */ + if (imageProcessor->mParams.downloadedBytes < sizeof(imageProcessor->mFixedOtaHeader)) + { + uint8_t *header = reinterpret_cast(&(imageProcessor->mFixedOtaHeader)); + if (imageProcessor->mBlock.size() + imageProcessor->mParams.downloadedBytes < sizeof(imageProcessor->mFixedOtaHeader)) + { + memcpy(header + imageProcessor->mParams.downloadedBytes, imageProcessor->mBlock.data(), imageProcessor->mBlock.size()); + } + else + { + memcpy(header + imageProcessor->mParams.downloadedBytes, imageProcessor->mBlock.data(), sizeof(imageProcessor->mFixedOtaHeader) - imageProcessor->mParams.downloadedBytes); + } + } + + /* chip::OTAImageHeaderParser can be used for processing the variable size header */ + ChipLogDetail(SoftwareUpdate, "Write block %d, %d", (size_t)imageProcessor->mParams.downloadedBytes, imageProcessor->mBlock.size()); if (!writeExtFlashImgPages(imageProcessor->mNvsHandle, imageProcessor->mParams.downloadedBytes, imageProcessor->mBlock)) { imageProcessor->mDownloader->EndDownload(CHIP_ERROR_WRITE_FAILED); diff --git a/src/platform/cc13x2_26x2/OTAImageProcessorImpl.h b/src/platform/cc13x2_26x2/OTAImageProcessorImpl.h index 700cef6141a618..5aab56a291bd9e 100644 --- a/src/platform/cc13x2_26x2/OTAImageProcessorImpl.h +++ b/src/platform/cc13x2_26x2/OTAImageProcessorImpl.h @@ -62,6 +62,12 @@ class OTAImageProcessorImpl : public OTAImageProcessorInterface uint16_t mMetaPage; MutableByteSpan mBlock; OTADownloader * mDownloader; + + struct fixedOtaHeader { + uint32_t fileIdentifier; + uint64_t totalSize; + uint32_t headerSize; + } PACK_STRUCT_STRUCT mFixedOtaHeader; }; } // namespace chip diff --git a/third_party/ti_simplelink_sdk/oad_merge_tool.py b/third_party/ti_simplelink_sdk/oad_merge_tool.py new file mode 100644 index 00000000000000..88c25465e4c0e4 --- /dev/null +++ b/third_party/ti_simplelink_sdk/oad_merge_tool.py @@ -0,0 +1,27 @@ +# Copyright 2020 Texas Instruments Incorporated + +"""Simple hexmerge script for combining the BIM and App + +This script provides a basic utility to combine the OAD application binary file with the Boot Image Manager hex file. The output is a combined hex file that can be programmed on the target and run. + +Run with: + python oad_merge_tool.py +""" + +import sys +import intelhex + +oad_bin_file = sys.argv[1] +bim_hex_file = sys.argv[2] +combined_hex = sys.argv[3] + +# merge binary executable with bim hex file +ota_image = intelhex.IntelHex() +ota_image.fromfile(oad_bin_file, format='bin') + +bim_hex = intelhex.IntelHex() +bim_hex.fromfile(bim_hex_file, format='hex') + +ota_image.merge(bim_hex) + +ota_image.tofile(combined_hex, format='hex') diff --git a/third_party/ti_simplelink_sdk/run_oad_tool.py b/third_party/ti_simplelink_sdk/run_oad_tool.py deleted file mode 100644 index 9c7b62da4f883d..00000000000000 --- a/third_party/ti_simplelink_sdk/run_oad_tool.py +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright 2020 Texas Instruments Incorporated - -"""A wrapper to run the oad tool. - -This script provides a basic Python wrapper for GN to call the TI OAD image -tool. This will result in a downloadable binary file. Currently this is only -used for CC13XX_CC26XX devices. - -Run with: - python run_oad_tool.py -""" - -import sys -import subprocess -import json -import intelhex - -# The extension is probably not necessary -if sys.platform.startswith('win'): - proc_call = [sys.argv[1] + '/tools/common/oad/oad_image_tool.exe'] - -else: - proc_call = [sys.argv[1] + '/tools/common/oad/oad_image_tool'] - -root_out_dir = sys.argv[2] -project_name = sys.argv[3] -pem_file = sys.argv[4] -hex_file = root_out_dir + '/' + project_name + '.hex' -oad_bin_file = root_out_dir + '/' + project_name + '.bin' -combined_hex = root_out_dir + '/' + project_name + '-bim.hex' -bim_hex_file = sys.argv[5] - -proc_call += [ - '--verbose', - 'ccs', - root_out_dir, - '7', - '-hex1', hex_file, - '-k', pem_file, - '-o', sys.argv[3] -] - -# run oad_tool to fill in the header -subprocess.call(proc_call) - -# merge binary executable with bim hex file -ota_image = intelhex.IntelHex() -ota_image.fromfile(oad_bin_file, format='bin') - -bim_hex = intelhex.IntelHex() -bim_hex.fromfile(bim_hex_file, format='hex') - -ota_image.merge(bim_hex) - -ota_image.tofile(combined_hex, format='hex') diff --git a/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni b/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni index e3b55cdabdefb1..1298549d236656 100644 --- a/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni +++ b/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni @@ -26,7 +26,7 @@ template("ti_simplelink_executable") { if (chip_enable_ota_requestor) { # Generating the ota binary image - final_target = "${target_name}_ota" + final_target = "${target_name}.ota" } else { # The executable is the final target. final_target = "${simplelink_target_name}.out" @@ -37,9 +37,33 @@ template("ti_simplelink_executable") { objcopy_image_format = "ihex" objcopy = "arm-none-eabi-objcopy" + config("${simplelink_target_name}_config") { + defines = [] + + if (defined(invoker.defines)) { + defines += invoker.defines + } + + # add OTA options if available + if (defined(invoker.device_vid)) { + defines += [ "CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID=${invoker.device_vid}" ] + } + if (defined(invoker.device_pid)) { + defines += [ "CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID=${invoker.device_pid}" ] + } + if (defined(invoker.software_ver)) { + defines += [ "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION=${invoker.software_ver}" ] + } + if (defined(invoker.software_ver_str)) { + defines += [ "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING=\"${invoker.software_ver_str}\"" ] + } + } + flashable_executable("${simplelink_target_name}.out") { forward_variables_from(invoker, "*") + public_configs = [ ":${simplelink_target_name}_config" ] + if (ti_simplelink_device_family == "cc13x2x7_26x2x7") { if (chip_enable_ota_requestor) { sources += @@ -63,21 +87,34 @@ template("ti_simplelink_executable") { if (chip_enable_ota_requestor && ti_simplelink_device_family == "cc13x2x7_26x2x7") { - pw_python_action("${target_name}_ota") { + pw_python_action("${simplelink_target_name}.bin") { public_deps = [ ":${simplelink_target_name}.out.image" ] - script = "${ti_simplelink_sdk_build_root}/run_oad_tool.py" + script = "${ti_simplelink_sdk_root}//tools/common/oad/oad_image_tool.py" sources = [ "${root_out_dir}/${objcopy_image_name}" ] - outputs = [ - "${root_out_dir}/${output_base_name}.bin", - "${root_out_dir}/${output_base_name}-bim.hex", + outputs = [ "${root_out_dir}/${output_base_name}.bin" ] + + args = [ + "--verbose", + "ccs", + rebase_path(root_out_dir, root_build_dir), + "7", + "-hex1", rebase_path("${root_out_dir}/${output_base_name}.hex", root_build_dir), + "-o", output_base_name ] if (defined(invoker.pem_file)) { - pem_file = invoker.pem_file + args += [ "-k", rebase_path(invoker.pem_file, root_build_dir) ] } else { - pem_file = "${ti_simplelink_sdk_root}/tools/common/oad/private.pem" + args += [ "-k", rebase_path("${ti_simplelink_sdk_root}/tools/common/oad/private.pem", root_build_dir) ] } + } + pw_python_action("${simplelink_target_name}-bim.hex") { + public_deps = [ ":${simplelink_target_name}.bin" ] + + script = "${ti_simplelink_sdk_build_root}/oad_merge_tool.py" + sources = [ "${root_out_dir}/${output_base_name}.bin" ] + outputs = [ "${root_out_dir}/${output_base_name}-bim.hex" ] if (defined(invoker.bim_hex)) { bim_hex = invoker.bim_hex @@ -86,12 +123,54 @@ template("ti_simplelink_executable") { } args = [ - rebase_path(ti_simplelink_sdk_root, root_build_dir), - rebase_path(root_out_dir, root_build_dir), - output_base_name, - rebase_path(pem_file, root_build_dir), + rebase_path("${root_out_dir}/${output_base_name}.bin", root_build_dir), rebase_path(bim_hex, root_build_dir), + rebase_path("${root_out_dir}/${output_base_name}-bim.hex", root_build_dir), + ] + + args += [ "${root_out_dir}/${output_base_name}-bim.hex" ] + } + pw_python_action("${target_name}.ota") { + public_deps = [ ":${simplelink_target_name}-bim.hex" ] + + script = "${chip_root}/src/app/ota_image_tool.py" + sources = [ "${root_out_dir}/${output_base_name}.bin" ] + outputs = [ "${root_out_dir}/${output_base_name}.ota" ] + + args = [ + "create", + rebase_path("${root_out_dir}/${output_base_name}.bin", root_build_dir), + rebase_path("${root_out_dir}/${output_base_name}.ota", root_build_dir), ] + + if (defined(invoker.device_vid)) { + args += [ "-v", invoker.device_vid ] + } else { + args += [ "-v", "0xFFF1" ] + } + if (defined(invoker.device_pid)) { + args += [ "-p", invoker.device_pid ] + } else { + args += [ "-p", "0x8006" ] + } + if (defined(invoker.software_ver)) { + args += [ "-vn", invoker.software_ver ] + } else { + args += [ "-vn", "0x0001" ] + } + if (defined(invoker.software_ver_str)) { + args += [ "-vs", invoker.software_ver_str ] + } else { + args += [ "-vs", "1.0d1" ] + } + if (defined(invoker.ota_digest)) { + args += [ "-da", invoker.ota_digest ] + } else { + args += [ "-da", "sha256" ] + } + if (defined(invoker.ota_args)) { + args += invoker.ota_args + } } } diff --git a/third_party/ti_simplelink_sdk/ti_simplelink_sdk.gni b/third_party/ti_simplelink_sdk/ti_simplelink_sdk.gni index 0d63fb6905b688..caf6d1ffeefdbd 100644 --- a/third_party/ti_simplelink_sdk/ti_simplelink_sdk.gni +++ b/third_party/ti_simplelink_sdk/ti_simplelink_sdk.gni @@ -466,5 +466,8 @@ template("ti_simplelink_sdk") { ":${sdk_target_name}_openthread_platform", ] } + if (defined(invoker.public_configs)) { + public_configs = invoker.public_configs + } } } From a79976333c44fb6014839e614c0ddfa03e176c34 Mon Sep 17 00:00:00 2001 From: Seth Rickard Date: Tue, 19 Apr 2022 15:56:09 +0000 Subject: [PATCH 02/14] add software trip version for first run --- src/lib/support/DefaultStorageKeyAllocator.h | 1 + .../cc13x2_26x2/OTAImageProcessorImpl.cpp | 35 +++++++++++++++++++ .../cc13x2_26x2/OTAImageProcessorImpl.h | 2 +- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/lib/support/DefaultStorageKeyAllocator.h b/src/lib/support/DefaultStorageKeyAllocator.h index 32a2100c44cdd6..f029fe27acdf83 100644 --- a/src/lib/support/DefaultStorageKeyAllocator.h +++ b/src/lib/support/DefaultStorageKeyAllocator.h @@ -111,6 +111,7 @@ class DefaultStorageKeyAllocator static const char * OTAUpdateToken() { return "g/o/ut"; } static const char * OTACurrentUpdateState() { return "g/o/us"; } static const char * OTATargetVersion() { return "g/o/tv"; } + static const char * OTATripVersion() { return "g/o/tr"; } // Event number counter. const char * IMEventNumber() { return Format("g/im/e"); } diff --git a/src/platform/cc13x2_26x2/OTAImageProcessorImpl.cpp b/src/platform/cc13x2_26x2/OTAImageProcessorImpl.cpp index fd2fbe0c0d0dda..e0b1d726639396 100644 --- a/src/platform/cc13x2_26x2/OTAImageProcessorImpl.cpp +++ b/src/platform/cc13x2_26x2/OTAImageProcessorImpl.cpp @@ -85,6 +85,41 @@ CHIP_ERROR OTAImageProcessorImpl::ProcessBlock(ByteSpan & block) return CHIP_NO_ERROR; } +bool OTAImageProcessorImpl::IsFirstImageRun() +{ + CHIP_ERROR err; + uint32_t runningSwVer; + uint32_t otaTripSwVer; + + err = ConfigurationMgr().GetSoftwareVersion(runningSwVer); + SuccessOrExit(err); + err = KeyValueStoreMgr().Get(DefaultStorageKeyAllocator::OTATripVersion(), &otaTripSwVer); + if (CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND == err) + { + // Trip version does not exist, place the current version in KVS + // This is the first run of the device with no persisted data, likely a + // factory reset + err = KeyValueStoreMgr().Put(DefaultStorageKeyAllocator::OTATripVersion(), runningSwVer); + SuccessOrExit(err); + return false; + } + SuccessOrExit(err); + + if (runningSwVer != otaTripSwVer) + { + // The version stored in the KVS does not match the version reported by + // the Configuration Manager + // This is the first time this version has run. + err = KeyValueStoreMgr().Put(DefaultStorageKeyAllocator::OTATripVersion(), runningSwVer); + SuccessOrExit(err); + return true; + } + +exit: + return false; + +} + /* DESIGN NOTE: The Boot Image Manager will search external flash for an * `ExtImageInfo_t` structure every 4K for 1M. This structure points to where * the executable image is in external flash with a uint32_t. It is possible to diff --git a/src/platform/cc13x2_26x2/OTAImageProcessorImpl.h b/src/platform/cc13x2_26x2/OTAImageProcessorImpl.h index 5aab56a291bd9e..b5842a6ddb7713 100644 --- a/src/platform/cc13x2_26x2/OTAImageProcessorImpl.h +++ b/src/platform/cc13x2_26x2/OTAImageProcessorImpl.h @@ -35,7 +35,7 @@ class OTAImageProcessorImpl : public OTAImageProcessorInterface CHIP_ERROR Apply() override; CHIP_ERROR Abort() override; CHIP_ERROR ProcessBlock(ByteSpan & block) override; - bool IsFirstImageRun() override { return false; } + bool IsFirstImageRun() override; CHIP_ERROR ConfirmCurrentImage() override { return CHIP_NO_ERROR; } void SetOTADownloader(OTADownloader * downloader) { mDownloader = downloader; } From bffbabea73a4493a4b9eacae1bd5a84aed9360d2 Mon Sep 17 00:00:00 2001 From: Seth Rickard Date: Tue, 19 Apr 2022 15:58:03 +0000 Subject: [PATCH 03/14] change isFirstRun to be based on the OTA update process and target SW version --- src/lib/support/DefaultStorageKeyAllocator.h | 1 - .../cc13x2_26x2/OTAImageProcessorImpl.cpp | 40 ++++++------------- 2 files changed, 13 insertions(+), 28 deletions(-) diff --git a/src/lib/support/DefaultStorageKeyAllocator.h b/src/lib/support/DefaultStorageKeyAllocator.h index f029fe27acdf83..32a2100c44cdd6 100644 --- a/src/lib/support/DefaultStorageKeyAllocator.h +++ b/src/lib/support/DefaultStorageKeyAllocator.h @@ -111,7 +111,6 @@ class DefaultStorageKeyAllocator static const char * OTAUpdateToken() { return "g/o/ut"; } static const char * OTACurrentUpdateState() { return "g/o/us"; } static const char * OTATargetVersion() { return "g/o/tv"; } - static const char * OTATripVersion() { return "g/o/tr"; } // Event number counter. const char * IMEventNumber() { return Format("g/im/e"); } diff --git a/src/platform/cc13x2_26x2/OTAImageProcessorImpl.cpp b/src/platform/cc13x2_26x2/OTAImageProcessorImpl.cpp index e0b1d726639396..8ed7b5468f8b4e 100644 --- a/src/platform/cc13x2_26x2/OTAImageProcessorImpl.cpp +++ b/src/platform/cc13x2_26x2/OTAImageProcessorImpl.cpp @@ -87,33 +87,19 @@ CHIP_ERROR OTAImageProcessorImpl::ProcessBlock(ByteSpan & block) bool OTAImageProcessorImpl::IsFirstImageRun() { - CHIP_ERROR err; - uint32_t runningSwVer; - uint32_t otaTripSwVer; - - err = ConfigurationMgr().GetSoftwareVersion(runningSwVer); - SuccessOrExit(err); - err = KeyValueStoreMgr().Get(DefaultStorageKeyAllocator::OTATripVersion(), &otaTripSwVer); - if (CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND == err) - { - // Trip version does not exist, place the current version in KVS - // This is the first run of the device with no persisted data, likely a - // factory reset - err = KeyValueStoreMgr().Put(DefaultStorageKeyAllocator::OTATripVersion(), runningSwVer); - SuccessOrExit(err); - return false; - } - SuccessOrExit(err); - - if (runningSwVer != otaTripSwVer) - { - // The version stored in the KVS does not match the version reported by - // the Configuration Manager - // This is the first time this version has run. - err = KeyValueStoreMgr().Put(DefaultStorageKeyAllocator::OTATripVersion(), runningSwVer); - SuccessOrExit(err); - return true; - } + CHIP_ERROR err; + OTARequestorInterface *requestor; + uint32_t runningSwVer; + + err = ConfigurationMgr().GetSoftwareVersion(runningSwVer); + SuccessOrExit(err); + + requestor = GetRequestorInstance(); + if (chip::app::Clusters::OtaSoftwareUpdateRequestor::OTAUpdateStateEnum::kApplying == requestor->GetCurrentUpdateState() + && runningSwVer == requestor->GetTargetVersion()) + { + return true; + } exit: return false; From 20089be1682fbed928670648141a39414c6da73a Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 20 Apr 2022 14:52:59 +0000 Subject: [PATCH 04/14] Restyled by clang-format --- .../cc13x2_26x2/OTAImageProcessorImpl.cpp | 39 ++++++++++--------- .../cc13x2_26x2/OTAImageProcessorImpl.h | 3 +- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/platform/cc13x2_26x2/OTAImageProcessorImpl.cpp b/src/platform/cc13x2_26x2/OTAImageProcessorImpl.cpp index 8ed7b5468f8b4e..48a703cd3b7b8f 100644 --- a/src/platform/cc13x2_26x2/OTAImageProcessorImpl.cpp +++ b/src/platform/cc13x2_26x2/OTAImageProcessorImpl.cpp @@ -87,23 +87,22 @@ CHIP_ERROR OTAImageProcessorImpl::ProcessBlock(ByteSpan & block) bool OTAImageProcessorImpl::IsFirstImageRun() { - CHIP_ERROR err; - OTARequestorInterface *requestor; - uint32_t runningSwVer; + CHIP_ERROR err; + OTARequestorInterface * requestor; + uint32_t runningSwVer; - err = ConfigurationMgr().GetSoftwareVersion(runningSwVer); - SuccessOrExit(err); + err = ConfigurationMgr().GetSoftwareVersion(runningSwVer); + SuccessOrExit(err); - requestor = GetRequestorInstance(); - if (chip::app::Clusters::OtaSoftwareUpdateRequestor::OTAUpdateStateEnum::kApplying == requestor->GetCurrentUpdateState() - && runningSwVer == requestor->GetTargetVersion()) - { - return true; - } + requestor = GetRequestorInstance(); + if (chip::app::Clusters::OtaSoftwareUpdateRequestor::OTAUpdateStateEnum::kApplying == requestor->GetCurrentUpdateState() && + runningSwVer == requestor->GetTargetVersion()) + { + return true; + } exit: return false; - } /* DESIGN NOTE: The Boot Image Manager will search external flash for an @@ -321,7 +320,7 @@ void OTAImageProcessorImpl::HandlePrepareDownload(intptr_t context) void OTAImageProcessorImpl::HandleFinalize(intptr_t context) { ExtImageInfo_t header; - auto * imageProcessor = reinterpret_cast(context); + auto * imageProcessor = reinterpret_cast(context); const uint8_t extImgId[] = OAD_EFL_MAGIC; if (imageProcessor == nullptr) @@ -329,7 +328,8 @@ void OTAImageProcessorImpl::HandleFinalize(intptr_t context) return; } - if (!readExtFlashImgHeader(imageProcessor->mNvsHandle, &(header.fixedHdr), imageProcessor->mFixedOtaHeader.headerSize + sizeof(imageProcessor->mFixedOtaHeader))) + if (!readExtFlashImgHeader(imageProcessor->mNvsHandle, &(header.fixedHdr), + imageProcessor->mFixedOtaHeader.headerSize + sizeof(imageProcessor->mFixedOtaHeader))) { return; } @@ -338,7 +338,8 @@ void OTAImageProcessorImpl::HandleFinalize(intptr_t context) header.extFlAddr = IMG_START + imageProcessor->mFixedOtaHeader.headerSize + sizeof(imageProcessor->mFixedOtaHeader); header.counter = 0x0; - if (validateExtFlashImage(imageProcessor->mNvsHandle, imageProcessor->mFixedOtaHeader.headerSize + sizeof(imageProcessor->mFixedOtaHeader))) + if (validateExtFlashImage(imageProcessor->mNvsHandle, + imageProcessor->mFixedOtaHeader.headerSize + sizeof(imageProcessor->mFixedOtaHeader))) { // only write the meta header if the crc check passes writeExtFlashMetaHeader(imageProcessor->mNvsHandle, &header); @@ -409,20 +410,22 @@ void OTAImageProcessorImpl::HandleProcessBlock(intptr_t context) /* Save the fixed size header */ if (imageProcessor->mParams.downloadedBytes < sizeof(imageProcessor->mFixedOtaHeader)) { - uint8_t *header = reinterpret_cast(&(imageProcessor->mFixedOtaHeader)); + uint8_t * header = reinterpret_cast(&(imageProcessor->mFixedOtaHeader)); if (imageProcessor->mBlock.size() + imageProcessor->mParams.downloadedBytes < sizeof(imageProcessor->mFixedOtaHeader)) { memcpy(header + imageProcessor->mParams.downloadedBytes, imageProcessor->mBlock.data(), imageProcessor->mBlock.size()); } else { - memcpy(header + imageProcessor->mParams.downloadedBytes, imageProcessor->mBlock.data(), sizeof(imageProcessor->mFixedOtaHeader) - imageProcessor->mParams.downloadedBytes); + memcpy(header + imageProcessor->mParams.downloadedBytes, imageProcessor->mBlock.data(), + sizeof(imageProcessor->mFixedOtaHeader) - imageProcessor->mParams.downloadedBytes); } } /* chip::OTAImageHeaderParser can be used for processing the variable size header */ - ChipLogDetail(SoftwareUpdate, "Write block %d, %d", (size_t)imageProcessor->mParams.downloadedBytes, imageProcessor->mBlock.size()); + ChipLogDetail(SoftwareUpdate, "Write block %d, %d", (size_t) imageProcessor->mParams.downloadedBytes, + imageProcessor->mBlock.size()); if (!writeExtFlashImgPages(imageProcessor->mNvsHandle, imageProcessor->mParams.downloadedBytes, imageProcessor->mBlock)) { imageProcessor->mDownloader->EndDownload(CHIP_ERROR_WRITE_FAILED); diff --git a/src/platform/cc13x2_26x2/OTAImageProcessorImpl.h b/src/platform/cc13x2_26x2/OTAImageProcessorImpl.h index b5842a6ddb7713..daf6ea4ffde029 100644 --- a/src/platform/cc13x2_26x2/OTAImageProcessorImpl.h +++ b/src/platform/cc13x2_26x2/OTAImageProcessorImpl.h @@ -63,7 +63,8 @@ class OTAImageProcessorImpl : public OTAImageProcessorInterface MutableByteSpan mBlock; OTADownloader * mDownloader; - struct fixedOtaHeader { + struct fixedOtaHeader + { uint32_t fileIdentifier; uint64_t totalSize; uint32_t headerSize; From 2191d13f881ed014e33ae723441dd568fe2d3af8 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 20 Apr 2022 14:53:00 +0000 Subject: [PATCH 05/14] Restyled by gn --- .../ti_simplelink_executable.gni | 77 +++++++++++++++---- 1 file changed, 60 insertions(+), 17 deletions(-) diff --git a/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni b/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni index 1298549d236656..225e8bc3f21df8 100644 --- a/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni +++ b/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni @@ -49,10 +49,13 @@ template("ti_simplelink_executable") { defines += [ "CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID=${invoker.device_vid}" ] } if (defined(invoker.device_pid)) { - defines += [ "CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID=${invoker.device_pid}" ] + defines += + [ "CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID=${invoker.device_pid}" ] } if (defined(invoker.software_ver)) { - defines += [ "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION=${invoker.software_ver}" ] + defines += [ + "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION=${invoker.software_ver}", + ] } if (defined(invoker.software_ver_str)) { defines += [ "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING=\"${invoker.software_ver_str}\"" ] @@ -99,14 +102,23 @@ template("ti_simplelink_executable") { "ccs", rebase_path(root_out_dir, root_build_dir), "7", - "-hex1", rebase_path("${root_out_dir}/${output_base_name}.hex", root_build_dir), - "-o", output_base_name + "-hex1", + rebase_path("${root_out_dir}/${output_base_name}.hex", root_build_dir), + "-o", + output_base_name, ] if (defined(invoker.pem_file)) { - args += [ "-k", rebase_path(invoker.pem_file, root_build_dir) ] + args += [ + "-k", + rebase_path(invoker.pem_file, root_build_dir), + ] } else { - args += [ "-k", rebase_path("${ti_simplelink_sdk_root}/tools/common/oad/private.pem", root_build_dir) ] + args += [ + "-k", + rebase_path("${ti_simplelink_sdk_root}/tools/common/oad/private.pem", + root_build_dir), + ] } } pw_python_action("${simplelink_target_name}-bim.hex") { @@ -125,7 +137,8 @@ template("ti_simplelink_executable") { args = [ rebase_path("${root_out_dir}/${output_base_name}.bin", root_build_dir), rebase_path(bim_hex, root_build_dir), - rebase_path("${root_out_dir}/${output_base_name}-bim.hex", root_build_dir), + rebase_path("${root_out_dir}/${output_base_name}-bim.hex", + root_build_dir), ] args += [ "${root_out_dir}/${output_base_name}-bim.hex" ] @@ -144,29 +157,59 @@ template("ti_simplelink_executable") { ] if (defined(invoker.device_vid)) { - args += [ "-v", invoker.device_vid ] + args += [ + "-v", + invoker.device_vid, + ] } else { - args += [ "-v", "0xFFF1" ] + args += [ + "-v", + "0xFFF1", + ] } if (defined(invoker.device_pid)) { - args += [ "-p", invoker.device_pid ] + args += [ + "-p", + invoker.device_pid, + ] } else { - args += [ "-p", "0x8006" ] + args += [ + "-p", + "0x8006", + ] } if (defined(invoker.software_ver)) { - args += [ "-vn", invoker.software_ver ] + args += [ + "-vn", + invoker.software_ver, + ] } else { - args += [ "-vn", "0x0001" ] + args += [ + "-vn", + "0x0001", + ] } if (defined(invoker.software_ver_str)) { - args += [ "-vs", invoker.software_ver_str ] + args += [ + "-vs", + invoker.software_ver_str, + ] } else { - args += [ "-vs", "1.0d1" ] + args += [ + "-vs", + "1.0d1", + ] } if (defined(invoker.ota_digest)) { - args += [ "-da", invoker.ota_digest ] + args += [ + "-da", + invoker.ota_digest, + ] } else { - args += [ "-da", "sha256" ] + args += [ + "-da", + "sha256", + ] } if (defined(invoker.ota_args)) { args += invoker.ota_args From 90e7d4dc7ee0c3c8b4163e6fd101d2f1bb8bd060 Mon Sep 17 00:00:00 2001 From: Seth Rickard Date: Wed, 20 Apr 2022 15:01:53 +0000 Subject: [PATCH 06/14] use tab instead of spaces in gitmodules --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index d2f35c99693d3a..3ce86dc4e554a6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -246,7 +246,7 @@ url = https://github.com/TexasInstruments/cc13xx_cc26xx_sdk.git branch = main platforms = cc13x2_26x2 - ignore = dirty + ignore = dirty [submodule "third_party/efr32_sdk/wiseconnect-wifi-bt-sdk"] path = third_party/efr32_sdk/wiseconnect-wifi-bt-sdk url = https://github.com/SiliconLabs/wiseconnect-wifi-bt-sdk From 92450d0104d2850c37f96fb27f9288c0c7dc7e20 Mon Sep 17 00:00:00 2001 From: Seth Rickard Date: Wed, 20 Apr 2022 21:56:45 +0000 Subject: [PATCH 07/14] copy header and c style comments --- .../cc13x2_26x2/OTAImageProcessorImpl.cpp | 22 +++++++------------ .../ti_simplelink_sdk/oad_merge_tool.py | 16 +++++++++++++- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/platform/cc13x2_26x2/OTAImageProcessorImpl.cpp b/src/platform/cc13x2_26x2/OTAImageProcessorImpl.cpp index 48a703cd3b7b8f..9331668283b2eb 100644 --- a/src/platform/cc13x2_26x2/OTAImageProcessorImpl.cpp +++ b/src/platform/cc13x2_26x2/OTAImageProcessorImpl.cpp @@ -87,22 +87,19 @@ CHIP_ERROR OTAImageProcessorImpl::ProcessBlock(ByteSpan & block) bool OTAImageProcessorImpl::IsFirstImageRun() { - CHIP_ERROR err; OTARequestorInterface * requestor; uint32_t runningSwVer; - err = ConfigurationMgr().GetSoftwareVersion(runningSwVer); - SuccessOrExit(err); - - requestor = GetRequestorInstance(); - if (chip::app::Clusters::OtaSoftwareUpdateRequestor::OTAUpdateStateEnum::kApplying == requestor->GetCurrentUpdateState() && - runningSwVer == requestor->GetTargetVersion()) + if (CHIP_NO_ERROR != ConfigurationMgr().GetSoftwareVersion(runningSwVer)) { - return true; + return false; } -exit: - return false; + requestor = GetRequestorInstance(); + + return (requestor->GetTargetVersion() == runningSwVer) && + (requestor->GetCurrentUpdateState() == + chip::app::Clusters::OtaSoftwareUpdateRequestor::OTAUpdateStateEnum::kApplying); } /* DESIGN NOTE: The Boot Image Manager will search external flash for an @@ -152,10 +149,7 @@ static bool writeExtFlashImgPages(NVS_Handle handle, size_t bytesWritten, Mutabl ChipLogError(SoftwareUpdate, "NVS_write failed status: %d", status); return false; } - else - { - return true; - } + return true; } static bool readExtFlashMetaHeader(NVS_Handle handle, ExtImageInfo_t * header) diff --git a/third_party/ti_simplelink_sdk/oad_merge_tool.py b/third_party/ti_simplelink_sdk/oad_merge_tool.py index 88c25465e4c0e4..262732619014b3 100644 --- a/third_party/ti_simplelink_sdk/oad_merge_tool.py +++ b/third_party/ti_simplelink_sdk/oad_merge_tool.py @@ -1,4 +1,18 @@ -# Copyright 2020 Texas Instruments Incorporated +#!/usr/bin/env python + +# Copyright (c) 2022 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """Simple hexmerge script for combining the BIM and App From 7d180a096668a02c9dc39b85957c48b6c0ffcf32 Mon Sep 17 00:00:00 2001 From: Seth Rickard Date: Wed, 20 Apr 2022 22:07:42 +0000 Subject: [PATCH 08/14] avoid writing python bytecode with environment variable --- .gitmodules | 1 - third_party/ti_simplelink_sdk/ti_simplelink_executable.gni | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 3ce86dc4e554a6..7fadeb79ec8fcf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -246,7 +246,6 @@ url = https://github.com/TexasInstruments/cc13xx_cc26xx_sdk.git branch = main platforms = cc13x2_26x2 - ignore = dirty [submodule "third_party/efr32_sdk/wiseconnect-wifi-bt-sdk"] path = third_party/efr32_sdk/wiseconnect-wifi-bt-sdk url = https://github.com/SiliconLabs/wiseconnect-wifi-bt-sdk diff --git a/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni b/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni index 225e8bc3f21df8..b4017a42d671b8 100644 --- a/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni +++ b/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni @@ -94,6 +94,7 @@ template("ti_simplelink_executable") { public_deps = [ ":${simplelink_target_name}.out.image" ] script = "${ti_simplelink_sdk_root}//tools/common/oad/oad_image_tool.py" + environment = [ "PYTHONDONTWRITEBYTECODE=1" ] sources = [ "${root_out_dir}/${objcopy_image_name}" ] outputs = [ "${root_out_dir}/${output_base_name}.bin" ] From a82610904a6b2a7f30b6cd0731b400539236f792 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 20 Apr 2022 22:08:07 +0000 Subject: [PATCH 09/14] Restyled by clang-format --- src/platform/cc13x2_26x2/OTAImageProcessorImpl.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/platform/cc13x2_26x2/OTAImageProcessorImpl.cpp b/src/platform/cc13x2_26x2/OTAImageProcessorImpl.cpp index 9331668283b2eb..09286a6aa9aedb 100644 --- a/src/platform/cc13x2_26x2/OTAImageProcessorImpl.cpp +++ b/src/platform/cc13x2_26x2/OTAImageProcessorImpl.cpp @@ -98,8 +98,7 @@ bool OTAImageProcessorImpl::IsFirstImageRun() requestor = GetRequestorInstance(); return (requestor->GetTargetVersion() == runningSwVer) && - (requestor->GetCurrentUpdateState() == - chip::app::Clusters::OtaSoftwareUpdateRequestor::OTAUpdateStateEnum::kApplying); + (requestor->GetCurrentUpdateState() == chip::app::Clusters::OtaSoftwareUpdateRequestor::OTAUpdateStateEnum::kApplying); } /* DESIGN NOTE: The Boot Image Manager will search external flash for an From 01ea0073e8ddfeed4a415ff3396e3b25ff42d423 Mon Sep 17 00:00:00 2001 From: Seth Rickard Date: Mon, 25 Apr 2022 14:40:27 +0000 Subject: [PATCH 10/14] add gitignore to ti submodule --- third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx | 2 +- third_party/ti_simplelink_sdk/ti_simplelink_executable.gni | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx b/third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx index f9db17b6d9c07f..55eba10c7f93d1 160000 --- a/third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx +++ b/third_party/ti_simplelink_sdk/repo_cc13xx_cc26xx @@ -1 +1 @@ -Subproject commit f9db17b6d9c07f9c2d613d297a0fcfaacbea2f06 +Subproject commit 55eba10c7f93d1bdc2f875e888f76d9396c00dbf diff --git a/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni b/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni index b4017a42d671b8..225e8bc3f21df8 100644 --- a/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni +++ b/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni @@ -94,7 +94,6 @@ template("ti_simplelink_executable") { public_deps = [ ":${simplelink_target_name}.out.image" ] script = "${ti_simplelink_sdk_root}//tools/common/oad/oad_image_tool.py" - environment = [ "PYTHONDONTWRITEBYTECODE=1" ] sources = [ "${root_out_dir}/${objcopy_image_name}" ] outputs = [ "${root_out_dir}/${output_base_name}.bin" ] From 1fb4856d58cf96a90451c4a258e36779b3954120 Mon Sep 17 00:00:00 2001 From: Seth Rickard Date: Mon, 25 Apr 2022 16:43:58 +0000 Subject: [PATCH 11/14] add matter_ prefix to ota parameters --- .../all-clusters-app/cc13x2x7_26x2x7/BUILD.gn | 7 -- .../all-clusters-app/cc13x2x7_26x2x7/args.gni | 5 ++ examples/lock-app/cc13x2x7_26x2x7/BUILD.gn | 12 --- examples/lock-app/cc13x2x7_26x2x7/args.gni | 5 ++ examples/pump-app/cc13x2x7_26x2x7/BUILD.gn | 7 -- examples/pump-app/cc13x2x7_26x2x7/args.gni | 5 ++ .../cc13x2x7_26x2x7/BUILD.gn | 7 -- .../cc13x2x7_26x2x7/args.gni | 5 ++ .../ti_simplelink_executable.gni | 89 ++++++------------- 9 files changed, 49 insertions(+), 93 deletions(-) diff --git a/examples/all-clusters-app/cc13x2x7_26x2x7/BUILD.gn b/examples/all-clusters-app/cc13x2x7_26x2x7/BUILD.gn index 46e8e9d0c9c7c1..33383bb4484128 100644 --- a/examples/all-clusters-app/cc13x2x7_26x2x7/BUILD.gn +++ b/examples/all-clusters-app/cc13x2x7_26x2x7/BUILD.gn @@ -26,13 +26,6 @@ import("${ti_simplelink_sdk_build_root}/ti_simplelink_sdk.gni") assert(current_os == "freertos") -declare_args() { - device_vid = "0xFFF1" - device_pid = "0x8006" - software_ver = "0x0001" - software_ver_str = "1.0d1" -} - project_dir = "${chip_root}/examples/all-clusters-app/cc13x2x7_26x2x7" ti_simplelink_sdk("sdk") { diff --git a/examples/all-clusters-app/cc13x2x7_26x2x7/args.gni b/examples/all-clusters-app/cc13x2x7_26x2x7/args.gni index 3e93cef8d30ef7..473c57e517650c 100644 --- a/examples/all-clusters-app/cc13x2x7_26x2x7/args.gni +++ b/examples/all-clusters-app/cc13x2x7_26x2x7/args.gni @@ -44,3 +44,8 @@ chip_config_network_layer_ble = true # Disable lock tracking, since our FreeRTOS configuration does not set # INCLUDE_xSemaphoreGetMutexHolder chip_stack_lock_tracking = "none" + +matter_device_vid = "0xFFF1" +matter_device_pid = "0x8006" +matter_software_ver = "0x0001" +matter_software_ver_str = "1.0d1" diff --git a/examples/lock-app/cc13x2x7_26x2x7/BUILD.gn b/examples/lock-app/cc13x2x7_26x2x7/BUILD.gn index 9c127522984b5c..57792e12f69e0c 100644 --- a/examples/lock-app/cc13x2x7_26x2x7/BUILD.gn +++ b/examples/lock-app/cc13x2x7_26x2x7/BUILD.gn @@ -26,13 +26,6 @@ import("${ti_simplelink_sdk_build_root}/ti_simplelink_sdk.gni") assert(current_os == "freertos") -declare_args() { - device_vid = "0xFFF1" - device_pid = "0x8006" - software_ver = "0x0001" - software_ver_str = "1.0d1" -} - project_dir = "${chip_root}/examples/lock-app/cc13x2x7_26x2x7" ti_simplelink_sdk("sdk") { @@ -80,11 +73,6 @@ ti_sysconfig("sysconfig") { ti_simplelink_executable("lock_app") { output_name = "chip-${ti_simplelink_board}-lock-example.out" - device_vid = device_vid - device_pid = device_pid - software_ver = software_ver - software_ver_str = software_ver_str - sources = [ "${project_dir}/main/AppTask.cpp", "${project_dir}/main/BoltLockManager.cpp", diff --git a/examples/lock-app/cc13x2x7_26x2x7/args.gni b/examples/lock-app/cc13x2x7_26x2x7/args.gni index d0aac2a4b7ab2d..3e0fea67f07f68 100644 --- a/examples/lock-app/cc13x2x7_26x2x7/args.gni +++ b/examples/lock-app/cc13x2x7_26x2x7/args.gni @@ -40,3 +40,8 @@ chip_config_network_layer_ble = true chip_stack_lock_tracking = "none" chip_openthread_ftd = true + +matter_device_vid = "0xFFF1" +matter_device_pid = "0x8006" +matter_software_ver = "0x0001" +matter_software_ver_str = "1.0d1" diff --git a/examples/pump-app/cc13x2x7_26x2x7/BUILD.gn b/examples/pump-app/cc13x2x7_26x2x7/BUILD.gn index 61b4a5d0dfb023..237b81f36ad747 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/BUILD.gn +++ b/examples/pump-app/cc13x2x7_26x2x7/BUILD.gn @@ -25,13 +25,6 @@ import("${ti_simplelink_sdk_build_root}/ti_simplelink_sdk.gni") assert(current_os == "freertos") -declare_args() { - device_vid = "0xFFF1" - device_pid = "0x800A" - software_ver = "0x0001" - software_ver_str = "1.0d1" -} - project_dir = "${chip_root}/examples/pump-app/cc13x2x7_26x2x7" ti_simplelink_sdk("sdk") { diff --git a/examples/pump-app/cc13x2x7_26x2x7/args.gni b/examples/pump-app/cc13x2x7_26x2x7/args.gni index cbf1d65f3ef7bb..de194f41d074e1 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/args.gni +++ b/examples/pump-app/cc13x2x7_26x2x7/args.gni @@ -39,3 +39,8 @@ chip_config_network_layer_ble = true # Disable lock tracking, since our FreeRTOS configuration does not set # INCLUDE_xSemaphoreGetMutexHolder chip_stack_lock_tracking = "none" + +matter_device_vid = "0xFFF1" +matter_device_pid = "0x800A" +matter_software_ver = "0x0001" +matter_software_ver_str = "1.0d1" diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/BUILD.gn b/examples/pump-controller-app/cc13x2x7_26x2x7/BUILD.gn index 7f4b91d89f7e4b..d3031712c04a58 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/BUILD.gn +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/BUILD.gn @@ -26,13 +26,6 @@ import("${ti_simplelink_sdk_build_root}/ti_simplelink_sdk.gni") assert(current_os == "freertos") -declare_args() { - device_vid = "0xFFF1" - device_pid = "0x8011" - software_ver = "0x0001" - software_ver_str = "1.0d1" -} - project_dir = "${chip_root}/examples/pump-controller-app/cc13x2x7_26x2x7" ti_simplelink_sdk("sdk") { diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/args.gni b/examples/pump-controller-app/cc13x2x7_26x2x7/args.gni index 2b1db21d690d61..1c562220f076c3 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/args.gni +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/args.gni @@ -38,3 +38,8 @@ chip_config_network_layer_ble = true # Disable lock tracking, since our FreeRTOS configuration does not set # INCLUDE_xSemaphoreGetMutexHolder chip_stack_lock_tracking = "none" + +matter_device_vid = "0xFFF1" +matter_device_pid = "0x8011" +matter_software_ver = "0x0001" +matter_software_ver_str = "1.0d1" diff --git a/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni b/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni index 225e8bc3f21df8..cd085b0fb54886 100644 --- a/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni +++ b/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni @@ -21,6 +21,18 @@ import("${chip_root}/src/platform/device.gni") import("ti_simplelink_board.gni") import("ti_simplelink_sdk.gni") +declare_args() { + matter_device_vid = "" + matter_device_pid = "" + matter_software_ver = "" + matter_software_ver_str = "" +} + +assert(matter_device_vid != "", "matter_device_vid must be specified") +assert(matter_device_pid != "", "matter_device_pid must be specified") +assert(matter_software_ver != "", "matter_software_ver must be specified") +assert(matter_software_ver_str != "", "matter_software_ver_str must be specified") + template("ti_simplelink_executable") { simplelink_target_name = target_name @@ -45,21 +57,12 @@ template("ti_simplelink_executable") { } # add OTA options if available - if (defined(invoker.device_vid)) { - defines += [ "CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID=${invoker.device_vid}" ] - } - if (defined(invoker.device_pid)) { - defines += - [ "CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID=${invoker.device_pid}" ] - } - if (defined(invoker.software_ver)) { - defines += [ - "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION=${invoker.software_ver}", - ] - } - if (defined(invoker.software_ver_str)) { - defines += [ "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING=\"${invoker.software_ver_str}\"" ] - } + defines += [ + "CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID=${matter_device_vid}", + "CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID=${matter_device_pid}", + "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION=${matter_software_ver}", + "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING=\"${matter_software_ver_str}\"", + ] } flashable_executable("${simplelink_target_name}.out") { @@ -156,54 +159,20 @@ template("ti_simplelink_executable") { rebase_path("${root_out_dir}/${output_base_name}.ota", root_build_dir), ] - if (defined(invoker.device_vid)) { - args += [ - "-v", - invoker.device_vid, - ] - } else { - args += [ - "-v", - "0xFFF1", - ] - } - if (defined(invoker.device_pid)) { - args += [ - "-p", - invoker.device_pid, - ] - } else { - args += [ - "-p", - "0x8006", - ] - } - if (defined(invoker.software_ver)) { - args += [ - "-vn", - invoker.software_ver, - ] - } else { - args += [ - "-vn", - "0x0001", - ] - } - if (defined(invoker.software_ver_str)) { - args += [ - "-vs", - invoker.software_ver_str, - ] - } else { - args += [ - "-vs", - "1.0d1", - ] - } + args += [ + "-v", + matter_device_vid, + "-p", + matter_device_pid, + "-vn", + matter_software_ver, + "-vs", + matter_software_ver_str, + ] if (defined(invoker.ota_digest)) { args += [ "-da", - invoker.ota_digest, + matter_ota_digest, ] } else { args += [ From 64a13fe46ffa4d1d381ba4e77d01971507218bc0 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Mon, 25 Apr 2022 16:44:46 +0000 Subject: [PATCH 12/14] Restyled by gn --- third_party/ti_simplelink_sdk/ti_simplelink_executable.gni | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni b/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni index cd085b0fb54886..bfc53899edb7d6 100644 --- a/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni +++ b/third_party/ti_simplelink_sdk/ti_simplelink_executable.gni @@ -31,7 +31,8 @@ declare_args() { assert(matter_device_vid != "", "matter_device_vid must be specified") assert(matter_device_pid != "", "matter_device_pid must be specified") assert(matter_software_ver != "", "matter_software_ver must be specified") -assert(matter_software_ver_str != "", "matter_software_ver_str must be specified") +assert(matter_software_ver_str != "", + "matter_software_ver_str must be specified") template("ti_simplelink_executable") { simplelink_target_name = target_name From e4d215f5644759de6fb606a183589f6fcece8d6c Mon Sep 17 00:00:00 2001 From: Seth Rickard Date: Mon, 25 Apr 2022 16:57:11 +0000 Subject: [PATCH 13/14] update comment --- .../cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h | 2 +- .../lock-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h | 2 +- .../pump-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h | 2 +- .../cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/all-clusters-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h b/examples/all-clusters-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h index a19157147c0093..ed275e1a3d6b43 100644 --- a/examples/all-clusters-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h +++ b/examples/all-clusters-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h @@ -58,7 +58,7 @@ #define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1 /** - * Values set by BUILD.gn: + * Values set by args.gni: * CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID * CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING diff --git a/examples/lock-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h b/examples/lock-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h index 082d0ec805cc49..21dc7cd5274a7c 100644 --- a/examples/lock-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h +++ b/examples/lock-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h @@ -60,7 +60,7 @@ #endif /** - * Values set by BUILD.gn: + * Values set by args.gni: * CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID * CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h b/examples/pump-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h index 35eeeade2cb66d..185a3f6bf35c89 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h +++ b/examples/pump-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h @@ -53,7 +53,7 @@ #define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1 /** - * Values set by BUILD.gn: + * Values set by args.gni: * CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID * CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h index 35eeeade2cb66d..185a3f6bf35c89 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/main/include/CHIPProjectConfig.h @@ -53,7 +53,7 @@ #define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1 /** - * Values set by BUILD.gn: + * Values set by args.gni: * CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID * CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING From 7b5b51e9c95bd9aaa21dd6e5b08d1688a70f7268 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Apr 2022 20:35:47 +0000 Subject: [PATCH 14/14] Bump third_party/pigweed/repo from `3d2ffee` to `dcd0d9f` Bumps [third_party/pigweed/repo](https://github.com/google/pigweed) from `3d2ffee` to `dcd0d9f`. - [Release notes](https://github.com/google/pigweed/releases) - [Commits](https://github.com/google/pigweed/compare/3d2ffeec739c32dc5f3071ae4227bd43eededd81...dcd0d9fe866aeba6c109a2149f59fe4c185ecd27) --- updated-dependencies: - dependency-name: third_party/pigweed/repo dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- third_party/pigweed/repo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/pigweed/repo b/third_party/pigweed/repo index 3d2ffeec739c32..dcd0d9fe866aeb 160000 --- a/third_party/pigweed/repo +++ b/third_party/pigweed/repo @@ -1 +1 @@ -Subproject commit 3d2ffeec739c32dc5f3071ae4227bd43eededd81 +Subproject commit dcd0d9fe866aeba6c109a2149f59fe4c185ecd27