Quantcast

[PATCH v1 0/4] Add FIT support for falcon boot

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH v1 0/4] Add FIT support for falcon boot

York Sun-3
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

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH v1 1/4] tools: pblimage: Fix address calculation

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

Signed-off-by: York Sun <[hidden email]>
---

 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

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH v1 2/4] cmd: spl: Fix compiling warning

York Sun-3
In reply to this post by York Sun-3
Fix warning "cast from pointer to integer of different size".

Signed-off-by: York Sun <[hidden email]>
---

 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

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH v1 3/4] lib: Add Kconfig option SPL_GZIP and SPL_ZLIB

York Sun-3
In reply to this post by York Sun-3
Use these two options to enable gunzip support for SPL boot.

Signed-off-by: York Sun <[hidden email]>
---

 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

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH v1 4/4] spl: fit: Add FIT image support for falcon boot

York Sun-3
In reply to this post by York Sun-3
Detect the image type before going the route to boot OS. Last kernel
image sets the entry point.

Signed-off-by: York Sun <[hidden email]>

---

 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

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH v1 0/4] Add FIT support for falcon boot

Lokesh Vutla
In reply to this post by York Sun-3
+ 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@.../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(-)
>
_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH v1 0/4] Add FIT support for falcon boot

York Sun-3
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

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH v1 0/4] Add FIT support for falcon boot

Andre Przywara-3
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
_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH v1 0/4] Add FIT support for falcon boot

York Sun-3
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
_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Loading...