diff --git a/demo/env/stm32f10x/rtt/components/easyflash/port/ef_port.c b/demo/env/stm32f10x/rtt/components/easyflash/port/ef_port.c index 8f17ad9..0b9a880 100644 --- a/demo/env/stm32f10x/rtt/components/easyflash/port/ef_port.c +++ b/demo/env/stm32f10x/rtt/components/easyflash/port/ef_port.c @@ -143,13 +143,16 @@ EfErrCode ef_port_write(uint32_t addr, const uint32_t *buf, size_t size) { FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR); for (i = 0; i < size; i += 4, buf++, addr += 4) { /* write data */ - FLASH_ProgramWord(addr, *buf); - read_data = *(uint32_t *)addr; - /* check data */ - if (read_data != *buf) { - result = EF_WRITE_ERR; - break; - } + read_data = *(uint32_t *)addr; + if (read_data != *buf) { + FLASH_ProgramWord(addr, *buf); + read_data = *(uint32_t *)addr; + /* check data */ + if (read_data != *buf) { + result = EF_WRITE_ERR; + break; + } + } } FLASH_Lock(); diff --git a/easyflash/src/ef_log.c b/easyflash/src/ef_log.c index e7747a3..bb77363 100644 --- a/easyflash/src/ef_log.c +++ b/easyflash/src/ef_log.c @@ -239,7 +239,7 @@ static uint32_t find_sec_using_end_addr(uint32_t addr) { return sector_start + EF_ERASE_MIN_SIZE - continue_ff; } else { /* all sector not has continuous 0xFF, so the sector is full */ - return sector_start + EF_ERASE_MIN_SIZE; + return sector_start + EF_ERASE_MIN_SIZE+LOG_SECTOR_HEADER_SIZE; } }