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

firmware/storage: Fixed bug in Boards meshme and vs203 #317

Merged
merged 1 commit into from
Jul 18, 2022
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
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