-
Notifications
You must be signed in to change notification settings - Fork 7.4k
usb: device_next: save some flash and RAM #90791
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
Merged
fabiobaltieri
merged 8 commits into
zephyrproject-rtos:main
from
jfischer-no:pr-device_next-try-to-save-some-flash
Jun 3, 2025
Merged
usb: device_next: save some flash and RAM #90791
fabiobaltieri
merged 8 commits into
zephyrproject-rtos:main
from
jfischer-no:pr-device_next-try-to-save-some-flash
Jun 3, 2025
+268
−96
Conversation
This file contains hidden or 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
Disabling it if not needed can save about 400 bytes of flash memory. Signed-off-by: Johann Fischer <[email protected]>
Disabling it if not needed can save about 100 bytes of flash memory. Signed-off-by: Johann Fischer <[email protected]>
Allowing message callback execution from the USBD thread saves about 800 bytes. For small devices, the option can be useful to reduce flash/RAM usage, those with enough resources should not bother about it. Signed-off-by: Johann Fischer <[email protected]>
tmon-nordic
requested changes
May 29, 2025
@@ -81,8 +81,15 @@ config USBD_MSG_SLAB_COUNT | |||
help | |||
Maximum number of USB device notification messages that can be queued. | |||
|
|||
config USBD_MSG_DEFERRED_MODE | |||
bool "Execute message callback from system workqueue" | |||
default y |
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.
This change is a step in the right direction, however I would prefer this to be default n
.
Add Kconfig option to use dedicated workqueue in CDC ACM but use the system work queue in CDC ACM by default. Signed-off-by: Johann Fischer <[email protected]>
Disable high-speed descriptors when they are not in use saves 64 bytes in flash/RAM. It is unlikely that it will scale well enough to be used in all class implementations or to support a different speed. Signed-off-by: Johann Fischer <[email protected]>
The required buffer is 128 bytes per instance on a full-speed device. Use common (UDC) buffer, as this results in a smaller footprint. Signed-off-by: Johann Fischer <[email protected]>
Disable the high-speed USB device descriptor if it is not in use. Add checks to the code where the high-speed descriptor may be used. Signed-off-by: Johann Fischer <[email protected]>
Do not add functions to the high-speed iterable section when high-speed support is disabled. Signed-off-by: Johann Fischer <[email protected]>
c06c6ad
to
f4e9a24
Compare
|
tmon-nordic
approved these changes
Jun 3, 2025
fabiobaltieri
approved these changes
Jun 3, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area: Samples
Samples
area: USB
Universal Serial Bus
Experimental
Experimental features not enabled by default
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.
Allow disabling of features that may not be needed. Exclude high-speed structures that the compiler cannot optimize if high-speed support is not enabled. Some of the if/endifs in CDC ACM are not worth it, as the resource savings are minimal.
The savings are about 1640B Flash and 1608B RAM (44892B/16240B vs 43252B/14632B) on frdm_k645f and 1944B Flash and 1752B RAM (54528B/15952B vs 52584B/14200B) on reel_board when built
samples/subsys/usb/cdc_acm
with options-DCONFIG_USBD_MSG_DEFERRED_MODE=n -DCONFIG_USBD_VREQ_SUPPORT=n -DCONFIG_USBD_BOS_SUPPORT=n
.