-
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 #19460
Merged
bors
merged 2 commits into
RIOT-OS:master
from
dylad:pr/cpu/stm32/usbdev_fs/fixes_for_msc
Apr 9, 2023
Merged
cpu/stm32/usbdev_fs: fix ep registration and EP_REG assignments #19460
bors
merged 2 commits into
RIOT-OS:master
from
dylad:pr/cpu/stm32/usbdev_fs/fixes_for_msc
Apr 9, 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]>
dylad
added
the
Process: needs backport
Integration Process: The PR is required to be backported to a release or feature branch
label
Apr 7, 2023
dylad
requested review from
aabadie,
fjmolinas,
DipSwitch and
vincent-d
as code owners
April 7, 2023 19:46
github-actions
bot
added
Area: cpu
Area: CPU/MCU ports
Platform: ARM
Platform: This PR/issue effects ARM-based platforms
labels
Apr 7, 2023
dylad
added
the
CI: ready for build
If set, CI server will compile all applications for all available boards for the labeled PR
label
Apr 7, 2023
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
force-pushed
the
pr/cpu/stm32/usbdev_fs/fixes_for_msc
branch
from
April 7, 2023 20:41
c03b951
to
701242d
Compare
gschorcht
approved these changes
Apr 8, 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.
The changes make sense and are working, tested with STMF32F303ZE.
gschorcht
added
the
Type: bug
The issue reports a bug / The PR fixes a bug (including spelling errors)
label
Apr 8, 2023
bors merge |
Build succeeded: |
bors bot
added a commit
that referenced
this pull request
Apr 14, 2023
19462: cpu/stm32/usbdev_fs: fix ep registration and EP_REG assignments [backport 2023.04] r=dylad a=dylad ### Contribution description This backport PR provides two fixes for the usbdev_fs driver: Fix endpoints registration Fix assignment of toggleable bits in EP_REG(x) registers 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 Co-authored-by: Dylan Laduranty <[email protected]>
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: needs backport
Integration Process: The PR is required to be backported to a release or feature branch
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 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
This can be tested with tests/usbus_msc on any board using this
usbdev_fs
driver.It is easier to test this PR with #19443 alongside. Then the following would be enough:
CFLAGS='-DSECTOR_COUNT=64' USEMODULE='mtd_emulated' make -j8 BOARD=p-nucleo-wb55 -C tests/usbus_msc flash
Otherwise this can also be tested by attaching a SPI<->SDCARD adapter.
Issues/PRs references
None.