All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 0/3] omap: Provide fastboot variables for fastboot.sh
@ 2017-05-22 16:16 Sam Protsenko
  2017-05-22 16:16 ` [U-Boot] [PATCH v2 1/3] omap: Add routine for setting fastboot variables Sam Protsenko
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Sam Protsenko @ 2017-05-22 16:16 UTC (permalink / raw)
  To: u-boot

fastboot.sh is a script used for flashing Android images for TI boards
(and can be found in corresponding AOSP sources). This script relies on
some fastboot variables, which can be accessed with "fastboot getvar"
command.

This patch series exports those variables, which fastboot.sh script
relies on. The list of added variables:
 - "cpu": CPU type (string, like "DRA752")
 - "secure": CPU security index (string, like "GP")
 - "board_rev": board revision (string, like "A.30")
 - "userdata_size": size of userdata partition (number, in KiB)

Variables are enabled for AM57x EVM and DRA7 EVM boards, which are
mainly supported TI boards, capable of Android running.

Changes in v2:
 - use get_device_type() instead of omap_get_cpu_type()
 - guard omap_set_fastboot_vars() with CONFIG_FASTBOOT_FLASH
 - use correct board names

Sam Protsenko (3):
  omap: Add routine for setting fastboot variables
  arm: am57xx: Set fastboot variables in environment
  arm: dra7: Set fastboot variables in environment

 arch/arm/include/asm/omap_common.h |   6 ++
 arch/arm/mach-omap2/utils.c        | 115 +++++++++++++++++++++++++++++++++++++
 board/ti/am57xx/board.c            |   1 +
 board/ti/dra7xx/evm.c              |   1 +
 4 files changed, 123 insertions(+)

-- 
2.11.0

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

* [U-Boot] [PATCH v2 1/3] omap: Add routine for setting fastboot variables
  2017-05-22 16:16 [U-Boot] [PATCH v2 0/3] omap: Provide fastboot variables for fastboot.sh Sam Protsenko
@ 2017-05-22 16:16 ` Sam Protsenko
  2017-05-23  1:25   ` Tom Rini
  2017-06-12 22:42   ` [U-Boot] [U-Boot, v2, " Tom Rini
  2017-05-22 16:16 ` [U-Boot] [PATCH v2 2/3] arm: am57xx: Set fastboot variables in environment Sam Protsenko
  2017-05-22 16:16 ` [U-Boot] [PATCH v2 3/3] arm: dra7: " Sam Protsenko
  2 siblings, 2 replies; 10+ messages in thread
From: Sam Protsenko @ 2017-05-22 16:16 UTC (permalink / raw)
  To: u-boot

This patch reuses new option, which allows us to expose variables
from environment to "fastboot getvar" command. Those variables must be
of "fastboot.%s" format.

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
---
Changes in v2:
 - use get_device_type() instead of omap_get_cpu_type()
 - guard omap_set_fastboot_vars() with CONFIG_FASTBOOT_FLASH
 - use correct board names

 arch/arm/include/asm/omap_common.h |   6 ++
 arch/arm/mach-omap2/utils.c        | 115 +++++++++++++++++++++++++++++++++++++
 2 files changed, 121 insertions(+)

diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h
index c1a70b15d0..a4bfa0c451 100644
--- a/arch/arm/include/asm/omap_common.h
+++ b/arch/arm/include/asm/omap_common.h
@@ -643,6 +643,12 @@ void omap_die_id_get_board_serial(struct tag_serialnr *serialnr);
 void omap_die_id_usbethaddr(void);
 void omap_die_id_display(void);
 
+#ifdef CONFIG_FASTBOOT_FLASH
+void omap_set_fastboot_vars(void);
+#else
+static inline void omap_set_fastboot_vars(void) { }
+#endif
+
 void recalibrate_iodelay(void);
 
 void omap_smc1(u32 service, u32 val);
diff --git a/arch/arm/mach-omap2/utils.c b/arch/arm/mach-omap2/utils.c
index 2d03ebfbd3..1d0b63350a 100644
--- a/arch/arm/mach-omap2/utils.c
+++ b/arch/arm/mach-omap2/utils.c
@@ -18,6 +18,121 @@ static void do_cancel_out(u32 *num, u32 *den, u32 factor)
 	}
 }
 
+#ifdef CONFIG_FASTBOOT_FLASH
+static void omap_set_fastboot_cpu(void)
+{
+	char *cpu;
+	u32 cpu_rev = omap_revision();
+
+	switch (cpu_rev) {
+	case DRA752_ES1_0:
+	case DRA752_ES1_1:
+	case DRA752_ES2_0:
+		cpu = "DRA752";
+		break;
+	case DRA722_ES1_0:
+	case DRA722_ES2_0:
+		cpu = "DRA722";
+		break;
+	default:
+		cpu = NULL;
+		printf("Warning: fastboot.cpu: unknown CPU rev: %u\n", cpu_rev);
+	}
+
+	setenv("fastboot.cpu", cpu);
+}
+
+static void omap_set_fastboot_secure(void)
+{
+	const char *secure;
+	u32 dev = get_device_type();
+
+	switch (dev) {
+	case EMU_DEVICE:
+		secure = "EMU";
+		break;
+	case HS_DEVICE:
+		secure = "HS";
+		break;
+	case GP_DEVICE:
+		secure = "GP";
+		break;
+	default:
+		secure = NULL;
+		printf("Warning: fastboot.secure: unknown CPU sec: %u\n", dev);
+	}
+
+	setenv("fastboot.secure", secure);
+}
+
+static void omap_set_fastboot_board_rev(void)
+{
+	const char *board_rev;
+
+	board_rev = getenv("board_rev");
+	if (board_rev == NULL)
+		printf("Warning: fastboot.board_rev: unknown board revision\n");
+
+	setenv("fastboot.board_rev", board_rev);
+}
+
+#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
+static u32 omap_mmc_get_part_size(const char *part)
+{
+	int res;
+	struct blk_desc *dev_desc;
+	disk_partition_t info;
+	u64 sz = 0;
+
+	dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
+	if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
+		error("invalid mmc device\n");
+		return 0;
+	}
+
+	res = part_get_info_by_name(dev_desc, part, &info);
+	if (res < 0) {
+		error("cannot find partition: '%s'\n", part);
+		return 0;
+	}
+
+	/* Calculate size in bytes */
+	sz = (info.size * (u64)info.blksz);
+	/* to KiB */
+	sz >>= 10;
+
+	return (u32)sz;
+}
+
+static void omap_set_fastboot_userdata_size(void)
+{
+	char buf[16];
+	u32 sz_kb;
+
+	sz_kb = omap_mmc_get_part_size("userdata");
+	if (sz_kb == 0) {
+		buf[0] = '\0';
+		printf("Warning: fastboot.userdata_size: unable to calc\n");
+	} else {
+		sprintf(buf, "%u", sz_kb);
+	}
+
+	setenv("fastboot.userdata_size", buf);
+}
+#else
+static inline void omap_set_fastboot_userdata_size(void)
+{
+}
+#endif /* CONFIG_FASTBOOT_FLASH_MMC_DEV */
+void omap_set_fastboot_vars(void)
+{
+	omap_set_fastboot_cpu();
+	omap_set_fastboot_secure();
+	omap_set_fastboot_board_rev();
+	omap_set_fastboot_userdata_size();
+}
+#endif /* CONFIG_FASTBOOT_FLASH */
+
 /*
  * Cancel out the denominator and numerator of a fraction
  * to get smaller numerator and denominator.
-- 
2.11.0

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

* [U-Boot] [PATCH v2 2/3] arm: am57xx: Set fastboot variables in environment
  2017-05-22 16:16 [U-Boot] [PATCH v2 0/3] omap: Provide fastboot variables for fastboot.sh Sam Protsenko
  2017-05-22 16:16 ` [U-Boot] [PATCH v2 1/3] omap: Add routine for setting fastboot variables Sam Protsenko
@ 2017-05-22 16:16 ` Sam Protsenko
  2017-05-23  1:18   ` Tom Rini
  2017-06-12 22:42   ` [U-Boot] [U-Boot, v2, " Tom Rini
  2017-05-22 16:16 ` [U-Boot] [PATCH v2 3/3] arm: dra7: " Sam Protsenko
  2 siblings, 2 replies; 10+ messages in thread
From: Sam Protsenko @ 2017-05-22 16:16 UTC (permalink / raw)
  To: u-boot

One can obtain those variables using next commands:

    $ fastboot getvar cpu
    $ fastboot getvar secure
    $ fastboot getvar board_rev
    $ fastboot getvar userdata_size

Those variables are needed for fastboot.sh script.

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
---
Changes in v2: None

 board/ti/am57xx/board.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/board/ti/am57xx/board.c b/board/ti/am57xx/board.c
index 3be697a6ea..c8ebcdbcc8 100644
--- a/board/ti/am57xx/board.c
+++ b/board/ti/am57xx/board.c
@@ -573,6 +573,7 @@ int board_late_init(void)
 			    val);
 
 	omap_die_id_serial();
+	omap_set_fastboot_vars();
 
 	am57x_idk_lcd_detect();
 
-- 
2.11.0

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

* [U-Boot] [PATCH v2 3/3] arm: dra7: Set fastboot variables in environment
  2017-05-22 16:16 [U-Boot] [PATCH v2 0/3] omap: Provide fastboot variables for fastboot.sh Sam Protsenko
  2017-05-22 16:16 ` [U-Boot] [PATCH v2 1/3] omap: Add routine for setting fastboot variables Sam Protsenko
  2017-05-22 16:16 ` [U-Boot] [PATCH v2 2/3] arm: am57xx: Set fastboot variables in environment Sam Protsenko
@ 2017-05-22 16:16 ` Sam Protsenko
  2017-05-23  1:18   ` Tom Rini
  2017-06-12 22:43   ` [U-Boot] [U-Boot, v2, " Tom Rini
  2 siblings, 2 replies; 10+ messages in thread
From: Sam Protsenko @ 2017-05-22 16:16 UTC (permalink / raw)
  To: u-boot

One can obtain those variables using next commands:

    $ fastboot getvar cpu
    $ fastboot getvar secure
    $ fastboot getvar board_rev
    $ fastboot getvar userdata_size

Those variables are needed for fastboot.sh script.

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
---
Changes in v2: None

 board/ti/dra7xx/evm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c
index 8c02addd08..7d36f03fa1 100644
--- a/board/ti/dra7xx/evm.c
+++ b/board/ti/dra7xx/evm.c
@@ -561,6 +561,7 @@ int board_late_init(void)
 		setenv("boot_fit", "1");
 
 	omap_die_id_serial();
+	omap_set_fastboot_vars();
 #endif
 	return 0;
 }
-- 
2.11.0

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

* [U-Boot] [PATCH v2 2/3] arm: am57xx: Set fastboot variables in environment
  2017-05-22 16:16 ` [U-Boot] [PATCH v2 2/3] arm: am57xx: Set fastboot variables in environment Sam Protsenko
@ 2017-05-23  1:18   ` Tom Rini
  2017-06-12 22:42   ` [U-Boot] [U-Boot, v2, " Tom Rini
  1 sibling, 0 replies; 10+ messages in thread
From: Tom Rini @ 2017-05-23  1:18 UTC (permalink / raw)
  To: u-boot

On Mon, May 22, 2017 at 07:16:41PM +0300, Sam Protsenko wrote:

> One can obtain those variables using next commands:
> 
>     $ fastboot getvar cpu
>     $ fastboot getvar secure
>     $ fastboot getvar board_rev
>     $ fastboot getvar userdata_size
> 
> Those variables are needed for fastboot.sh script.
> 
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170522/a7deb45b/attachment.sig>

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

* [U-Boot] [PATCH v2 3/3] arm: dra7: Set fastboot variables in environment
  2017-05-22 16:16 ` [U-Boot] [PATCH v2 3/3] arm: dra7: " Sam Protsenko
@ 2017-05-23  1:18   ` Tom Rini
  2017-06-12 22:43   ` [U-Boot] [U-Boot, v2, " Tom Rini
  1 sibling, 0 replies; 10+ messages in thread
From: Tom Rini @ 2017-05-23  1:18 UTC (permalink / raw)
  To: u-boot

On Mon, May 22, 2017 at 07:16:42PM +0300, Sam Protsenko wrote:

> One can obtain those variables using next commands:
> 
>     $ fastboot getvar cpu
>     $ fastboot getvar secure
>     $ fastboot getvar board_rev
>     $ fastboot getvar userdata_size
> 
> Those variables are needed for fastboot.sh script.
> 
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170522/afd6bb34/attachment.sig>

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

* [U-Boot] [PATCH v2 1/3] omap: Add routine for setting fastboot variables
  2017-05-22 16:16 ` [U-Boot] [PATCH v2 1/3] omap: Add routine for setting fastboot variables Sam Protsenko
@ 2017-05-23  1:25   ` Tom Rini
  2017-06-12 22:42   ` [U-Boot] [U-Boot, v2, " Tom Rini
  1 sibling, 0 replies; 10+ messages in thread
From: Tom Rini @ 2017-05-23  1:25 UTC (permalink / raw)
  To: u-boot

On Mon, May 22, 2017 at 07:16:40PM +0300, Sam Protsenko wrote:

> This patch reuses new option, which allows us to expose variables
> from environment to "fastboot getvar" command. Those variables must be
> of "fastboot.%s" format.
> 
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
> ---
> Changes in v2:
>  - use get_device_type() instead of omap_get_cpu_type()
>  - guard omap_set_fastboot_vars() with CONFIG_FASTBOOT_FLASH
>  - use correct board names
> 
>  arch/arm/include/asm/omap_common.h |   6 ++
>  arch/arm/mach-omap2/utils.c        | 115 +++++++++++++++++++++++++++++++++++++
>  2 files changed, 121 insertions(+)
> 
> diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h
> index c1a70b15d0..a4bfa0c451 100644
> --- a/arch/arm/include/asm/omap_common.h
> +++ b/arch/arm/include/asm/omap_common.h
> @@ -643,6 +643,12 @@ void omap_die_id_get_board_serial(struct tag_serialnr *serialnr);
>  void omap_die_id_usbethaddr(void);
>  void omap_die_id_display(void);
>  
> +#ifdef CONFIG_FASTBOOT_FLASH
> +void omap_set_fastboot_vars(void);
> +#else
> +static inline void omap_set_fastboot_vars(void) { }
> +#endif
> +
>  void recalibrate_iodelay(void);
>  
>  void omap_smc1(u32 service, u32 val);
> diff --git a/arch/arm/mach-omap2/utils.c b/arch/arm/mach-omap2/utils.c
> index 2d03ebfbd3..1d0b63350a 100644
> --- a/arch/arm/mach-omap2/utils.c
> +++ b/arch/arm/mach-omap2/utils.c
> @@ -18,6 +18,121 @@ static void do_cancel_out(u32 *num, u32 *den, u32 factor)
>  	}
>  }
>  
> +#ifdef CONFIG_FASTBOOT_FLASH
> +static void omap_set_fastboot_cpu(void)
> +{
> +	char *cpu;
> +	u32 cpu_rev = omap_revision();
> +
> +	switch (cpu_rev) {
> +	case DRA752_ES1_0:
> +	case DRA752_ES1_1:
> +	case DRA752_ES2_0:
> +		cpu = "DRA752";
> +		break;
> +	case DRA722_ES1_0:
> +	case DRA722_ES2_0:
> +		cpu = "DRA722";
> +		break;
> +	default:
> +		cpu = NULL;
> +		printf("Warning: fastboot.cpu: unknown CPU rev: %u\n", cpu_rev);
> +	}
> +
> +	setenv("fastboot.cpu", cpu);
> +}
> +
> +static void omap_set_fastboot_secure(void)
> +{
> +	const char *secure;
> +	u32 dev = get_device_type();
> +
> +	switch (dev) {
> +	case EMU_DEVICE:
> +		secure = "EMU";
> +		break;
> +	case HS_DEVICE:
> +		secure = "HS";
> +		break;
> +	case GP_DEVICE:
> +		secure = "GP";
> +		break;
> +	default:
> +		secure = NULL;
> +		printf("Warning: fastboot.secure: unknown CPU sec: %u\n", dev);
> +	}
> +
> +	setenv("fastboot.secure", secure);
> +}

OK, this shows that the code we have in
arch/arm/mach-omap2/am33xx/sys_info.c and
arch/arm/mach-omap2/hwinit-common.c and
arch/arm/mach-omap2/omap3/sys_info.c needs to get re-worked a bit so
that we:
- Don't bloat families that we won't have (since we know at build time
  what's possible)
- Don't repeat the same code in N places to check device type / family /
  PG.

Yes, this will require a little more work as the fastboot side is OK
with "DRA722", the question I have is can we construct that similar to
what omap_rev_string() does?  Thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170522/ae254c85/attachment.sig>

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

* [U-Boot] [U-Boot, v2, 1/3] omap: Add routine for setting fastboot variables
  2017-05-22 16:16 ` [U-Boot] [PATCH v2 1/3] omap: Add routine for setting fastboot variables Sam Protsenko
  2017-05-23  1:25   ` Tom Rini
@ 2017-06-12 22:42   ` Tom Rini
  1 sibling, 0 replies; 10+ messages in thread
From: Tom Rini @ 2017-06-12 22:42 UTC (permalink / raw)
  To: u-boot

On Mon, May 22, 2017 at 07:16:40PM +0300, Semen Protsenko wrote:

> This patch reuses new option, which allows us to expose variables
> from environment to "fastboot getvar" command. Those variables must be
> of "fastboot.%s" format.
> 
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170612/f6d6b469/attachment.sig>

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

* [U-Boot] [U-Boot, v2, 2/3] arm: am57xx: Set fastboot variables in environment
  2017-05-22 16:16 ` [U-Boot] [PATCH v2 2/3] arm: am57xx: Set fastboot variables in environment Sam Protsenko
  2017-05-23  1:18   ` Tom Rini
@ 2017-06-12 22:42   ` Tom Rini
  1 sibling, 0 replies; 10+ messages in thread
From: Tom Rini @ 2017-06-12 22:42 UTC (permalink / raw)
  To: u-boot

On Mon, May 22, 2017 at 07:16:41PM +0300, Semen Protsenko wrote:

> One can obtain those variables using next commands:
> 
>     $ fastboot getvar cpu
>     $ fastboot getvar secure
>     $ fastboot getvar board_rev
>     $ fastboot getvar userdata_size
> 
> Those variables are needed for fastboot.sh script.
> 
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
> Reviewed-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170612/0bbe5582/attachment.sig>

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

* [U-Boot] [U-Boot, v2, 3/3] arm: dra7: Set fastboot variables in environment
  2017-05-22 16:16 ` [U-Boot] [PATCH v2 3/3] arm: dra7: " Sam Protsenko
  2017-05-23  1:18   ` Tom Rini
@ 2017-06-12 22:43   ` Tom Rini
  1 sibling, 0 replies; 10+ messages in thread
From: Tom Rini @ 2017-06-12 22:43 UTC (permalink / raw)
  To: u-boot

On Mon, May 22, 2017 at 07:16:42PM +0300, Semen Protsenko wrote:

> One can obtain those variables using next commands:
> 
>     $ fastboot getvar cpu
>     $ fastboot getvar secure
>     $ fastboot getvar board_rev
>     $ fastboot getvar userdata_size
> 
> Those variables are needed for fastboot.sh script.
> 
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
> Reviewed-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170612/7852212e/attachment.sig>

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

end of thread, other threads:[~2017-06-12 22:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-22 16:16 [U-Boot] [PATCH v2 0/3] omap: Provide fastboot variables for fastboot.sh Sam Protsenko
2017-05-22 16:16 ` [U-Boot] [PATCH v2 1/3] omap: Add routine for setting fastboot variables Sam Protsenko
2017-05-23  1:25   ` Tom Rini
2017-06-12 22:42   ` [U-Boot] [U-Boot, v2, " Tom Rini
2017-05-22 16:16 ` [U-Boot] [PATCH v2 2/3] arm: am57xx: Set fastboot variables in environment Sam Protsenko
2017-05-23  1:18   ` Tom Rini
2017-06-12 22:42   ` [U-Boot] [U-Boot, v2, " Tom Rini
2017-05-22 16:16 ` [U-Boot] [PATCH v2 3/3] arm: dra7: " Sam Protsenko
2017-05-23  1:18   ` Tom Rini
2017-06-12 22:43   ` [U-Boot] [U-Boot, v2, " Tom Rini

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.