diff --git a/flash/inc/flash.h b/flash/inc/flash.h index 9bf23b0..8552872 100644 --- a/flash/inc/flash.h +++ b/flash/inc/flash.h @@ -44,7 +44,7 @@ if (!(EXPR)) \ while (1); \ } /* EasyFlash software version number */ -#define FLASH_SW_VERSION "1.03.13" +#define FLASH_SW_VERSION "1.03.23" typedef struct _flash_env{ char *key; diff --git a/flash/src/flash_env_wl.c b/flash/src/flash_env_wl.c index 277c62d..22c7164 100644 --- a/flash/src/flash_env_wl.c +++ b/flash/src/flash_env_wl.c @@ -585,8 +585,10 @@ FlashErrCode flash_save_env(void) { case FLASH_ERASE_ERR: { FLASH_INFO("Warning: Erased environment variables fault!\n"); FLASH_INFO("Moving environment variables to next available position.\n"); - /* calculate move offset address */ - move_offset_addr = (env_detail_size / flash_erase_min_size + 1) * flash_erase_min_size; + /* Calculate move offset address. + * Current strategy is optimistic. It will offset the flash erasure minimum size. + */ + move_offset_addr = flash_erase_min_size; /* calculate and set next available data section address */ set_cur_using_data_addr(get_cur_using_data_addr() + move_offset_addr); /* calculate and set next available environment variables detail part end address */ @@ -605,8 +607,10 @@ FlashErrCode flash_save_env(void) { case FLASH_WRITE_ERR: { FLASH_INFO("Warning: Saved environment variables fault!\n"); FLASH_INFO("Moving environment variables to next available position.\n"); - /* calculate move offset address */ - move_offset_addr = (env_detail_size / flash_erase_min_size + 1) * flash_erase_min_size; + /* Calculate move offset address. + * Current strategy is optimistic. It will offset the flash erasure minimum size. + */ + move_offset_addr = flash_erase_min_size; /* calculate and set next available data section address */ set_cur_using_data_addr(get_cur_using_data_addr() + move_offset_addr); /* calculate and set next available environment variables detail part end address */