LOG_ (over RTT) and SHELL (over UART2)

I am having issues separating the LOG_ and Shell on the nrf5340. (I am currently using the DevBoard)
I have created an overlay file to move the shell on UART2, which is connected via an FTDI adapter to my PC.
/ {

    chosen {
      zephyr,shell-uart = &uart2;
    };
  };
  
  &pinctrl {
    uart2_default: uart2_default {
        group1 {
            psels = <NRF_PSEL(UART_TX, 1, 11)>;
        };
        group2 {
            psels = <NRF_PSEL(UART_RX, 1, 12)>;
            bias-pull-up;
        };
    };
    uart2_sleep: uart2_sleep {
        group1 {
            psels = <NRF_PSEL(UART_TX, 1, 11)>,
                    <NRF_PSEL(UART_RX, 1, 12)>;
            low-power-enable;
        };
    };
};

&uart2 {
    compatible = "nordic,nrf-uarte";
    status = "okay";
    current-speed = <115200>;
    pinctrl-0 = <&uart2_default>;
	pinctrl-1 = <&uart2_sleep>;
	pinctrl-names = "default", "sleep";
  };
Modified the prj.conf
# RTT LOGGING
CONFIG_LOG=y
CONFIG_LOG_BACKEND_RTT=y
CONFIG_LOG_BACKEND_UART=n
CONFIG_LOG_MODE_DEFERRED=y
Added the Shell

# SHELL
CONFIG_SHELL=y
CONFIG_SHELL_MINIMAL=y
CONFIG_SHELL_BACKEND_RTT=n
The result is as follows





so basically the LOGs are output in both backends. Any thoughts?
Parents
  • Replying to myself as I have spent some time looking for the issue. I was missing

    ##  Disables log output to all shell backends
    CONFIG_SHELL_LOG_BACKEND=n


    CONFIG_SHELL_LOG_BACKEND

    Once that is added to the project configuration the LOG_ is just in the log console and the shell is being output via RTT.

    main.c

    #include <zephyr/kernel.h>
    #include <zephyr/logging/log.h>
    
    LOG_MODULE_REGISTER(log_rtt, LOG_LEVEL_INF);
    
    #define STACKSIZE 1024
    
    #define LOG_THREAD_PRIORITY 7
    
    void log_thread(void)
    {
            uint16_t i = 0;
    
    	while (1) {
    		/* Display a simple string "Hello x" */
    		LOG_INF("Hello %d\n", i++);
    		/* Make the thread yield */
            k_yield();
    		/* Put the thread to sleep */
    		k_msleep(1000);
    	}
    }
    
    K_THREAD_DEFINE(log_thread_id, STACKSIZE, log_thread, NULL, NULL, NULL,
    		LOG_THREAD_PRIORITY, 0, 0);

    prj.conf

    # Logging
    CONFIG_LOG=y
    CONFIG_LOG_BACKEND_UART=n
    CONFIG_LOG_BACKEND_RTT=y
    CONFIG_LOG_MODE_DEFERRED=y
    
    # Realtime
    CONFIG_POSIX_CLOCK=y
    
    # RTT Shell subsys
    CONFIG_SHELL=y
    CONFIG_SHELL_MINIMAL=y
    ## We will not use USART
    CONFIG_SHELL_BACKEND_SERIAL=y
    ##  Disables log output to all shell backends
    CONFIG_SHELL_LOG_BACKEND=n
    ## We will not use USART
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_SHELL_BACKEND_RTT=n

Reply
  • Replying to myself as I have spent some time looking for the issue. I was missing

    ##  Disables log output to all shell backends
    CONFIG_SHELL_LOG_BACKEND=n


    CONFIG_SHELL_LOG_BACKEND

    Once that is added to the project configuration the LOG_ is just in the log console and the shell is being output via RTT.

    main.c

    #include <zephyr/kernel.h>
    #include <zephyr/logging/log.h>
    
    LOG_MODULE_REGISTER(log_rtt, LOG_LEVEL_INF);
    
    #define STACKSIZE 1024
    
    #define LOG_THREAD_PRIORITY 7
    
    void log_thread(void)
    {
            uint16_t i = 0;
    
    	while (1) {
    		/* Display a simple string "Hello x" */
    		LOG_INF("Hello %d\n", i++);
    		/* Make the thread yield */
            k_yield();
    		/* Put the thread to sleep */
    		k_msleep(1000);
    	}
    }
    
    K_THREAD_DEFINE(log_thread_id, STACKSIZE, log_thread, NULL, NULL, NULL,
    		LOG_THREAD_PRIORITY, 0, 0);

    prj.conf

    # Logging
    CONFIG_LOG=y
    CONFIG_LOG_BACKEND_UART=n
    CONFIG_LOG_BACKEND_RTT=y
    CONFIG_LOG_MODE_DEFERRED=y
    
    # Realtime
    CONFIG_POSIX_CLOCK=y
    
    # RTT Shell subsys
    CONFIG_SHELL=y
    CONFIG_SHELL_MINIMAL=y
    ## We will not use USART
    CONFIG_SHELL_BACKEND_SERIAL=y
    ##  Disables log output to all shell backends
    CONFIG_SHELL_LOG_BACKEND=n
    ## We will not use USART
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_SHELL_BACKEND_RTT=n

Children
Related