From patchwork Wed Jan 27 00:01:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tedd Ho-Jeong An X-Patchwork-Id: 371684 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90715C433E0 for ; Wed, 27 Jan 2021 04:28:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5070520715 for ; Wed, 27 Jan 2021 04:28:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238679AbhA0E1r (ORCPT ); Tue, 26 Jan 2021 23:27:47 -0500 Received: from mga03.intel.com ([134.134.136.65]:38304 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389679AbhA0AG6 (ORCPT ); Tue, 26 Jan 2021 19:06:58 -0500 IronPort-SDR: h5VRoszl5it1STPadwl/mzibzwq/wSMpyWTYbd+buHi/16q7Mush9qJwZENFRGjarV6CdlGP7F WFUzYFZSGkOg== X-IronPort-AV: E=McAfee;i="6000,8403,9876"; a="180071626" X-IronPort-AV: E=Sophos;i="5.79,377,1602572400"; d="scan'208";a="180071626" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2021 16:01:06 -0800 IronPort-SDR: lZa2XQaHGIz1xsSUSc/BOzpUbXar3WQzIBk43IZl0lNttFTW6ciQUtMiwocsc1jAKC4Y0VXBmS rVSipsfNIj2Q== X-IronPort-AV: E=Sophos;i="5.79,377,1602572400"; d="scan'208";a="393897678" Received: from rkfoote-mobl1.amr.corp.intel.com ([10.251.7.251]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2021 16:01:05 -0800 Message-ID: Subject: [PATCH BlueZ] tools/bluemoon: Display FW version of firmware file From: Tedd Ho-Jeong An To: linux-bluetooth@vger.kernel.org Date: Tue, 26 Jan 2021 19:01:05 -0500 Organization: Intel Corporation User-Agent: Evolution 3.36.5 (3.36.5-1.fc32) MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Tedd Ho-Jeong An 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: