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

USB_UART_DTR_WAIT not working on nrf52840_pca10059 #16518

Closed
iod opened this issue May 30, 2019 · 13 comments · Fixed by #16613
Closed

USB_UART_DTR_WAIT not working on nrf52840_pca10059 #16518

iod opened this issue May 30, 2019 · 13 comments · Fixed by #16613
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

@iod
Copy link

iod commented May 30, 2019

USB_UART_DTR_WAIT no longer working on nrf52840_pca10059 after commit 3880a42

@iod iod added the bug The issue is a bug, or the PR is fixing a bug label May 30, 2019
@carlescufi carlescufi added area: USB Universal Serial Bus platform: nRF Nordic nRFx labels May 30, 2019
@carlescufi
Copy link
Member

@iod can you please post which sample you are using, and how you are flashing the sample?

@iod
Copy link
Author

iod commented May 30, 2019

src/main.c

#include <stdio.h>

void main(void)
{
  printf("hello usb\n");
}

prj.conf

CONFIG_UART_CONSOLE=y
CONFIG_UART_CONSOLE_ON_DEV_NAME="CDC_ACM_0"
CONFIG_UART_LINE_CTRL=y
CONFIG_USB=y
CONFIG_USB_UART_CONSOLE=y

CONFIG_USB_UART_DTR_WAIT=y # <- not in samples version, that seems to cause the issue

flashed: with nrfutil dfu usb-serial to nrf52840_pca10059

expected: to be able to connect to device which prints hello usb

actual: ttyACM device no longer shows up after flash

@finikorg
Copy link
Collaborator

I tested samples/subsys/usb/console with reel_board, works as before.

@carlescufi
Copy link
Member

@iod for completeness, can you please test samples/subsys/usb/console on this board to see if this is an issue there?

@lemrey
Copy link
Collaborator

lemrey commented May 31, 2019

Have tested samples/subsys/usb/console on nrf52840_pca10059, without the nRF5 booatloder.
The device shows up and I get the expected output on the console.

@carlescufi
Copy link
Member

I tested samples/subsys/usb/console on nrf52840_pca10059 with the nRF5 bootloader flashing with nrfutil and it works fine

@iod
Copy link
Author

iod commented May 31, 2019

I have narrowed it down to CONFIG_USB_UART_DTR_WAIT=y that seems to be not working.
@finikorg @lemrey @carlescufi maybe you can add that to the sample to retest?

@iod iod changed the title USB UART not working on nrf52840_pca10059 USB_UART_DTR_WAIT not working on nrf52840_pca10059 May 31, 2019
@carlescufi
Copy link
Member

I have narrowed it down to CONFIG_USB_UART_DTR_WAIT=y that seems to be not working.
@finikorg @lemrey @carlescufi maybe you can add that to the sample to retest?

@finikorg any idea why this particular configuration would have stopped working?

@anangl
Copy link
Member

anangl commented Jun 3, 2019

I can only confirm that the problem seems to be the option CONFIG_USB_UART_DTR_WAIT=y. It is not specific to nrf52840_pca10059 or to the application. The same behavior (the CDC ACM device does not show up) can be observed also on nrf52840_pca10056, and also with samples/subsys/usb/console after adding the mentioned option.

@jfischer-no
Copy link
Collaborator

The problem is the init prio (level is APPLICATION anywhere):

CDC ACM class: KERNEL_INIT_PRIORITY_DEVICE 50
uart_console: UART_CONSOLE_INIT_PRIORITY 60
usb_device: APPLICATION_INIT_PRIORITY 90

uart_console_init blocks before usb device stack was initialized.

Workaround: set UART_CONSOLE_INIT_PRIORITY to 91

@jfischer-no jfischer-no added priority: low Low impact/importance bug and removed platform: nRF Nordic nRFx labels Jun 3, 2019
@iod
Copy link
Author

iod commented Jun 3, 2019

@jfischer-phytec-iot I wanted to confirm that the workaround:

CONFIG_UART_CONSOLE_INIT_PRIORITY=91

fixes the issue the issue for me, thank you.

@carlescufi
Copy link
Member

@jfischer-phytec-iot should we add that line to the sample?

@finikorg
Copy link
Collaborator

finikorg commented Jun 4, 2019

I am thinking about following:

diff --git a/drivers/console/Kconfig b/drivers/console/Kconfig
index fc89bb83c0..3914f572cb 100644
--- a/drivers/console/Kconfig
+++ b/drivers/console/Kconfig
@@ -53,6 +53,7 @@ config UART_CONSOLE
 
 config UART_CONSOLE_INIT_PRIORITY
        int "Init priority"
+       default 95 if USB_UART_DTR_WAIT
        default 60
        depends on UART_CONSOLE
        help
diff --git a/samples/subsys/usb/console/prj.conf b/samples/subsys/usb/console/prj.conf
index e51d82323b..0961ff4487 100644
--- a/samples/subsys/usb/console/prj.conf
+++ b/samples/subsys/usb/console/prj.conf
@@ -8,3 +8,5 @@ CONFIG_USB_UART_CONSOLE=y
 CONFIG_UART_INTERRUPT_DRIVEN=y
 CONFIG_UART_LINE_CTRL=y
 CONFIG_UART_CONSOLE_ON_DEV_NAME="CDC_ACM_0"
+
+CONFIG_USB_UART_DTR_WAIT=y

That default value is only assigned if we put CONFIG_USB_UART_DTR_WAIT=y tp prj.conf

finikorg added a commit to finikorg/zephyr that referenced this issue Jun 4, 2019
It does make sense to initialize USB console after USB Device stack.
Note that the value is selected only if we specify USB_UART_CONSOLE
in prj.conf, not in menuconfig afterwards.

Fixes zephyrproject-rtos#16518

Signed-off-by: Andrei Emeltchenko <[email protected]>
carlescufi pushed a commit that referenced this issue Jun 5, 2019
It does make sense to initialize USB console after USB Device stack.
Note that the value is selected only if we specify USB_UART_CONSOLE
in prj.conf, not in menuconfig afterwards.

Fixes #16518

Signed-off-by: Andrei Emeltchenko <[email protected]>
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.

6 participants