diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index 1bd31f9fe..6a71298e5 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -1859,11 +1859,12 @@ static int read_memory(struct target *target, uint32_t address, return ERROR_FAIL; } dmi_write(target, DMI_ABSTRACTCS, DMI_ABSTRACTCS_CMDERR); - dmi_write(target, DMI_ABSTRACTAUTO, 0x1 << DMI_ABSTRACTAUTO_AUTOEXECDATA_OFFSET); uint32_t abstractcs; for (uint32_t i = 0; i < count; i++) { uint32_t value = dmi_read(target, DMI_DATA0); + if (i == 0) + dmi_write(target, DMI_ABSTRACTAUTO, 0x1 << DMI_ABSTRACTAUTO_AUTOEXECDATA_OFFSET); switch (size) { case 1: buffer[i] = value;