From patchwork Tue Jun 18 21:08:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sjoerd Simons X-Patchwork-Id: 1118340 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=collabora.co.uk Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45T11M6qzdz9s4Y for ; Wed, 19 Jun 2019 07:09:43 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 818EFC21F99; Tue, 18 Jun 2019 21:09:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_PASS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id A4E80C22006; Tue, 18 Jun 2019 21:09:13 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D62A3C22018; Tue, 18 Jun 2019 21:09:05 +0000 (UTC) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lists.denx.de (Postfix) with ESMTPS id 3A18CC22019 for ; Tue, 18 Jun 2019 21:09:02 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sjoerd) with ESMTPSA id B520F260ED4 Received: by beast.luon.net (Postfix, from userid 1000) id CFA623E057F; Tue, 18 Jun 2019 23:08:59 +0200 (CEST) From: Sjoerd Simons To: u-boot@lists.denx.de Date: Tue, 18 Jun 2019 23:08:59 +0200 Message-Id: <20190618210859.9901-1-sjoerd.simons@collabora.co.uk> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Cc: "NXP i.MX U-Boot Team" Subject: [U-Boot] [PATCH] imx :hab: Add hab version command X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" THe RVT data includes a major and minor version in its header parameter. Add a new command to print this out. Signed-off-by: Sjoerd Simons --- Unfortunately there doesn't seem to be a way to get the minor version of the hab ROM. While there is a get_version function pointer in the vector table it's documented to only be valid during the ROM phase and a quick hack to try and call it on my board always returned 1 :/. arch/arm/include/asm/mach-imx/hab.h | 1 + arch/arm/mach-imx/hab.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/arch/arm/include/asm/mach-imx/hab.h b/arch/arm/include/asm/mach-imx/hab.h index 95df88423c..5c82a148b4 100644 --- a/arch/arm/include/asm/mach-imx/hab.h +++ b/arch/arm/include/asm/mach-imx/hab.h @@ -189,6 +189,7 @@ typedef void hapi_clock_init_t(void); #define HAB_CID_ROM 0 /**< ROM Caller ID */ #define HAB_CID_UBOOT 1 /**< UBOOT Caller ID*/ +#define HAB_TAG_RVT 0xDD /* ROM Vector Table */ #define HAB_CMD_HDR 0xD4 /* CSF Header */ #define HAB_CMD_WRT_DAT 0xCC /* Write Data command tag */ #define HAB_CMD_CHK_DAT 0xCF /* Check Data command tag */ diff --git a/arch/arm/mach-imx/hab.c b/arch/arm/mach-imx/hab.c index d42a15e877..e8487932c0 100644 --- a/arch/arm/mach-imx/hab.c +++ b/arch/arm/mach-imx/hab.c @@ -365,6 +365,21 @@ static int do_hab_failsafe(cmd_tbl_t *cmdtp, int flag, int argc, return 0; } +static int do_hab_version(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + struct hab_hdr *hdr = (struct hab_hdr *)HAB_RVT_BASE; + + if (hdr->tag != HAB_TAG_RVT) { + printf("Unexpected header tag: %x\n", hdr->tag); + return CMD_RET_FAILURE; + } + + printf("HAB version: %d.%d\n", hdr->par >> 4, hdr->par & 0xf); + + return 0; +} + static int do_authenticate_image_or_failover(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { @@ -421,6 +436,12 @@ U_BOOT_CMD( "ivt_offset - hex offset of IVT in the image" ); +U_BOOT_CMD( + hab_version, 1, 0, do_hab_version, + "print HAB major/minor version", + "" + ); + #endif /* !defined(CONFIG_SPL_BUILD) */ /* Get CSF Header length */