Skip to content

Commit 2570368

Browse files
Revert "[nxp noup][platform][common] Add support for NVS key storage wear statistics"
This reverts commit 8ad9c4b. Signed-off-by: marius-alex-tache <marius.tache@nxp.com>
1 parent f5966d9 commit 2570368

File tree

3 files changed

+0
-64
lines changed

3 files changed

+0
-64
lines changed

src/platform/nxp/common/CHIPDeviceNXPPlatformDefaultConfig.h

-4
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,6 @@
102102
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT 1
103103
#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD
104104

105-
#ifndef CHIP_DEVICE_CONFIG_KVS_WEAR_STATS_KEY
106-
#define CHIP_DEVICE_CONFIG_KVS_WEAR_STATS_KEY "nxp/diag/usr"
107-
#endif // CHIP_DEVICE_CONFIG_KVS_WEAR_STATS_KEY
108-
109105
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD && !CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
110106
#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DISCOVERY 1
111107
#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1

src/platform/nxp/common/NXPConfig.h

-3
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,6 @@ class NXPConfig
191191
#endif
192192
static int SaveIntKeysToFS(void);
193193
static int SaveStringKeysToFS(void);
194-
#if (CHIP_DEVICE_CONFIG_KVS_WEAR_STATS == 1)
195-
static CHIP_ERROR InitStorageWearStats(void);
196-
#endif
197194
};
198195

199196
} // namespace Internal

src/platform/nxp/common/NXPConfigNVS.cpp

-57
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,10 @@
2020
#include <lib/core/CHIPEncoding.h>
2121
#include <platform/CHIPDeviceError.h>
2222
#include <platform/internal/testing/ConfigUnitTest.h>
23-
#include <platform/nxp/common/CHIPDeviceNXPPlatformDefaultConfig.h>
2423
#include <settings.h>
2524

2625
/* Only for flash init, to be move to sdk framework */
2726
#include "port/nvs_port.h"
28-
#if (CHIP_DEVICE_CONFIG_KVS_WEAR_STATS == 1)
29-
#include "fwk_nvs_stats.h"
30-
#endif /* CHIP_DEVICE_CONFIG_KVS_WEAR_STATS */
3127

3228
// These can be overridden by the application as needed.
3329
#ifndef CHIP_DEVICE_INTEGER_SETTINGS_KEY
@@ -141,17 +137,6 @@ int DeleteSubtreeCallback(const char * name, size_t /* entrySize */, settings_re
141137

142138
return 0;
143139
}
144-
145-
#if (CHIP_DEVICE_CONFIG_KVS_WEAR_STATS == 1)
146-
void OnFlashSectorWearCountUpdate(uint16_t sector_idx, const nvs_storage_wear_profile_t * flash_wear_profile)
147-
{
148-
char keyUser[] = CHIP_DEVICE_CONFIG_KVS_WEAR_STATS_KEY;
149-
const size_t flash_wear_profile_size = NVS_STORAGE_WEAR_PROFILE_SIZE(flash_wear_profile->sector_count);
150-
151-
/* Update the NVS stats key in storage */
152-
NXPConfig::WriteConfigValueBin((const char *) keyUser, (uint8_t *) flash_wear_profile, flash_wear_profile_size);
153-
}
154-
#endif /* CHIP_DEVICE_CONFIG_KVS_WEAR_STATS */
155140
} // namespace
156141

157142
CHIP_ERROR NXPConfig::Init()
@@ -166,50 +151,8 @@ CHIP_ERROR NXPConfig::Init()
166151

167152
ReturnErrorCodeIf(settings_subsys_init(), CHIP_ERROR_PERSISTED_STORAGE_FAILED);
168153

169-
#if (CHIP_DEVICE_CONFIG_KVS_WEAR_STATS == 1)
170-
ReturnErrorOnFailure(InitStorageWearStats());
171-
#endif /* CHIP_DEVICE_CONFIG_KVS_WEAR_STATS */
172-
173-
return CHIP_NO_ERROR;
174-
}
175-
176-
#if (CHIP_DEVICE_CONFIG_KVS_WEAR_STATS == 1)
177-
CHIP_ERROR NXPConfig::InitStorageWearStats(void)
178-
{
179-
nvs_storage_wear_profile_t * flash_wear_profile = NULL;
180-
const size_t flash_wear_profile_size = NVS_STORAGE_WEAR_PROFILE_SIZE((uint32_t) NV_STORAGE_MAX_SECTORS);
181-
size_t size;
182-
char keyUser[] = CHIP_DEVICE_CONFIG_KVS_WEAR_STATS_KEY;
183-
184-
/* Create an empty flash wear profile */
185-
flash_wear_profile = (nvs_storage_wear_profile_t *) calloc(1, flash_wear_profile_size);
186-
ReturnErrorCodeIf(flash_wear_profile == NULL, CHIP_ERROR_NO_MEMORY);
187-
188-
/* Try to read the flash wear profile from the User Support diagnostic log key */
189-
CHIP_ERROR err = ReadConfigValueBin((const char *) keyUser, (uint8_t *) flash_wear_profile, flash_wear_profile_size, size);
190-
if ((err != CHIP_NO_ERROR) || (size != flash_wear_profile_size) ||
191-
(flash_wear_profile->sector_count != (uint32_t) NV_STORAGE_MAX_SECTORS))
192-
{
193-
/* Either the flash wear stats are not available in the persistent
194-
* storage or the flash wear statistics that we have read are not
195-
* compatible with the current persistent storage configuration. In
196-
* this case - just reset and save the flash wear statistics. */
197-
flash_wear_profile->sector_count = (uint32_t) NV_STORAGE_MAX_SECTORS;
198-
memset(flash_wear_profile->erase_count, 0, (uint32_t) NV_STORAGE_MAX_SECTORS * sizeof(uint16_t));
199-
WriteConfigValueBin((const char *) keyUser, (uint8_t *) flash_wear_profile, flash_wear_profile_size);
200-
}
201-
else
202-
{
203-
/* Load the flash wear profile into the NVS statistics */
204-
nvs_stats_load_profile(flash_wear_profile);
205-
}
206-
free(flash_wear_profile);
207-
208-
nvs_stats_config_event_handler(OnFlashSectorWearCountUpdate);
209-
210154
return CHIP_NO_ERROR;
211155
}
212-
#endif /* CHIP_DEVICE_CONFIG_KVS_WEAR_STATS */
213156

214157
CHIP_ERROR NXPConfig::ReadConfigValue(Key key, bool & val)
215158
{

0 commit comments

Comments
 (0)