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) {