All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 0/3] toradex: common: fix/improve config block handling
@ 2019-03-25 16:18 Marcel Ziswiler
  2019-03-25 16:18 ` [U-Boot] [PATCH v2 1/3] toradex: configblock: add an -y parameter to 'cfgblock create’ Marcel Ziswiler
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Marcel Ziswiler @ 2019-03-25 16:18 UTC (permalink / raw)
  To: u-boot


This series adds a -y parameter to cfgblock create command, unifies the
behaviour when the config block is missing and fixes an off-by-one
issue.

Changes in v2:
- Introduced a define for the Toradex OUI ("0x00142dUL") as suggested by
  Igor.
- Removed redundant comment as suggested by Igor.

Bhuvanchandra DV (1):
  toradex: common: unify behaviour when config block is missing

Dominik Sliwa (1):
  toradex: configblock: add an -y parameter to 'cfgblock create’

Marcel Ziswiler (1):
  tdx-cfg-block: fix off by one issue

 board/toradex/common/tdx-cfg-block.c | 41 ++++++++++++++++++----------
 board/toradex/common/tdx-common.c    | 34 ++++++++++++-----------
 2 files changed, 45 insertions(+), 30 deletions(-)

-- 
2.20.1

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

* [U-Boot] [PATCH v2 1/3] toradex: configblock: add an -y parameter to 'cfgblock create’
  2019-03-25 16:18 [U-Boot] [PATCH v2 0/3] toradex: common: fix/improve config block handling Marcel Ziswiler
@ 2019-03-25 16:18 ` Marcel Ziswiler
  2019-03-25 16:18 ` [U-Boot] [PATCH v2 2/3] toradex: common: unify behaviour when config block is missing Marcel Ziswiler
  2019-03-25 16:18 ` [U-Boot] [PATCH v2 3/3] tdx-cfg-block: fix off by one issue Marcel Ziswiler
  2 siblings, 0 replies; 5+ messages in thread
From: Marcel Ziswiler @ 2019-03-25 16:18 UTC (permalink / raw)
  To: u-boot

From: Dominik Sliwa <dominik.sliwa@toradex.com>

Add an optional -y parameter to 'cfgblock create’ to simplify
automation.

Signed-off-by: Dominik Sliwa <dominik.sliwa@toradex.com>
Acked-by: Stefan Agner <stefan.agner@toradex.com>
Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Reviewed-by: Igor Opaniuk <igor.opaniuk@toradex.com>

---

Changes in v2: None

 board/toradex/common/tdx-cfg-block.c | 39 ++++++++++++++++++----------
 1 file changed, 26 insertions(+), 13 deletions(-)

diff --git a/board/toradex/common/tdx-cfg-block.c b/board/toradex/common/tdx-cfg-block.c
index d4f5b1803a..2fcb998ae4 100644
--- a/board/toradex/common/tdx-cfg-block.c
+++ b/board/toradex/common/tdx-cfg-block.c
@@ -418,6 +418,7 @@ static int do_cfgblock_create(cmd_tbl_t *cmdtp, int flag, int argc,
 	int offset = 0;
 	int ret = CMD_RET_SUCCESS;
 	int err;
+	int force_overwrite = 0;
 
 	/* Allocate RAM area for config block */
 	config_block = memalign(ARCH_DMA_MINALIGN, size);
@@ -428,6 +429,11 @@ static int do_cfgblock_create(cmd_tbl_t *cmdtp, int flag, int argc,
 
 	memset(config_block, 0xff, size);
 
+	if (argc >= 3) {
+		if (argv[2][0] == '-' && argv[2][1] == 'y')
+			force_overwrite = 1;
+	}
+
 	read_tdx_cfg_block();
 	if (valid_cfgblock) {
 #if defined(CONFIG_TDX_CFG_BLOCK_IS_IN_NAND)
@@ -448,24 +454,31 @@ static int do_cfgblock_create(cmd_tbl_t *cmdtp, int flag, int argc,
 		       CONFIG_TDX_CFG_BLOCK_OFFSET);
 		goto out;
 #else
-		char message[CONFIG_SYS_CBSIZE];
-		sprintf(message,
-			"A valid Toradex config block is present, still recreate? [y/N] ");
+		if (!force_overwrite) {
+			char message[CONFIG_SYS_CBSIZE];
 
-		if (!cli_readline(message))
-			goto out;
+			sprintf(message,
+				"A valid Toradex config block is present, still recreate? [y/N] ");
 
-		if (console_buffer[0] != 'y' && console_buffer[0] != 'Y')
-			goto out;
+			if (!cli_readline(message))
+				goto out;
+
+			if (console_buffer[0] != 'y' &&
+			    console_buffer[0] != 'Y')
+				goto out;
+		}
 #endif
 	}
 
 	/* Parse new Toradex config block data... */
-	if (argc < 3)
+	if (argc < 3 || (force_overwrite && argc < 4)) {
 		err = get_cfgblock_interactive();
-	else
-		err = get_cfgblock_barcode(argv[2]);
-
+	} else {
+		if (force_overwrite)
+			err = get_cfgblock_barcode(argv[3]);
+		else
+			err = get_cfgblock_barcode(argv[2]);
+	}
 	if (err) {
 		ret = CMD_RET_FAILURE;
 		goto out;
@@ -549,8 +562,8 @@ static int do_cfgblock(cmd_tbl_t *cmdtp, int flag, int argc,
 }
 
 U_BOOT_CMD(
-	cfgblock, 3, 0, do_cfgblock,
+	cfgblock, 4, 0, do_cfgblock,
 	"Toradex config block handling commands",
-	"create [barcode] - (Re-)create Toradex config block\n"
+	"create [-y] [barcode] - (Re-)create Toradex config block\n"
 	"cfgblock reload - Reload Toradex config block from flash"
 );
-- 
2.20.1

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

* [U-Boot] [PATCH v2 2/3] toradex: common: unify behaviour when config block is missing
  2019-03-25 16:18 [U-Boot] [PATCH v2 0/3] toradex: common: fix/improve config block handling Marcel Ziswiler
  2019-03-25 16:18 ` [U-Boot] [PATCH v2 1/3] toradex: configblock: add an -y parameter to 'cfgblock create’ Marcel Ziswiler
@ 2019-03-25 16:18 ` Marcel Ziswiler
  2019-03-28 14:29   ` Igor Opaniuk
  2019-03-25 16:18 ` [U-Boot] [PATCH v2 3/3] tdx-cfg-block: fix off by one issue Marcel Ziswiler
  2 siblings, 1 reply; 5+ messages in thread
From: Marcel Ziswiler @ 2019-03-25 16:18 UTC (permalink / raw)
  To: u-boot

From: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com>

If the config block is missing, various things may fail or behave
strangely on certain modules. This patch unifies that behaviour by
using a fake MAC address, until user updates the config block.

Signed-off-by: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com>
Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>

---

Changes in v2:
- Introduced a define for the Toradex OUI ("0x00142dUL") as suggested by
  Igor.
- Removed redundant comment as suggested by Igor.

 board/toradex/common/tdx-common.c | 34 ++++++++++++++++---------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/board/toradex/common/tdx-common.c b/board/toradex/common/tdx-common.c
index fde230c955..2d560cceaf 100644
--- a/board/toradex/common/tdx-common.c
+++ b/board/toradex/common/tdx-common.c
@@ -12,6 +12,8 @@
 #include <asm/setup.h>
 #include "tdx-common.h"
 
+#define TORADEX_OUI 0x00142dUL
+
 #ifdef CONFIG_TDX_CFG_BLOCK
 static char tdx_serial_str[9];
 static char tdx_board_rev_str[6];
@@ -68,20 +70,25 @@ int show_board_info(void)
 	unsigned char ethaddr[6];
 
 	if (read_tdx_cfg_block()) {
-		printf("Missing Toradex config block\n");
+		printf("MISSING TORADEX CONFIG BLOCK\n");
+		tdx_eth_addr.oui = htonl(TORADEX_OUI << 8);
+		tdx_eth_addr.nic = htonl(tdx_serial << 8);
 		checkboard();
-		return 0;
+	} else {
+		sprintf(tdx_serial_str, "%08u", tdx_serial);
+		sprintf(tdx_board_rev_str, "V%1d.%1d%c",
+			tdx_hw_tag.ver_major,
+			tdx_hw_tag.ver_minor,
+			(char)tdx_hw_tag.ver_assembly + 'A');
+
+		env_set("serial#", tdx_serial_str);
+
+		printf("Model: Toradex %s %s, Serial# %s\n",
+		       toradex_modules[tdx_hw_tag.prodid],
+		       tdx_board_rev_str,
+		       tdx_serial_str);
 	}
 
-	/* board serial-number */
-	sprintf(tdx_serial_str, "%08u", tdx_serial);
-	sprintf(tdx_board_rev_str, "V%1d.%1d%c",
-		tdx_hw_tag.ver_major,
-		tdx_hw_tag.ver_minor,
-		(char)tdx_hw_tag.ver_assembly + 'A');
-
-	env_set("serial#", tdx_serial_str);
-
 	/*
 	 * Check if environment contains a valid MAC address,
 	 * set the one from config block if not
@@ -101,11 +108,6 @@ int show_board_info(void)
 	}
 #endif
 
-	printf("Model: Toradex %s %s, Serial# %s\n",
-	       toradex_modules[tdx_hw_tag.prodid],
-	       tdx_board_rev_str,
-	       tdx_serial_str);
-
 	return 0;
 }
 
-- 
2.20.1

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

* [U-Boot] [PATCH v2 3/3] tdx-cfg-block: fix off by one issue
  2019-03-25 16:18 [U-Boot] [PATCH v2 0/3] toradex: common: fix/improve config block handling Marcel Ziswiler
  2019-03-25 16:18 ` [U-Boot] [PATCH v2 1/3] toradex: configblock: add an -y parameter to 'cfgblock create’ Marcel Ziswiler
  2019-03-25 16:18 ` [U-Boot] [PATCH v2 2/3] toradex: common: unify behaviour when config block is missing Marcel Ziswiler
@ 2019-03-25 16:18 ` Marcel Ziswiler
  2 siblings, 0 replies; 5+ messages in thread
From: Marcel Ziswiler @ 2019-03-25 16:18 UTC (permalink / raw)
  To: u-boot

From: Marcel Ziswiler <marcel.ziswiler@toradex.com>

Fix toradex_modules array off by one issue potentially leading to
spurious printout during boot e.g.

    Model: Toradex  V1.2A,

instead of

    Model: Toradex UNKNOWN MODULE V1.2A.

Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Acked-by: Max Krummenacher <max.krummenacher@toradex.com>
Reviewed-by: Igor Opaniuk <igor.opaniuk@toradex.com>

---

Changes in v2: None

 board/toradex/common/tdx-cfg-block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/toradex/common/tdx-cfg-block.c b/board/toradex/common/tdx-cfg-block.c
index 2fcb998ae4..b90077bedc 100644
--- a/board/toradex/common/tdx-cfg-block.c
+++ b/board/toradex/common/tdx-cfg-block.c
@@ -261,7 +261,7 @@ int read_tdx_cfg_block(void)
 	}
 
 	/* Cap product id to avoid issues with a yet unknown one */
-	if (tdx_hw_tag.prodid > (sizeof(toradex_modules) /
+	if (tdx_hw_tag.prodid >= (sizeof(toradex_modules) /
 				  sizeof(toradex_modules[0])))
 		tdx_hw_tag.prodid = 0;
 
-- 
2.20.1

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

* [U-Boot] [PATCH v2 2/3] toradex: common: unify behaviour when config block is missing
  2019-03-25 16:18 ` [U-Boot] [PATCH v2 2/3] toradex: common: unify behaviour when config block is missing Marcel Ziswiler
@ 2019-03-28 14:29   ` Igor Opaniuk
  0 siblings, 0 replies; 5+ messages in thread
From: Igor Opaniuk @ 2019-03-28 14:29 UTC (permalink / raw)
  To: u-boot

Reviewed-by: Igor Opaniuk <igor.opaniuk@toradex.com>

On Mon, Mar 25, 2019 at 6:19 PM Marcel Ziswiler <marcel@ziswiler.com> wrote:
>
> From: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com>
>
> If the config block is missing, various things may fail or behave
> strangely on certain modules. This patch unifies that behaviour by
> using a fake MAC address, until user updates the config block.
>
> Signed-off-by: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com>
> Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
>
> ---
>
> Changes in v2:
> - Introduced a define for the Toradex OUI ("0x00142dUL") as suggested by
>   Igor.
> - Removed redundant comment as suggested by Igor.
>
>  board/toradex/common/tdx-common.c | 34 ++++++++++++++++---------------
>  1 file changed, 18 insertions(+), 16 deletions(-)
>
> diff --git a/board/toradex/common/tdx-common.c b/board/toradex/common/tdx-common.c
> index fde230c955..2d560cceaf 100644
> --- a/board/toradex/common/tdx-common.c
> +++ b/board/toradex/common/tdx-common.c
> @@ -12,6 +12,8 @@
>  #include <asm/setup.h>
>  #include "tdx-common.h"
>
> +#define TORADEX_OUI 0x00142dUL
> +
>  #ifdef CONFIG_TDX_CFG_BLOCK
>  static char tdx_serial_str[9];
>  static char tdx_board_rev_str[6];
> @@ -68,20 +70,25 @@ int show_board_info(void)
>         unsigned char ethaddr[6];
>
>         if (read_tdx_cfg_block()) {
> -               printf("Missing Toradex config block\n");
> +               printf("MISSING TORADEX CONFIG BLOCK\n");
> +               tdx_eth_addr.oui = htonl(TORADEX_OUI << 8);
> +               tdx_eth_addr.nic = htonl(tdx_serial << 8);
>                 checkboard();
> -               return 0;
> +       } else {
> +               sprintf(tdx_serial_str, "%08u", tdx_serial);
> +               sprintf(tdx_board_rev_str, "V%1d.%1d%c",
> +                       tdx_hw_tag.ver_major,
> +                       tdx_hw_tag.ver_minor,
> +                       (char)tdx_hw_tag.ver_assembly + 'A');
> +
> +               env_set("serial#", tdx_serial_str);
> +
> +               printf("Model: Toradex %s %s, Serial# %s\n",
> +                      toradex_modules[tdx_hw_tag.prodid],
> +                      tdx_board_rev_str,
> +                      tdx_serial_str);
>         }
>
> -       /* board serial-number */
> -       sprintf(tdx_serial_str, "%08u", tdx_serial);
> -       sprintf(tdx_board_rev_str, "V%1d.%1d%c",
> -               tdx_hw_tag.ver_major,
> -               tdx_hw_tag.ver_minor,
> -               (char)tdx_hw_tag.ver_assembly + 'A');
> -
> -       env_set("serial#", tdx_serial_str);
> -
>         /*
>          * Check if environment contains a valid MAC address,
>          * set the one from config block if not
> @@ -101,11 +108,6 @@ int show_board_info(void)
>         }
>  #endif
>
> -       printf("Model: Toradex %s %s, Serial# %s\n",
> -              toradex_modules[tdx_hw_tag.prodid],
> -              tdx_board_rev_str,
> -              tdx_serial_str);
> -
>         return 0;
>  }
>
> --
> 2.20.1
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot

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

end of thread, other threads:[~2019-03-28 14:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-25 16:18 [U-Boot] [PATCH v2 0/3] toradex: common: fix/improve config block handling Marcel Ziswiler
2019-03-25 16:18 ` [U-Boot] [PATCH v2 1/3] toradex: configblock: add an -y parameter to 'cfgblock create’ Marcel Ziswiler
2019-03-25 16:18 ` [U-Boot] [PATCH v2 2/3] toradex: common: unify behaviour when config block is missing Marcel Ziswiler
2019-03-28 14:29   ` Igor Opaniuk
2019-03-25 16:18 ` [U-Boot] [PATCH v2 3/3] tdx-cfg-block: fix off by one issue Marcel Ziswiler

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.