This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to divert RTT logging to uart1 in Zephyr

I'm currently using Zephyr with Nordic Segger v5.50c.

Most of the code uses NRF_LOG, NRF_ERR statements which are printed to the Nordic Segger terminal.

I also configured the dts to use uart0, which is connected to a modem and is working fine.

I want to enable uart1 in the dts, and use it for RTT logging as well. For this I read:
https://docs.zephyrproject.org/latest/reference/logging/index.html

On the above they write about frontend and backend logging. But no reference to uart0 or uart1.
It looks like documentation how to write the code, but not how to configure the uart (might be Nordic documentation not Zephyr documentation)

I also found:
https://devzone.nordicsemi.com/f/nordic-q-a/73368/how-to-make-log_inf-and-log_err-print-over-uart0-in-nrf9160

But I don't understand chosen and the other parameters? Can it be this simple?

I also found:
https://devzone.nordicsemi.com/f/nordic-q-a/21189/how-to-enable-uart-or-rtt-logging-in-examples

But I don't see anywhere how to choose which uart to use? Is it uart0 by default?

I also noticed CONFIG_NRFX_UARTE0, but CONFIG_NRFX_UARTE1 does not exist? Maybe only uart0 is supported?
Do I have to reconfigure uart1 for the modem?

Parents Reply Children
  • In the overlay file the use of &gpio1 is not allowed, but it is allowed in the dts?

    Can you explain this?

    In the overlay:

    &uart1 {
      compatible = "nordic,nrf-uarte";
      status = "okay";
      current-speed = <115200>;
      tx-pin = <&gpio1 1 0>;
      rx-pin = <&gpio1 2 0>;
    };
    

    In the dts:

    &uart0 {
      compatible = "nordic,nrf-uarte";
      status = "okay";
      current-speed = <115200>;
      tx-pin = <44>;
      rx-pin = <30>;
    
      bg96 {
        compatible = "quectel,bg96";
        label = "BG96";
    
        reset-gpios = <&gpio1 14 0>;
        power-key-gpios = <&gpio1 15 0>;
        ring-indicator-gpios = <&gpio0 29 0>;
        dtr-gpios = <&gpio1 11 0>;
        enable-gpios = <&gpio0 27 0>;
      };
    };
    

  • Hi,

     

    ephimee said:
    In the overlay file the use of &gpio1 is not allowed, but it is allowed in the dts?

    The "tx-pin" and "rx-pin" members of the uartX device reflects how the hardware peripheral requires you to specify a GPIO, as shown here:

    https://infocenter.nordicsemi.com/topic/ps_nrf52840/uarte.html?cp=4_0_0_5_33_8_23#register.PSEL.TXD

     

    The "B" field here specifies the port for bus peripherals such as UARTE.

    P1.01 will then translate to "33" decimal in this register.

     

    Kind regards,

    Håkon

  • I've added this to the existing overlay:

    / {
    
      chosen {
        zephyr,console = &uart1;
      };
    };
    
    &uart1 {
      compatible = "nordic,nrf-uarte";
      status = "okay";
      current-speed = <115200>;
      tx-pin = <33>;
      rx-pin = <34>;
    };
    

    I added this to prj.conf:

    CONFIG_LOG_BACKEND_UART=y
    CONFIG_LOG_BACKEND_RTT=y
    CONFIG_NRFX_UARTE1=y
    CONFIG_NRFX_UARTE=y
    

    But I still don't get anything on uart1. Am I missing something?

    In the terminal window of Segger I still see all the logging.

  • Hi,

     

    ephimee said:
    In the terminal window of Segger I still see all the logging.

    This is because you still have RTT enabled.

     

    I added the same overlay to hello_world (no RTT enabled), and it prints on the tx-pin (P1.01) at my end:

     

    Kind regards,

    Håkon

  • I have the following changes in prj.conf:

    CONFIG_LOG_BACKEND_UART=y
    CONFIG_LOG_BACKEND_RTT=n
    CONFIG_USE_SEGGER_RTT=n
    CONFIG_NRFX_UARTE1=y
    CONFIG_NRFX_UARTE=y

    Now I don't get any logging in terminal, but also no logging on uart1.

Related