public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] arm: mvebu: turris_omnia: Show MCU version
@ 2022-08-10  9:00 Pali Rohár
  2022-08-10 17:57 ` Marek Behún
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Pali Rohár @ 2022-08-10  9:00 UTC (permalink / raw)
  To: Stefan Roese, Marek Behún; +Cc: u-boot

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 <pali@kernel.org>
---
 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 <dm/uclass.h>
 #include <dt-bindings/gpio/gpio.h>
 #include <fdt_support.h>
+#include <hexdump.h>
 #include <time.h>
 #include <linux/bitops.h>
 #include <linux/delay.h>
@@ -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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] arm: mvebu: turris_omnia: Show MCU version
  2022-08-10  9:00 [PATCH] arm: mvebu: turris_omnia: Show MCU version Pali Rohár
@ 2022-08-10 17:57 ` Marek Behún
  2022-08-17  6:17 ` Stefan Roese
  2022-08-23 14:59 ` Stefan Roese
  2 siblings, 0 replies; 4+ messages in thread
From: Marek Behún @ 2022-08-10 17:57 UTC (permalink / raw)
  To: Pali Rohár; +Cc: Stefan Roese, u-boot

On Wed, 10 Aug 2022 11:00:25 +0200
Pali Rohár <pali@kernel.org> wrote:

> +static const char * const omnia_get_mcu_version(void)

why the second const?

Marek

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] arm: mvebu: turris_omnia: Show MCU version
  2022-08-10  9:00 [PATCH] arm: mvebu: turris_omnia: Show MCU version Pali Rohár
  2022-08-10 17:57 ` Marek Behún
@ 2022-08-17  6:17 ` Stefan Roese
  2022-08-23 14:59 ` Stefan Roese
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Roese @ 2022-08-17  6:17 UTC (permalink / raw)
  To: Pali Rohár, Marek Behún; +Cc: u-boot

On 10.08.22 11:00, Pali Rohár wrote:
> 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 <pali@kernel.org>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   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 <dm/uclass.h>
>   #include <dt-bindings/gpio/gpio.h>
>   #include <fdt_support.h>
> +#include <hexdump.h>
>   #include <time.h>
>   #include <linux/bitops.h>
>   #include <linux/delay.h>
> @@ -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");

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] arm: mvebu: turris_omnia: Show MCU version
  2022-08-10  9:00 [PATCH] arm: mvebu: turris_omnia: Show MCU version Pali Rohár
  2022-08-10 17:57 ` Marek Behún
  2022-08-17  6:17 ` Stefan Roese
@ 2022-08-23 14:59 ` Stefan Roese
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Roese @ 2022-08-23 14:59 UTC (permalink / raw)
  To: Pali Rohár, Marek Behún; +Cc: u-boot

On 10.08.22 11:00, Pali Rohár wrote:
> 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 <pali@kernel.org>

Applied to u-boot-marvell/master

Thanks,
Stefan

> ---
>   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 <dm/uclass.h>
>   #include <dt-bindings/gpio/gpio.h>
>   #include <fdt_support.h>
> +#include <hexdump.h>
>   #include <time.h>
>   #include <linux/bitops.h>
>   #include <linux/delay.h>
> @@ -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");

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-08-23 14:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-10  9:00 [PATCH] arm: mvebu: turris_omnia: Show MCU version Pali Rohár
2022-08-10 17:57 ` Marek Behún
2022-08-17  6:17 ` Stefan Roese
2022-08-23 14:59 ` Stefan Roese

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox