This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to make LOG_INF and LOG_ERR print over UART0 in nrf9160?

In the past I was able to get the Serial LTE Example application working over UART0 on the pins used in my custom board. I did so by adding a file called nrf9160dk_nrf9160.overlay with the lines 


&uart0 {
current-speed = <115200>;
status = "okay";
tx-pin = <1>;
rx-pin = <0>;
rts-pin = <0xFFFFFFFF>;
cts-pin = <0xFFFFFFFF>;
};

Now I have upgraded to ncs v1.5.0 and am trying to move the mqtt_simple sample onto my custom board.

In this case adding my .overlay does not show any communication over UART 0. When the project is built with this overlay and put on the DK there is nothing in LTE Link Monitor at all.

I figure as good a place as any to start is trying to get LOG_INF and LOG_ERR to print to UART0 on pins 1 and 0.

How can I do that?

Parents
  • Hello,

    you can check a couple of things in the zephyr.dts file, which is located in the ../build/zephyr folder of your application.

    1. The UART0 device should have the same properties as specified in the overlay file (see example below, which is from an application build without overlay for target nrf9160dk_nrf9160).

    uart0: uart@8000 {
    				compatible = "nordic,nrf-uarte";
    				reg = < 0x8000 0x1000 >;
    				interrupts = < 0x8 0x1 >;
    				status = "okay";
    				label = "UART_0";
    				current-speed = < 0x1c200 >;
    				tx-pin = < 0x1d >;
    				rx-pin = < 0x1c >;
    				rts-pin = < 0x1b >;
    				cts-pin = < 0x1a >;
    			};

    2. UART0 must be assigned to zephyr,console in the /chosen node.

    chosen {
    		zephyr,flash-controller = &flash_controller;
    		zephyr,entropy = &cryptocell_sw;
    		zephyr,console = &uart0;
    		zephyr,shell-uart = &uart0;
    		zephyr,uart-mcumgr = &uart0;
    		zephyr,flash = &flash0;
    		zephyr,sram = &sram0_ns;
    		zephyr,code-partition = &slot0_ns_partition;
    	};

    Let me know if you have any more questions!

    Regards,

    Markus

  • Hi Markus,

    Thank you for the quick reply.

    My zephyr.dts checks out exactly as you show given the changes I wanted to see. 

    uart0: uart@8000 {
    compatible = "nordic,nrf-uarte";
    reg = < 0x8000 0x1000 >;
    interrupts = < 0x8 0x1 >;
    status = "okay";
    label = "UART_0";
    current-speed = < 0x1c200 >;
    tx-pin = < 0x1 >;
    rx-pin = < 0x0 >;
    rts-pin = < 0xffffffff >;
    cts-pin = < 0xffffffff >;


    chosen {
    zephyr,flash-controller = &flash_controller;
    zephyr,entropy = &cryptocell_sw;
    zephyr,console = &uart0;
    zephyr,shell-uart = &uart0;
    zephyr,uart-mcumgr = &uart0;
    zephyr,flash = &flash0;
    zephyr,sram = &sram0_ns;
    zephyr,code-partition = &slot0_ns_partition;
    };


    It was already like this, but I did a fresh build anyway. No change in behavior. Nothing on UART0, not even the boot messages if I reset the chip.

    Let me clarify how I do the overlays in case something has changed since this method was given to me:

    1) In the mqtt_simple project directory I placed a new file called nrf9160dk_nrf9160ns.overlay (note the "ns")

    &uart1 {
    status = "disabled";
    };

    &uart0 {
    current-speed = <115200>;
    status = "okay";
    tx-pin = <1>;
    rx-pin = <0>;
    rts-pin = <0xFFFFFFFF>;
    cts-pin = <0xFFFFFFFF>;
    };

    2) In the SPM directory I added nrf9160dk_nrf9160.overlay (note the lack of "ns")

    /* Needed to get NRF_PWMn defined. */
    &pwm1 {
    status = "okay";
    };

    &pwm2 {
    status = "okay";
    };

    &pwm3 {
    status = "okay";
    };

    &uart0 {
    current-speed = <115200>;
    status = "okay";
    tx-pin = <1>;
    rx-pin = <0>;
    rts-pin = <0xFFFFFFFF>;
    cts-pin = <0xFFFFFFFF>;
    };

    The PWM stuff was already there.

    Adding these lines in ncs V1.3.1 allowed me to run the at_client or the serial_lte_modem application on my custom board. I could issue AT commands over UART0 from my external mcu, and see the responses. I would see the bootup messages over UART0 when I reset the chip.

    I use Segger Embedded Studio. When I "Open NRF SDK project..." I select nrf9160dk_nrf9160ns as the Board Name.

    Also, I just tried this method on the ncs/v1.5.0/nrf/samples/nrf9160/at_client and it did not work.

    It works on the ncs v1.3.1 and does not work on ncs v1.5.0


Reply
  • Hi Markus,

    Thank you for the quick reply.

    My zephyr.dts checks out exactly as you show given the changes I wanted to see. 

    uart0: uart@8000 {
    compatible = "nordic,nrf-uarte";
    reg = < 0x8000 0x1000 >;
    interrupts = < 0x8 0x1 >;
    status = "okay";
    label = "UART_0";
    current-speed = < 0x1c200 >;
    tx-pin = < 0x1 >;
    rx-pin = < 0x0 >;
    rts-pin = < 0xffffffff >;
    cts-pin = < 0xffffffff >;


    chosen {
    zephyr,flash-controller = &flash_controller;
    zephyr,entropy = &cryptocell_sw;
    zephyr,console = &uart0;
    zephyr,shell-uart = &uart0;
    zephyr,uart-mcumgr = &uart0;
    zephyr,flash = &flash0;
    zephyr,sram = &sram0_ns;
    zephyr,code-partition = &slot0_ns_partition;
    };


    It was already like this, but I did a fresh build anyway. No change in behavior. Nothing on UART0, not even the boot messages if I reset the chip.

    Let me clarify how I do the overlays in case something has changed since this method was given to me:

    1) In the mqtt_simple project directory I placed a new file called nrf9160dk_nrf9160ns.overlay (note the "ns")

    &uart1 {
    status = "disabled";
    };

    &uart0 {
    current-speed = <115200>;
    status = "okay";
    tx-pin = <1>;
    rx-pin = <0>;
    rts-pin = <0xFFFFFFFF>;
    cts-pin = <0xFFFFFFFF>;
    };

    2) In the SPM directory I added nrf9160dk_nrf9160.overlay (note the lack of "ns")

    /* Needed to get NRF_PWMn defined. */
    &pwm1 {
    status = "okay";
    };

    &pwm2 {
    status = "okay";
    };

    &pwm3 {
    status = "okay";
    };

    &uart0 {
    current-speed = <115200>;
    status = "okay";
    tx-pin = <1>;
    rx-pin = <0>;
    rts-pin = <0xFFFFFFFF>;
    cts-pin = <0xFFFFFFFF>;
    };

    The PWM stuff was already there.

    Adding these lines in ncs V1.3.1 allowed me to run the at_client or the serial_lte_modem application on my custom board. I could issue AT commands over UART0 from my external mcu, and see the responses. I would see the bootup messages over UART0 when I reset the chip.

    I use Segger Embedded Studio. When I "Open NRF SDK project..." I select nrf9160dk_nrf9160ns as the Board Name.

    Also, I just tried this method on the ncs/v1.5.0/nrf/samples/nrf9160/at_client and it did not work.

    It works on the ncs v1.3.1 and does not work on ncs v1.5.0


Children
No Data
Related