-
Notifications
You must be signed in to change notification settings - Fork 2k
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
sys/usbus: answer get_status if request is standard type #20475
Merged
bergzand
merged 1 commit into
RIOT-OS:master
from
dylad:pr/usbus/fix_get_status_response
Mar 18, 2024
Merged
sys/usbus: answer get_status if request is standard type #20475
bergzand
merged 1 commit into
RIOT-OS:master
from
dylad:pr/usbus/fix_get_status_response
Mar 18, 2024
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
Signed-off-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
github-actions
bot
added
Area: USB
Area: Universal Serial Bus
Area: sys
Area: System
labels
Mar 17, 2024
dylad
added
the
Type: bug
The issue reports a bug / The PR fixes a bug (including spelling errors)
label
Mar 17, 2024
benpicco
added
the
CI: ready for build
If set, CI server will compile all applications for all available boards for the labeled PR
label
Mar 18, 2024
bergzand
approved these changes
Mar 18, 2024
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.
Untested Ack!
@bergzand for the record: Here are my terminal output with this PR:
Against, the output of current master:
|
Thanks @bergzand ! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Area: sys
Area: System
Area: USB
Area: Universal Serial Bus
CI: ready for build
If set, CI server will compile all applications for all available boards for the labeled PR
Type: bug
The issue reports a bug / The PR fixes a bug (including spelling errors)
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.
Contribution description
this PR intends to fix #20474. In current master, a device doesn't behave properly when
dfu-util
is sending a detach request.Once this request is sent, device must reboot into bootloader. However, it doesn't work in master since #17090.
#17090 introduces (among other things) a way for
USBUS
to answer standard requests (received on the control endpoints aka EP0).However, DFU is an USB class which uses the same endpoints to operate. When
dfu-util
sends the detach request,USBUS
wrongly interprets it as a standardget_status
request so the stack answers it instead of the DFU interface.Indeed, both the DFU detach request and the standard
get_status
have the same request number.USB_SETUP_REQ_GET_STATUS
andDFU_DETACH
are both 0x00.Thus, this PR introduces a new check to ensure if the request should be processed by
USBUS
or by an interface.The request type of a DFU detach request is 0x21 which correspond to
USB_SETUP_REQUEST_RECIPIENT_INTERFACE
|USB_SETUP_REQUEST_TYPE_CLASS
.This way, when
dfu-util
send a detach request,USBUS
will now pass it to the interface and will only processUSB_SETUP_REQUEST_TYPE_STANDARD
, as it is suppose to do.Testing procedure
Flash
riotboot_dfu
bootloader into your board:make BOARD=same54-xpro -C bootloaders/riotboot_dfu flash
Then flash a first app into your board through dfu;
FEATURES_REQUIRED=riotboot PROGRAMMER=dfu-util USEMODULE=usbus_dfu make -j4 BOARD=same54-xpro -C tests/sys/shell riotboot/flash-slot0
Finally, flash a second app while the first is running:
DFU_USB_ID=1209:7d00 FEATURES_REQUIRED=riotboot PROGRAMMER=dfu-util USEMODULE=usbus_dfu make -j4 BOARD=same54-xpro -C tests/leds riotboot/flash-slot1
On current master, the last step will fail, the device will never reboot into bootloader and stays in the first app.
With this PR, device will reboot, flash the second application then runs it.
Issues/PRs references
Fixes #20474