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

  • Hi,

     

    Could you scope the TXD pin (P1.01) and see if anything outputs on this pin?

    Note that this pin is not connected to the USB-UART bridge on the debugger side, so you have to manually connect your own USB-UART adapter to these two pins that you defined.

     

    Kind regards,

    Håkon

  • Because I'm pretty new to Zephyr, I thought of a way to verify the uart1 connection.

    In order to do this, I used an old project not based on Zephyr. It is based on the app_uart example from the SDK 16 library.
    The project uses a BG96 modem, so what I did is change the pins of the BG96 to the uart1. Now on the USB FTDI I can see the AT commands coming in (firmware tries to communicate with BG96), thus verifying that the hardware is connected correctly and that the NRF is able to communicate over it.

Related