Zephyr: USB_UART_DTR_WAIT not working on nrf52840_pca10059

Created on 30 May 2019  路  13Comments  路  Source: zephyrproject-rtos/zephyr

USB_UART_DTR_WAIT no longer working on nrf52840_pca10059 after commit 3880a42

USB bug low

Most helpful comment

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

All 13 comments

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

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

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

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

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.

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

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?

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?

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.

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-phytec-iot I wanted to confirm that the workaround:

CONFIG_UART_CONSOLE_INIT_PRIORITY=91

fixes the issue the issue for me, thank you.

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

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

Was this page helpful?
0 / 5 - 0 ratings