From bc22795eeb3eddf5f43a2166e4fa1ee3c64d0abb Mon Sep 17 00:00:00 2001 From: armink Date: Thu, 24 Nov 2016 10:04:16 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E3=80=90=E4=BF=AE=E5=A4=8D=E3=80=91L?= =?UTF-8?q?OG=20=E5=8A=9F=E8=83=BD=E8=AF=BB=E5=8F=96=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E8=B5=B7=E5=A7=8B=204=20=E5=AD=97=E8=8A=82?= =?UTF-8?q?=E4=B9=B1=E7=A0=81=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82=E6=84=9F?= =?UTF-8?q?=E8=B0=A2=E7=BD=91=E5=8F=8B=20@heisewangluo=20=E7=9A=84?= =?UTF-8?q?=E5=8F=8D=E9=A6=88=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: armink --- easyflash/inc/easyflash.h | 2 +- easyflash/src/ef_log.c | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/easyflash/inc/easyflash.h b/easyflash/inc/easyflash.h index 9a162d6..a02671c 100644 --- a/easyflash/inc/easyflash.h +++ b/easyflash/inc/easyflash.h @@ -67,7 +67,7 @@ if (!(EXPR)) \ while (1); \ } /* EasyFlash software version number */ -#define EF_SW_VERSION "2.10.24" +#define EF_SW_VERSION "2.11.24" typedef struct _ef_env{ char *key; diff --git a/easyflash/src/ef_log.c b/easyflash/src/ef_log.c index 1747b65..d627488 100644 --- a/easyflash/src/ef_log.c +++ b/easyflash/src/ef_log.c @@ -352,11 +352,15 @@ EfErrCode ef_log_write(const uint32_t *log, size_t size) { /* must be call this function after initialize OK */ EF_ASSERT(init_ok); - /* write address is after log end address */ - write_addr = log_end_addr + 4; + /* write address is after log end address when LOG AREA isn't empty */ + if (log_start_addr != log_end_addr) { + write_addr = log_end_addr + 4; + } else { + write_addr = log_start_addr; + } /* write the already erased but not used area */ writable_size = EF_ERASE_MIN_SIZE - ((write_addr - log_area_start_addr) % EF_ERASE_MIN_SIZE); - if (writable_size != EF_ERASE_MIN_SIZE) { + if ((writable_size != EF_ERASE_MIN_SIZE) || (log_start_addr == log_end_addr)) { if (size > writable_size) { result = ef_port_write(write_addr, log, writable_size); if (result != EF_NO_ERR) {