bt_hci_cmd_send_sync times out and causes reboot

My app is running on a board with the nRF9160 as the Bluetooth host and the nRF52820 as the controller with HCI commands being sent over UART. Both MCUs are running NCS 1.7.0. Occasionally, my app will reset when establishing a connection as the Central device. I've attached a Bluetooth debug log because I can't interpret it very well. As far as I can tell, there doesn't seem to be any issues

[00:11:29.303,161] <dbg> scan.scan_filter_match: GW rpc data is for me, trying to connect
[00:11:29.303,161] <dbg> bt_hci_core.bt_hci_cmd_create: opcode 0x2042 param_len 6
[00:11:29.303,161] <dbg> bt_hci_core.bt_hci_cmd_create: buf 0x2003daa8
[00:11:29.303,192] <dbg> bt_hci_core.bt_hci_cmd_send_sync: buf 0x2003daa8 opcode 0x2042 len 9
[00:11:29.303,253] <dbg> bt_hci_core.process_events: count 2
[00:11:29.303,253] <dbg> bt_hci_core.process_events: ev->state 4
[00:11:29.303,283] <dbg> bt_hci_core.send_cmd: calling net_buf_get
[00:11:29.303,283] <dbg> bt_hci_core.send_cmd: calling sem_take_wait
[00:11:29.303,283] <dbg> bt_hci_core.send_cmd: Sending command 0x2042 (buf 0x2003daa8) to driver
[00:11:29.303,314] <dbg> bt_hci_core.bt_send: buf 0x2003daa8 len 9 type 0
[00:11:29.303,344] <dbg> bt_hci_core.process_events: ev->state 0
[00:11:29.303,375] <dbg> bt_hci_core.hci_tx_thread: Calling k_poll with 2 events
[00:11:29.315,460] <dbg> bt_buf.bt_buf_get_cmd_complete: sent_cmd 0x2003daa8
[00:11:29.315,734] <dbg> bt_hci_core.hci_cmd_complete: opcode 0x2042
[00:11:29.315,734] <dbg> bt_hci_core.hci_cmd_done: opcode 0x2042 status 0x00 buf 0x2003daa8
[00:11:29.315,765] <dbg> bt_hci_core.bt_hci_cmd_send_sync: rsp 0x2003daa8 opcode 0x2042 len 1
[00:11:29.315,795] <inf> scan: Stopping BLE scanning
[00:11:29.315,826] <dbg> bt_hci_core.bt_hci_cmd_create: opcode 0x2039 param_len 6
[00:11:29.315,826] <dbg> bt_hci_core.bt_hci_cmd_create: buf 9
[00:11:29.315,887] <dbg> bt_hci_core.process_events: count 2
[00:11:29.315,887] <dbg> bt_hci_core.process_events: ev->state 4
[00:11:29.315,917] <dbg> bt_hci_core.send_cmd: calling net_buf_get
[00:11:29.315,948] <dbg> bt_hci_core.send_cmd: calling sem_take_wait
[00:11:29.315,948] <dbg> bt_hci_core.send_cmd: Sending command 0x2039 (buf 0x2003daa8) to driver
[00:11:29.315,948] <dbg> bt_hci_core.bt_send: buf 0x2003daa8 len 9 type 0
[00:11:29.315,979] <dbg> bt_hci_core.process_events: ev->state 0
[00:11:29.316,009] <dbg> bt_hci_core.hci_tx_thread: Calling k_poll with 2 events
[00:11:29.317,535] <dbg> bt_buf.bt_buf_get_cmd_complete: sent_cmd 0x2003daa8
[00:11:29.317,810] <dbg> bt_hci_core.hci_cmd_complete: opcode 0x2039
[00:11:29.317,810] <dbg> bt_hci_core.hci_cmd_done: opcode 0x2039 status 0x00 buf 0x2003daa8
[00:11:29.317,871] <dbg> bt_hci_core.bt_hci_cmd_send_sync: rsp 0x2003daa8 opcode 0x2039 len [00:11:29.567,932] <dbg> ble.attempt_connection: Trying to create conn
[00:11:29.567,993] <dbg> bt_hci_core.bt_hci_cmd_create: opcode 0x2043 param_len 26
[00:11:29.568,023] <dbg> bt_hci_core.bt_hci_cmd_create: buf 0x2003daa8
[00:11:29.568,023] <dbg> bt_hci_core.bt_hci_cmd_send_sync: buf 0x2003daa8 opcode 0x2043 len 29
[00:11:29.568,084] <dbg> bt_hci_core.process_events: count 2
[00:11:29.568,084] <dbg> bt_hci_core.process_events: ev->state 4
[00:11:29.568,084] <dbg> bt_hci_core.send_cmd: calling net_buf_get
[00:11:29.568,084] <dbg> bt_hci_core.send_cmd: calling sem_take_wait
[00:11:29.568,084] <dbg> bt_hci_core.send_cmd: Sending command 0x2043 (buf 0x2003daa8) to driver
[00:11:29.568,115] <dbg> bt_hci_core.bt_send: buf 0x2003daa8 len 29 type 0
[00:11:29.568,145] <dbg> bt_hci_core.process_events: ev->state 0
[00:11:29.568,176] <dbg> bt_hci_core.hci_tx_thread: Calling k_poll with 2 events
[00:11:30.068,054] <dbg> bt_hci_core.bt_hci_cmd_create: opcode 0x200e param_len 0
[00:11:30.068,084] <dbg> bt_hci_core.bt_hci_cmd_create: buf 0x2003da90
[00:11:30.068,084] <dbg> bt_hci_core.bt_hci_cmd_send_sync: buf 0x2003da90 opcode 0x200e len 3
[00:11:30.068,145] <dbg> bt_hci_core.process_events: count 2
[00:11:30.068,145] <dbg> bt_hci_core.process_events: ev->state 4
[00:11:30.068,145] <dbg> bt_hci_core.send_cmd: calling net_buf_get
[00:11:30.068,145] <dbg> bt_hci_core.send_cmd: calling sem_take_wait
ASSERTION FAIL [err == 0] @ WEST_TOPDIR/zephyr/subsys/bluetooth/host/hci_core.c:305

  k_sem_take failed with err -11

[00:11:39.568,328] <err> os: r0/a1:  0x00000003  r1/a2:  0x00000000  r2/a3:  0x2001c410
[00:11:39.568,328] <err> os: r3/a4:  0x00000002 r12/ip:  0x0000a000 r14/lr:  0x000469b5
[00:11:39.568,328] <err> os:  xpsr:  0x41000000
[00:11:39.568,359] <err> os: s[ 0]:  0x00000000  s[ 1]:  0x00000000  s[ 2]:  0x00000000  s[ 3]:  0x00000000
[00:11:39.568,359] <err> os: s[ 4]:  0x00000000  s[ 5]:  0x00000000  s[ 6]:  0x00000000  s[ 7]:  0x00000000
[00:11:39.568,359] <err> os: s[ 8]:  0x00000000  s[ 9]:  0x00000000  s[10]:  0x00000000  s[11]:  0x00000000
[00:11:39.568,389] <err> os: s[12]:  0x00000000  s[13]:  0x00000000  s[14]:  0x00000000  s[15]:  0x00000000
[00:11:39.568,389] <err> os: fpscr:  0x2003d9d8
[00:11:39.568,389] <err> os: Faulting instruction address (r15/pc): 0x000469c0
[00:11:39.568,389] <err> os: >>> ZEPHYR FATAL ERROR 3: Kernel oops on CPU 0
[00:11:39.568,420] <err> os: Current thread: 0x2001c5c8 (bt_rx_thread)
[00:11:40.553,588] <err> fatal_error: Resetting system

Parents
  • Hi,

    The assert on line 305 in hci_core.c indicate that the Bluetooth host implementation (on the nRF9160) cannot communicate witht the controller (on the nRF52820). So you have logs from the nRF52 side?

  • [00:01:15.219,635] <err> os: ***** BUS FAULT *****
    [00:01:15.219,635] <err> os:   Precise data bus error
    [00:01:15.219,635] <err> os:   BFAR Address: 0xa14056200m
    [00:01:15.219,665] <err> os: r0/a1:  0x20003240  r1/a2:  0x000001e0  r2/a3:  0xa140561c
    [00:01:15.219,665] <err> os: r3/a4:  0x00000000 r12/ip:  0x20000e08 r14/lr:  0x00010d23
    [00:01:15.219,665] <err> os:  xpsr:  0x21000000
    [00:01:15.219,696] <err> os: Faulting instruction address (r15/pc): 0x0002583c
    [00:01:15.219,696] <err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
    [00:01:15.219,696] <err> os: Current thread: 0x20001e68 (unknown)
    [00:01:15.863,616] <err> fatal_error: Resetting system

    Fatal error on 52820 side. Honestly not too enlightening after running arm-none-eabi-addr2line, just a ?? as line number

  • Hi,

    I see. addr2line will print ?? when it cannot determine the file name, so the information is likely not in the .elf file then. Could there be an invalid pointer for some reason? The PC value seems sensible, though (within the expected range). What do you see if you add2line with the address in LR (0x00010d23)?

  • I'll have to reproduce the issue again since I believe my build has changed since I sent this. Want to double check that the address is mapping correctly. Usually I see ?? when there's a stack overflow, but that would be surprising to me since my app is essentially the hci_uart sample with a few extra lines of code to allow for a FOTA

  • Hi,

    Normally you would get an MPU fault if there is a stack overflow, but if you don't have the MPU stack guard enabled, you could see this. So it makes sense to make sure you have CONFIG_MPU_STACK_GUARD=y. If you also add CONFIG_THREAD_NAME=y you will see the name of the thread with the failure.

Reply Children
Related