-
-
Notifications
You must be signed in to change notification settings - Fork 773
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
Fix: CMSIS-DAP block I/O #1999
Open
dragonmux
wants to merge
15
commits into
main
Choose a base branch
from
fix/cmsis-dap-block-io
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix: CMSIS-DAP block I/O #1999
+120
−75
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dragonmux
added
Bug
Confirmed bug
BMP Firmware
Black Magic Probe Firmware (not PC hosted software)
labels
Nov 11, 2024
dragonmux
force-pushed
the
fix/cmsis-dap-block-io
branch
from
November 11, 2024 17:05
2f2424f
to
b0380c0
Compare
…pecialised in mass data transfers so we get the the actual amount transferred
…s a full packet amount of data, messing up the Bulk transfer transport state
…perly detecting and handling short responses due to target errors, leading to very bad things happening on return
… resulted in it not properly taking into account the command byte prefix in responses
… resulted in it not properly taking into account the command byte prefix in responses
…`perform_dap_transfer_block_write()`
…o not crash when a fault occurs, but instead propagate it correctly
…p for the access goes wrong
…p_transfer_block_read()` to be a little more sane
… failed partial read up the stack and handling WAIT responses in read as best as we can
…)` to exactly fit the max amount transferrable in a go and nothing more
…low any buffers anywhere
dragonmux
force-pushed
the
fix/cmsis-dap-block-io
branch
from
November 15, 2024 14:05
b0380c0
to
bd6188b
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Detailed description
This PR addresses a series of bugs found by j4cbo and Xobs on Discord concerning CMSIS-DAP adaptors. They concern: how the backend handles FAULT responses; how the backend handles WAIT responses due to AP hangs during block transfers (and subsequently, short responses); how the backend handles full responses over Bulk (ZLP handling); how the backend chunks reads; how the backend chunks writes.
This fixes the behaviour of the backend so that when a FAULT response is encountered, the backend cleanly returns up the stack as in a normal transport request - the main code base knows how to handle this, so don't
exit()
out when it can usually be recovered, and otherwise reported.This fixes the behaviour of the backend not aborting a transfer on encountering a WAIT response, which is roughly equivalent to the WAIT repsonse handling in adiv5_swd.c.
This fixes mischunking causing over-long read requests to be sent to the adaptor, and over-short write requests, both resulting in nasty data corruption issues. It also makes the buffer behaviour more consistent in initialisation and usage so when a fault like a WAIT response occurs, the data passed back to GDB is in an initialised state, and not just whatever garbage was on the stack.
Tested against the STM32H7 and STM32F1 - the F1's Flash routines trigger the read chunking issue, resulting in Flash data corruption; the H7's tracing components trigger the other conditions as when TRACECLKEN is not set in the DBGMCU, the tracing components are entirely unclocked and accessing their registers results in a permanent WAIT condition on the AP and a bus hang; and then the next request after that results in a FAULT response. Reading 512 byte blocks using GDB's Python interface triggers the over-long read requests. The following was the testing protocol for this:
Power cycling the target is required after doing this testing protocol in its failing state configuration, and writing DBGMCU's CR register to 0x00700007 with
set
required for a re-run to test the success state.Your checklist for this pull request
Closing issues