how to wait for BLE controller initialization?
Vakul Garg <vakul.garg@...>
I am using zephyr with nxp board frdm_k64f. It is connected with frdm_kw41z running the BLE firmware.
The kw41z acts as BLE controller.
The two boards get powered up together.
In this setup, bt_enable() executes even before frdm_kw41z firmware could complete initialization.
This leads to bt_hci_cmd_send_sync failing for command BT_HCI_OP_RESET.
The failure happens due to timeout on semaphore ‘sync_sem’.
As a workaround, I have to insert a delay of 1 second in bt_enable().
Can someone guide me how to fix such a race condition properly?
On Thu, Dec 21, 2017, Vakul Garg wrote:
I am using zephyr with nxp board frdm_k64f. It is connected withTo me this sounds like something the HCI driver should handle, since
that's the entity that's expected to deal with HW-specific details. You
could e.g. make the HCI driver for your controller block on its open()
call until the HW is ready to receive HCI commands. If you're using the
existing H:4 driver (i.e. drivers/bluetooth/hci/h4.c) you could also use
UART flow control for this, i.e. the controller would only assert the
CTS line when it's ready to receive commands.