samples: nrf5340: Trigger fatal error in an assertion handler

Trigger BT_ASSERT with message to inform kernel when encountering an
unrecoverable condition in order to dump all pending logging messages.

In this change, the log level is configured by CONFIG_BT_LOG_LEVEL

Signed-off-by: Ryan Chu <ryan.chu@nordicsemi.no>
This commit is contained in:
Ryan Chu 2021-03-05 15:11:41 +01:00 committed by Carles Cufí
commit c5db0bdafe

View file

@ -12,7 +12,6 @@
#include <zephyr.h> #include <zephyr.h>
#include <arch/cpu.h> #include <arch/cpu.h>
#include <sys/byteorder.h> #include <sys/byteorder.h>
#include <logging/log.h>
#include <sys/util.h> #include <sys/util.h>
#include <drivers/ipm.h> #include <drivers/ipm.h>
@ -30,9 +29,9 @@
#include <bluetooth/buf.h> #include <bluetooth/buf.h>
#include <bluetooth/hci_raw.h> #include <bluetooth/hci_raw.h>
#define LOG_LEVEL LOG_LEVEL_INFO #define BT_DBG_ENABLED 0
#define LOG_MODULE_NAME hci_rpmsg #define LOG_MODULE_NAME hci_rpmsg
LOG_MODULE_REGISTER(LOG_MODULE_NAME); #include "common/log.h"
static int endpoint_id; static int endpoint_id;
@ -234,7 +233,7 @@ static int hci_rpmsg_send(struct net_buf *buf)
#if defined(CONFIG_BT_CTLR_ASSERT_HANDLER) #if defined(CONFIG_BT_CTLR_ASSERT_HANDLER)
void bt_ctlr_assert_handle(char *file, uint32_t line) void bt_ctlr_assert_handle(char *file, uint32_t line)
{ {
LOG_ERR("Controller assert in: %s at %d", file, line); BT_ASSERT_MSG(false, "Controller assert in: %s at %d", file, line);
} }
#endif /* CONFIG_BT_CTLR_ASSERT_HANDLER */ #endif /* CONFIG_BT_CTLR_ASSERT_HANDLER */