From ccc7799b09ba5f01994b7544034b60add0a6c200 Mon Sep 17 00:00:00 2001 From: armink Date: Thu, 24 Nov 2016 10:06:58 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E3=80=90=E6=9B=B4=E6=96=B0=E3=80=91R?= =?UTF-8?q?T-Thread=20Demo=20=E4=BD=BF=E7=94=A8=E7=9A=84=20EasyFlash=20?= =?UTF-8?q?=E5=BA=93=E8=87=B3=E6=9C=80=E6=96=B0=E7=89=88=E6=9C=AC=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: armink --- .../stm32f10x/components/easyflash/inc/easyflash.h | 2 +- .../stm32f10x/components/easyflash/src/ef_log.c | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/demo/os/rt-thread/stm32f10x/components/easyflash/inc/easyflash.h b/demo/os/rt-thread/stm32f10x/components/easyflash/inc/easyflash.h index 9a162d6..a02671c 100644 --- a/demo/os/rt-thread/stm32f10x/components/easyflash/inc/easyflash.h +++ b/demo/os/rt-thread/stm32f10x/components/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/demo/os/rt-thread/stm32f10x/components/easyflash/src/ef_log.c b/demo/os/rt-thread/stm32f10x/components/easyflash/src/ef_log.c index 1747b65..d627488 100644 --- a/demo/os/rt-thread/stm32f10x/components/easyflash/src/ef_log.c +++ b/demo/os/rt-thread/stm32f10x/components/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) {