No output to UART console when CONFIG_BT=y

There is no output to UART console when I set CONFIG_BT=y in prj.conf

peripheral_lbs sample project in ncs V2.0.2 can't printk anything.  

  • Hello Hieu, 

    Thanks again for your quick response.  Just a follow up question.  Would Nordic fix this hard-coded bug which broke the overlay function or it would require Zephyr Project to fix it ? 

    Thanks, 

    JC

  • Hi JC,

    I think there is just a misunderstanding here that makes you see it as a bug. It is not really one.

    Device Tree specification, which the .dts and .overlay files are about, describes the hardware to the toolchain.
    Kconfig is to configure the software libraries and features used by your project.

    With that in mind, let's look at it again. We disabled UART in the hardware description through the overlay file.
    However, UART Console remains enabled in the Kconfig through default settings in nrf5340dk_nrf5340_cpuapp_defconfig.

    When the software library is built, the feature found that its necessary backend reference is not available. Of course the build process would complain, right?

    As an experiment, I keep UART0 disabled, and turned UART1 on instead and provided it to the UART Console feature. It works!

    / {
    
    	chosen {
    		zephyr,console = &uart1;
    		zephyr,shell-uart = &uart1;
    		zephyr,uart-mcumgr = &uart1;
    		zephyr,bt-mon-uart = &uart1;
    		zephyr,bt-c2h-uart = &uart1;
    	};
    };
    
    &uart0 {
    	// status = "okay";
        status = "disabled";
    	current-speed = <115200>;
    	pinctrl-0 = <&uart0_default>;
    	pinctrl-1 = <&uart0_sleep>;
    	pinctrl-names = "default", "sleep";
    };
    
    &uart1 {
    	status = "okay";
    	compatible = "nordic,nrf-uarte";
    	current-speed = <115200>;
    	
    	// Map UART1 to UART0 default pins
    	pinctrl-0 = <&uart0_default>;
    	pinctrl-1 = <&uart0_sleep>;
    	pinctrl-names = "default", "sleep";
    };

    CONFIG_UART_CONSOLE=y

    I hope this clears thing up for you. I do agree that a lot of these setups are not very intuitive and obvious though. For example, I wouldn't notice CONFIG_UART_CONSOLE is enabled by nrf5340dk_nrf5340_cpuapp_defconfig if I wasn't using the VS Code Extension and see the GUI tooltips that pointed it out.

    If you are interested in getting a better grasp at these things, I recommend you to take a look at this course we created to help people getting started with the nRF Connect SDK: https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/

    Best regards,
    Hieu

  • Hello Zephyr Expert, 

    NCS V2.1.0 Zephyr peripheral_lbs example hard-coded UART0 console to 

    rts: <&gpio0 19>

    tx: <&gpio0 20>

    cts: <&gpio0 21>

    rx: <&gpio0 22>

    so it Can't be overwritten by overlay file nrf5340dk_nrf5340_cuppapp.overlay

    and it Can't be changed by editing nrf5340_cupapp_commmon.dts

    and Can't be changed by editing nrf5340_cupapp_commmon-pinctrl.dtsi

    and Can't be changed by editing nrf5340_cpuapp_peripherals.dtsi

    I need to change the UART console tx pin to P1.1 and rx pin to P0.29

    Any suggestion ??

    Thanks,

    JC

     

  • Now I can change the UART console tx pin to P1.1 and rx pin to P0.29 by editing the nrf5340_cupapp_commmon-pinctrl.dtsi.  However, the console stop printing during boot up process. This is the only output from the console

    *** Booting Zephyr OS build v3.1.99-ncs1 ***

    then it stopped printing.  The debugger still running and stepping through printk(), but nothing printing to console.  Something modified the pin configuration back to the original pin configuration ???  Digging deeper into this problem

  • Hi JC,

    Glad to know you are able to change the pin now. I was a little worried that I would not be able to verify the solution I give you, as I don't have an external UART board right now.

    The line of log you observed is printed by the bootloader. It has its own firmware and pin configuration. Therefore it is not affected by the change you made and still print a log out.

    If you wish to turn off bootloader logging, you can refer to this DevZone Q&A:  MCUboot - disabling uart console print log 

    Once again, I must remind you that changing .dtsi, .dts, and .overlay file is not the correct way to configure your custom board. I strongly advise you to create a .dts file for your own board, referencing the nrf53_cpuap_***.dts* files.

    Best regards,

    Hieu

Related