-
Notifications
You must be signed in to change notification settings - Fork 8.2k
usb: patches to resolve issues around Kconfig option USB_UART_CONSOLE #40220
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
Closed
jfischer-no
wants to merge
13
commits into
zephyrproject-rtos:main
from
jfischer-no:pr-usb_uart_console
+184
−168
Closed
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ee570c8
usb: cdc_acm: use same init level and priority as serial drivers
jfischer-no b0dc396
usb: limit scope of CONFIG_USB_UART_CONSOLE
jfischer-no 623ace0
usb: deprecate Kconfig option USB_UART_CONSOLE
jfischer-no 9b88cba
usb: add option to initialize USB device support at boot
jfischer-no 4d53a79
shields: add generic shield to use CDC ACM UART as backend
jfischer-no 1d52620
samples: shell_module: use generic CDC ACM shield
jfischer-no a92896b
tests: bluetooth: shell: use generic CDC ACM shield
jfischer-no 561c894
tests: uart_basic_api: use generic CDC ACM shield
jfischer-no 461b174
samples: sensortile_box: use generic CDC ACM shield
jfischer-no 74b92d7
samples: usb: console: fix configuration
jfischer-no 9c03497
boards: clean up CDC ACM configuration for nRF52840 based boards
jfischer-no 105e3da
usb: remove the remains of USB_UART_CONSOLE
jfischer-no 6c32698
shields: cdc_acm: add support for zephyr,bt-c2h-uart property
jfischer-no File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ | |
| #include <sys/byteorder.h> | ||
| #include <zephyr.h> | ||
| #include <usb/usb_device.h> | ||
| #include <drivers/uart.h> | ||
|
|
||
| #include <shell/shell.h> | ||
|
|
||
|
|
@@ -122,10 +123,20 @@ static void hrs_notify(void) | |
|
|
||
| void main(void) | ||
| { | ||
| if (IS_ENABLED(CONFIG_USB_UART_CONSOLE)) { | ||
| usb_enable(NULL); | ||
| k_sleep(K_SECONDS(2)); | ||
| #if DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_shell_uart), zephyr_cdc_acm_uart) | ||
|
||
| const struct device *dev; | ||
| uint32_t dtr = 0; | ||
|
|
||
| dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_shell_uart)); | ||
| if (!device_is_ready(dev) || usb_enable(NULL)) { | ||
| return; | ||
| } | ||
|
|
||
| while (!dtr) { | ||
| uart_line_ctrl_get(dev, UART_LINE_CTRL_DTR, &dtr); | ||
| k_sleep(K_MSEC(100)); | ||
| } | ||
| #endif | ||
|
|
||
| printk("Type \"help\" for supported commands."); | ||
| printk("Before any Bluetooth commands you must `bt init` to initialize" | ||
|
|
||
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
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.
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.
First observation, the default priority of
95was chosen because of the USB stack initialization, see:df2bb46
So what has changed, since console can now be initialized at
60instead ?This commit only changed the symbol used: d8bc37b
but the default value is still
50SERIAL_INIT_PRIORITYdefaults toKERNEL_INIT_PRIORITY_DEVICEdefault ==50Second observation:
The
CONSOLE_INIT_PRIORITYdefaults toKERNEL_INIT_PRIORITY_DEFAULT==40when UART_CONSOLE is not enabled, and the setting is having a prompt.This means this setting suffers from the stuck symbols syndrome:
https://docs.zephyrproject.org/latest/guides/build/kconfig/tips.html#stuck-symbols-in-menuconfig-and-guiconfig
meaning that if anyone later enables the
USB_UART_CONSOLEor theUART_CONSOLE, then the priority will not change, in which case the40value would risk still being active and not thepreferreddefault of60.I believe majority of boards are having
CONFIG_UART_CONSOLE=yin their_defconfigso it might not be a real problem, but it still looks as we might have a risk of strangely behaving system.And it sounds to me as there is also some upper bound dependency since
95is no longer a good default.So should this priority in reality be a range ?
Where the upper and lower bounds might be defined by other settings.
Or should the setting be promptless in certain cases ?
Note, a promptless setting can still be controlled through a Kconfig file, for example
Kconfig.boardThere 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.
CDC ACM UART driver has been reworked a bit and does not block when USB device support is not initialized, (behaves like regular UART).
I am in favor of this option.
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.
I would like to see this sentence in the commit message, as that is an important piece of information in order to understand why changing the default from
95to60is safe.