Error in configuring UART pins in SDK2.3.0

Hi there,

I have recently switched my complete "Bluetooth Peripheral" Project from the SDK version 1.9.1 to 2.3.0 

I have been facing some of the pin control issue for the UART, as I have observe you have change the way the UART is working and added the pinctrl functionality.

Previously on the 1.9.1, I was using the UART pins shown under.

&uart0 {
	rts-pin = < 0xff >;
	cts-pin = < 0xff >;
};

&uart2 {
	current-speed = <9600>;
	status = "okay";
	tx-pin = <4>;  
	rx-pin = <5>;
	rts-pin = < 0xff >;
	cts-pin = < 0xff >;
	rx-pull-up;
};

I am using this UART2 for communicating with the BMS(Battery management system), but now in the new SDK when using the same pin configuration, I am getting the error 

"d:\v2.3.0\zephyr\include\zephyr\toolchain\gcc.h:78:36: error: static assertion failed: "/soc/peripheral@50000000/uart@b000 defined without required pin configuration""

"d:\v2.3.0\zephyr\include\zephyr\toolchain\gcc.h:78:36: error: static assertion failed: "/soc/peripheral@50000000/uart@b000 has legacy *-pin properties defined although PINCTRL is enabled"

I am using SDK 2.3.0, and my board is the Nordic Thingy53.

Could you please advise on how to resolve this error and properly configure the UART on my SoC?

Regards 
Sachin

  • Hi Sachin,

    If pinctrl is enabled (as it is in your case) then you must define the UART pins under the &pinctrl node of the devicetree. The pins defined directly in the uart devices are not used and are the cause of your second error.

    Take a look at the board for Thingy53 (ncs\v2.3.0\zephyr\boards\arm\thingy53_nrf5340). Specifically, look at thingy53_nrf5340_common-pinctrl.dtsi which defines the pins for many of the devices on Thingy53. This dtsi file is included by thingy53_nrf5340_common.dts. Also note how the pinctrl nodes are tied back into the &uart node.

    Good luck.

    /Ross

  • Hi, 
    Thanks for answering 

    Can you please right me up the code, as I don't know how to use pinctrl in code.

  • I have figure out something and change the code accordingly, look at the changes that I have done and compare it with the old UART config and tell me if this is the correct way?

    &uart2 {
    	current-speed = <9600>;
    	status = "okay";	
    	rx-pull-up;
    	pinctrl-0 = <&uart2_default>;
    	pinctrl-1 = <&uart2_sleep>;
    	pinctrl-names = "default", "sleep";
    };
    &pinctrl {
    	uart2_default: uart2_default {
    		group1 {
    			psels = <NRF_PSEL(UART_TX, 0, 4)>,
    				<NRF_PSEL(UART_RX, 0, 5)>;
    		};
    	};
    
    	uart2_sleep: uart2_sleep {
    		group1 {
    			psels = <NRF_PSEL(UART_TX, 0, 4)>,
    				<NRF_PSEL(UART_RX, 0, 5)>;
    			low-power-enable;
    		};
    	};
    };

  • That mostly looks okay. However, the rx-pull-up is related to the rx-pin and should also be done using pinctrl. You can see this mentioned in the bindings file ncs\v2.3.0\zephyr\dts\bindings\serial\nordic,nrf-uart-common.yaml which marks it as deprecated.

    &uart2 {
        current-speed = <9600>;
        status = "okay";    
        pinctrl-0 = <&uart2_default>;
        pinctrl-1 = <&uart2_sleep>;
        pinctrl-names = "default", "sleep";
    };
    &pinctrl {
        uart2_default: uart2_default {
            group1 {
                psels = <NRF_PSEL(UART_TX, 0, 4)>;
            };
            group2 {
                psels = <NRF_PSEL(UART_RX, 0, 5)>;
                bias-pull-up;
            };
        };

        uart2_sleep: uart2_sleep {
            group1 {
                psels = <NRF_PSEL(UART_TX, 0, 4)>,
                    <NRF_PSEL(UART_RX, 0, 5)>;
                low-power-enable;
            };
        };
    };

  • Wow great,
    I replace the old code with the code you provided.

    I am using 

    static const struct device *bms_uart;

    bms_uart = device_get_binding("UART_2");

    if (bms_uart == NULL) {
        printk("Failed to get UART2 binding\n");    
        return;        
      }

    In order to bind the device, but this is not working and always printing failed.

Related