* [PATCH BlueZ v2 1/2] tools/bluemoon: Display FW version of firmware file
@ 2021-01-29 23:51 Tedd Ho-Jeong An
2021-01-29 23:51 ` [PATCH BlueZ v2 2/2] tools/bluemoon: Add support for checking other firware file types Tedd Ho-Jeong An
2021-01-30 0:06 ` [BlueZ,v2,1/2] tools/bluemoon: Display FW version of firmware file bluez.test.bot
0 siblings, 2 replies; 3+ messages in thread
From: Tedd Ho-Jeong An @ 2021-01-29 23:51 UTC (permalink / raw)
To: linux-bluetooth
From: Tedd Ho-Jeong An <tedd.an@intel.com>
This patch displays a FW version after parsing the WRITE_BOOT_PARAMS
command in the firmeare file. It also change the display type for
Module vendor and Date in the CSS header to hex for easy read.
---
tools/bluemoon.c | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/tools/bluemoon.c b/tools/bluemoon.c
index 8b62b1e7b..912f4f2a9 100644
--- a/tools/bluemoon.c
+++ b/tools/bluemoon.c
@@ -805,8 +805,10 @@ static void analyze_firmware(const char *path)
le32_to_cpu(css->header_version) >> 16,
le32_to_cpu(css->header_version) & 0xffff);
printf("Module ID:\t%u\n", le32_to_cpu(css->module_id));
- printf("Module vendor:\t%u\n", le32_to_cpu(css->module_vendor));
- printf("Date:\t\t%u\n", le32_to_cpu(css->date));
+ printf("Module vendor:\t0x%x\n", le32_to_cpu(css->module_vendor));
+ printf("Date:\t\t%04x-%02x-%02x\n", le32_to_cpu(css->date) >> 16,
+ le32_to_cpu(css->date) >> 8 & 0xff,
+ le32_to_cpu(css->date) & 0xff);
printf("Size:\t\t%u DWORDs / %u bytes\n", le32_to_cpu(css->size),
le32_to_cpu(css->size) * 4);
printf("Key size:\t%u DWORDs / %u bytes\n",
@@ -840,13 +842,29 @@ static void analyze_firmware(const char *path)
while (firmware_offset < firmware_size) {
uint16_t opcode;
uint8_t dlen;
+ struct cmd_write_boot_params *params;
opcode = get_le16(firmware_data + firmware_offset);
dlen = firmware_data[firmware_offset + 2];
switch (opcode) {
- case CMD_NO_OPERATION:
case CMD_WRITE_BOOT_PARAMS:
+ params = (void *)&firmware_data[firmware_offset + 3];
+ printf("Boot Parameters\n");
+ printf("Boot Address:\t0x%08x\n",
+ le32_to_cpu(params->boot_addr));
+ printf("FW Version(yy):\t%d (0x%02X)\n",
+ params->fw_build_yy + 2000,
+ params->fw_build_yy);
+ printf("FW Version(cw):\t%d (0x%02X)\n",
+ params->fw_build_cw,
+ params->fw_build_cw);
+ printf("FW Version(nn):\t%d (0x%02X)\n",
+ params->fw_build_nn,
+ params->fw_build_nn);
+
+ printf("\n");
+ case CMD_NO_OPERATION:
case CMD_MEMORY_WRITE:
break;
default:
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH BlueZ v2 2/2] tools/bluemoon: Add support for checking other firware file types.
2021-01-29 23:51 [PATCH BlueZ v2 1/2] tools/bluemoon: Display FW version of firmware file Tedd Ho-Jeong An
@ 2021-01-29 23:51 ` Tedd Ho-Jeong An
2021-01-30 0:06 ` [BlueZ,v2,1/2] tools/bluemoon: Display FW version of firmware file bluez.test.bot
1 sibling, 0 replies; 3+ messages in thread
From: Tedd Ho-Jeong An @ 2021-01-29 23:51 UTC (permalink / raw)
To: linux-bluetooth
From: Tedd Ho-Jeong An <tedd.an@intel.com>
There are more firmware files for Intel devices like .ddc, and .bseq.
This patch checks the file extenstion and analyze the firmware file.
---
tools/bluemoon.c | 131 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 131 insertions(+)
diff --git a/tools/bluemoon.c b/tools/bluemoon.c
index 912f4f2a9..5940fec9d 100644
--- a/tools/bluemoon.c
+++ b/tools/bluemoon.c
@@ -127,6 +127,8 @@ struct cmd_trigger_exception {
uint8_t type;
} __attribute__ ((packed));
+#define CMD_DDC_CONFIG_WRITE 0xfc8b
+
#define CMD_MEMORY_WRITE 0xfc8e
static struct bt_hci *hci_dev;
@@ -608,7 +610,10 @@ static const struct {
{ 0x0a, "iBT 2.1 (AG620)" },
{ 0x0b, "iBT 3.0 (LnP)" },
{ 0x0c, "iBT 3.0 (WsP)" },
+ { 0x11, "iBT 3.5 (JfP)" },
{ 0x12, "iBT 3.5 (ThP)" },
+ { 0x13, "iBT 3.5 (HrP)" },
+ { 0x14, "iBT 3.5 (CcP)" },
{ }
};
@@ -657,6 +662,16 @@ static void read_version_complete(const void *data, uint8_t size,
}
if (load_firmware) {
+ /* This option is only suppored for the legacy ROM produce,
+ * which can be identified by the fw_variant == 0x01
+ */
+ if (rsp->fw_variant != 0x01) {
+ printf("FW Variant: 0x%02x\n", rsp->fw_variant);
+ fprintf(stderr, "This device is not supported\n");
+ mainloop_quit();
+ return;
+ }
+
if (load_firmware_value) {
printf("Firmware: %s\n", load_firmware_value);
request_firmware(load_firmware_value);
@@ -735,6 +750,95 @@ static void read_version_complete(const void *data, uint8_t size,
mainloop_quit();
}
+struct ddc {
+ uint8_t size;
+ uint16_t id;
+ uint8_t value[0];
+} __attribute__ ((packed));
+
+static unsigned int analyze_ddc(uint8_t *data, ssize_t len)
+{
+ unsigned int ddc_num;
+ ssize_t offset;
+ struct ddc *ddc;
+
+ ddc_num = 0;
+ offset = 0;
+
+ while (offset < len) {
+ ddc = (void *)&data[offset];
+ offset += ddc->size + 1;
+ ddc_num++;
+ }
+
+ return ddc_num;
+}
+
+static void analyze_firmware_bseq(uint8_t *data, ssize_t len)
+{
+ struct cmd_write_bd_data *bddata = NULL;
+ unsigned int cmd_num;
+ unsigned int evt_num;
+ unsigned int ddc_num;
+ ssize_t offset;
+
+ offset = 0;
+ cmd_num = 0;
+ evt_num = 0;
+ ddc_num = 0;
+
+ while (offset < len) {
+ uint8_t type;
+ struct bt_hci_cmd_hdr *cmd_hdr;
+ struct bt_hci_evt_hdr *evt_hdr;
+
+ type = data[offset];
+ offset += 1;
+
+ /* Command */
+ if (type == 0x01) {
+ cmd_hdr = (void *)&data[offset];
+
+ if (cmd_hdr->opcode == CMD_WRITE_BD_DATA)
+ bddata = (void *)&data[offset + 3];
+
+ if (cmd_hdr->opcode == CMD_DDC_CONFIG_WRITE)
+ ddc_num = analyze_ddc((void *)&data[offset + 3],
+ cmd_hdr->plen);
+
+ offset += cmd_hdr->plen + sizeof(*cmd_hdr);
+ cmd_num++;
+
+ } else if (type == 0x02) {
+ evt_hdr = (void *)&data[offset];
+ offset += evt_hdr->plen + sizeof(*evt_hdr);
+ evt_num++;
+ } else {
+ fprintf(stderr, "Unknown type: 0x%02x\n", type);
+ return;
+ }
+
+ }
+
+ printf("Command count:\t%d\n", cmd_num);
+ printf("Event count:\t%d\n", evt_num);
+
+ if (bddata) {
+ printf("\n");
+ printf("BD Data Configuration\n");
+ printf("Features:\t%02X%02X %02X%02X %02X%02X %02X%02X\n",
+ bddata->features[7], bddata->features[6],
+ bddata->features[5], bddata->features[4],
+ bddata->features[3], bddata->features[2],
+ bddata->features[1], bddata->features[0]);
+ printf("LE Features:\t%02x\n", bddata->le_features);
+ printf("LMP Version:\t0x%02x\n", bddata->lmp_version);
+ }
+
+ if (ddc_num)
+ printf("Total DDC:\t%d\n", ddc_num);
+}
+
struct css_hdr {
uint32_t module_type;
uint32_t header_len;
@@ -753,6 +857,7 @@ static void analyze_firmware(const char *path)
{
unsigned int cmd_num = 0;
struct css_hdr *css;
+ const char *ext;
struct stat st;
ssize_t len;
int fd;
@@ -790,6 +895,32 @@ static void analyze_firmware(const char *path)
goto done;
}
+ /* Check the file extension for file type */
+ ext = strrchr(path, '.');
+ if (!ext) {
+ fprintf(stderr, "Unable to get the file extension from path\n");
+ goto done;
+ }
+
+ if (!strncmp(ext, ".ddc", 4)) {
+ printf("Firmware file type: DDC file\n\n");
+ cmd_num = analyze_ddc(firmware_data, len);
+ printf("Total DDC:\t%d\n", cmd_num);
+ goto done;
+
+ } else if (!strncmp(ext, ".bseq", 5)) {
+ printf("Firmware file type: BSEQ file\n\n");
+ analyze_firmware_bseq(firmware_data, len);
+ goto done;
+
+ } else if (!strncmp(ext, ".sfi", 4))
+ printf("Firmware file type: SFI file\n\n");
+
+ else {
+ fprintf(stderr, "Unknown file extension: %s\n", ext);
+ goto done;
+ }
+
if ((size_t) len < sizeof(*css)) {
fprintf(stderr, "Firmware file is too short\n");
goto done;
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [BlueZ,v2,1/2] tools/bluemoon: Display FW version of firmware file
2021-01-29 23:51 [PATCH BlueZ v2 1/2] tools/bluemoon: Display FW version of firmware file Tedd Ho-Jeong An
2021-01-29 23:51 ` [PATCH BlueZ v2 2/2] tools/bluemoon: Add support for checking other firware file types Tedd Ho-Jeong An
@ 2021-01-30 0:06 ` bluez.test.bot
1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2021-01-30 0:06 UTC (permalink / raw)
To: linux-bluetooth, hj.tedd.an
[-- Attachment #1: Type: text/plain, Size: 2168 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=424645
---Test result---
##############################
Test: CheckPatch - FAIL
Output:
tools/bluemoon: Add support for checking other firware file types.
WARNING:TYPO_SPELLING: 'firware' may be misspelled - perhaps 'firmware'?
#4:
Subject: [PATCH] tools/bluemoon: Add support for checking other firware file
^^^^^^^
WARNING:TYPO_SPELLING: 'extenstion' may be misspelled - perhaps 'extension'?
#8:
This patch checks the file extenstion and analyze the firmware file.
^^^^^^^^^^
WARNING:TYPO_SPELLING: 'suppored' may be misspelled - perhaps 'supported'?
#38: FILE: tools/bluemoon.c:665:
+ /* This option is only suppored for the legacy ROM produce,
^^^^^^^^
WARNING:PREFER_DEFINED_ATTRIBUTE_MACRO: Prefer __packed over __attribute__((packed))
#59: FILE: tools/bluemoon.c:757:
+} __attribute__ ((packed));
- total: 0 errors, 4 warnings, 168 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
"[PATCH] tools/bluemoon: Add support for checking other firware file" has style problems, please review.
NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPLIT_STRING SSCANF_TO_KSTRTO
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
##############################
Test: CheckGitLint - FAIL
Output:
tools/bluemoon: Add support for checking other firware file types.
1: T3 Title has trailing punctuation (.): "tools/bluemoon: Add support for checking other firware file types."
##############################
Test: CheckBuild - PASS
##############################
Test: MakeCheck - PASS
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-30 0:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-29 23:51 [PATCH BlueZ v2 1/2] tools/bluemoon: Display FW version of firmware file Tedd Ho-Jeong An
2021-01-29 23:51 ` [PATCH BlueZ v2 2/2] tools/bluemoon: Add support for checking other firware file types Tedd Ho-Jeong An
2021-01-30 0:06 ` [BlueZ,v2,1/2] tools/bluemoon: Display FW version of firmware file bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).