Add FIT support for falcon boot
cover Add FIT support for falcon 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(-)
Signature · 1 line
2.7.4
PATCH 1/4 tools: pblimage: Fix address calculation
The image size should be added to the initial pbl command, not bit "ORed".
---
tools/pblimage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/pblimage.c +1 -1
@@ -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 ;
Signature · 1 line
2.7.4
PATCH 2/4 cmd: spl: Fix compiling warning
In reply to York SunFix warning "cast from pointer to integer of different size".
---
cmd/spl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
cmd/spl.c +4 -4
@@ -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--;
Signature · 1 line
2.7.4
PATCH 3/4 lib: Add Kconfig option SPL_GZIP and SPL_ZLIB
In reply to York SunUse these two options to enable gunzip support for SPL boot.
---
lib/Kconfig | 7 +++++++ lib/Makefile | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-)
lib/Kconfig +7 -0
@@ -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
lib/Makefile +2 -2
@@ -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/
Signature · 1 line
2.7.4
PATCH 4/4 spl: fit: Add FIT image support for falcon boot
In reply to York SunDetect the image type before going the route to boot OS. Last kernel image sets the entry point.
---
Kconfig | 7 +++++ common/spl/spl_fit.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++ include/image.h | 4 +++ 3 files changed, 83 insertions(+)
Kconfig +7 -0
@@ -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
common/spl/spl_fit.c +72 -0
95 lines not on this page · raw message
include/image.h +4 -0
@@ -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
Signature · 1 line
2.7.4
cover Add FIT support for falcon boot
In reply to York Sun+ Andre
Quoted 2 lines · York Sun
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
Quoted 17 lines
York Sun (4):
tools: pblimage: Fix address calculation
cmd: spl: Fix compiling warning
lib: AddKconfigoptionSPL_GZIPandSPL_ZLIB
spl: fit: Add FIT image support for falcon bootKconfig | 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(-)
cover Add FIT support for falcon boot
Quoted 4 lines · Lokesh Vutla
+ Andre
On Monday 15 May 2017 09:31 PM, York Sun wrote:
Quoted 8 lines
Quoted 2 lines
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.
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
cover Add FIT support for falcon boot
Hi York,
Quoted 12 lines · york sun
Quoted 11 lines · Lokesh Vutla
+ Andre
Quoted 2 lines · York Sun
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.
Quoted 6 lines
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
cover Add FIT support for falcon boot
Quoted 27 lines · Andre Przywara
Hi York,
Quoted 12 lines · york sun
Quoted 11 lines · Lokesh Vutla
+ Andre
Quoted 2 lines · York Sun
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.
Quoted 6 lines
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.
Thanks for the update.
York
cover Add FIT support for falcon boot
In reply to Andre PrzywaraQuoted 22 lines · Andre Przywara
Hi York,
Quoted 12 lines · york sun
Quoted 11 lines · Lokesh Vutla
+ Andre
Quoted 2 lines · York Sun
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.
Quoted 6 lines
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.
Quoted 5 lines
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
cover Add FIT support for falcon boot
On 09/06/17 19:48, york sun wrote:
Hi York,
Quoted 29 lines · Andre Przywara
Quoted 22 lines
Hi York,
Quoted 12 lines · york sun
Quoted 11 lines · Lokesh Vutla
+ Andre
Quoted 2 lines · York Sun
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.
Quoted 6 lines
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.
Quoted 5 lines
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.
Quoted 7 lines
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_pointis set to either the last image's entry point (if set), or to thespl_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.
Quoted 3 lines
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.
Quoted 4 lines
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.
Quoted 6 lines
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.
Quoted 19 lines
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(); }
Quoted 6 lines
/* 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.
Quoted 2 lines
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.
cover Add FIT support for falcon boot
Quoted 78 lines · André Przywara
On 09/06/17 19:48, york sun wrote:
Hi York,
Quoted 29 lines · Andre Przywara
Quoted 22 lines
Hi York,
Quoted 12 lines · york sun
Quoted 11 lines · Lokesh Vutla
+ Andre
Quoted 2 lines · York Sun
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.
Quoted 6 lines
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.
Quoted 5 lines
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.Quoted 7 lines
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_pointis set to either the last image's entry point (if set), or to thespl_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.Quoted 3 lines
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 ofCONFIG_OF_SEPARATE). Other than that U-Boot isn't very special.Quoted 4 lines
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.
Quoted 6 lines
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.
Quoted 4 lines
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.
Quoted 25 lines
Quoted 25 lines
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 */ }
Quoted 8 lines
Quoted 1 line
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?
Quoted 7 lines
Quoted 3 lines
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