Skip to content

Commit 4f6d933

Browse files
ivaniushkovrlubos
authored andcommitted
bluetooth: controller: add sdc_get_assertion_message
Added a function to print reason of SDC assert. The function is only compilied in when CONFIG_LOG is enabled since it requires additional flash size. sdc_assert_messages[] array is provided in nrfxlib and contains list of documented SDC assert messages. Signed-off-by: Ivan Iushkov <ivan.iushkov@nordicsemi.no>
1 parent 31d62eb commit 4f6d933

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

subsys/bluetooth/controller/hci_driver.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
#include <zephyr/sys/byteorder.h>
1818
#include <zephyr/sys/util.h>
1919
#include <stdbool.h>
20+
#include <stdlib.h>
2021
#include <zephyr/sys/__assert.h>
2122

2223
#include <sdc.h>
24+
#include <sdc_asserts.h>
2325
#include <sdc_soc.h>
2426
#include <sdc_hci.h>
2527
#include <sdc_hci_vs.h>
@@ -333,6 +335,23 @@ void sdc_assertion_handler(const char *const file, const uint32_t line)
333335
}
334336

335337
#else /* !IS_ENABLED(CONFIG_BT_CTLR_ASSERT_HANDLER) */
338+
339+
#if defined(CONFIG_LOG)
340+
const char *sdc_get_assertion_message(const char *const file, const uint32_t line)
341+
{
342+
uint32_t file_id = atoi(file);
343+
344+
for (uint32_t i = 0; i < ARRAY_SIZE(sdc_assert_messages); i++) {
345+
if (sdc_assert_messages[i].file_id == file_id &&
346+
sdc_assert_messages[i].line == line) {
347+
return sdc_assert_messages[i].assert_msg;
348+
}
349+
}
350+
351+
return NULL;
352+
}
353+
#endif /* CONFIG_LOG */
354+
336355
void sdc_assertion_handler(const char *const file, const uint32_t line)
337356
{
338357
volatile char assert_file_id[11] = { 0 };
@@ -345,6 +364,11 @@ void sdc_assertion_handler(const char *const file, const uint32_t line)
345364
(char *)assert_file_id, assert_line);
346365
#elif defined(CONFIG_LOG)
347366
LOG_ERR("SoftDevice Controller ASSERT: %s, %d", (char *)assert_file_id, assert_line);
367+
const char *failure_reason_msg =
368+
sdc_get_assertion_message((char *)assert_file_id, assert_line);
369+
if (failure_reason_msg) {
370+
LOG_ERR("ASSERT REASON: %s", failure_reason_msg);
371+
}
348372
k_oops();
349373
#elif defined(CONFIG_PRINTK)
350374
printk("SoftDevice Controller ASSERT: %s, %d\n", (char *)assert_file_id, assert_line);

0 commit comments

Comments
 (0)