diff --git a/examples/ota-requestor-app/infineon/cyw30739/args.gni b/examples/ota-requestor-app/infineon/cyw30739/args.gni index 37d8fa8d701fb9..67d2b05e5e1845 100644 --- a/examples/ota-requestor-app/infineon/cyw30739/args.gni +++ b/examples/ota-requestor-app/infineon/cyw30739/args.gni @@ -17,6 +17,6 @@ import("${chip_root}/src/platform/Infineon/CYW30739/args.gni") cyw30739_sdk_target = get_label_info(":sdk", "label_no_toolchain") -chip_openthread_ftd = true +chip_openthread_ftd = false chip_enable_ota_requestor = true diff --git a/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.cpp b/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.cpp index e61edab6ebfd18..a62fffaf57f190 100644 --- a/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.cpp +++ b/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.cpp @@ -114,12 +114,12 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Put(const char * key, const void * value, CHIP_ERROR err = CHIP_NO_ERROR; KeyConfigIdEntry * entry; - const size_t keyLength = strnlen(key, PersistentStorageDelegate::kKeyLengthMax + 1); + const size_t keyLength = strnlen(key, PersistentStorageDelegate::kKeyLengthMax); VerifyOrExit(keyLength != 0 && keyLength <= PersistentStorageDelegate::kKeyLengthMax && value_size <= kMaxPersistedValueLengthSupported, err = CHIP_ERROR_INVALID_ARGUMENT); - entry = AllocateEntry(key, keyLength); + entry = AllocateEntry(key); VerifyOrExit(entry != nullptr, ChipLogError(DeviceLayer, "%s AllocateEntry %s", __func__, ErrorStr(err)); err = CHIP_ERROR_NO_MEMORY); @@ -129,7 +129,7 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Put(const char * key, const void * value, } entry->SetValueSize(value_size); - SuccessOrExit(err = CYW30739Config::WriteConfigValueBin(entry->GetKeyConfigKey(), &entry->mStorage, sizeof(entry->mStorage))); + SuccessOrExit(err = CYW30739Config::WriteConfigValueBin(entry->GetKeyConfigKey(), &entry->mStorage, entry->mStorage.GetSize())); exit: return err; @@ -171,10 +171,12 @@ CHIP_ERROR KeyValueStoreManagerImpl::EraseAll(void) return CHIP_NO_ERROR; } -KeyValueStoreManagerImpl::KeyStorage::KeyStorage(const char * key, size_t keyLength) : mValueSize(0) +KeyValueStoreManagerImpl::KeyStorage::KeyStorage(const char * key) : mValueSize(0) { memset(mKey, 0, sizeof(mKey)); - memcpy(mKey, key, keyLength); + + if (key != NULL) + strncpy(mKey, key, sizeof(mKey)); } bool KeyValueStoreManagerImpl::KeyStorage::IsMatchKey(const char * key) const @@ -182,14 +184,14 @@ bool KeyValueStoreManagerImpl::KeyStorage::IsMatchKey(const char * key) const return strncmp(mKey, key, sizeof(mKey)) == 0; } -KeyValueStoreManagerImpl::KeyConfigIdEntry * KeyValueStoreManagerImpl::AllocateEntry(const char * key, size_t keyLength) +KeyValueStoreManagerImpl::KeyConfigIdEntry * KeyValueStoreManagerImpl::AllocateEntry(const char * key) { Optional freeConfigID; KeyConfigIdEntry * newEntry = FindEntry(key, &freeConfigID); ReturnErrorCodeIf(newEntry != nullptr, newEntry); ReturnErrorCodeIf(!freeConfigID.HasValue(), nullptr); - newEntry = Platform::New(freeConfigID.Value(), KeyStorage(key, keyLength)); + newEntry = Platform::New(freeConfigID.Value(), KeyStorage(key)); ReturnErrorCodeIf(newEntry == nullptr, nullptr); KeyConfigIdEntry * entry = static_cast(slist_tail(&mKeyConfigIdList)); diff --git a/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.h b/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.h index 5938bd28a56c98..7c9045574d03a4 100644 --- a/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.h +++ b/src/platform/Infineon/CYW30739/KeyValueStoreManagerImpl.h @@ -59,11 +59,12 @@ class KeyValueStoreManagerImpl final : public KeyValueStoreManager struct KeyStorage { - KeyStorage(const char * key = nullptr, size_t keyLength = 0); + KeyStorage(const char * key = nullptr); + constexpr size_t GetSize() const { return sizeof(mValueSize) + strnlen(mKey, sizeof(mKey)); } bool IsMatchKey(const char * key) const; - size_t mValueSize; + uint16_t mValueSize; char mKey[PersistentStorageDelegate::kKeyLengthMax]; }; @@ -81,14 +82,14 @@ class KeyValueStoreManagerImpl final : public KeyValueStoreManager } constexpr KeyConfigIdEntry * Next() const { return static_cast(next); } constexpr uint8_t NextConfigID() const { return mConfigID + 1; } - constexpr size_t GetValueSize() const { return mStorage.mValueSize; } - constexpr void SetValueSize(size_t valueSize) { mStorage.mValueSize = valueSize; } + constexpr uint16_t GetValueSize() const { return mStorage.mValueSize; } + constexpr void SetValueSize(uint16_t valueSize) { mStorage.mValueSize = valueSize; } uint8_t mConfigID; KeyStorage mStorage; }; - KeyConfigIdEntry * AllocateEntry(const char * key, size_t keyLength); + KeyConfigIdEntry * AllocateEntry(const char * key); KeyConfigIdEntry * FindEntry(const char * key, Optional * freeConfigID = nullptr); // ===== Members for internal use by the following friends. diff --git a/third_party/infineon/cyw30739_sdk/btp_reader.py b/third_party/infineon/cyw30739_sdk/btp_reader.py index 71fd7c28144ec7..69ee21956329d7 100644 --- a/third_party/infineon/cyw30739_sdk/btp_reader.py +++ b/third_party/infineon/cyw30739_sdk/btp_reader.py @@ -52,7 +52,7 @@ def main(): items["ConfigXS1Location"] = items["ConfigDS2Location"] + ds_len if option.enable_ota: - items["ConfigXS1Length"] = 0x00076000 + items["ConfigXS1Length"] = 0x00073000 items["ConfigXS2Location"] = ( items["ConfigXS1Location"] + items["ConfigXS1Length"] ) diff --git a/third_party/infineon/cyw30739_sdk/flash.btp b/third_party/infineon/cyw30739_sdk/flash.btp index d6acdcb269a510..e57581ecb82493 100644 --- a/third_party/infineon/cyw30739_sdk/flash.btp +++ b/third_party/infineon/cyw30739_sdk/flash.btp @@ -36,12 +36,12 @@ DevicePreset "30739 Flash" DLConfigSerialControlBaudRate = 115200 DLConfigEEPROMAccessSpeed = 100 DLConfigVSOffset = 0 - ConfigDSLocation = 0x505000 - ConfigDS2Location = 0x519000 + ConfigDSLocation = 0x509000 + ConfigDS2Location = 0x51d000 DLConfigSSLocation = 0x500000 DLConfigIncludeBTWSecurityKey = 0 DLConfigVSLocation = 0x501000 - DLConfigVSLength = 0x2000 + DLConfigVSLength = 0x4000 DLConfigRemoteDeviceCount = 0 DLConfigBD_ADDRBase = "30739A0*****" DLConfigFixedBD_ADDRFlag = "Can change"