SHELL over USB (CDC ACM class device) will not accept incoming characters with Zephyr 2.7.0

Hi,

I used to be able to configure a console (SHELL) to run over a UART over USB connection (USB CDC ACM device) on Zephyr 2.5.0. With the latest version of nRF Connect SDK I am not able to run my SHELL over USB. This version of the SDK installs  Zephyr 2.7.0 when I run "west update".

In Zephyr 2.7.0, I noticed that configuration parameters CONFIG_UART_CONSOLE_ON_DEV_NAME and CONFIG_UART_SHELL_ON_DEV_NAME are no longer valid. I was using those parameters to port the SHELL over USB. I now follow the examples given in zephyr/sample/subsys/shell.

Here is the code where I intiate the SHELL over USB:

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));
}

Execution is stuck in this loop above.

If I omit those lines, then my console does not receive incoming characters. It only prints whatever information sent to it (through printk() for instance).

Here are my configuration parameters:

CONFIG_SERIAL=y

# Redirect console to CDC
CONFIG_USB_UART_CONSOLE=y
CONFIG_USB_DEVICE_PID=0x0101
CONFIG_USB_SELF_POWERED=n
CONFIG_USB_WORKQUEUE=y
CONFIG_USB_WORKQUEUE_STACK_SIZE=1024
CONFIG_USB_WORKQUEUE_PRIORITY=-1
CONFIG_USB_CDC_ACM=y
CONFIG_USB_CDC_ACM_RINGBUF_SIZE=1024

#CONFIG_USB_CDC_ACM_DEVICE_NAME="CDC_ACM"
#CONFIG_USB_CDC_ACM_DEVICE_COUNT=1

CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_LINE_CTRL=y
CONFIG_SHELL_BACKEND_SERIAL_INIT_PRIORITY=51
#CONFIG_DEVICE_SHELL=y
#CONFIG_KERNEL_SHELL=y

#Shell through COM port
CONFIG_SHELL=y
CONFIG_CONSOLE=y
CONFIG_STDOUT_CONSOLE=y
CONFIG_SHELL_BACKEND_SERIAL=y
CONFIG_SHELL_BACKENDS=y

My dts overlay file has the following lines to support SHELL over USB:

/ {
chosen {
zephyr,console = &cdc_acm_uart0;
};
};

&zephyr_udc0 {
cdc_acm_uart0: cdc_acm_uart0 {
compatible = "zephyr,cdc-acm-uart";
label = "CDC_ACM_0";
};
};

Anyone saw the same problem and/or has a solution for it ?

Philippe O'Reilly

Parents
  • Hi Philippe

    Most likely the issue is that you are setting the console rather than the shell in your DTS overlay. 

    To fix this you should change this line:

    zephyr,console = &cdc_acm_uart0;

    To this:

    zephyr,shell-uart = &cdc_acm_uart0;

    According to the developers, in v2.7.0 there were some changes to how CDC ACM UART is configured, and the CDC ACM behavior has been changed to mimic UART more closely. Instead of using the Kconfig *ON_DEV_NAME options the chosen properties are used directly. For a more details description of the CDC ACM UART please have a look here.

    For a full list of the Kconfig options removed in this release you can have a look here.  

    Best regards
    Torbjørn

Reply
  • Hi Philippe

    Most likely the issue is that you are setting the console rather than the shell in your DTS overlay. 

    To fix this you should change this line:

    zephyr,console = &cdc_acm_uart0;

    To this:

    zephyr,shell-uart = &cdc_acm_uart0;

    According to the developers, in v2.7.0 there were some changes to how CDC ACM UART is configured, and the CDC ACM behavior has been changed to mimic UART more closely. Instead of using the Kconfig *ON_DEV_NAME options the chosen properties are used directly. For a more details description of the CDC ACM UART please have a look here.

    For a full list of the Kconfig options removed in this release you can have a look here.  

    Best regards
    Torbjørn

Children
Related