221 lines
5.6 KiB
Diff
221 lines
5.6 KiB
Diff
From d8e252a5627678bdea3f7861d0aea7725cca12a2 Mon Sep 17 00:00:00 2001
|
|
From: Zhu Lv <zhu.lv@amlogic.com>
|
|
Date: Wed, 25 Mar 2026 17:22:51 +0800
|
|
Subject: [PATCH] BT: extract amlbt fw log [1/1]
|
|
|
|
PD#SWPL-258545
|
|
|
|
Problem:
|
|
extract amlbt fw log
|
|
|
|
Solution:
|
|
btmon extract amlbt fw log through
|
|
hci command and save to files
|
|
|
|
Verify:
|
|
A113X2
|
|
|
|
Signed-off-by: Zhu Lv <zhu.lv@amlogic.com>
|
|
---
|
|
Makefile.tools | 2 ++
|
|
monitor/ellisys.c | 10 ++++++++++
|
|
monitor/main.c | 25 +++++++++++++++++++++++--
|
|
monitor/packet.c | 15 +++++++++++++++
|
|
src/shared/btsnoop.c | 11 +++++++++++
|
|
5 files changed, 61 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/Makefile.tools b/Makefile.tools
|
|
index 1b43ca4..5db915a 100644
|
|
--- a/Makefile.tools
|
|
+++ b/Makefile.tools
|
|
@@ -50,11 +50,13 @@ monitor_btmon_SOURCES = monitor/main.c monitor/bt.h \
|
|
monitor/jlink.h monitor/jlink.c \
|
|
monitor/tty.h monitor/emulator.h \
|
|
monitor/att.h monitor/att.c \
|
|
+ monitor/amlbt_fwlog.h monitor/amlbt_fwlog.c \
|
|
src/log.h src/log.c \
|
|
src/textfile.h src/textfile.c \
|
|
src/settings.h src/settings.c
|
|
monitor_btmon_LDADD = lib/libbluetooth-internal.la \
|
|
src/libshared-mainloop.la \
|
|
+ -lz -lpthread \
|
|
$(GLIB_LIBS) $(UDEV_LIBS) -ldl
|
|
|
|
if MANPAGES
|
|
diff --git a/monitor/ellisys.c b/monitor/ellisys.c
|
|
index 61ac24c..17c9953 100644
|
|
--- a/monitor/ellisys.c
|
|
+++ b/monitor/ellisys.c
|
|
@@ -28,6 +28,8 @@
|
|
#include "src/shared/btsnoop.h"
|
|
#include "ellisys.h"
|
|
|
|
+#include "amlbt_fwlog.h"
|
|
+
|
|
static int ellisys_fd = -1;
|
|
static uint16_t ellisys_index = 0xffff;
|
|
|
|
@@ -83,6 +85,14 @@ void ellisys_inject_hci(struct timeval *tv, uint16_t index, uint16_t opcode,
|
|
struct iovec iov[2];
|
|
int iovcnt;
|
|
|
|
+ if (opcode == BTSNOOP_OPCODE_EVENT_PKT) {
|
|
+ const uint8_t *tmp = data;
|
|
+ if (tmp[0] == AMLBT_FWLOG_EVENT) {
|
|
+ ALOGD("cmd: 0x%02x", tmp[0]);
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+
|
|
if (!tv)
|
|
return;
|
|
|
|
diff --git a/monitor/main.c b/monitor/main.c
|
|
index 3ec3a5f..9af87d8 100644
|
|
--- a/monitor/main.c
|
|
+++ b/monitor/main.c
|
|
@@ -32,11 +32,14 @@
|
|
#include "control.h"
|
|
#include "display.h"
|
|
|
|
+#include "amlbt_fwlog.h"
|
|
+
|
|
static void signal_callback(int signum, void *user_data)
|
|
{
|
|
switch (signum) {
|
|
case SIGINT:
|
|
case SIGTERM:
|
|
+ fwlog_close();
|
|
mainloop_quit();
|
|
break;
|
|
}
|
|
@@ -70,7 +73,11 @@ static void usage(void)
|
|
"\t RTT control block parameters\n"
|
|
"\t-C, --columns [width] Output width if not a terminal\n"
|
|
"\t-c, --color [mode] Output color: auto/always/never\n"
|
|
- "\t-h, --help Show help options\n");
|
|
+ "\t-h, --help Show help options\n"
|
|
+ "\t-f, --btfwlog-file Set btfwlog-file path\n"
|
|
+ "\t-j, --btfwlog-size Set btfwlog-size unit:M\n"
|
|
+ "\t-k, --btfwlog-cnt Set btfwlog-cnt\n");
|
|
+
|
|
}
|
|
|
|
static const struct option main_options[] = {
|
|
@@ -97,6 +104,9 @@ static const struct option main_options[] = {
|
|
{ "color", required_argument, NULL, 'c' },
|
|
{ "todo", no_argument, NULL, '#' },
|
|
{ "version", no_argument, NULL, 'v' },
|
|
+ { "btfwlog-file", required_argument, NULL, 'f' },
|
|
+ { "btfwlog-size", required_argument, NULL, 'j' },
|
|
+ { "btfwlog-cnt", required_argument, NULL, 'k' },
|
|
{ "help", no_argument, NULL, 'h' },
|
|
{ }
|
|
};
|
|
@@ -126,7 +136,7 @@ int main(int argc, char *argv[])
|
|
struct sockaddr_un addr;
|
|
|
|
opt = getopt_long(argc, argv,
|
|
- "r:w:a:s:p:i:d:B:V:MNtTSAE:PJ:R:C:c:vh",
|
|
+ "r:w:a:s:p:i:d:B:V:MNtTSAIE:PJ:R:C:c:f:j:k:vh",
|
|
main_options, NULL);
|
|
if (opt < 0)
|
|
break;
|
|
@@ -230,6 +240,15 @@ int main(int argc, char *argv[])
|
|
packet_todo();
|
|
lmp_todo();
|
|
return EXIT_SUCCESS;
|
|
+ case 'f':
|
|
+ fwlog_set_path(strdup(optarg));
|
|
+ break;
|
|
+ case 'j':
|
|
+ fwlog_set_size(atoi(optarg));
|
|
+ break;
|
|
+ case 'k':
|
|
+ fwlog_set_cnt(atoi(optarg));
|
|
+ break;
|
|
case 'v':
|
|
printf("%s\n", VERSION);
|
|
return EXIT_SUCCESS;
|
|
@@ -253,6 +272,8 @@ int main(int argc, char *argv[])
|
|
|
|
printf("Bluetooth monitor ver %s\n", VERSION);
|
|
|
|
+ fwlog_init();
|
|
+
|
|
keys_setup();
|
|
|
|
packet_set_filter(filter_mask);
|
|
diff --git a/monitor/packet.c b/monitor/packet.c
|
|
index 46587e0..57096c7 100644
|
|
--- a/monitor/packet.c
|
|
+++ b/monitor/packet.c
|
|
@@ -46,6 +46,8 @@
|
|
#include "broadcom.h"
|
|
#include "packet.h"
|
|
|
|
+#include "amlbt_fwlog.h"
|
|
+
|
|
#define COLOR_CHANNEL_LABEL COLOR_WHITE
|
|
#define COLOR_FRAME_LABEL COLOR_WHITE
|
|
#define COLOR_INDEX_LABEL COLOR_WHITE
|
|
@@ -4162,6 +4164,14 @@ void packet_monitor(struct timeval *tv, struct ucred *cred,
|
|
uint16_t manufacturer;
|
|
const char *ident;
|
|
|
|
+ if (opcode == BTSNOOP_OPCODE_EVENT_PKT) {
|
|
+ const uint8_t *tmp = data;
|
|
+ if (tmp[0] == AMLBT_FWLOG_EVENT) {
|
|
+ ALOGD("cmd: 0x%02x", tmp[0]);
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+
|
|
if (index != HCI_DEV_NONE) {
|
|
index_current = index;
|
|
}
|
|
@@ -12098,6 +12108,11 @@ void packet_hci_event(struct timeval *tv, struct ucred *cred, uint16_t index,
|
|
char extra_str[25];
|
|
int i;
|
|
|
|
+ if (hdr->evt == AMLBT_FWLOG_EVENT) {
|
|
+ ALOGD("cmd: 0x%02x", hdr->evt);
|
|
+ return;
|
|
+ }
|
|
+
|
|
if (index >= MAX_INDEX) {
|
|
print_field("Invalid index (%d).", index);
|
|
return;
|
|
diff --git a/src/shared/btsnoop.c b/src/shared/btsnoop.c
|
|
index 0a68282..bb66962 100644
|
|
--- a/src/shared/btsnoop.c
|
|
+++ b/src/shared/btsnoop.c
|
|
@@ -25,6 +25,8 @@
|
|
|
|
#include "src/shared/btsnoop.h"
|
|
|
|
+#include "monitor/amlbt_fwlog.h"
|
|
+
|
|
struct btsnoop_hdr {
|
|
uint8_t id[8]; /* Identification Pattern */
|
|
uint32_t version; /* Version Number = 1 */
|
|
@@ -319,6 +321,15 @@ bool btsnoop_write_hci(struct btsnoop *btsnoop, struct timeval *tv,
|
|
{
|
|
uint32_t flags;
|
|
|
|
+ if (opcode == BTSNOOP_OPCODE_EVENT_PKT) {
|
|
+ const uint8_t *tmp = data;
|
|
+ if (tmp[0] == AMLBT_FWLOG_EVENT) {
|
|
+ ALOGD("cmd: 0x%02x", tmp[0]);
|
|
+ fwlog_record(tmp, size);
|
|
+ return true;
|
|
+ }
|
|
+ }
|
|
+
|
|
if (!btsnoop)
|
|
return false;
|
|
|
|
--
|
|
2.42.0
|
|
|