Skip to content
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

K22F USB Console/Shell #25811

Closed
asob opened this issue May 29, 2020 · 2 comments · Fixed by #25894
Closed

K22F USB Console/Shell #25811

asob opened this issue May 29, 2020 · 2 comments · Fixed by #25894
Assignees
Labels
area: USB Universal Serial Bus bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug

Comments

@asob
Copy link

asob commented May 29, 2020

I've been testing out Zephyr's USB connectivity options on FRDM-K22F and got some questions:

  1. samples/subsys/usb/console/ compiles and runs okay as long as the USB is connected. If usb is not connected the application will not run, this happens, as I can see it because of flag CONFIG_USB_UART_DTR_WAIT=y. My understanding was that if i compile the app with CONFIG_USB_UART_DTR_WAIT=n the application will run immediately, however after compiling and uploading it to target the USB CDC Serial is not being recognized by the host operating system. Is it all possible to have a console via USB without the DTR flag?
  2. Is it possible to have shell redirected to USB Serial? The documentation is kinda of cryptic regarding this.
@jfischer-no
Copy link
Collaborator

jfischer-no commented May 29, 2020

regarding (1):

There is a bug that prevents initialization of the USB device stack if DTR_WAIT is not enabled, I already mentioned it on the slack but forgot to fix. @asob Please try the patch below, I will open a PR later.

diff --git a/drivers/console/uart_console.c b/drivers/console/uart_console.c
index b3c57366c3..660d0b5241 100644
--- a/drivers/console/uart_console.c
+++ b/drivers/console/uart_console.c
@@ -601,14 +601,14 @@ static int uart_console_init(struct device *arg)
 
        __ASSERT_NO_MSG(uart_console_dev);
 
-#if defined(CONFIG_USB_UART_CONSOLE) && defined(CONFIG_USB_UART_DTR_WAIT)
+#if defined(CONFIG_USB_UART_CONSOLE)
        int ret;
 
        ret = usb_enable(NULL);
        if (ret != 0) {
                return ret;
        }
-
+#if defined(CONFIG_USB_UART_DTR_WAIT)
        while (1) {
                u32_t dtr = 0U;
 
@@ -618,6 +618,7 @@ static int uart_console_init(struct device *arg)
                }
        }
        k_busy_wait(1000000);
+#endif
 #endif
 
        uart_console_hook_install();

@jfischer-no jfischer-no added bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug labels May 29, 2020
@asob
Copy link
Author

asob commented May 29, 2020

@jfischer-phytec-iot

Thanks for the patch, for some reason git apply <patch> didn't work fork me, kept throwing the same errors:

~/zephyrproject/zephyr$ git apply ~/usb_dtr_fix.patch
error: patch failed: drivers/console/uart_console.c:601
error: drivers/console/uart_console.c: patch does not apply

But I went ahead and just modified the uart_console.c manually, the results are as follows:

  1. Board is powered on, code starts executing
  2. Connect USB, CDC Serial is detected in Device Manager
  3. Open up terminal (PuTTY) -> Console output is visible
  4. Disconnect USB while PuTTY is still running
  5. Reconnect USB -> CDC Serial is detected in Device Manager
  6. Open up terminal -> No console output

If after step (3) PuTTY is first closed instead of just disconnecting USB and then USB is disconnected and reconnected, console output re-appears.

jfischer-no added a commit to jfischer-no/zephyr that referenced this issue Jun 2, 2020
Initialize USB even if USB_UART_DTR_WAIT is not enabled.

Fixes: zephyrproject-rtos#25811

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
carlescufi pushed a commit that referenced this issue Jun 2, 2020
Initialize USB even if USB_UART_DTR_WAIT is not enabled.

Fixes: #25811

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: USB Universal Serial Bus bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants