All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v1 0/4] Add FIT support for falcon boot
@ 2017-05-15 16:01 York Sun
  2017-05-15 16:01 ` [U-Boot] [PATCH v1 1/4] tools: pblimage: Fix address calculation York Sun
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: York Sun @ 2017-05-15 16:01 UTC (permalink / raw)
  To: u-boot

This patch set adds FIT support for falcon boot. GZIP is enabled
to supported compressed image.


York Sun (4):
  tools: pblimage: Fix address calculation
  cmd: spl: Fix compiling warning
  lib: Add Kconfig option SPL_GZIP and SPL_ZLIB
  spl: fit: Add FIT image support for falcon boot

 Kconfig              |  7 +++++
 cmd/spl.c            |  8 +++---
 common/spl/spl_fit.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/image.h      |  4 +++
 lib/Kconfig          |  7 +++++
 lib/Makefile         |  4 +--
 tools/pblimage.c     |  2 +-
 7 files changed, 97 insertions(+), 7 deletions(-)

-- 
2.7.4

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

* [U-Boot] [PATCH v1 1/4] tools: pblimage: Fix address calculation
  2017-05-15 16:01 [U-Boot] [PATCH v1 0/4] Add FIT support for falcon boot York Sun
@ 2017-05-15 16:01 ` York Sun
  2017-05-15 16:01 ` [U-Boot] [PATCH v1 2/4] cmd: spl: Fix compiling warning York Sun
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: York Sun @ 2017-05-15 16:01 UTC (permalink / raw)
  To: u-boot

The image size should be added to the initial pbl command, not bit
"ORed".

Signed-off-by: York Sun <york.sun@nxp.com>
---

 tools/pblimage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/pblimage.c b/tools/pblimage.c
index ffc3268..d25a733 100644
--- a/tools/pblimage.c
+++ b/tools/pblimage.c
@@ -293,7 +293,7 @@ int pblimage_check_params(struct image_tool_params *params)
 		pbi_crc_cmd2 = 0;
 		pbl_cmd_initaddr = params->addr & PBL_ADDR_24BIT_MASK;
 		pbl_cmd_initaddr |= PBL_ACS_CONT_CMD;
-		pbl_cmd_initaddr |= uboot_size;
+		pbl_cmd_initaddr += uboot_size;
 		pbl_end_cmd[0] = 0x09610000;
 		pbl_end_cmd[1] = 0x00000000;
 		pbl_end_cmd[2] = 0x096100c0;
-- 
2.7.4

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

* [U-Boot] [PATCH v1 2/4] cmd: spl: Fix compiling warning
  2017-05-15 16:01 [U-Boot] [PATCH v1 0/4] Add FIT support for falcon boot York Sun
  2017-05-15 16:01 ` [U-Boot] [PATCH v1 1/4] tools: pblimage: Fix address calculation York Sun
@ 2017-05-15 16:01 ` York Sun
  2017-05-15 16:01 ` [U-Boot] [PATCH v1 3/4] lib: Add Kconfig option SPL_GZIP and SPL_ZLIB York Sun
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: York Sun @ 2017-05-15 16:01 UTC (permalink / raw)
  To: u-boot

Fix warning "cast from pointer to integer of different size".

Signed-off-by: York Sun <york.sun@nxp.com>
---

 cmd/spl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/cmd/spl.c b/cmd/spl.c
index 057764a..562140a 100644
--- a/cmd/spl.c
+++ b/cmd/spl.c
@@ -108,12 +108,12 @@ static int spl_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	c = find_cmd_tbl(argv[1], &cmd_spl_export_sub[0],
 		ARRAY_SIZE(cmd_spl_export_sub));
-	if ((c) && ((int)c->cmd <= SPL_EXPORT_LAST)) {
+	if ((c) && ((long)c->cmd <= SPL_EXPORT_LAST)) {
 		argc -= 2;
 		argv += 2;
-		if (call_bootm(argc, argv, subcmd_list[(int)c->cmd]))
+		if (call_bootm(argc, argv, subcmd_list[(long)c->cmd]))
 			return -1;
-		switch ((int)c->cmd) {
+		switch ((long)c->cmd) {
 #ifdef CONFIG_OF_LIBFDT
 		case SPL_EXPORT_FDT:
 			printf("Argument image is now in RAM: 0x%p\n",
@@ -147,7 +147,7 @@ static int do_spl(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	c = find_cmd_tbl(argv[1], &cmd_spl_sub[0], ARRAY_SIZE(cmd_spl_sub));
 	if (c) {
-		cmd = (int)c->cmd;
+		cmd = (long)c->cmd;
 		switch (cmd) {
 		case SPL_EXPORT:
 			argc--;
-- 
2.7.4

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

* [U-Boot] [PATCH v1 3/4] lib: Add Kconfig option SPL_GZIP and SPL_ZLIB
  2017-05-15 16:01 [U-Boot] [PATCH v1 0/4] Add FIT support for falcon boot York Sun
  2017-05-15 16:01 ` [U-Boot] [PATCH v1 1/4] tools: pblimage: Fix address calculation York Sun
  2017-05-15 16:01 ` [U-Boot] [PATCH v1 2/4] cmd: spl: Fix compiling warning York Sun
@ 2017-05-15 16:01 ` York Sun
  2017-05-15 16:01 ` [U-Boot] [PATCH v1 4/4] spl: fit: Add FIT image support for falcon boot York Sun
  2017-05-16  5:35 ` [U-Boot] [PATCH v1 0/4] Add FIT " Lokesh Vutla
  4 siblings, 0 replies; 12+ messages in thread
From: York Sun @ 2017-05-15 16:01 UTC (permalink / raw)
  To: u-boot

Use these two options to enable gunzip support for SPL boot.

Signed-off-by: York Sun <york.sun@nxp.com>
---

 lib/Kconfig  | 7 +++++++
 lib/Makefile | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/Kconfig b/lib/Kconfig
index db09151..f730a07 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -150,6 +150,13 @@ config LZ4
 
 config LZO
 	bool
+
+config SPL_GZIP
+	bool "Enable gzip decompression support for SPL build"
+	select SPL_ZLIB
+
+config SPL_ZLIB
+	bool
 endmenu
 
 config ERRNO_STR
diff --git a/lib/Makefile b/lib/Makefile
index 23e9f1e..4412df1 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -11,7 +11,6 @@ obj-$(CONFIG_EFI) += efi/
 obj-$(CONFIG_EFI_LOADER) += efi_loader/
 obj-$(CONFIG_LZMA) += lzma/
 obj-$(CONFIG_LZO) += lzo/
-obj-$(CONFIG_ZLIB) += zlib/
 obj-$(CONFIG_BZIP2) += bzip2/
 obj-$(CONFIG_TIZEN) += tizen/
 obj-$(CONFIG_FIT) += libfdt/
@@ -25,7 +24,6 @@ obj-y += crc16.o
 obj-$(CONFIG_ERRNO_STR) += errno_str.o
 obj-$(CONFIG_FIT) += fdtdec_common.o
 obj-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o
-obj-$(CONFIG_GZIP) += gunzip.o
 obj-$(CONFIG_GZIP_COMPRESSED) += gzip.o
 obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += smbios.o
 obj-y += initcall.o
@@ -47,6 +45,8 @@ endif
 obj-$(CONFIG_$(SPL_)RSA) += rsa/
 obj-$(CONFIG_$(SPL_)SHA1) += sha1.o
 obj-$(CONFIG_$(SPL_)SHA256) += sha256.o
+obj-$(CONFIG_$(SPL_)ZLIB) += zlib/
+obj-$(CONFIG_$(SPL_)GZIP) += gunzip.o
 
 obj-$(CONFIG_SPL_SAVEENV) += qsort.o
 obj-$(CONFIG_$(SPL_)OF_LIBFDT) += libfdt/
-- 
2.7.4

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

* [U-Boot] [PATCH v1 4/4] spl: fit: Add FIT image support for falcon boot
  2017-05-15 16:01 [U-Boot] [PATCH v1 0/4] Add FIT support for falcon boot York Sun
                   ` (2 preceding siblings ...)
  2017-05-15 16:01 ` [U-Boot] [PATCH v1 3/4] lib: Add Kconfig option SPL_GZIP and SPL_ZLIB York Sun
@ 2017-05-15 16:01 ` York Sun
  2017-05-16  5:35 ` [U-Boot] [PATCH v1 0/4] Add FIT " Lokesh Vutla
  4 siblings, 0 replies; 12+ messages in thread
From: York Sun @ 2017-05-15 16:01 UTC (permalink / raw)
  To: u-boot

Detect the image type before going the route to boot OS. Last kernel
image sets the entry point.

Signed-off-by: York Sun <york.sun@nxp.com>

---

 Kconfig              |  7 +++++
 common/spl/spl_fit.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/image.h      |  4 +++
 3 files changed, 83 insertions(+)

diff --git a/Kconfig b/Kconfig
index 1cf990d..e850941 100644
--- a/Kconfig
+++ b/Kconfig
@@ -239,6 +239,13 @@ config SPL_FIT_IMAGE_POST_PROCESS
 	  injected into the FIT creation (i.e. the blobs would have been pre-
 	  processed before being added to the FIT image).
 
+config SPL_FIT_IMAGE_SECURE_VALIDATE
+	bool "Enable validation of FIT image after loaded by SPL"
+	depends on SPL_LOAD_FIT && SPL_OS_BOOT && CHAIN_OF_TRUST
+	help
+	  Enable secure boot validation on OS FIT image before extracting
+	  individual images.
+
 endif # FIT
 
 config OF_BOARD_SETUP
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index aae556f..cf23628 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -123,6 +123,9 @@ static int get_aligned_image_size(struct spl_load_info *info, int data_size,
 	return (data_size + info->bl_len - 1) / info->bl_len;
 }
 
+#ifndef CONFIG_SYS_BOOTM_LEN
+#define CONFIG_SYS_BOOTM_LEN 0x800000
+#endif
 int spl_load_simple_fit(struct spl_image_info *spl_image,
 			struct spl_load_info *info, ulong sector, void *fit)
 {
@@ -136,6 +139,12 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
 	int base_offset, align_len = ARCH_DMA_MINALIGN - 1;
 	int src_sector;
 	void *dst, *src;
+#ifdef CONFIG_SPL_FIT
+	const void *data;
+	size_t d_size;
+	int len;
+	uint8_t type, image_comp;
+#endif
 
 	/*
 	 * Figure out where the external images start. This is the base for the
@@ -180,7 +189,19 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
 		return -1;
 	}
 
+#ifdef CONFIG_SPL_FIT
+	data = fdt_getprop(fit, node, "type", &len);
+	if (data == NULL) {
+		printf("Cannot get image type\n");
+		return -1;
+	}
+	type = genimg_get_type_id(data);
+	if (type == IH_TYPE_KERNEL)
+		goto boot_kernel;
+#endif
+
 	/* Get its information and set up the spl_image structure */
+
 	data_offset = fdt_getprop_u32(fit, node, "data-offset");
 	data_size = fdt_getprop_u32(fit, node, "data-size");
 	load = fdt_getprop_u32(fit, node, "load");
@@ -254,4 +275,55 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
 	memcpy(dst, src, fdt_len);
 
 	return 0;
+
+#ifdef CONFIG_SPL_FIT
+boot_kernel:
+#ifdef CONFIG_SPL_FIT_IMAGE_SECURE_VALIDATE
+	board_fit_image_secure_validate(fit);
+#endif
+	for (; node >= 0; node = fdt_next_subnode(fit, node)) {
+		data = fdt_getprop(fit, node, "os", &len);
+		if (data == NULL)
+			spl_image->os = -1;
+		else
+			spl_image->os = genimg_get_os_id(data);
+
+		data = fdt_getprop(fit, node, "type", &len);
+		if (data == NULL) {
+			printf("Cannot get image type\n");
+			return -1;
+		}
+		load = fdt_getprop_u32(fit, node, "load");
+		type = genimg_get_type_id(data);
+		if (type == IH_TYPE_KERNEL) {
+			spl_image->load_addr = load;
+			spl_image->entry_point = load;
+		}
+		dst = (void *)load;
+		if (fit_image_get_data(fit, node, &data, &d_size)) {
+			printf("Cannot get image data/size\n");
+			return -1;
+		}
+		if (fit_image_get_comp(fit, node, &image_comp))
+			printf("Cannot get image compression format.\n");
+
+		debug("%s size %lx, data %p, %s\n",
+		      genimg_get_type_name(type),
+		      (ulong)d_size, dst,
+		      genimg_get_comp_name(image_comp));
+		if (image_comp == IH_COMP_GZIP && type == IH_TYPE_KERNEL) {
+#ifdef CONFIG_SPL_GZIP
+			if (gunzip(dst, CONFIG_SYS_BOOTM_LEN, (void *)data, &d_size))
+				puts("Uncompressing error\n");
+#else
+			puts("GZIP is not enabled\n");
+			return -EINVAL;
+#endif
+		} else {
+			memcpy(dst, data, d_size);
+		}
+	}
+
+	return 0;
+#endif
 }
diff --git a/include/image.h b/include/image.h
index 3f26f9b..10f5544 100644
--- a/include/image.h
+++ b/include/image.h
@@ -1274,6 +1274,10 @@ int board_fit_config_name_match(const char *name);
 void board_fit_image_post_process(void **p_image, size_t *p_size);
 #endif /* CONFIG_SPL_FIT_IMAGE_POST_PROCESS */
 
+#ifdef CONFIG_SPL_FIT_IMAGE_SECURE_VALIDATE
+void board_fit_image_secure_validate(void *fit);
+#endif
+
 /**
  * Mapping of image types to function handlers to be invoked on the associated
  * loaded images
-- 
2.7.4

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

* [U-Boot] [PATCH v1 0/4] Add FIT support for falcon boot
  2017-05-15 16:01 [U-Boot] [PATCH v1 0/4] Add FIT support for falcon boot York Sun
                   ` (3 preceding siblings ...)
  2017-05-15 16:01 ` [U-Boot] [PATCH v1 4/4] spl: fit: Add FIT image support for falcon boot York Sun
@ 2017-05-16  5:35 ` Lokesh Vutla
  2017-05-16 15:54   ` york sun
  4 siblings, 1 reply; 12+ messages in thread
From: Lokesh Vutla @ 2017-05-16  5:35 UTC (permalink / raw)
  To: u-boot

+ Andre


On Monday 15 May 2017 09:31 PM, York Sun wrote:
> This patch set adds FIT support for falcon boot. GZIP is enabled
> to supported compressed image.

Did you get a chance to look at Andre's "SPL: extend FIT loading
support"[1] patch series? This series addresses similar problem in a
more generic way.

[1] https://www.mail-archive.com/u-boot at lists.denx.de/msg246692.html

Thanks and regards,
Lokesh


> 
> 
> York Sun (4):
>   tools: pblimage: Fix address calculation
>   cmd: spl: Fix compiling warning
>   lib: Add Kconfig option SPL_GZIP and SPL_ZLIB
>   spl: fit: Add FIT image support for falcon boot
> 
>  Kconfig              |  7 +++++
>  cmd/spl.c            |  8 +++---
>  common/spl/spl_fit.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  include/image.h      |  4 +++
>  lib/Kconfig          |  7 +++++
>  lib/Makefile         |  4 +--
>  tools/pblimage.c     |  2 +-
>  7 files changed, 97 insertions(+), 7 deletions(-)
> 

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

* [U-Boot] [PATCH v1 0/4] Add FIT support for falcon boot
  2017-05-16  5:35 ` [U-Boot] [PATCH v1 0/4] Add FIT " Lokesh Vutla
@ 2017-05-16 15:54   ` york sun
  2017-05-19  9:56     ` Andre Przywara
  0 siblings, 1 reply; 12+ messages in thread
From: york sun @ 2017-05-16 15:54 UTC (permalink / raw)
  To: u-boot

On 05/15/2017 10:42 PM, Lokesh Vutla wrote:
> + Andre
>
>
> On Monday 15 May 2017 09:31 PM, York Sun wrote:
>> This patch set adds FIT support for falcon boot. GZIP is enabled
>> to supported compressed image.
>
> Did you get a chance to look at Andre's "SPL: extend FIT loading
> support"[1] patch series? This series addresses similar problem in a
> more generic way.
>
> [1] https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.mail-archive.com%2Fu-boot%40lists.denx.de%2Fmsg246692.html&data=01%7C01%7Cyork.sun%40nxp.com%7C63ec3a7e245445e2253d08d49c1e542b%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0&sdata=XrCyv6JBg02fwP7MEMo1hg8rVCOGnEQ741Hs0oLwZVg%3D&reserved=0

I only received partial patches from Andre's set. Looks like that set 
should cover my changes by supporting multiple images. I was focusing on 
a fast boot path for the past two months. I can rebase my patch once 
Andre's set is merged.

York

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

* [U-Boot] [PATCH v1 0/4] Add FIT support for falcon boot
  2017-05-16 15:54   ` york sun
@ 2017-05-19  9:56     ` Andre Przywara
  2017-05-19 15:15       ` york sun
  2017-06-09 18:48       ` york sun
  0 siblings, 2 replies; 12+ messages in thread
From: Andre Przywara @ 2017-05-19  9:56 UTC (permalink / raw)
  To: u-boot

Hi York,

On 16/05/17 16:54, york sun wrote:
> On 05/15/2017 10:42 PM, Lokesh Vutla wrote:
>> + Andre
>>
>>
>> On Monday 15 May 2017 09:31 PM, York Sun wrote:
>>> This patch set adds FIT support for falcon boot. GZIP is enabled
>>> to supported compressed image.
>>
>> Did you get a chance to look at Andre's "SPL: extend FIT loading
>> support"[1] patch series? This series addresses similar problem in a
>> more generic way.
>>
>> [1] https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.mail-archive.com%2Fu-boot%40lists.denx.de%2Fmsg246692.html&data=01%7C01%7Cyork.sun%40nxp.com%7C63ec3a7e245445e2253d08d49c1e542b%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0&sdata=XrCyv6JBg02fwP7MEMo1hg8rVCOGnEQ741Hs0oLwZVg%3D&reserved=0
> 
> I only received partial patches from Andre's set. Looks like that set 
> should cover my changes by supporting multiple images. I was focusing on 
> a fast boot path for the past two months. I can rebase my patch once 
> Andre's set is merged.

FYI: My patches have been merged into u-boot-sunxi/master[1], which is
based on origin/master as of earlier this week.
I take it they get merged into origin before -rc1, but meanwhile you
could base on u-boot-sunxi/master.

Cheers,
Andre.

[1] http://git.denx.de/?p=u-boot/u-boot-sunxi.git;a=shortlog

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

* [U-Boot] [PATCH v1 0/4] Add FIT support for falcon boot
  2017-05-19  9:56     ` Andre Przywara
@ 2017-05-19 15:15       ` york sun
  2017-06-09 18:48       ` york sun
  1 sibling, 0 replies; 12+ messages in thread
From: york sun @ 2017-05-19 15:15 UTC (permalink / raw)
  To: u-boot

On 05/19/2017 02:56 AM, Andre Przywara wrote:
> Hi York,
>
> On 16/05/17 16:54, york sun wrote:
>> On 05/15/2017 10:42 PM, Lokesh Vutla wrote:
>>> + Andre
>>>
>>>
>>> On Monday 15 May 2017 09:31 PM, York Sun wrote:
>>>> This patch set adds FIT support for falcon boot. GZIP is enabled
>>>> to supported compressed image.
>>>
>>> Did you get a chance to look at Andre's "SPL: extend FIT loading
>>> support"[1] patch series? This series addresses similar problem in a
>>> more generic way.
>>>
>>> [1] https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.mail-archive.com%2Fu-boot%40lists.denx.de%2Fmsg246692.html&data=01%7C01%7Cyork.sun%40nxp.com%7C63ec3a7e245445e2253d08d49c1e542b%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0&sdata=XrCyv6JBg02fwP7MEMo1hg8rVCOGnEQ741Hs0oLwZVg%3D&reserved=0
>>
>> I only received partial patches from Andre's set. Looks like that set
>> should cover my changes by supporting multiple images. I was focusing on
>> a fast boot path for the past two months. I can rebase my patch once
>> Andre's set is merged.
>
> FYI: My patches have been merged into u-boot-sunxi/master[1], which is
> based on origin/master as of earlier this week.
> I take it they get merged into origin before -rc1, but meanwhile you
> could base on u-boot-sunxi/master.
>
> Cheers,
> Andre.
>
> [1] https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgit.denx.de%2F%3Fp%3Du-boot%2Fu-boot-sunxi.git%3Ba%3Dshortlog&data=01%7C01%7Cyork.sun%40nxp.com%7C15aaad5759e8473cc8ca08d49e9d5f11%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0&sdata=yjdSr%2BloxYTaLql0nI2rfeLCVS3upXK7%2BO8IapUNkNA%3D&reserved=0
>

Thanks for the update.

York

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

* [U-Boot] [PATCH v1 0/4] Add FIT support for falcon boot
  2017-05-19  9:56     ` Andre Przywara
  2017-05-19 15:15       ` york sun
@ 2017-06-09 18:48       ` york sun
  2017-06-12 23:13         ` André Przywara
  1 sibling, 1 reply; 12+ messages in thread
From: york sun @ 2017-06-09 18:48 UTC (permalink / raw)
  To: u-boot

On 05/19/2017 02:56 AM, Andre Przywara wrote:
> Hi York,
> 
> On 16/05/17 16:54, york sun wrote:
>> On 05/15/2017 10:42 PM, Lokesh Vutla wrote:
>>> + Andre
>>>
>>>
>>> On Monday 15 May 2017 09:31 PM, York Sun wrote:
>>>> This patch set adds FIT support for falcon boot. GZIP is enabled
>>>> to supported compressed image.
>>>
>>> Did you get a chance to look at Andre's "SPL: extend FIT loading
>>> support"[1] patch series? This series addresses similar problem in a
>>> more generic way.
>>>
>>> [1] https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.mail-archive.com%2Fu-boot%40lists.denx.de%2Fmsg246692.html&data=01%7C01%7Cyork.sun%40nxp.com%7C63ec3a7e245445e2253d08d49c1e542b%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0&sdata=XrCyv6JBg02fwP7MEMo1hg8rVCOGnEQ741Hs0oLwZVg%3D&reserved=0
>>
>> I only received partial patches from Andre's set. Looks like that set
>> should cover my changes by supporting multiple images. I was focusing on
>> a fast boot path for the past two months. I can rebase my patch once
>> Andre's set is merged.
> 
> FYI: My patches have been merged into u-boot-sunxi/master[1], which is
> based on origin/master as of earlier this week.
> I take it they get merged into origin before -rc1, but meanwhile you
> could base on u-boot-sunxi/master.
> 

Andre,

Reading through your commits, I am glad to see you can support multiple 
images. My understanding is you use "loadables" to indicate extra images 
to load after loading U-Boot. The spl_image->entry_point is set to 
either the last image's entry point (if set), or to the 
spl_image->load_addr. Do I get it right?

When you process the images, if there is a "firmware" image, you presume 
it is U-Boot and load it. If no such image, you take the first image in 
"loadables", presuming it is U-Boot. Do I understand you correctly? In 
your example its file, you demonstrated multiple "firmware" images, and 
U-Boot has type of "standalone". Since you didn't put "firmware" in the 
config node, I presume you would hit the "loadables". Correct?

While I try to rebase my patch on top of yours, I realize you still 
presume U-Boot image always exists. This is what I am trying to change 
for falcon boot. I think the easiest way is to leave "firmware" node 
absent in config node, and check the image type before setting 
spl_image->os. After that I can follow the code flow to load ramdisk, 
etc. I just have to add the "loadables" into my its. How about this flow 
with pseudo code

node = spl_fit_get_image_node(fit, images, "firmware", 0);
if (node < 0) {
	node = spl_fit_get_image_node(fit, images, "loadables", 0);
	index = 1;
}
if (node < 0)
	return -1;

if (image_type(node) == IH_TYPE_KERNEL) {
	index = 0;	/* reset to first image */
} else {
	/* presuming U-Boot */
	spl_image->os = IH_OS_U_BOOT;
	continue_to_read_device_tree();
}

/* check if there are more images to load */
for (; ; index++) {
	/* keep existing code */
}

What do you think?

I will need to modify spl_load_fit_image() a little bit to support 
compressed kernel image.

York

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

* [U-Boot] [PATCH v1 0/4] Add FIT support for falcon boot
  2017-06-09 18:48       ` york sun
@ 2017-06-12 23:13         ` André Przywara
  2017-06-12 23:28           ` York Sun
  0 siblings, 1 reply; 12+ messages in thread
From: André Przywara @ 2017-06-12 23:13 UTC (permalink / raw)
  To: u-boot

On 09/06/17 19:48, york sun wrote:

Hi York,

> On 05/19/2017 02:56 AM, Andre Przywara wrote:
>> Hi York,
>>
>> On 16/05/17 16:54, york sun wrote:
>>> On 05/15/2017 10:42 PM, Lokesh Vutla wrote:
>>>> + Andre
>>>>
>>>>
>>>> On Monday 15 May 2017 09:31 PM, York Sun wrote:
>>>>> This patch set adds FIT support for falcon boot. GZIP is enabled
>>>>> to supported compressed image.
>>>>
>>>> Did you get a chance to look at Andre's "SPL: extend FIT loading
>>>> support"[1] patch series? This series addresses similar problem in a
>>>> more generic way.
>>>>
>>>> [1] https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.mail-archive.com%2Fu-boot%40lists.denx.de%2Fmsg246692.html&data=01%7C01%7Cyork.sun%40nxp.com%7C63ec3a7e245445e2253d08d49c1e542b%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0&sdata=XrCyv6JBg02fwP7MEMo1hg8rVCOGnEQ741Hs0oLwZVg%3D&reserved=0
>>>
>>> I only received partial patches from Andre's set. Looks like that set
>>> should cover my changes by supporting multiple images. I was focusing on
>>> a fast boot path for the past two months. I can rebase my patch once
>>> Andre's set is merged.
>>
>> FYI: My patches have been merged into u-boot-sunxi/master[1], which is
>> based on origin/master as of earlier this week.
>> I take it they get merged into origin before -rc1, but meanwhile you
>> could base on u-boot-sunxi/master.
>>
> 
> Andre,
> 
> Reading through your commits, I am glad to see you can support multiple 
> images. My understanding is you use "loadables" to indicate extra images 
> to load after loading U-Boot. The spl_image->entry_point is set to 
> either the last image's entry point (if set), or to the 
> spl_image->load_addr. Do I get it right?

The idea is to use the start address from the _first_ image that
provides an entry point.
So if the "firmware" image has one, this is used, if not, the first
image from the loadables section which provides an explicit "entry"
property wins.
This is used for Allwinner, where we want to load U-Boot and append the
right DTB, but need to branch into the Trusted Firmware image.

> When you process the images, if there is a "firmware" image, you presume 
> it is U-Boot and load it. If no such image, you take the first image in 
> "loadables", presuming it is U-Boot. Do I understand you correctly?

Yes, this is right.
This whole scheme is just meant to provide compatibility with the
existing behaviour (with just the single image load).
The whole reason why U-Boot proper is treated specially here is to be
able to append the right DTB, which has to be loaded right behind the
end of the U-Boot image (to match the expectation of
CONFIG_OF_SEPARATE). Other than that U-Boot isn't very special.

> In 
> your example its file, you demonstrated multiple "firmware" images, and 
> U-Boot has type of "standalone". Since you didn't put "firmware" in the 
> config node, I presume you would hit the "loadables". Correct?

Exactly. U-Boot proper is just a loadable here. This special treatment
of the "firmware" node is just there to support older .its files.
Not sure if that is really needed, as I would expect the .its file *for
the SPL* to be generated and shipped with U-Boot, though.

> While I try to rebase my patch on top of yours, I realize you still 
> presume U-Boot image always exists. This is what I am trying to change 
> for falcon boot. I think the easiest way is to leave "firmware" node 
> absent in config node, and check the image type before setting 
> spl_image->os. After that I can follow the code flow to load ramdisk, 
> etc.

So you want to load Linux directly, without U-Boot proper?
FWIW, I once made an setup where I still use U-Boot proper, but load the
kernel and initrd together with it (by the SPL), so the default
environment can just proceed to booti, without needing to load anything.

> I just have to add the "loadables" into my its. How about this flow 
> with pseudo code
> 
> node = spl_fit_get_image_node(fit, images, "firmware", 0);
> if (node < 0) {
> 	node = spl_fit_get_image_node(fit, images, "loadables", 0);
> 	index = 1;
> }
> if (node < 0)
> 	return -1;
> 
> if (image_type(node) == IH_TYPE_KERNEL) {
> 	index = 0;	/* reset to first image */
> } else {
> 	/* presuming U-Boot */
> 	spl_image->os = IH_OS_U_BOOT;
> 	continue_to_read_device_tree();
> }
> 
> /* check if there are more images to load */
> for (; ; index++) {
> 	/* keep existing code */
> }
> 
> What do you think?

Yes, that sounds correct. Actually I was already toying with the idea of
supporting special image types in the SPL (like the kernel here), but
didn't want to extend the tight SPL code just for the sake of it.
But since you have a use case, I think this is a sensible extension.
It might even be worse to make this more flexible and provide some means
to extend this support for further image types later.

> I will need to modify spl_load_fit_image() a little bit to support 
> compressed kernel image.

Please consider to protect it with #ifdefs to avoid bloating the SPL
image. On sunxi we are quite tight already for AArch64 ...

Cheers,
Andre.

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

* [U-Boot] [PATCH v1 0/4] Add FIT support for falcon boot
  2017-06-12 23:13         ` André Przywara
@ 2017-06-12 23:28           ` York Sun
  0 siblings, 0 replies; 12+ messages in thread
From: York Sun @ 2017-06-12 23:28 UTC (permalink / raw)
  To: u-boot

On 06/12/2017 04:16 PM, André Przywara wrote:
> On 09/06/17 19:48, york sun wrote:
> 
> Hi York,
> 
>> On 05/19/2017 02:56 AM, Andre Przywara wrote:
>>> Hi York,
>>>
>>> On 16/05/17 16:54, york sun wrote:
>>>> On 05/15/2017 10:42 PM, Lokesh Vutla wrote:
>>>>> + Andre
>>>>>
>>>>>
>>>>> On Monday 15 May 2017 09:31 PM, York Sun wrote:
>>>>>> This patch set adds FIT support for falcon boot. GZIP is enabled
>>>>>> to supported compressed image.
>>>>>
>>>>> Did you get a chance to look at Andre's "SPL: extend FIT loading
>>>>> support"[1] patch series? This series addresses similar problem in a
>>>>> more generic way.
>>>>>
>>>>> [1] https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.mail-archive.com%2Fu-boot%40lists.denx.de%2Fmsg246692.html&data=01%7C01%7Cyork.sun%40nxp.com%7C63ec3a7e245445e2253d08d49c1e542b%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0&sdata=XrCyv6JBg02fwP7MEMo1hg8rVCOGnEQ741Hs0oLwZVg%3D&reserved=0
>>>>
>>>> I only received partial patches from Andre's set. Looks like that set
>>>> should cover my changes by supporting multiple images. I was focusing on
>>>> a fast boot path for the past two months. I can rebase my patch once
>>>> Andre's set is merged.
>>>
>>> FYI: My patches have been merged into u-boot-sunxi/master[1], which is
>>> based on origin/master as of earlier this week.
>>> I take it they get merged into origin before -rc1, but meanwhile you
>>> could base on u-boot-sunxi/master.
>>>
>>
>> Andre,
>>
>> Reading through your commits, I am glad to see you can support multiple
>> images. My understanding is you use "loadables" to indicate extra images
>> to load after loading U-Boot. The spl_image->entry_point is set to
>> either the last image's entry point (if set), or to the
>> spl_image->load_addr. Do I get it right?
> 
> The idea is to use the start address from the _first_ image that
> provides an entry point.
> So if the "firmware" image has one, this is used, if not, the first
> image from the loadables section which provides an explicit "entry"
> property wins.
> This is used for Allwinner, where we want to load U-Boot and append the
> right DTB, but need to branch into the Trusted Firmware image.
> 
>> When you process the images, if there is a "firmware" image, you presume
>> it is U-Boot and load it. If no such image, you take the first image in
>> "loadables", presuming it is U-Boot. Do I understand you correctly?
> 
> Yes, this is right.
> This whole scheme is just meant to provide compatibility with the
> existing behaviour (with just the single image load).
> The whole reason why U-Boot proper is treated specially here is to be
> able to append the right DTB, which has to be loaded right behind the
> end of the U-Boot image (to match the expectation of
> CONFIG_OF_SEPARATE). Other than that U-Boot isn't very special.
> 
>> In
>> your example its file, you demonstrated multiple "firmware" images, and
>> U-Boot has type of "standalone". Since you didn't put "firmware" in the
>> config node, I presume you would hit the "loadables". Correct?
> 
> Exactly. U-Boot proper is just a loadable here. This special treatment
> of the "firmware" node is just there to support older .its files.
> Not sure if that is really needed, as I would expect the .its file *for
> the SPL* to be generated and shipped with U-Boot, though.
> 
>> While I try to rebase my patch on top of yours, I realize you still
>> presume U-Boot image always exists. This is what I am trying to change
>> for falcon boot. I think the easiest way is to leave "firmware" node
>> absent in config node, and check the image type before setting
>> spl_image->os. After that I can follow the code flow to load ramdisk,
>> etc.
> 
> So you want to load Linux directly, without U-Boot proper?
> FWIW, I once made an setup where I still use U-Boot proper, but load the
> kernel and initrd together with it (by the SPL), so the default
> environment can just proceed to booti, without needing to load anything.

I am trying to make the falcon boot work with FIT image. We only need 
the SPL part of U-Boot.

> 
>> I just have to add the "loadables" into my its. How about this flow
>> with pseudo code
>>
>> node = spl_fit_get_image_node(fit, images, "firmware", 0);
>> if (node < 0) {
>> 	node = spl_fit_get_image_node(fit, images, "loadables", 0);
>> 	index = 1;
>> }
>> if (node < 0)
>> 	return -1;
>>
>> if (image_type(node) == IH_TYPE_KERNEL) {
>> 	index = 0;	/* reset to first image */
>> } else {
>> 	/* presuming U-Boot */
>> 	spl_image->os = IH_OS_U_BOOT;
>> 	continue_to_read_device_tree();
>> }
>>
>> /* check if there are more images to load */
>> for (; ; index++) {
>> 	/* keep existing code */
>> }
>>
>> What do you think?
> 
> Yes, that sounds correct. Actually I was already toying with the idea of
> supporting special image types in the SPL (like the kernel here), but
> didn't want to extend the tight SPL code just for the sake of it.
> But since you have a use case, I think this is a sensible extension.
> It might even be worse to make this more flexible and provide some means
> to extend this support for further image types later.

I want to get rid of your "loadables" and use the "load" instead. If an 
image has load address, let's load it. What do you think?

> 
>> I will need to modify spl_load_fit_image() a little bit to support
>> compressed kernel image.
> 
> Please consider to protect it with #ifdefs to avoid bloating the SPL
> image. On sunxi we are quite tight already for AArch64 ...
> 

That's not a problem. I was thinking to use CONFIG_SPL_OS_BOOT and 
CONFIG_SPL_GZIP together.

York

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

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

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-15 16:01 [U-Boot] [PATCH v1 0/4] Add FIT support for falcon boot York Sun
2017-05-15 16:01 ` [U-Boot] [PATCH v1 1/4] tools: pblimage: Fix address calculation York Sun
2017-05-15 16:01 ` [U-Boot] [PATCH v1 2/4] cmd: spl: Fix compiling warning York Sun
2017-05-15 16:01 ` [U-Boot] [PATCH v1 3/4] lib: Add Kconfig option SPL_GZIP and SPL_ZLIB York Sun
2017-05-15 16:01 ` [U-Boot] [PATCH v1 4/4] spl: fit: Add FIT image support for falcon boot York Sun
2017-05-16  5:35 ` [U-Boot] [PATCH v1 0/4] Add FIT " Lokesh Vutla
2017-05-16 15:54   ` york sun
2017-05-19  9:56     ` Andre Przywara
2017-05-19 15:15       ` york sun
2017-06-09 18:48       ` york sun
2017-06-12 23:13         ` André Przywara
2017-06-12 23:28           ` York Sun

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.