From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 339ACC00140 for ; Wed, 10 Aug 2022 09:00:51 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 50AD283C5E; Wed, 10 Aug 2022 11:00:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="pTVh7HQj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 13FCE8026A; Wed, 10 Aug 2022 11:00:46 +0200 (CEST) Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D87CA83F36 for ; Wed, 10 Aug 2022 11:00:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 61ED3B81B50; Wed, 10 Aug 2022 09:00:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA929C433C1; Wed, 10 Aug 2022 09:00:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660122041; bh=3TF0MvnZXJH23+jqTWhKEKLqiGnPjZqwXNVgEzRSP+8=; h=From:To:Cc:Subject:Date:From; b=pTVh7HQjfkDsMIM2NQD2e/s/V9XRscgikJT7VQulte3fKGjStgHufWTeTIvZAD24c rs5eDzO/oEsrAEoy9Q50gugQWaaOwLWOkx8fF/tXkdB/RcUnzsHfCOhALV7hqlAGTQ vvPrB+iRvoBZB8XaEyPtMaqBgMlceC6XlqBxCOkhtuu0EczIF6Fggu6dfgWcYnzN1D fmcreFBnwfioZXfUT/AeumqGuxMUQC+/Kek0Xpzzadw/tfOFxqVveK3IWL4FSvZAzM 9vElO6ecJ1fCqXScljt7GRkzNm8kMXeIHFDkV7XCStVNkX/p8q8/fExhXz4JazmtGR S4Dqb3UopTuMA== Received: by pali.im (Postfix) id E009B895; Wed, 10 Aug 2022 11:00:37 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Stefan Roese , =?UTF-8?q?Marek=20Beh=C3=BAn?= Cc: u-boot@lists.denx.de Subject: [PATCH] arm: mvebu: turris_omnia: Show MCU version Date: Wed, 10 Aug 2022 11:00:25 +0200 Message-Id: <20220810090025.8786-1-pali@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean There are already more MCU firmware versions for Turris Omnia in production, so display git commit (version) of the MCU firmware during U-Boot startup. It will help to identify what version of MCU firmware is Turris Omnia using. MCU firmware for Turris Omnia is open source and available at website: https://gitlab.nic.cz/turris/hw/omnia_hw_ctrl It can be updated from running system via i2c bus with this tool: https://gitlab.nic.cz/turris/omnia-mcutool Signed-off-by: Pali Rohár --- board/CZ.NIC/turris_omnia/turris_omnia.c | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c index 5ddd873d0250..caae8ce44695 100644 --- a/board/CZ.NIC/turris_omnia/turris_omnia.c +++ b/board/CZ.NIC/turris_omnia/turris_omnia.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -61,7 +62,9 @@ DECLARE_GLOBAL_DATA_PTR; enum mcu_commands { CMD_GET_STATUS_WORD = 0x01, CMD_GET_RESET = 0x09, + CMD_GET_FW_VERSION_APP = 0x0a, CMD_WATCHDOG_STATE = 0x0b, + CMD_GET_FW_VERSION_BOOT = 0x0e, /* available if STS_FEATURES_SUPPORTED bit set in status word */ CMD_GET_FEATURES = 0x10, @@ -428,6 +431,38 @@ static const char * const omnia_get_mcu_type(void) return mcu_types[stsword & STS_MCU_TYPE_MASK]; } +static const char * const omnia_get_mcu_version(void) +{ + static char version[82]; + u8 version_app[20]; + u8 version_boot[20]; + int ret; + + ret = omnia_mcu_read(CMD_GET_FW_VERSION_APP, &version_app, sizeof(version_app)); + if (ret) + return "unknown"; + + ret = omnia_mcu_read(CMD_GET_FW_VERSION_BOOT, &version_boot, sizeof(version_boot)); + if (ret) + return "unknown"; + + /* + * If git commits of MCU bootloader and MCU application are same then + * show version only once. If they are different then show both commits. + */ + if (!memcmp(version_app, version_boot, 20)) { + bin2hex(version, version_app, 20); + version[40] = '\0'; + } else { + bin2hex(version, version_boot, 20); + version[40] = '/'; + bin2hex(version + 41, version_app, 20); + version[81] = '\0'; + } + + return version; +} + /* * Define the DDR layout / topology here in the board file. This will * be used by the DDR3 init code in the SPL U-Boot version to configure @@ -944,6 +979,7 @@ int show_board_info(void) err = turris_atsha_otp_get_serial_number(&version_num, &serial_num); printf("Model: Turris Omnia\n"); printf(" MCU type: %s\n", omnia_get_mcu_type()); + printf(" MCU version: %s\n", omnia_get_mcu_version()); printf(" RAM size: %i MiB\n", omnia_get_ram_size_gb() * 1024); if (err) printf(" Serial Number: unknown\n"); -- 2.20.1