Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage; Defragment kve storage when starting up by default #1364

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/hal/src/storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@
#define KVE_PARTITION_START (1024)
#define KVE_PARTITION_LENGTH (7*1024)

#define DEFAULT_DEFRAG_ON_STARTUP true

#ifdef CONFIG_DEFRAG_STORAGE_ON_STARTUP
#define DEFRAG_ON_STARTUP CONFIG_DEFRAG_STORAGE_ON_STARTUP
#else
#define DEFRAG_ON_STARTUP DEFAULT_DEFRAG_ON_STARTUP
#endif

static SemaphoreHandle_t storageMutex;

static size_t readEeprom(size_t address, void* data, size_t length)
Expand Down Expand Up @@ -127,6 +135,9 @@ void storageInit()
storageMutex = xSemaphoreCreateMutex();

isInit = true;
if (DEFRAG_ON_STARTUP) {
kveDefrag(&kve);
}
}

bool storageTest()
Expand Down
8 changes: 8 additions & 0 deletions src/modules/src/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,12 @@ config PARAM_SILENT_UPDATES
about parameter updates, so this option should be enabled if you know
what you are doing.

config DEFRAG_STORAGE_ON_STARTUP
bool "Defrag_on_startup"
default y
help
This enables defragmentation of parameter storage memory everytime the
CPU is started. It increases startup time, depending on
fragmentation level.

endmenu
Loading