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

usbus/msc: wrong error handling and behavior after usb reset #19478

Open
dylad opened this issue Apr 17, 2023 · 0 comments
Open

usbus/msc: wrong error handling and behavior after usb reset #19478

dylad opened this issue Apr 17, 2023 · 0 comments
Labels
Area: USB Area: Universal Serial Bus Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Comments

@dylad
Copy link
Member

dylad commented Apr 17, 2023

Description

usbus/msc has several design issues regarding its error handling, especially if something turns wrong during a mtd read or write. If an error occurs during a read operation, the IN endpoint will be stalled to indicate that something went wrong to the host, then the host should clear the stall and device must generate a CSW block to end the current transaction.
Nevertheless, the current behavior is wrong and CSW is never generate, which cause issues.
Currently there is no way to fix this issue, as usbus doesn't tell the interface that the endpoint stall condition has been cleared, thus we cannot generate the CBW block since we don't know when the bulk IN endpoint will be available to transfer new data.

Moreover, there is another issue regarding the USB reset. If host tries to perform an USB reset, the current MSC implementation will not work anymore after that. This is because the MSC Bulk OUT endpoint not being set as ready by the MSC after the reset.

Some work are being done to fix these issues but API changes are required (in USBUS) to be done first.

Expected results

MSC should work reliably and should be able to recover properly from an USB reset without having to reset the board.

Actual results

If an error occurs during a read or write operations, the MSC implementation will misbehaves on its bulk IN endpoint and won't work anymore after the USB reset. Only a board reset will allow to recover.

Versions

Current RIOT master

Thanks @gschorcht for shedding some light on these issues.

@dylad dylad added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Area: USB Area: Universal Serial Bus labels Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: USB Area: Universal Serial Bus Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

No branches or pull requests

1 participant