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 <jonathan.rico@nordicsemi.no>
This commit is contained in:
Jonathan Rico 2023-08-31 17:36:45 +02:00 committed by Carles Cufí
commit 434ea2b2ff

View file

@ -24,10 +24,7 @@
#include <zephyr/bluetooth/hci_raw.h> #include <zephyr/bluetooth/hci_raw.h>
#include <zephyr/bluetooth/hci_vs.h> #include <zephyr/bluetooth/hci_vs.h>
#if defined(CONFIG_BT_HCI_VS_FATAL_ERROR)
#include <zephyr/logging/log_ctrl.h> #include <zephyr/logging/log_ctrl.h>
#endif /* CONFIG_BT_HCI_VS_FATAL_ERROR */
#include <zephyr/logging/log.h> #include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(hci_rpmsg, CONFIG_BT_LOG_LEVEL); 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 */ #endif /* !CONFIG_BT_HCI_VS_FATAL_ERROR */
/* Flush the logs before locking the CPU */
LOG_PANIC();
while (true) { while (true) {
}; };
} }
@ -322,8 +322,6 @@ void bt_ctlr_assert_handle(char *file, uint32_t line)
#if defined(CONFIG_BT_HCI_VS_FATAL_ERROR) #if defined(CONFIG_BT_HCI_VS_FATAL_ERROR)
void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *esf) void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *esf)
{ {
LOG_PANIC();
/* Disable interrupts, this is unrecoverable */ /* Disable interrupts, this is unrecoverable */
(void)irq_lock(); (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"); LOG_ERR("Halting system");
/* Flush the logs before locking the CPU */
LOG_PANIC();
while (true) { while (true) {
}; };