Skip to content
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

cmsisdap: Fix block transfer response parsing #767

Merged
merged 1 commit into from
Aug 21, 2021

Conversation

Dirbaio
Copy link
Member

@Dirbaio Dirbaio commented Aug 14, 2021

Fixes a regression when flashing the rp2040 inrdocued in #745. Logs: https://gist.github.com/Dirbaio/7c7bc3fc7023679b9f36aa4c627a7f40

@Tiwalun was there a particular reason to change it to use the buffer len? Does changing it back break something?

@Dirbaio Dirbaio added the changelog:skip This PR does not require a changelog entry on release label Aug 14, 2021
@twelho
Copy link

twelho commented Aug 17, 2021

I'll confirm that this fixes all the CLI tools and cargo flash resulting in that exact same slice length mismatch panic with an ATSAMD51G19A probed by an ST-Link V2 clone running dap42. cargo flash was hitting various timeouts (likely due to countless retries, with the debug logs filling up with messages like Expected 14 responses, got 15 responses with data..), so I wasn't sure if the issue was with the probe or the code. Thank you so much for this patch, after a week of debugging and frustration the tools now seem to finally work without issues and I was able to successfully flash the chip.

@twelho
Copy link

twelho commented Aug 17, 2021

The preceding calculation of num_transfers and associated Expected {} responses, got {} responses with data.. debug print could also be removed now as they're left unused after this change.

@Tiwalun
Copy link
Member

Tiwalun commented Aug 17, 2021

The transfer count doesn't work unfortunately, because only reads have a response. So the transfer count does not indicate how much data we have to read. It might make sense to use it as an upper limit.

The best solution would probably be to store the number of reads somewhere.

@Dirbaio Dirbaio changed the title cmsisdap: use transfer count from packet instead of from buffer length. cmsisdap: Fix block transfer response parsing Aug 18, 2021
@Dirbaio
Copy link
Member Author

Dirbaio commented Aug 18, 2021

Okay, this should be correct now, if I understood the problem correctly:

  • For reads, read exactly transfer_count words from the payload.
  • For writes, read nothing from the payload.

Again, tested working flashing RP2040 with DapperMime probe firmware.

@Yatekii Yatekii requested a review from Tiwalun August 18, 2021 23:26
Copy link
Member

@Yatekii Yatekii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors r+

@bors
Copy link
Contributor

bors bot commented Aug 21, 2021

@bors bors bot merged commit 73ac1e4 into probe-rs:master Aug 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:skip This PR does not require a changelog entry on release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants