Skip to content

Commit

Permalink
Merge pull request #317 from eduazocar/feature/storage_fixes
Browse files Browse the repository at this point in the history
firmware/storage: Fixed bug in Boards meshme and vs203
  • Loading branch information
CW-75 authored Jul 18, 2022
2 parents 74e64ca + 02ce140 commit ae76885
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions firmware/sys/storage/include/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
6 changes: 3 additions & 3 deletions firmware/sys/storage/storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand All @@ -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)) {
Expand Down

0 comments on commit ae76885

Please sign in to comment.