From d80224448ad494687f011b22c1719db16113c458 Mon Sep 17 00:00:00 2001 From: mx1117 <30313912+mx1117@users.noreply.github.com> Date: Thu, 28 Oct 2021 18:54:48 +0800 Subject: [PATCH] Update ef_env.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EF_WG_ALIGN_DOWN(size) 可能为0,需要额外判断以避免某些芯片flash写0长度数据出错。 --- easyflash/src/ef_env.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/easyflash/src/ef_env.c b/easyflash/src/ef_env.c index 01bac5a..a3a4c31 100644 --- a/easyflash/src/ef_env.c +++ b/easyflash/src/ef_env.c @@ -1286,9 +1286,13 @@ static EfErrCode align_write(uint32_t addr, const uint32_t *buf, size_t size) #endif memset(align_data, 0xFF, align_data_size); - result = ef_port_write(addr, buf, EF_WG_ALIGN_DOWN(size)); + align_remain = EF_WG_ALIGN_DOWN(size);//use align_remain temporary to save aligned size. - align_remain = size - EF_WG_ALIGN_DOWN(size); + if(align_remain > 0){//it may be 0 in this function. + result = ef_port_write(addr, buf, align_remain); + } + + align_remain = size - align_remain; if (result == EF_NO_ERR && align_remain) { memcpy(align_data, (uint8_t *)buf + EF_WG_ALIGN_DOWN(size), align_remain); result = ef_port_write(addr + EF_WG_ALIGN_DOWN(size), (uint32_t *) align_data, align_data_size);