UART Configuration Custom Board nRF5340

Hello!

I have a custom board that I am trying to set up but I'm not entirely sure what to do.

In my board, I have an nRF5340 SoC, that has 2 interfaced with the external world: a micro USB port (connections are done exactly like the DK), and a UART with RX in PIN 1.00, and TX in PIN 1.01.

I want to use the micro USB to print something to a console as a "debugging" tool, and the more classic UART to print some different stuff.

What are the devicetree and defconfig configurations for this kind of usecase? I think I should set two different UART interface in the dts (&uart0 and &uart1?), but how do I tell one UART to go trough USB? In the DK dts I can see

chosen {
		zephyr,console = &uart0;
		zephyr,shell-uart = &uart0;
		zephyr,uart-mcumgr = &uart0;
		zephyr,bt-mon-uart = &uart0;
		zephyr,bt-c2h-uart = &uart0;
		zephyr,bt-hci-rpmsg-ipc = &ipc0;
	};

but I can't figure out what exactly I need to use in my custom board.

Any help would be appreciated

Parents
  • Hello,

    I suggest to take a look at the applications\matter_weather_station project for the Thingy:53.

    In specific you can find that there is an overlay file that will override from default uart to usb cdc uart for logging/shell:

    Default using uart (\boards\arm\thingy53_nrf5340)

            zephyr,console = &uart0;
            zephyr,shell-uart = &uart0;

    To usb cdc uart (\matter_weather_station\configuration\thingy53_nrf5340_cpuappapp.overlay)

            zephyr,console = &cdc_acm_uart0;
            zephyr,shell-uart = &cdc_acm_uart0;

    In addition I can find in the prj.conf the following:

    # Configure UART logging and shell
    CONFIG_LOG=y
    CONFIG_LOG_MODE_DEFERRED=y
    CONFIG_LOG_BACKEND_UART=n
    CONFIG_LOG_PRINTK=y
    CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=1024
    CONFIG_LOG_PROCESS_THREAD_STARTUP_DELAY_MS=4000
    CONFIG_LOG_BUFFER_SIZE=8192
    CONFIG_LOG_FUNC_NAME_PREFIX_DBG=n
    CONFIG_MATTER_LOG_LEVEL_DBG=y
    CONFIG_SHELL=y
    CONFIG_SHELL_LOG_BACKEND=y

    # Enable USB CDC ACM
    CONFIG_USB_DEVICE_STACK=y
    CONFIG_USB_DEVICE_REMOTE_WAKEUP=n
    CONFIG_USB_DEVICE_PRODUCT="Thingy:53 Matter Weather"
    CONFIG_USB_DEVICE_VID=0x1915
    CONFIG_USB_DEVICE_PID=0x530D
    CONFIG_USB_CDC_ACM=y
    CONFIG_USB_CDC_ACM_LOG_LEVEL_ERR=y
    CONFIG_USB_DEVICE_LOG_LEVEL_ERR=y
    CONFIG_UART_LINE_CTRL=y
    CONFIG_SHELL_BACKEND_SERIAL_INIT_PRIORITY=51
    CONFIG_SHELL_BACKEND_SERIAL_CHECK_DTR=y

    Best regards,
    Kenneth

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

    Hi Kenneth,

    I assume that I need to define a node label as above (I found this also here https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/subsys/usb/console), but when compiling I have a parse error having the zephyr_udc0 undefined.

    How can I solve this behaviour?

Reply Children
Related