Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update hci_core.c #2130

Open
wants to merge 1 commit into
base: v2.7.0-ncs1-branch
Choose a base branch
from

Conversation

ViktorRindom
Copy link

Changed K_FOREVER to K_NO_WAIT in k_sem_take(&bt_dev.ncmd_sem, K_NO_WAIT); in static void send_cmd(void)

If I don't do this, then my program hits timeout:

SEGGER J-Link V7.94e - Real time terminal output
SEGGER J-Link (unknown) V1.0, SN=960000685
Process: JLink.exe
[00:00:00.372,467] os: setup_thread_stack: stack 0x200199a0 for thread 0x2000e280: obj_size=4096 buf_start=0x200199a0 buf_size 4096 stack_ptr=0x2001a9a0
[00:00:00.388,397] lpuart: api_rx_enable: RX: Enabling
[00:00:00.394,927] os: setup_thread_stack: stack 0x200136b8 for thread 0x2000d320: obj_size=1304 buf_start=0x200136b8 buf_size 1304 stack_ptr=0x20013bd0
[00:00:00.410,552] bt_hci_core: bt_hci_driver_register: Registered H:4
[00:00:00.418,518] os: setup_thread_stack: stack 0x20016c60 for thread 0x2000c710: obj_size=1024 buf_start=0x20016c60 buf_size 1024 stack_ptr=0x20017060
[00:00:00.434,173] os: z_impl_k_mutex_lock: 0x2000e1c8 took mutex 0x2000c7e8, count: 1, orig prio: 0
[00:00:00.444,854] spi_nrfx_spim: spi_context_buffers_setup: tx_bufs 0x20019888 - rx_bufs 0x20019890 - 1
[00:00:00.455,871] spi_nrfx_spim: spi_context_buffers_setup: current_tx 0x20019878 (1), current_rx 0x20019880 (1),[00:00:03.182,891] ble: Initializing Bluetooth..
[00:00:03.188,781] os: z_impl_k_mutex_lock: 0x2000d230 took mutex 0x2000d034, count: 1, orig prio: 7
[00:00:03.199,584] os: z_impl_k_mutex_lock: 0x2000d230 took mutex 0x2000e4bc, count: 1, orig prio: 7
[00:00:03.210,266] fs_nvs: nvs_recover_last_ate: Recovering last ate from sector 0
[00:00:03.224,853] os: z_impl_k_mutex_unlock: mutex 0x2000e4bc lock_count: 1
[00:00:03.233,306] os: z_impl_k_mutex_unlock: new owner of mutex 0x2000e4bc: 0 (prio: -1000)
[00:00:03.243,194] fs_nvs: 2 Sectors of 4096 bytes
[00:00:03.249,267] fs_nvs: alloc wra: 0, fe8
[00:00:03.254,791] fs_nvs: data wra: 0, 0
[00:00:03.260,040] settings: settings_nvs_backend_init: Initialized
[00:00:03.267,669] os: z_impl_k_mutex_unlock: mutex 0x2000d034 lock_count: 1
[00:00:03.276,123] os: z_impl_k_mutex_unlock: new owner of mutex 0x2000d034: 0 (prio: -1000)
[00:00:03.286,071] os: setup_thread_stack: stack 0x20013bd0 for thread 0x2000d3f8: obj_size=4096 buf_start=0x20013bd0 buf_size 4096 stack_ptr=0x20014bd0
[00:00:03.301,940] bt_hci_core: hci_tx_thread: Started
[00:00:03.308,380] bt_hci_core: hci_tx_thread: Calling k_poll with 2 events
[00:00:03.316,802] os: setup_thread_stack: stack 0x20014bd0 for thread 0x2000d4b0: obj_size=4096 buf_start=0x20014bd0 buf_size 4096 stack_ptr=0x20015bd0
[00:00:03.332,733] bt_driver: h4_open:
[00:00:03.337,829] os: setup_thread_stack: stack 0x20015c60 for thread 0x2000dea0: obj_size=4096 buf_start=0x20015c60 buf_size 4096 stack_ptr=0x20016c60
[00:00:03.353,698] bt_driver: rx_thread: started
[00:00:03.359,588] bt_driver: rx_thread: rx.buf 0
[00:00:03.365,600] bt_hci_core: bt_hci_cmd_create: opcode 0x0c03 param_len 0
[00:00:03.374,053] bt_hci_core: bt_hci_cmd_create: buf 0x2001fc10
[00:00:03.381,500] bt_hci_core: bt_hci_cmd_send_sync: buf 0x2001fc10 opcode 0x0c03 len 3
[00:00:03.391,082] bt_hci_core: process_events: count 2
[00:00:03.397,613] bt_hci_core: process_events: ev->state 4
[00:00:03.404,479] bt_hci_core: send_cmd: calling net_buf_get
[00:00:03.411,560] bt_hci_core: send_cmd: calling sem_take_wait
[00:00:03.418,823] main: ble_thread running
[00:00:03.425,140] os: z_tick_sleep: thread 0x2000d230 for 327680 ticks
ASSERTION FAIL [err == 0] @ WEST_TOPDIR/zephyr/subsys/bluetooth/host/hci_core.c:333
command opcode 0x0c03 timeout with err -11
[00:00:13.403,045] os: r0/a1: 0x00000003 r1/a2: 0x20012965 r2/a3: 0x00000000
[00:00:13.412,231] os: r3/a4: 0x00000003 r12/ip: 0x00000000 r14/lr: 0x0000e3c5
[00:00:13.421,386] os: xpsr: 0x01000000
[00:00:13.426,910] os: Faulting instruction address (r15/pc): 0x0000e3d2
[00:00:13.435,272] os: >>> ZEPHYR FATAL ERROR 3: Kernel oops on CPU 0
[00:00:13.443,359] os: Current thread: 0x2000e280 (sysworkq)
[00:00:13.450,592] os: Halting system

The function "k_sem_take()" also mentions that if it is run from inside a ISR the option should always be "K_NO_WAIT"

image

changed K_FOREVER to K_NO_WAIT in k_sem_take(&bt_dev.ncmd_sem, K_NO_WAIT); in static void send_cmd(void)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant