I am not able to add the cdc_acm in my application (board= nrf52840)

first i change to my kconfig file add this

source "samples/subsys/usb/common/Kconfig.sample_usbd"

source "Kconfig.zephyr
second I add to cmakelits 
include(${ZEPHYR_BASE}/samples/subsys/usb/common/common.cmake)
third i add there usb_next_prj.config file from there example
fourth i add there prj.config in my file
fifth i add there main file program 
If I run there example from sample cdc_acm it work correctly in my custom board of nrf52840 but hen i add to my application it not work here is config of my custom board in 
prj.conf

CONFIG_STDOUT_CONSOLE=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_PRODUCT="Zephyr CDC ACM sample"
CONFIG_USB_DEVICE_PID=0x0001
CONFIG_LOG=y
CONFIG_USB_DRIVER_LOG_LEVEL_ERR=y
CONFIG_USB_DEVICE_LOG_LEVEL_ERR=y
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_LINE_CTRL=y
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n




# Application Specific Configuration
CONFIG_APP_WIPE_STORAGE=n
CONFIG_DOTT_LOG_LEVEL_DBG=y
CONFIG_DISPLAY=y
CONFIG_DISPLAY_LOG_LEVEL_INF=y
CONFIG_SPI_LOG_LEVEL_INF=y
CONFIG_HEAP_MEM_POOL_SIZE=16384


# Enable MCUmgr and dependencies.
CONFIG_NET_BUF=y
CONFIG_ZCBOR=y
CONFIG_CRC=y
CONFIG_MCUMGR=y
CONFIG_STREAM_FLASH=y
CONFIG_FLASH_MAP=y

# Some command handlers require a large stack.
# Add 256 bytes to accommodate upload command (lfs_stat overflows)
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2304
CONFIG_MAIN_STACK_SIZE=2048

# Ensure an MCUboot-compatible binary is generated.
CONFIG_BOOTLOADER_MCUBOOT=y

# Enable flash operations.
CONFIG_FLASH=y
CONFIG_FLASH_MAP=y

# Required by the `taskstat` command.
CONFIG_THREAD_MONITOR=y

# Support for taskstat command
CONFIG_MCUMGR_GRP_OS_TASKSTAT=y

# Enable most core commands.
CONFIG_IMG_MANAGER=y
CONFIG_MCUMGR_GRP_IMG=y
CONFIG_MCUMGR_GRP_OS=y

# Enable logging
CONFIG_LOG=y
CONFIG_LOG_MODE_IMMEDIATE=n
CONFIG_LOG_BACKEND_RTT=n
CONFIG_LOG_FUNC_NAME_PREFIX_DBG=n
CONFIG_MCUBOOT_UTIL_LOG_LEVEL_WRN=y
CONFIG_MIPI_DBI_LOG_LEVEL_DBG=n
CONFIG_DISPLAY_LOG_LEVEL_DBG=n

## BT Support
CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="Dott"
CONFIG_BT_BAS=y
CONFIG_BT_DIS=y
CONFIG_BT_DIS_FW_REV=y
CONFIG_BT_DIS_FW_REV_STR="1.0.0"

# Allow for large Bluetooth data packets.
CONFIG_BT_L2CAP_TX_MTU=498
CONFIG_BT_BUF_ACL_RX_SIZE=502
CONFIG_BT_BUF_ACL_TX_SIZE=502
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251

# Enable the Bluetooth mcumgr transport (unauthenticated).
CONFIG_MCUMGR_TRANSPORT_BT=y
CONFIG_MCUMGR_TRANSPORT_BT_AUTHEN=n
CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL=y

# Enable the Shell mcumgr transport.
CONFIG_BASE64=y
CONFIG_CRC=y
CONFIG_SHELL=y
CONFIG_SHELL_BACKEND_SERIAL=n
CONFIG_SHELL_BACKEND_DUMMY=y
CONFIG_MCUMGR_TRANSPORT_SHELL=y
CONFIG_MCUMGR_GRP_SHELL=y

# Enable the mcumgr Packet Reassembly feature over Bluetooth and its configuration dependencies.
# MCUmgr buffer size is optimized to fit one SMP packet divided into five Bluetooth Write Commands,
# transmitted with the maximum possible MTU value: 498 bytes.
CONFIG_MCUMGR_TRANSPORT_BT_REASSEMBLY=y
CONFIG_MCUMGR_TRANSPORT_NETBUF_SIZE=2475
CONFIG_MCUMGR_GRP_OS_MCUMGR_PARAMS=y
CONFIG_MCUMGR_TRANSPORT_WORKQUEUE_STACK_SIZE=4608

# Enable the LittleFS file system.
CONFIG_FILE_SYSTEM=y
CONFIG_FILE_SYSTEM_LITTLEFS=y

# Enable file system commands
CONFIG_MCUMGR_GRP_FS=y
CONFIG_MCUMGR_MGMT_NOTIFICATION_HOOKS=y
CONFIG_MCUMGR_GRP_FS_FILE_ACCESS_HOOK=y

# Enable the storage erase command.
CONFIG_MCUMGR_GRP_ZBASIC=y
CONFIG_MCUMGR_GRP_ZBASIC_STORAGE_ERASE=y

# Disable Bluetooth ping support
CONFIG_BT_CTLR_LE_PING=n

# Disable shell commands that are not needed
CONFIG_CLOCK_CONTROL_NRF_SHELL=n
CONFIG_DEVICE_SHELL=y
CONFIG_DEVMEM_SHELL=y
CONFIG_FLASH_SHELL=y

# Button Support
CONFIG_GPIO=y
CONFIG_PRINTK=y

# Settings
CONFIG_SETTINGS=y
CONFIG_SETTINGS_RUNTIME=y
CONFIG_SETTINGS_FILE=y
CONFIG_SETTINGS_FILE_PATH="/lfs1/runsettings"
# Logging
CONFIG_LOG=y
CONFIG_LOG_DEFAULT_LEVEL=3
CONFIG_USBD_LOG_LEVEL_WRN=y
CONFIG_USBD_CDC_ACM_LOG_LEVEL_ERR=y
CONFIG_UDC_DRIVER_LOG_LEVEL_WRN=y
CONFIG_STDOUT_CONSOLE=y

second config of my custom board
CONFIG_LOG_MODE_IMMEDIATE=n
CONFIG_UART_CONSOLE=n
CONFIG_USE_SEGGER_RTT=y
CONFIG_RTT_CONSOLE=y
CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_SHOW_COLOR=
Here is zip from which i have to want functionality in my application
Parents
  • Hi,

    Which version of the nRF Connect SDK are you using?

    Your example works when I test it on the nRF52840 DK with v3.0.0.

    Please note that by default, the USB CDC ACM on the DK is the nRF USB, and not the UART routed through the interface MCU, so you must connect the USB cable to the nRF USB connector:

    Here is everything you need to add for USB CDC ACM in a project:

    Devicetree overlay:

    / {
    	chosen {
    		// What to have here depends on what you will use cdc_acm_uart for
    		// Here are some examples:
    		
    		// zephyr,shell-uart = &cdc_acm_uart0;
    		// zephyr,console = &cdc_acm_uart0;
    	};
    };
    
    &zephyr_udc0 {
    	cdc_acm_uart0: cdc_acm_uart0 {
    		compatible = "zephyr,cdc-acm-uart";
    	};
    };
    

    prj.conf:

    CONFIG_USB_CDC_ACM=y
    CONFIG_USB_DEVICE_STACK=y
    CONFIG_USB_DEVICE_REMOTE_WAKEUP=n
    CONFIG_USB_DEVICE_PRODUCT="My USB product"
    CONFIG_USB_DEVICE_VID=0x1915
    CONFIG_USB_DEVICE_PID=0x0000

    main.c:

    #include <zephyr/usb/usb_device.h>
    
    ...
    
    int ret;
    ret = usb_enable(NULL);
    if (ret != 0 && ret != -EALREADY) {
    	return 0;
    }

    I have attached a project where I have added USB CDC ACM support to Zephyr's Hello World to show how to add support for this easily.

    usb_cdc_acm_hello_world.zip

    Best regards,
    Marte

Reply
  • Hi,

    Which version of the nRF Connect SDK are you using?

    Your example works when I test it on the nRF52840 DK with v3.0.0.

    Please note that by default, the USB CDC ACM on the DK is the nRF USB, and not the UART routed through the interface MCU, so you must connect the USB cable to the nRF USB connector:

    Here is everything you need to add for USB CDC ACM in a project:

    Devicetree overlay:

    / {
    	chosen {
    		// What to have here depends on what you will use cdc_acm_uart for
    		// Here are some examples:
    		
    		// zephyr,shell-uart = &cdc_acm_uart0;
    		// zephyr,console = &cdc_acm_uart0;
    	};
    };
    
    &zephyr_udc0 {
    	cdc_acm_uart0: cdc_acm_uart0 {
    		compatible = "zephyr,cdc-acm-uart";
    	};
    };
    

    prj.conf:

    CONFIG_USB_CDC_ACM=y
    CONFIG_USB_DEVICE_STACK=y
    CONFIG_USB_DEVICE_REMOTE_WAKEUP=n
    CONFIG_USB_DEVICE_PRODUCT="My USB product"
    CONFIG_USB_DEVICE_VID=0x1915
    CONFIG_USB_DEVICE_PID=0x0000

    main.c:

    #include <zephyr/usb/usb_device.h>
    
    ...
    
    int ret;
    ret = usb_enable(NULL);
    if (ret != 0 && ret != -EALREADY) {
    	return 0;
    }

    I have attached a project where I have added USB CDC ACM support to Zephyr's Hello World to show how to add support for this easily.

    usb_cdc_acm_hello_world.zip

    Best regards,
    Marte

Children
No Data
Related