From 7b086094041d915e14549ebf639039ced68493f9 Mon Sep 17 00:00:00 2001 From: "LAPTOP-ORSGE5M9\\lyy" Date: Sat, 2 Mar 2019 14:56:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DFlash=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=A4=B1=E8=B4=A5=EF=BC=8C=E5=8F=8Alog=5Fend?= =?UTF-8?q?=5Fadd=E8=BF=94=E5=9B=9E=E5=9D=97=E9=A6=96=E5=9D=80=E9=80=A0?= =?UTF-8?q?=E6=88=90=E6=97=A0=E6=B3=95=E5=86=99log=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rtt/components/easyflash/port/ef_port.c | 17 ++++++++++------- easyflash/src/ef_log.c | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) 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; } }