-
Notifications
You must be signed in to change notification settings - Fork 486
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
probe: stlink: Fix 1-byte transfers #1476
Conversation
The issue was discovered in the latest release of pyOCD (
Matching pyocd log and traceback:
When inspected with pdb, this leads to
|
Related (or pretty much the same 😉 ) issue -- #1444. |
Thanks! And helpful detail in the description. I'm about to push a change to remove Python 3.6 from the CI workflow, so it will run successfully. |
4180abf
to
a353c96
Compare
The way we calculate |
I think this commit not correct too. See fix at #1428 in comments. |
a353c96
to
44319b8
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.
Looks good! Thanks for the added comments.
Just noticed: you should probably add your copyright to the file header comment (meaning I'd prefer it 😄). I'll give you a chance before merging.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Internally the 1-byte transfers are handled in 3 phases: 1. read/write 8-bit chunks until the first aligned address is reached, 2. read/write 32-bit chunks from all aligned addresses, 3. read/write 8-bit chunks from the remaining unaligned addresses. Size of the first unaligned read/write is set to the result of address alignment check (4-byte) and can be either 1, 2, or 3 bytes (the value of `unaligned_count` calculated as `addr & 0x3`). This is incorrect and every transfer with the requested size smaller than `unaligned_count` is terminated with the following error: Unhandled exception in handle_message (b'm'): result size (3) != requested size (1) [gdbserver] Skip the first unaligned transfer if the requested size is so small that phase-1 would not even reach aligned address. Handle the whole request in the second unaligned read/write (phase-3).
44319b8
to
00a0c0b
Compare
OK, updated the copyright. Too bad this cancelled the whole CI pipeline. 😅 |
Thanks! |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Btw, I plan to cherry pick this fix to |
Internally the 1-byte transfers are handled in 3 phases: 1. read/write 8-bit chunks until the first aligned address is reached, 2. read/write 32-bit chunks from all aligned addresses, 3. read/write 8-bit chunks from the remaining unaligned addresses. Size of the first unaligned read/write is set to the result of address alignment check (4-byte) and can be either 1, 2, or 3 bytes (the value of `unaligned_count` calculated as `addr & 0x3`). This is incorrect and every transfer with the requested size smaller than `unaligned_count` is terminated with the following error: Unhandled exception in handle_message (b'm'): result size (3) != requested size (1) [gdbserver] Skip the first unaligned transfer if the requested size is so small that phase-1 would not even reach aligned address. Handle the whole request in the second unaligned read/write (phase-3).
Internally the 1-byte transfers are handled in 3 phases: 1. read/write 8-bit chunks until the first aligned address is reached, 2. read/write 32-bit chunks from all aligned addresses, 3. read/write 8-bit chunks from the remaining unaligned addresses. Size of the first unaligned read/write is set to the result of address alignment check (4-byte) and can be either 1, 2, or 3 bytes (the value of `unaligned_count` calculated as `addr & 0x3`). This is incorrect and every transfer with the requested size smaller than `unaligned_count` is terminated with the following error: Unhandled exception in handle_message (b'm'): result size (3) != requested size (1) [gdbserver] Skip the first unaligned transfer if the requested size is so small that phase-1 would not even reach aligned address. Handle the whole request in the second unaligned read/write (phase-3).
Internally the 1-byte transfers are handled in 3 phases:
Size of the first unaligned read/write is set to the result of address (4-byte) alignment check and can be either 1, 2, or 3 bytes (the value of
unaligned_count
calculated asaddr & 0x3
). This is incorrect and every transfer with the requested size smaller thanunaligned_count
is terminated with the following error:Skip the first unaligned transfer if the requested size is smaller than the result of the address alignment check. Handle the whole request in the second, unaligned read/write (phase 3. mentioned above).