This is an automated email from Gerrit. "Samuel Obuch <samuel.ob...@espressif.com>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8987
-- gerrit commit 259e2215839a557ce42ba854b883d99f818dabae Author: Samuel Obuch <samuel.ob...@espressif.com> Date: Tue Jul 8 22:04:08 2025 +0200 target/xtensa: fix unaligned memory read on retry When we read unaligned memory there is an offset in the albuff buffer, that we account for when copying back to original buffer. But in case the first access failed, the retry call already removed the offset, so doing it a second time shifts the returned memory. Change-Id: Ie255c367ca6a001bfe7038a76cf8a6443e398c51 Signed-off-by: Samuel Obuch <samuel.ob...@espressif.com> diff --git a/src/target/xtensa/xtensa.c b/src/target/xtensa/xtensa.c index 3366623d64..a0500b44e5 100644 --- a/src/target/xtensa/xtensa.c +++ b/src/target/xtensa/xtensa.c @@ -2071,13 +2071,16 @@ int xtensa_read_memory(struct target *target, target_addr_t address, uint32_t si if (xtensa->probe_lsddr32p == -1) xtensa->probe_lsddr32p = 1; xtensa->suppress_dsr_errors = prev_suppress; + if (bswap) + buf_bswap32(albuff, albuff, addrend_al - addrstart_al); + memcpy(buffer, albuff + (address & 3), (size * count)); } if (res != ERROR_OK) { if (xtensa->probe_lsddr32p != 0) { /* Disable fast memory access instructions and retry before reporting an error */ LOG_TARGET_DEBUG(target, "Disabling LDDR32.P/SDDR32.P"); xtensa->probe_lsddr32p = 0; - res = xtensa_read_memory(target, address, size, count, albuff); + res = xtensa_read_memory(target, address, size, count, buffer); bswap = false; } else { LOG_TARGET_WARNING(target, "Failed reading %d bytes at address "TARGET_ADDR_FMT, @@ -2085,9 +2088,6 @@ int xtensa_read_memory(struct target *target, target_addr_t address, uint32_t si } } - if (bswap) - buf_bswap32(albuff, albuff, addrend_al - addrstart_al); - memcpy(buffer, albuff + (address & 3), (size * count)); free(albuff); return res; } --