You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
E.g. when handling m/M OpenOCD is free to choose which access width to use.
Such accesses are done through target->type->read/write_buffer.
Currently, RISC-V targets use the default implementation of these functions:
It works by first accessing the memory using smaller sizes to align the start address by target_data_bits(), which is riscv013_data_bits() for a RISC-V target:
/* TODO: Once there is a spec for discovering abstract commands, we can
* take those into account as well. For now we assume abstract commands
* support XLEN-wide accesses. */
returnriscv_xlen(target);
} else {
assert(false);
}
}
LOG_TARGET_ERROR(target, "Unable to determine supported data bits on this target. Assuming 32 bits.");
return32;
}
Now imagine a target that supports only System Bus Access that is 64-bit wide. However, the target supports unaligned accesses. For such a target the algorithm will fail to write 32-bit aligned buffer, since it will first try to align it up by a 32-bit wide access.
This should be mitigated.
The text was updated successfully, but these errors were encountered:
imagine a target that supports only System Bus Access that is 64-bit wide. However, the target supports unaligned accesses. For such a target the algorithm will fail to write 32-bit aligned buffer, since it will first try to align it up by a 32-bit wide access.
In my opinion, targets that have the debug memory access considerably restricted (for example as described above) simply won't offer good debugging experience to the user.
The debug software (OpenOCD) could in theory emulate the memory reads and writes of smaller sizes, however this is not always possible. Imagine memory mapped peripherals where emulating a write by doing read-modify-write may have unintended side effects.
My recommendation is that hardware designers, who expect their targets to be debugged, make sure that all memory access widths that loads & stores support are available to the debugger, too. Otherwise the debug experience may be poor.
Thanks to @Qidi-ic for finding out about this! See #1177 for the original issue.
Memory accesses initiated through GDB (unlike the once done via TCL) do not carry the desired access width
(https://sourceware.org/gdb/current/onlinedocs/gdb.html/Packets.html#Packets).
E.g. when handling
m/M
OpenOCD is free to choose which access width to use.Such accesses are done through
target->type->read/write_buffer
.Currently, RISC-V targets use the default implementation of these functions:
riscv-openocd/src/target/target.c
Lines 2437 to 2471 in ea8f9d5
It works by first accessing the memory using smaller sizes to align the start address by
target_data_bits()
, which isriscv013_data_bits()
for a RISC-V target:riscv-openocd/src/target/riscv/riscv-013.c
Lines 2118 to 2152 in ea8f9d5
Now imagine a target that supports only System Bus Access that is 64-bit wide. However, the target supports unaligned accesses. For such a target the algorithm will fail to write 32-bit aligned buffer, since it will first try to align it up by a 32-bit wide access.
This should be mitigated.
The text was updated successfully, but these errors were encountered: