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

  • Hello sachin,

    As   mentioned it is a major change from NCS 1.9.x to 2.x.x, see the Migration guide. Introduced pinctrl which is a standard API for configuring the peripheral pins. You can go through this tutorial from Nordic for understanding the UART communication with NCS v2.x..x. But I suspect the error you are seeing now is not because of this. Could you run your code with a debugger and take look where it is crashing.

    I recommend you to try configuring UART before running the whole project and see whether it's working fine or not? Please expect a delay after this response since it is a holiday week here in Norway.

    Kind Regards,

    Abhijith

  • Hi  ,  

       thanks for giving me this tutorial link.

    I have gone as per the tutorial

    set all these values to y 

    CONFIG_UART_ASYNC_API=y
    CONFIG_NRFX_UARTE0=y
    CONFIG_SERIAL=y
    CONFIG_UART_NRFX=y

    added the header file, and at last added this line 
    bms_uart = DEVICE_DT_GET(DT_NODELABEL(uart2));
      if (!device_is_ready(bms_uart)) {
        printk("Failed to get UART2 binding\n");
    }
    This is my .overlay
    &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;
            };
        };
    };

    But it is showing this error 
    *** Booting Zephyr OS build v3.2.99-ncs2 ***
    02> [00:00:17.387,420] <inf> fs_nvs: nvs_mount: 8 Sectors of 4096 bytes
    02> [00:00:17.388,092] <inf> fs_nvs: nvs_mount: alloc wra: 0, fd0
    02> [00:00:17.388,702] <inf> fs_nvs: nvs_mount: data wra: 0, 1a
    02> Bluetooth initialized as slave
    02> [00:00:17.407,897] <err> os: usage_fault: ***** USAGE FAULT *****
    02> [00:00:17.408,508] <err> os: usage_fault:   Illegal use of the EPSR
    02> [00:00:17.409,118] <err> os: esf_dump: r0/a1:  0x0004ac2c  r1/a2:  0x20007294  r2/a3:  0x0000000d
    02> [00:00:17.409,973] <err> os: esf_dump: r3/a4:  0x000003e8 r12/ip:  0x00000000 r14/lr:  0x0001aabf
    02> [00:00:17.410,797] <err> os: esf_dump:  xpsr:  0x00000000
    02> [00:00:17.411,407] <err> os: esf_dump: s[ 0]:  0x00000000  s[ 1]:  0x00000000  s[ 2]:  0x00000000  s[ 3]:  0x00000000
    02> [00:00:17.412,414] <err> os: esf_dump: s[ 4]:  0x00000000  s[ 5]:  0x00000000  s[ 6]:  0x00000000  s[ 7]:  0x00000000
    02> [00:00:17.413,421] <err> os: esf_dump: s[ 8]:  0x00000000  s[ 9]:  0x00000000  s[10]:  0x00000000  s[11]:  0x00000000
    02> [00:00:17.414,428] <err> os: esf_dump: s[12]:  0x00000000  s[13]:  0x00000000  s[14]:  0x00000000  s[15]:  0x00000000
    02> [00:00:17.415,435] <err> os: esf_dump: fpscr:  0x00000000
    02> [00:00:17.416,015] <err> os: esf_dump: Faulting instruction address (r15/pc): 0x00000000
    02> [00:00:17.416,717] <err> os: z_fatal_error: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
    02> [00:00:17.417,480] <err> os: z_fatal_error: Current thread: 0x20004040 (unknown)
    02> [00:00:17.423,217] <err> fatal_error: k_sys_fatal_error_handler: Resetting system[0m
  • Hello,

    Your overlay file looks good to me. As I said before the error doesn't look like a UART issue. Did you run your code in a debugger and find out where the Program is crashing? I found some similar bug report in zephyr forum, see this.

    Kind Regards,

    Abhijith

  • Thanks  

    I have gone through the link you provided and get into another link in that. 
    this is what I have  added in my build  -DCONFIG_NO_OPTIMIZATIONS=y 

    This gives me more detail about the error. The error is due to stack overflow

    *** Booting Zephyr OS build v3.2.99-ncs2 ***
    [00:00:00.078,765] <inf> fs_nvs: nvs_mount: 8 Sectors of 4096 bytes
    [00:00:00.079,956] <inf> fs_nvs: nvs_mount: alloc wra: 0, fe8
    [00:00:00.081,054] <inf> fs_nvs: nvs_mount: data wra: 0, 0
    [00:00:21.955,017] <err> os: usage_fault: ***** USAGE FAULT *****
    [00:00:21.956,115] <err> os: usage_fault:   Stack overflow (context area not valid)
    [00:00:21.957,366] <err> os: esf_dump: r0/a1:  0x200152f0  r1/a2:  0x0008f7d1  r2/a3:  0x00000000
    [00:00:21.958,923] <err> os: esf_dump: r3/a4:  0x200043a0 r12/ip:  0x00000000 r14/lr:  0x00000000
    [00:00:21.960,418] <err> os: esf_dump:  xpsr:  0x00068800
    [00:00:21.961,578] <err> os: esf_dump: s[ 0]:  0x00000000  s[ 1]:  0x00000000  s[ 2]:  0x00000000  s[ 3]:  0x00000000
    [00:00:21.963,439] <err> os: esf_dump: s[ 4]:  0x00000000  s[ 5]:  0x00000000  s[ 6]:  0x00000000  s[ 7]:  0x00000000
    [00:00:21.965,301] <err> os: esf_dump: s[ 8]:  0x00000000  s[ 9]:  0x00000000  s[10]:  0x00000000  s[11]:  0x00000000
    [00:00:21.967,163] <err> os: esf_dump: s[12]:  0x00000000  s[13]:  0x00000000  s[14]:  0x00000000  s[15]:  0x00000000
    [00:00:21.968,994] <err> os: esf_dump: fpscr:  0x00000000
    [00:00:21.970,092] <err> os: esf_dump: Faulting instruction address (r15/pc): 0x20015308
    [00:00:21.971,466] <err> os: z_fatal_error: >>> ZEPHYR FATAL ERROR 2: Stack overflow on CPU 0
    [00:00:21.972,869] <err> os: z_fatal_error: Current thread: 0x200049a8 (BT TX)
    [00:00:21.994,140] <err> fatal_error: k_sys_fatal_error_handler: Resetting system

    I have changed the number of CONFIG to resolve this error especially CONFIG_BT_RX_STACK_SIZE=32768

    Here is what my prj.conf is having the stack sizes
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=16384
    CONFIG_MAIN_STACK_SIZE=16384	
    CONFIG_BT_L2CAP_TX_MTU=700
    CONFIG_BT_L2CAP_TX_BUF_COUNT=4
    CONFIG_BT_L2CAP_TX_FRAG_COUNT=3
    CONFIG_BT_BUF_ACL_TX_SIZE=550
    CONFIG_BT_BUF_ACL_RX_SIZE=550
    CONFIG_HEAP_MEM_POOL_SIZE=8192
    CONFIG_BT_RX_STACK_SIZE=32768 
     
    I have look into the code using debugger and the error is in the bt_enable(NULL); library
    The error is displaying when CPU moves in bt_init(); --> hci_init(); function.

    Please help me more to resolve this.   
    NOTE: As the stack problem is caused after adding the device pointer for UART2 that is why I am not creating another ticket for this problem.
  • Hello Sachin,

    I didn't get enough time to check this as I had some pending works due to the public holidays last week here in Norway. You can expect a response next week after Monday (since coming Monday is also a holiday).

    Thank you for understanding.

    Kind Regards,

    Abhijith 

Related