From 434ea2b2fffc7346f5c7ef855821e52dfe1d6f11 Mon Sep 17 00:00:00 2001 From: Jonathan Rico Date: Thu, 31 Aug 2023 17:36:45 +0200 Subject: [PATCH] Bluetooth: hci_rpmsg: flush the logs before locking CPU The logs were not visible when an assert fired on the controller and `CONFIG_BT_HCI_VS_FATAL_ERROR` was not set. Putting the logs in panic mode before entering the infinite loop fixes that. Signed-off-by: Jonathan Rico --- samples/bluetooth/hci_rpmsg/src/main.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/samples/bluetooth/hci_rpmsg/src/main.c b/samples/bluetooth/hci_rpmsg/src/main.c index 6534521df8a..32c4616cc79 100644 --- a/samples/bluetooth/hci_rpmsg/src/main.c +++ b/samples/bluetooth/hci_rpmsg/src/main.c @@ -24,10 +24,7 @@ #include #include -#if defined(CONFIG_BT_HCI_VS_FATAL_ERROR) #include -#endif /* CONFIG_BT_HCI_VS_FATAL_ERROR */ - #include LOG_MODULE_REGISTER(hci_rpmsg, CONFIG_BT_LOG_LEVEL); @@ -314,6 +311,9 @@ void bt_ctlr_assert_handle(char *file, uint32_t line) #endif /* !CONFIG_BT_HCI_VS_FATAL_ERROR */ + /* Flush the logs before locking the CPU */ + LOG_PANIC(); + while (true) { }; } @@ -322,8 +322,6 @@ void bt_ctlr_assert_handle(char *file, uint32_t line) #if defined(CONFIG_BT_HCI_VS_FATAL_ERROR) void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *esf) { - LOG_PANIC(); - /* Disable interrupts, this is unrecoverable */ (void)irq_lock(); @@ -344,6 +342,9 @@ void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *esf) LOG_ERR("Halting system"); + /* Flush the logs before locking the CPU */ + LOG_PANIC(); + while (true) { };