Skip to content

Commit

Permalink
bluetooth: honor log panic mode in monitor
Browse files Browse the repository at this point in the history
Once panic mode is entered, the log write functions are called from an ISR,
so must not try to acquire locks.

Signed-off-by: Armin Brauns <[email protected]>
  • Loading branch information
arbrauns committed Aug 2, 2024
1 parent e503799 commit 023bfdc
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions subsys/bluetooth/host/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ static void drop_add(uint16_t opcode)
#if defined(CONFIG_BT_DEBUG_MONITOR_RTT)
#include <SEGGER_RTT.h>

static bool panic_mode;

#define RTT_BUFFER_NAME CONFIG_BT_DEBUG_MONITOR_RTT_BUFFER_NAME
#define RTT_BUF_SIZE CONFIG_BT_DEBUG_MONITOR_RTT_BUFFER_SIZE

Expand All @@ -123,10 +125,14 @@ static void monitor_send(const void *data, size_t len)
}

if (!drop) {
SEGGER_RTT_LOCK();
if (!panic_mode) {
SEGGER_RTT_LOCK();
}
cnt = SEGGER_RTT_WriteNoLock(CONFIG_BT_DEBUG_MONITOR_RTT_BUFFER,
rtt_buf, rtt_buf_offset);
SEGGER_RTT_UNLOCK();
if (!panic_mode) {
SEGGER_RTT_UNLOCK();
}
}

if (!cnt) {
Expand Down Expand Up @@ -350,6 +356,9 @@ static void monitor_log_process(const struct log_backend *const backend,

static void monitor_log_panic(const struct log_backend *const backend)
{
#if defined(CONFIG_BT_DEBUG_MONITOR_RTT)
panic_mode = true;
#endif
}

static void monitor_log_init(const struct log_backend *const backend)
Expand Down

0 comments on commit 023bfdc

Please sign in to comment.