uart_tx api crashing issue

Hi, All

I try to modify the central uart example - mainly focus on uart function instead of BLE, I try to send a message back to uart use uart_tx() api instead of printk(), it seems working fine like this

 
    struct uart_data_t *buf = k_fifo_get(&fifo_uart_rx_data, K_FOREVER);
    
    if (uart_tx(uart, buf->data, buf->len, SYS_FOREVER_MS)) {
		LOG_WRN("Failed to send data over UART");
	}
	else {
		LOG_WRN("send data back to UART");
	}

But when I try to replace the uart_tx function with some message like below, and it keep crashing - reset

   
	uart_tx(uart, "UartDataRxed\n", 13, SYS_FOREVER_MS);
I wonder what I have done wrong with above, here is the RTT log message:
0> [00:00:00.025,787] <err> os: ***** BUS FAULT *****
00> [00:00:00.025,787] <err> os: Precise data bus error
00> [00:00:00.025,787] <err> os: BFAR Address: 0x2528206c[0m
00> [00:00:00.025,817] <err> os: r0/a1: 0x2528206c r1/a2: 0x00027b50 r2/a3: 0x20002300
00> [00:00:00.025,817] <err> os: r3/a4: 0x00000040 r12/ip: 0x00000000 r14/lr: 0x0001e533
00> [00:00:00.025,817] <err> os: xpsr: 0x21000012
00> [00:00:00.025,817] <err> os: Faulting instruction address (r15/pc): 0x0001e820
00> [00:00:00.025,848] <err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
00> [00:00:00.025,848] <err> os: Fault during interrupt handling
Thanks for your help!
Ping
Parents
  • Hi, Andreas

    I didn't change anything except that line. I use nrf Connect SDK v1.9.1, and VS Code.

    Regards!

    Ping

  • Hi,

    I am not able to reproduce the error using a nRF52833DK in NCS v1.9.1 in VS Code and changing only 

        struct uart_data_t *buf = k_fifo_get(&fifo_uart_rx_data, K_FOREVER);
        
        if (uart_tx(uart, buf->data, buf->len, SYS_FOREVER_MS)) {
    		LOG_WRN("Failed to send data over UART");
    	}

    to

        struct uart_data_t *buf = k_fifo_get(&fifo_uart_rx_data, K_FOREVER);
        
        if (uart_tx(uart, "UartDataRxed\n", 13, SYS_FOREVER_MS)) {
    		LOG_WRN("Failed to send data over UART");
    	}


    I was able to force a bus fault by adding " uart_tx(uart, "UartDataRxed\n", 13, SYS_FOREVER_MS);" in the case UART_TX_DONE: before any checks are done, which results in a thread interruption fault with the same zephyr error you got caused by. This error and crash is triggered by ,C:/Nordic/SDKs/ncs/v1.9.1/zephyr/kernel/thread.c:819(r15/pc) and C:/Nordic/SDKs/ncs/v1.9.1/zephyr/include/spinlock.h:129 (r14/lr), but I can't guarantee that this interruption error is what  caused the issue for you. 

    If you can add the central_uart project with the modifications and add it here, I can take a closer look if I either have misunderstood where you've done the change or if any other changes has happened by a mistake.

    Kind regards,
    Andreas

Reply
  • Hi,

    I am not able to reproduce the error using a nRF52833DK in NCS v1.9.1 in VS Code and changing only 

        struct uart_data_t *buf = k_fifo_get(&fifo_uart_rx_data, K_FOREVER);
        
        if (uart_tx(uart, buf->data, buf->len, SYS_FOREVER_MS)) {
    		LOG_WRN("Failed to send data over UART");
    	}

    to

        struct uart_data_t *buf = k_fifo_get(&fifo_uart_rx_data, K_FOREVER);
        
        if (uart_tx(uart, "UartDataRxed\n", 13, SYS_FOREVER_MS)) {
    		LOG_WRN("Failed to send data over UART");
    	}


    I was able to force a bus fault by adding " uart_tx(uart, "UartDataRxed\n", 13, SYS_FOREVER_MS);" in the case UART_TX_DONE: before any checks are done, which results in a thread interruption fault with the same zephyr error you got caused by. This error and crash is triggered by ,C:/Nordic/SDKs/ncs/v1.9.1/zephyr/kernel/thread.c:819(r15/pc) and C:/Nordic/SDKs/ncs/v1.9.1/zephyr/include/spinlock.h:129 (r14/lr), but I can't guarantee that this interruption error is what  caused the issue for you. 

    If you can add the central_uart project with the modifications and add it here, I can take a closer look if I either have misunderstood where you've done the change or if any other changes has happened by a mistake.

    Kind regards,
    Andreas

Children
No Data
Related