HCI: handling error

Hi!
I am developing project based on nrf9160 as a main processor and nrf52840 as a hci controller.
I am using nrf connect sdk 2.6.1.

I came across a potential issue in nrf connect sdk.

If bt_hci_cmd_send_sync() reaches timeout waiting for controller (HCI_CMD_TIMEOUT), BT_ASSERT_MSG in file hci_core.c, line 331 is activated.
This causes a processor hard fault condition, which is not a tolerable behaviour in the project I am working on. I'd like error to be returned and handled by the application.
I managed to disable hard fault functionality the condition by setting:

CONFIG_BT_ASSERT=n

There are two further issues though:
1. If BT_ASSERT is disabled, error from k_sem_take() is completely ignored, and function returns 0.
2. I saw that in newer zephyr version there are more and more calls to BT_ASSERT_MSG and BT_ASSERT, so I am not sure whether disabling it is safe.

Thank you for your help and time in advance.

KR,
Piotr
Parents Reply Children
  • Hi Piotr,

    I have reported this issue, and we have discussed it internally. 

    We understand that you want to isolate faults in the co-processor from triggering panic in the application processors. Although achievable, it is currently not implemented.
    Please note that returning an error from bt_hci_cmd_send_sync might result in somewhat undefined behavior if controller starts responding again. Late response from the controller could be misunderstood by the host to be a response to a subsequent command. This situation might however get resolved without problems, but this might not be what is expected.

    Regarding the safety of disabling CONFIG_BT_ASSSERT, our code relies on these assert messages to catch various rare-but-possible errors. If for example assertion check is not enabled, bt_hci_cmd_send_sync returns success when it should not. There might be other cases like this. It is up to you to do this risk analysis.

    Best regards,
    Dejan




Related