diff --git a/examples/persistent-storage/KeyValueStorageTest.cpp b/examples/persistent-storage/KeyValueStorageTest.cpp index 2a7a32771ad370..ed986e3042632d 100644 --- a/examples/persistent-storage/KeyValueStorageTest.cpp +++ b/examples/persistent-storage/KeyValueStorageTest.cpp @@ -153,10 +153,9 @@ CHIP_ERROR TestMultiRead() CHIP_ERROR TestZeroLength() { const char * kTestKey = "zero_key"; - const char kTestValue[] = "not used"; - char read_value[sizeof(kTestValue)]; + char read_value[10] = {0}; size_t read_size; - ReturnErrorOnFailure(KeyValueStoreMgr().Put(kTestKey, kTestValue, 0U)); + ReturnErrorOnFailure(KeyValueStoreMgr().Put(kTestKey, NULL, 0U)); ReturnErrorOnFailure(KeyValueStoreMgr().Get(kTestKey, read_value, sizeof(read_value), &read_size)); ReturnErrorCodeIf(read_size != 0U, CHIP_ERROR_INTERNAL); ReturnErrorOnFailure(KeyValueStoreMgr().Delete(kTestKey)); diff --git a/examples/persistent-storage/cc13x2x7_26x2x7/chip.syscfg b/examples/persistent-storage/cc13x2x7_26x2x7/chip.syscfg index 890c292f1d3100..c1419eaf6d22bb 100644 --- a/examples/persistent-storage/cc13x2x7_26x2x7/chip.syscfg +++ b/examples/persistent-storage/cc13x2x7_26x2x7/chip.syscfg @@ -43,6 +43,7 @@ var AESECB2 = AESECB.addInstance(); var Button1 = Button.addInstance(); var Button2 = Button.addInstance(); var NVS1 = NVS.addInstance(); +var NVS2 = NVS.addInstance(); var SHA21 = SHA2.addInstance(); var LED1 = LED.addInstance(); var LED2 = LED.addInstance(); @@ -93,9 +94,14 @@ CCFG.enableCodeGeneration = false; /* NVS */ NVS1.$name = "CONFIG_NVSINTERNAL"; + NVS1.internalFlash.regionBase = 0xAA000; NVS1.internalFlash.regionSize = 0x4000; +NVS2.$name = "CONFIG_NVSEXTERNAL"; +NVS2.nvsType = "External"; // NVS Region Type +NVS2.$hardware = system.deviceData.board.components.MX25R8035F; + /* RF */ /* if an antenna component exists, assign it to the rf instance */ if (system.deviceData.board && system.deviceData.board.components.RF) { diff --git a/src/platform/cc13x2_26x2/KeyValueStoreManagerImpl.cpp b/src/platform/cc13x2_26x2/KeyValueStoreManagerImpl.cpp index dce070ac11ac04..a507fcc2a63971 100644 --- a/src/platform/cc13x2_26x2/KeyValueStoreManagerImpl.cpp +++ b/src/platform/cc13x2_26x2/KeyValueStoreManagerImpl.cpp @@ -58,7 +58,14 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Get(const char * key, void * value, size_t CHIP_ERROR KeyValueStoreManagerImpl::_Put(const char * key, const void * value, size_t value_size) { VerifyOrReturnError(key, CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrReturnError(value, CHIP_ERROR_INVALID_ARGUMENT); + if (0U == value_size) + { + VerifyOrReturnError(nullptr == value, CHIP_ERROR_INVALID_ARGUMENT); + } + else + { + VerifyOrReturnError(nullptr != value, CHIP_ERROR_INVALID_ARGUMENT); + } return CC13X2_26X2Config::WriteKVS(key, value, value_size); } diff --git a/src/platform/cc32xx/KeyValueStoreManagerImpl.cpp b/src/platform/cc32xx/KeyValueStoreManagerImpl.cpp index fd5614b006fb75..87f3e2ef79bd41 100644 --- a/src/platform/cc32xx/KeyValueStoreManagerImpl.cpp +++ b/src/platform/cc32xx/KeyValueStoreManagerImpl.cpp @@ -50,7 +50,14 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Get(const char * key, void * value, size_t CHIP_ERROR KeyValueStoreManagerImpl::_Put(const char * key, const void * value, size_t value_size) { VerifyOrReturnError(key, CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrReturnError(value, CHIP_ERROR_INVALID_ARGUMENT); + if (0U == value_size) + { + VerifyOrReturnError(nullptr == value, CHIP_ERROR_INVALID_ARGUMENT); + } + else + { + VerifyOrReturnError(nullptr != value, CHIP_ERROR_INVALID_ARGUMENT); + } return CC32XXConfig::WriteKVS(key, value, value_size); }