Best Practice for enabling RTT in the devicetree

I'm developing firmware for a custom board developed with the nRF5340. We opted to use RTT as our logging/shell output as opposed to UART thanks to pcb size limitations. I'm setting up a custom devicetree file and noticed these lines as I was copying the files over from the nrf5340dk DTS files:

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

I understand &uart0 is a reference to the uart node for the development kit. Since we aren't using any of the UART ports, my thought is to

1) delete &uart0 as a node from the devicetree and then

2) replace the references in this chosen block with references to the RTT peripheral

My problem is that I don't understand how to do (2)--there doesn't seem to be a way for me to create a node for the RTT peripheral in the device tree. Is there some other way I can instruct the software to use RTT for the console, the shell, and the other functions listed in this "chosen" block?

Thanks for your help!

Parents
  • You don't need to enable RTT through DTS. Simply set these in the prj.conf file:

    # Disable UART Console and enable the RTT console
    CONFIG_UART_CONSOLE=n
    CONFIG_RTT_CONSOLE=y
    CONFIG_USE_SEGGER_RTT=y

    Best regards,

    Simon

  • Thank you for your response! That is what we're currently doing, but it doesn't feel very clean? If I simply remove that chosen block I run into compilation errors. I can post the whole if helpful, but this line should suffice: 

    C:\ncs\v2.0.0\zephyr\include\zephyr\device.h:96:39: error: '__device_dts_ord_DT_CHOSEN_zephyr_console_ORD' undeclared (first use in this function)

    If I understand correctly, I think we need to list some devicetree node as "chosen" for the console, shell-uart, etc. If we list UART, we also have to assign pins to the UART, or else run into other compilation errors. We have some extra unconnected pins so I can do that but perhaps you can see why I'd prefer to set RTT as the chosen interface?

    Let me know if you can think of some way to do that, or another way to clean up this issue, else we'll stay the course. 

  • Hi,

    The issue arises when you try to reference &uart0 in the "chosen" part of the dts file as shown in your initial question. If you remove &uart0 section from the dts file, you would also need to remove any reference to this part in the "chosen" section of the dts file. In other words, you should simply remove all lines that reference &uart0 in the "chosen" section of the dts file.
    RTT is commonly enabled through configuration options in prj.conf file.

    Best regards,
    Dejan

Reply
  • Hi,

    The issue arises when you try to reference &uart0 in the "chosen" part of the dts file as shown in your initial question. If you remove &uart0 section from the dts file, you would also need to remove any reference to this part in the "chosen" section of the dts file. In other words, you should simply remove all lines that reference &uart0 in the "chosen" section of the dts file.
    RTT is commonly enabled through configuration options in prj.conf file.

    Best regards,
    Dejan

Children
Related