-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
target/riscv: use batch interface in read_memory_bus_v1()
#1081
Conversation
read_memory_bus_v1()
This PR is based on #1073 |
b97f814
to
9c69123
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this change looks all right - thanks. I like how the use of the batch API simplifies the code in read_memory_bus_v1() and makes it easier to reason about.
Two things:
- I have not really grasped where exactly in the original code was the problem causing
read_memory_bus_v1()
is broken #1080, and what had to happen for it to occur. Could you please explain it. - I believe the order of sbdata0 reads should be different - please see my comments.
49e7dd9
to
e546940
Compare
How the issue occurs?
TL;DR:The condition riscv-openocd/src/target/riscv/riscv-013.c Line 3660 in c6bb902
Shoudl guarantee that the body of the loop riscv-openocd/src/target/riscv/riscv-013.c Line 3615 in c6bb902
is executed at least once for the read value to be correct. How the commit fixes the issue?The execution of the NOP is moved into the loop (the last operation in the batch). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@en-sc Thank you for explaining it in detail 👍. I have understood the original problem now.
LGTM!
Fixes riscv-collab#1080 Change-Id: Ifc1a48fcd0b28f7cdb1e5ad3cbd20d53ea3560a5 Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
@JanMatCodasip, please, take a look once again. There was a conflict with aa9a3fa. |
for (size_t k = 0; k <= last_key; ++k) { | ||
sbvalue[k] = riscv_batch_get_dmi_read_data(batch, | ||
last_key - k); | ||
buf_set_u32(buffer + i * size + k * 4, 0, 8 * size, sbvalue[k]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@en-sc you have an error here. size can be 8 here.
#7 0x000055555609d04c in buf_set_u32 (_buffer=0x5555569ca720 "\277", first=0, num=64, value=191)
at /home/nikita/projects/openocd/src/helper/binarybuffer.h:43
#8 0x00005555560b1d13 in read_memory_bus_v1 (target=0x5555569e5390, address=2147491969, size=8, count=2,
buffer=0x5555569ca720 "\277", increment=8) at ../openocd/src/target/riscv/riscv-013.c:3410
#9 0x00005555560b58c0 in read_memory (target=0x5555569e5390, address=2147491969, size=8, count=2,
buffer=0x5555569ca720 "\277", increment=8) at ../openocd/src/target/riscv/riscv-013.c:4397
#10 0x0000555555c9b5c8 in riscv_read_memory (target=0x5555569e5390, address=2147491969, size=8, count=2,
buffer=0x5555569ca720 "\277") at ../openocd/src/target/riscv/riscv.c:3088
#11 0x0000555555c2daee in target_read_memory (target=0x5555569e5390, address=2147491969, size=8, count=2,
buffer=0x5555569ca720 "\277") at ../openocd/src/target/target.c:1245
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(For reference, in case anyone wonders.)
This is being fixed in #1109
Fixes #1080