From 7076d58541719d38b5a3b718d9edfb6b0010cf14 Mon Sep 17 00:00:00 2001 From: armink Date: Thu, 26 Sep 2019 11:06:48 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=AD=A3=E3=80=91continue=5F?= =?UTF-8?q?ff=5Faddr=20=E8=AE=BF=E9=97=AE=20flash=20=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E8=B6=8A=E7=95=8C=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: armink --- easyflash/src/ef_env.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/easyflash/src/ef_env.c b/easyflash/src/ef_env.c index 6a4a0b9..fadfd16 100644 --- a/easyflash/src/ef_env.c +++ b/easyflash/src/ef_env.c @@ -456,11 +456,16 @@ static bool get_env_from_cache(const char *name, size_t name_len, uint32_t *addr static uint32_t continue_ff_addr(uint32_t start, uint32_t end) { uint8_t buf[32], last_data = 0x00; - size_t i, addr = start; + size_t i, addr = start, read_size; for (; start < end; start += sizeof(buf)) { - ef_port_read(start, (uint32_t *) buf, sizeof(buf)); - for (i = 0; i < sizeof(buf) && start + i < end; i++) { + if (start + sizeof(buf) < end) { + read_size = sizeof(buf); + } else { + read_size = end - start; + } + ef_port_read(start, (uint32_t *) buf, read_size); + for (i = 0; i < read_size; i++) { if (last_data != 0xFF && buf[i] == 0xFF) { addr = start + i; }