We tested our project a while ago with nrf sdk v1.9.1 using the lte_ble_gateway sample (app on nrf9160, hci_lpuart on nrf52840 using a nrf9160dk board). Now we have developed a good portion of our production firmware using the v2.1.2 SDK. We recently started adding the BLE interface features and the project builds fine (no errors) but when running the app on a dev board it hangs for a few seconds then crashes while initializing BLE with the following error:
ASSERTION FAIL [err == 0] @ WEST_TOPDIR/zephyr/subsys/bluetooth/host/hci_core.c:327
k_sem_take failed with err -11
We tried rebuilding our test project with nrf SDK v1.9.1 (we didn't change the hci_lpuart app or make any other changes) and found that the v1.9.1 app still worked as expected without issues. Unfortunately, our new firmware makes use of many v2+ sdk features like the event manager so it's difficult to revert back to 1.9.1.
Beside the SDK version there is one other change that I believe could be a culprit. In SDK 2.1.2 SPM is deprecated and we are building with TF-M now. The old project has a child image folder with this config:
# Set UARTE2 as non-secure, used for HCI CONFIG_SPM_NRF_UARTE2_NS=y
I'm not sure if there is an equivalent config we are missing for TF-M? Should we revert to SPM?
Configs below (They are all the same as in the lte_ble_gateway sample):
main_app/proj.conf
CONFIG_BT=y
CONFIG_BT_H4=y
CONFIG_BT_WAIT_NOP=y
CONFIG_BT_CENTRAL=y
CONFIG_BT_GATT_CLIENT=y
CONFIG_BT_GATT_DM=y
CONFIG_BT_SCAN=y
CONFIG_BT_SCAN_FILTER_ENABLE=y
CONFIG_BT_SCAN_UUID_CNT=1
CONFIG_UART_INTERRUPT_DRIVEN=y
boards/nrf9160dk_nrf9160_ns.conf
# BLE LPUART HCI
CONFIG_NRF_SW_LPUART=y
CONFIG_NRF_SW_LPUART_INT_DRIVEN=y
CONFIG_UART_2_ASYNC=y
CONFIG_UART_2_INTERRUPT_DRIVEN=n
CONFIG_UART_2_NRF_HW_ASYNC=y
CONFIG_UART_2_NRF_HW_ASYNC_TIMER=2
hci_lpuart/proj.conf
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_BT=y
CONFIG_BT_HCI_RAW=y
CONFIG_BT_HCI_RAW_H4=y
CONFIG_BT_HCI_RAW_H4_ENABLE=y
CONFIG_BT_BUF_ACL_RX_SIZE=251
CONFIG_BT_BUF_EVT_DISCARDABLE_SIZE=255
I can share board files too, but they are also the same as in the sample
POST EDITS/UPDATES:
1. I saw the changes listed in this similar thread https://devzone.nordicsemi.com/f/nordic-q-a/69603/lte_ble_gateway-sample-k_sem_take-failed-with-err--11 but sdk v2.1.2 seems to already implement both.
2. This can be reproduced by building the lte_ble_sample on sdk v2.1.2 and flashing an nrf9160dk (with hci_lpuart flashed to the boards nrf52840)