How to enable nrf USB port as both bluetooth controller and as a serial port in nrf5340 dk board through flashing of hci_usb application

Hi

 I am using nrf5340 dk board for my application development.  I want to configure the nrfUSB port as bluetooth controller and serial port

case 1:

 when iam trying to flash the bluetooth/hci usb application,then nrf USB port acting as a bluetooth controller by showing it as extra bluetooth controller through bluetoothctl command and it is not showing as serial port when iam checking with ls /dev command

case 2:

when i am trying to do flash the smp server with usb_cdc enabled hci_usb application ,then  nrf USB port it is not showing as bluetooth controller,but the serial port is enabled where the new images can uploaded through mcumgr.

I need a mechanism such that nrf USB connector in nrf5340 dk board should acts as a bluetooth controller and also acts as a serial port to upload the new images through smp server (mcumgr)

  • Hi,

    Could you try adding this to the application devicetree overlay:

    / {
    
        chosen {
    
            zephyr,console = &cdc_acm_uart0;
    
            };
    
    };
    
     
    
    &zephyr_udc0 {
    
        cdc_acm_uart0 {
    
            compatible = "zephyr,cdc-acm-uart";
    
        };
    
    };

  • Already from smp server- usb.overlay file copied in bluetooth hci-usb application and build the file using using usb.overlay file.

    / {
        chosen {
            zephyr,uart-mcumgr = &cdc_acm_uart0;
        };
    };

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

  • Could you try adding this line in the chosen node as well? For the main application. The cdc_acm_uart0 can be chosen for both uart-mcumgr and console.

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

    If that doesn't help, please let me see your prj.conf and build/zephyr/.config files

  •  I am not able to show another bluetooth controller in bluetoothctl after modifying it as you told.

    prj.conf file is shown below

    CONFIG_STDOUT_CONSOLE=y
    CONFIG_GPIO=y
    CONFIG_SERIAL=y
    CONFIG_UART_INTERRUPT_DRIVEN=y
    CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n

    CONFIG_BT=y
    CONFIG_BT_HCI_RAW=y

    CONFIG_USB_DEVICE_STACK=y
    CONFIG_USB_DEVICE_PID=0x000B
    CONFIG_USB_DEVICE_BLUETOOTH=y
    CONFIG_USB_DEVICE_BLUETOOTH_VS_H4=n

    # Workaround: Unable to allocate command buffer when using K_NO_WAIT since
    # Host number of completed commands does not follow normal flow control.
    CONFIG_BT_BUF_CMD_TX_COUNT=10

    # 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.
    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

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

    # Support for taskstat command
    CONFIG_MCUMGR_GRP_OS_TASKSTAT=y

    # Enable statistics and statistic names.
    CONFIG_STATS=y
    CONFIG_STATS_NAMES=y

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

    # Enable logging
    CONFIG_LOG=y
    CONFIG_MCUBOOT_UTIL_LOG_LEVEL_WRN=y

    # Disable debug logging
    CONFIG_LOG_MAX_LEVEL=3

    usbchanged.overlay

    /*
     * Copyright (c) 2021 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: Apache-2.0
     */



    / {
        chosen {
            zephyr,uart-mcumgr = &cdc_acm_uart0;
        };
    };

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

    / {

        chosen {

            zephyr,console = &cdc_acm_uart0;

            };

    };

    Build command used-

    test@MUTSL03530:~/ncs/v2.4.2/zephyr/samples/bluetooth/hci_usb1$ west build -b nrf5340dk_nrf5340_cpuapp --pristine -- -DOVERLAY_CONFIG=overlay-cdc.conf -DDTC_OVERLAY_FILE=usbchanged.overlay -DCONFIG_MCUBOOT_SIGNATURE_KEY_FILE=\"/home/test/ncs/v2.4.2/bootloader/mcuboot/root-rsa-2048.pem\"

Related