From 02ce14061faddb7ce1f0357bad3cb16916cff2bb Mon Sep 17 00:00:00 2001 From: eduazocar Date: Fri, 15 Jul 2022 11:20:53 -0400 Subject: [PATCH] firmware/storage: Fixed bug in Boards meshme and vs203 --- firmware/sys/storage/include/storage.h | 5 ++--- firmware/sys/storage/storage.c | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/firmware/sys/storage/include/storage.h b/firmware/sys/storage/include/storage.h index eb1af8654..3bcfa17d9 100644 --- a/firmware/sys/storage/include/storage.h +++ b/firmware/sys/storage/include/storage.h @@ -36,9 +36,8 @@ extern "C" { #endif #define LAST_AVAILABLE_PAGE (FLASHPAGE_NUMOF - 1) /*!< Last position in the block EEPROM*/ -#define MAX_SIZE_STORAGE (FLASH_PAGE_SIZE) /*!< max size to save in the page */ -#define MAX_NUMOF_FLASHPAGES \ - (FLASHPAGE_PAGES_PER_ROW * FLASH_PAGE_SIZE) /*!< max num of pages that can be manipulated */ +#define MAX_SIZE_STORAGE (FLASHPAGE_SIZE) /*!< max size to save in the page */ +#define MAX_NUMOF_FLASHPAGES FLASHPAGE_NUMOF /*!< max num of pages that can be manipulated */ /** @note The storage EEPROM section page could be resize with the bootloader block size * @warning Always the block EEPROM and BOOTLOADER are affected between them. */ diff --git a/firmware/sys/storage/storage.c b/firmware/sys/storage/storage.c index 636e1b244..2da259254 100644 --- a/firmware/sys/storage/storage.c +++ b/firmware/sys/storage/storage.c @@ -29,7 +29,7 @@ #include "storage.h" #include "mtd_flashpage.h" -static mtd_flashpage_t _dev = MTD_FLASHPAGE_INIT_VAL(FLASHPAGE_PAGES_PER_ROW); +static mtd_flashpage_t _dev = MTD_FLASHPAGE_INIT_VAL(8); static mtd_dev_t *dev = &_dev.base; int mtd_start(void) { @@ -56,7 +56,7 @@ int mtd_save(uint32_t key, void *value) { int mtd_save_compress(void *value, uint16_t len) { uint8_t *ptr = value; uint8_t buf[MAX_SIZE_STORAGE]; - uint8_t diff_size = MAX_SIZE_STORAGE; + uint16_t diff_size = MAX_SIZE_STORAGE; uint16_t num_pages = len / MAX_SIZE_STORAGE; uint8_t res_bits = len % MAX_SIZE_STORAGE; int8_t ret = 0; @@ -83,7 +83,7 @@ int mtd_save_compress(void *value, uint16_t len) { int mtd_load(void *value, uint16_t len) { uint8_t *ptr = value; - uint8_t diff_size = MAX_SIZE_STORAGE; + uint16_t diff_size = MAX_SIZE_STORAGE; uint16_t num_pages = len / MAX_SIZE_STORAGE; uint8_t res_bits = len % MAX_SIZE_STORAGE; if ((num_pages < 1) || (res_bits != 0)) {