From efcfcf555fd52922fd0ce0683ac490abee6c9896 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Wed, 9 Aug 2017 12:42:17 -0700 Subject: [PATCH] Fix assertion failure when reading from address 0. --- src/target/riscv/riscv-013.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index 4b0f71b6e..99a0280e9 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -1353,12 +1353,14 @@ static int read_memory(struct target *target, target_addr_t address, riscv_addr_t cur_addr = 0xbadbeef; riscv_addr_t fin_addr = address + (count * size); riscv_addr_t prev_addr = ((riscv_addr_t) address) - size; + bool first = true; LOG_DEBUG("writing until final address 0x%" PRIx64, fin_addr); while (count > 1 && (cur_addr = riscv_read_debug_buffer_x(target, d_addr)) < fin_addr) { LOG_DEBUG("transferring burst starting at address 0x%" TARGET_PRIxADDR " (previous burst was 0x%" TARGET_PRIxADDR ")", cur_addr, prev_addr); - assert(prev_addr < cur_addr); + assert(first || prev_addr < cur_addr); + first = false; prev_addr = cur_addr; riscv_addr_t start = (cur_addr - address) / size; assert (cur_addr >= address);