-
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
cpu/stm32/usbdev_fs: fix ep registration and EP_REG assignments [backport 2023.04] #19462
Merged
bors
merged 2 commits into
RIOT-OS:2023.04-branch
from
dylad:backport/cpu/stm32/usbdev_fs/fixes_for_msc
Apr 14, 2023
Merged
cpu/stm32/usbdev_fs: fix ep registration and EP_REG assignments [backport 2023.04] #19462
bors
merged 2 commits into
RIOT-OS:2023.04-branch
from
dylad:backport/cpu/stm32/usbdev_fs/fixes_for_msc
Apr 14, 2023
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
For the usbdev_fs peripheral, IN and OUT endpoints of the same index must have the same type. For instance, if EP1 OUT is a bulk endpoint, EP1 IN must either be unused or used as bulk too but it cannot be used as interrupt or isochronous. With the previous check, the following registration pattern (EP OUT Bulk -> EP IN Interrupt -> EP IN Bulk) would assign both EP OUT Bulk and EP IN Interrupt to same endpoint index. So the configuration would be broken. Applying the same registration pattern with this patch would now produce EP OUT Bulk -> 1 / EP IN Interrupt -> 2 / EP IN Bulk 1. Which is a working configuration for this IP Signed-off-by: Dylan Laduranty <[email protected]>
EP_REG(x) registers have a total of 6 toggleable bits. Those bits can only be toggled if we write a one to it, otherwise writing a zero has no effect This commit fixes all the access to these registers to prevent from modifying these bits when not needed Signed-off-by: Dylan Laduranty <[email protected]>
dylad
added
the
Process: release backport
Integration Process: The PR is a release backport of a change previously provided to master
label
Apr 10, 2023
dylad
requested review from
aabadie,
fjmolinas,
DipSwitch and
vincent-d
as code owners
April 10, 2023 19:21
github-actions
bot
added
Area: cpu
Area: CPU/MCU ports
Platform: ARM
Platform: This PR/issue effects ARM-based platforms
labels
Apr 10, 2023
dylad
changed the title
cpu/stm32/usbdev_fs: fix ep registration and EP_REG assignments [backport]
cpu/stm32/usbdev_fs: fix ep registration and EP_REG assignments [backport 2023.04]
Apr 10, 2023
MrKevinWeiss
approved these changes
Apr 14, 2023
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.
quick check for backport, looks good. ACK.
bors merge |
🕐 Waiting for PR status (GitHub check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set. |
MrKevinWeiss
added
the
CI: ready for build
If set, CI server will compile all applications for all available boards for the labeled PR
label
Apr 14, 2023
bors cancel |
Build succeeded: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Area: cpu
Area: CPU/MCU ports
CI: ready for build
If set, CI server will compile all applications for all available boards for the labeled PR
Platform: ARM
Platform: This PR/issue effects ARM-based platforms
Process: release backport
Integration Process: The PR is a release backport of a change previously provided to master
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 backport PR provides two fixes for the usbdev_fs driver:
These bugs were encountered with the USBUS MSC implementation.
Regarding the endpoints registration:
For the usbdev_fs peripheral, IN and OUT endpoints of the same index must have the same type.
For instance, if EP1 OUT is a bulk endpoint, EP1 IN must either be unused or used as bulk too but it cannot be used as interrupt or isochronous.
With the previous check, the following registration pattern (EP OUT Bulk -> EP IN Interrupt -> EP IN Bulk) would assign both EP OUT Bulk and EP IN Interrupt to same endpoint index. So the configuration would be broken.
Applying the same registration pattern with this patch would now produce EP OUT Bulk -> 1 / EP IN Interrupt -> 2 / EP IN Bulk 1. Which is a working configuration for this IP.
and for the second fix:
EP_REG(x) registers have a total of 6 toggleable bits. Those bits can only be toggled if we write a one to it, otherwise writing a zero has no effect
This commit fixes all the access to these registers to prevent from modifying these bits when not needed.
Without this patch, the endpoint status (VALID / NACK / STALL) can be erroneously modify because bits are not cleared when assigning the new content to the register and thus make the bits toggle and change values.
Testing procedure
See #19460
Issues/PRs references
#19460