From 0edf0e80c25145010ab570b9e9611cb01c8e40ef Mon Sep 17 00:00:00 2001 From: jedi Date: Tue, 6 Jul 2021 22:55:38 +0200 Subject: [PATCH] add function to clear config in flash --- firmware/system.c | 12 +++++++++++- firmware/system.h | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/firmware/system.c b/firmware/system.c index 3de7ada..f4a9e2e 100644 --- a/firmware/system.c +++ b/firmware/system.c @@ -10,4 +10,14 @@ #include #include -#include \ No newline at end of file +#include + +void system_clear_config(){ + vPortEnterCritical(); + uint32_t num_sectors = 5 + DEFAULT_SYSPARAM_SECTORS; + uint32_t start = sdk_flashchip.chip_size - num_sectors * sdk_flashchip.sector_size; + for (uint32_t i = 0; i < num_sectors; i++) { + spiflash_erase_sector(start + i * sdk_flashchip.sector_size); + } + sdk_system_restart(); +} \ No newline at end of file diff --git a/firmware/system.h b/firmware/system.h index 42ec187..1046f49 100644 --- a/firmware/system.h +++ b/firmware/system.h @@ -9,6 +9,8 @@ extern "C" { #endif +void system_clear_config(); + #ifdef __cplusplus } #endif