nRF9160 Using UART with printf without all the debugging outputs from Zephyr

How do I use printf to output my own messages, and read incoming data, from a UART port that is separate from Zephyr's debugging outputs? This UART line will be connected to another microcontroller for custom commands.

Here is what I have so far:

I want printf messages to be directed to the UART0 port for my program to talk to another device. I also want to be able to read the incoming messages.

Here is my code that works:

while (1) {
		char *s = console_getline();
		printf("Here's your string: %s\n", s);
	}

However, with the above code, I also get what appears to be debug outputs from Zephyr being put on my UART0 line. For example, when the device starts up, I get a bunch of debug messages, etc. Also, any printk() messages are also on UART0.

I thought I could get around this by modifying the kconfig settings (via kconfig or guiconfig). I tried disabling things like the kernal boot banner, logging, etc, but the settings are reset to the defaults after rebuilding the project.

  • My apologies for the late answer. Can you please add the following folder and file to your project folder: child_image/spm.conf

    In this file, add the following line: CONFIG_SERIAL=n

    Then, in your prj.conf add the following:

    CONFIG_UART_CONSOLE=n

    CONFIG_RTT_CONSOLE=y 

    Let me know how that works for you. 

    Kind regards,
    Øyvind

  • I tried your suggestion, but I'm still getting this output from UART0:

    *** Booting Zephyr OS build v2.7.99-ncs1-1  ***
    I: Starting bootloader
    I: Primary image: magic=bad, swap_type=0x0, copy_done=0x2, image_ok=0x2
    I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Boot source: none
    I: Swap type: none
    I: Bootloader chainload address offset: 0x10000
    I: Jumping to the first image slot
    +CEREG: 2,"4603","04EE0211",7
    +CSCON: 1
    +CEREG: 5,"4603","04EE0211",7,,,"11100000","11100000"
    %XTIME: "0A","2250011293210A","01"
    +CSCON: 0
    

    Would it be easier to use UART1 or UART2 for a custom communication channel instead? Is there any documentation on how to do this? (When I've tried to use UART1 or UART2 be modifying the dts or kconfig files, the program crashes).

Related