BUS fault/kerel panic on NUS

Hello Nordic team,

Our team deveopment a BLE NUS project, we use nrf5340 as BLE peripheral and nrf52840 dongle as BLE central. (NCS v1.8.0)

We use nrf52840 dongle transfer CMD data to nrf5340 by NUS.

If transfer data continously, it will make a fatal issue on nrf52840 dongle sometimes.

Error message as below

00> [00:01:33.570,251] <err> os: ***** BUS FAULT *****
00> [00:01:33.570,251] <err> os:   Precise data bus error
00> [00:01:33.570,251] <err> os:   BFAR Address: 0x28003c
00> [00:01:33.570,281] <err> os: r0/a1:  0x0028003c  r1/a2:  0x200084a4  r2/a3:  0x200021d8
00> [00:01:33.570,281] <err> os: r3/a4:  0x00000040 r12/ip:  0x00011865 r14/lr:  0x00025131
00> [00:01:33.570,281] <err> os:  xpsr:  0x21000012
00> [00:01:33.570,281] <err> os: Faulting instruction address (r15/pc): 0x00025654
00> [00:01:33.570,281] <err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
00> [00:01:33.570,312] <err> os: Fault during interrupt handling
00> 
00> [00:01:33.570,312] <err> os: Current thread: 0x20001898 (unknown)
00> [00:01:33.843,414] <err> fatal_error: Resetting system[0m

Or 

00> [00:00:40.695,648] <err> os: r0/a1:  0x00000004  r1/a2:  0x0000009a  r2/a3:  0x00000001
00> [00:00:40.695,648] <err> os: r3/a4:  0x00021cd9 r12/ip:  0x00000000 r14/lr:  0x0001256f
00> [00:00:40.695,678] <err> os:  xpsr:  0x41000012
00> [00:00:40.695,678] <err> os: Faulting instruction address (r15/pc): 0x0002bede
00> [00:00:40.695,678] <err> os: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0
00> [00:00:40.695,678] <err> os: Fault during interrupt handling
00> 
00> [00:00:40.695,678] <err> os: Current thread: 0x20001898 (unknown)
00> [00:00:40.904,663] <err> fatal_error: Resetting system

I think my question is similar as below

Forced disconnections when i try to send 50 bytes per second on UART example - Nordic Q&A - Nordic DevZone - Nordic DevZone (nordicsemi.com)

I have researched relevant question, but did not know how to solved it.

Souce Code as below

4848.central_uart.7z

Thanks.

Allen.

  • Hello Allen,

    What, in particular makes you think it is related to the issue in your link? And did you try applying the fix that was proposed in that ticket?

    Are you actually receiving your data from a uart input? (I am asking since you are using a dongle, which doesn't have anything connected to the UART pins by default.)

    How long are the packets that you are trying to send? Is it always less than 20 bytes? Or did you increase the MTU size? Sorry, your project probably holds answer to most of my questions, but I am on my way out of the office, and we are really short staffed because of Holiday Season. I am sorry for the inconvenience, but we will be back to normal operation in January. 

    In the meanwhile. Do I need anything other to reproduce your issue? Did you try this using two DKs instead of a Dongle and a DK? The reason I ask is that we don't have any dongles with debuggers, so it is a bit more difficult to debug on those.

    Best regards,

    Edvin

  • Hello Edvin,

    I have solved this issue yesterday, it seems a buffer overflow issue. But, the function still have strange condition.

    Are you actually receiving your data from a uart input? (I am asking since you are using a dongle, which doesn't have anything connected to the UART pins by default.)

    Yes, because I do not have enough time to add usb function to central uart code. So, I connect another UART converter(a CP210x UART brigge) to dongle UART pins. It can works transfer & read data.

    How long are the packets that you are trying to send? Is it always less than 20 bytes?

    My function only need transfer 8 - 9 bytes (include C/R character).

    I tried use some log. Then, I found issue like if host uart send 9 bytes. central_uart uart_cb function only recieved 8 bytes. 

    Because FW cannot detect C/R character, so it do not send data to peripheral (I mean below source code in uart_cb function)

    	case UART_RX_RDY:
    		//LOG_INF("UART_RX_RDY");
    		buf = CONTAINER_OF(evt->data.rx.buf, struct uart_data_t, data);
    		buf->len += evt->data.rx.len;
    		buf_release = false;
    		LOG_HEXDUMP_INF(buf->data, buf->len, "uart rx");
    		if (buf->len == UART_BUF_SIZE) {
    			k_fifo_put(&fifo_uart_rx_data, buf);
    		} else if ((evt->data.rx.buf[buf->len - 1] == '\n') ||
    			  (evt->data.rx.buf[buf->len - 1] == '\r')) {
    			k_fifo_put(&fifo_uart_rx_data, buf);
    			current_buf = evt->data.rx.buf;
    			buf_release = true;
    			uart_rx_disable(uart);
    		}
    
    		break;

    So, my host do not know data loss condition and host have retry mechanism. The uart_cb rx fifo will increase more and more. At the end, the fifo will overflow, more than the prj setting CONFIG_UART_0_NRF_TX_BUFFER_SIZE value.

    Then I tried to set CONFIG_UART_0_NRF_TX_BUFFER_SIZE is multiple of transfer data bytes. It still have loss data condition, but the retry mechanism works.

    In the meanwhile. Do I need anything other to reproduce your issue? 

    I have solved this issue, I think you do not need to reproduce issue.  But, I do not know why uart_cb  will have loss data issue. if you any other suggestions, please feel free to provide them.

    Finally, thanks your reply. Have a nice Holiday Season!!

    Allen.

Related