提交 3a31e0e9 编写于 作者: armink_ztl's avatar armink_ztl

1、【优化】Flash擦写时的坏块替换策略,采用比较乐观的策略,将数据移动偏移量改为Flash最小擦写大小。

Signed-off-by: armink_ztl's avatararmink <armink.ztl@gmail.com>
上级 cc71c4e4
......@@ -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;
......
......@@ -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 */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册