All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10] support for booting the compressed U-boot binary on Rockchip based SOC's
@ 2023-06-30 12:11 Manoj Sai
  2023-06-30 12:11 ` [PATCH 01/10] Makefile: Add support to generate GZIP compressed raw u-boot binary Manoj Sai
                   ` (11 more replies)
  0 siblings, 12 replies; 55+ messages in thread
From: Manoj Sai @ 2023-06-30 12:11 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: Da Xue, dsx724, Jagan Teki, Suniel Mahesh, Manoj Sai

This patchset adds the support on Rockchip based RK3399 and RK3328 SOC's 
that  compress the U-BOOT proper along with dtb and ATF in FIT image format.
Second stage bootloader(SPL) loads the compressed binaries, uncompress them and 
handover control to the next stage.
     
The size difference observed between uncompressed and compressed FIT images is nearly 67
to 70% and used two compression libraries,LZMA and GZIP. 

Patch 1/10  generate a GZIP-compressed raw U-boot binary using Makefile
Patch 2/10  address to store compressed U-BOOT raw binary using Kconfig
Patch 3/10  RAM location to store compressed U-BOOT raw binary for ROCKCHIP based RK3399 and RK3328 SOC's
Patch 4/10  uncompress the gzip U-BOOT binary and load the binaries if gzip compression supoort is enabled
Patch 5/10  generate a LZMA-compressed raw U-boot binary using Makefile
Patch 6/10  uncompress the lzma U-BOOT binary and load the binaries if lzma compression supoort is enabled
Patch 7/10  add u-boot-nodtb.bin.gz as an input binary in binman
Patch 8/10  add the GZIP compressed uboot raw binary to FIT image
Patch 9/10  add u-boot-nodtb.bin.lzma as an input binary in binman
Patch 10/10 add the LZMA compressed uboot raw binary to FIT image

Manoj Sai (10):
  Makefile: Add support to generate GZIP compressed raw u-boot binary
  spl: Kconfig: Address support for compressed U-BOOT raw binary
  rockchip: RAM location for the compressed U-BOOT raw binary
  spl: fit: support for booting a GZIP-compressed U-boot raw binary
  Makefile: Add support to generate LZMA compressed raw u-boot binary
  spl: fit: support for booting a LZMA-compressed U-boot raw binary
  binman: Add support for u-boot-nodtb.bin.gz as an input binary
  rockchip: Add GZIP compressed uboot raw binary to FIT image
  binman: Add support for u-boot-nodtb.bin.lzma as an input binary
  rockchip: Add LZMA compressed uboot raw binary to FIT image

 Makefile                                     |  6 ++++
 arch/arm/dts/rockchip-u-boot.dtsi            | 15 ++++++++
 arch/arm/mach-rockchip/Kconfig               |  3 ++
 common/spl/Kconfig                           | 15 ++++++++
 common/spl/spl_fit.c                         | 36 +++++++++++++++-----
 tools/binman/etype/283_u_boot_nodtb_lzma.dts | 11 ++++++
 tools/binman/etype/u_boot_nodtb_gzip.py      | 28 +++++++++++++++
 tools/binman/etype/u_boot_nodtb_lzma.py      | 28 +++++++++++++++
 tools/binman/ftest.py                        | 11 ++++++
 tools/binman/test/282_u_boot_nodtb_gzip.dts  | 11 ++++++
 10 files changed, 156 insertions(+), 8 deletions(-)
 create mode 100644 tools/binman/etype/283_u_boot_nodtb_lzma.dts
 create mode 100644 tools/binman/etype/u_boot_nodtb_gzip.py
 create mode 100644 tools/binman/etype/u_boot_nodtb_lzma.py
 create mode 100644 tools/binman/test/282_u_boot_nodtb_gzip.dts

-- 
2.25.1


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

* [PATCH 01/10] Makefile: Add support to generate GZIP compressed raw u-boot binary
  2023-06-30 12:11 [PATCH 00/10] support for booting the compressed U-boot binary on Rockchip based SOC's Manoj Sai
@ 2023-06-30 12:11 ` Manoj Sai
  2023-07-02 15:34   ` Simon Glass
  2023-06-30 12:11 ` [PATCH 02/10] spl: Kconfig: Address support for compressed U-BOOT raw binary Manoj Sai
                   ` (10 subsequent siblings)
  11 siblings, 1 reply; 55+ messages in thread
From: Manoj Sai @ 2023-06-30 12:11 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: Da Xue, dsx724, Jagan Teki, Suniel Mahesh, Manoj Sai

Add support for generating a GZIP-compressed raw U-boot binary.

Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
---
 Makefile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Makefile b/Makefile
index 444baaefd0..6e15ebd116 100644
--- a/Makefile
+++ b/Makefile
@@ -1312,6 +1312,9 @@ endif
 u-boot-nodtb.bin: u-boot FORCE
 	$(call if_changed,objcopy_uboot)
 	$(BOARD_SIZE_CHECK)
+ifeq ($(CONFIG_SPL_GZIP),y)
+	@gzip -k u-boot-nodtb.bin
+endif
 
 u-boot.ldr:	u-boot
 		$(CREATE_LDR_ENV)
-- 
2.25.1


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

* [PATCH 02/10] spl: Kconfig: Address support for compressed U-BOOT raw binary
  2023-06-30 12:11 [PATCH 00/10] support for booting the compressed U-boot binary on Rockchip based SOC's Manoj Sai
  2023-06-30 12:11 ` [PATCH 01/10] Makefile: Add support to generate GZIP compressed raw u-boot binary Manoj Sai
@ 2023-06-30 12:11 ` Manoj Sai
  2023-07-02 15:34   ` Simon Glass
  2023-06-30 12:11 ` [PATCH 03/10] rockchip: RAM location for the " Manoj Sai
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 55+ messages in thread
From: Manoj Sai @ 2023-06-30 12:11 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: Da Xue, dsx724, Jagan Teki, Suniel Mahesh, Manoj Sai

Add the support that ,if compression support is enabled in SPL
a location needs to be defined as the source address where
compressed U-BOOT raw binary will be stored.

spl_load_fit_image function takes care that, compressed U-Boot raw
binary which is placed at this address, will be uncompressed to default
CONFIG_SYS_TEXT_BASE location.

Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
---
 common/spl/Kconfig | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 2c042ad306..5dd1f3c469 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -1547,6 +1547,21 @@ config SPL_AT91_MCK_BYPASS
 	  The external source has to provide a stable clock on the XIN pin.
 	  If this option is disabled, the SoC expects a crystal oscillator
 	  that needs driving on both XIN and XOUT lines.
+choice
+	prompt "Location for compressed U-BOOT raw binary"
+	depends on SPL_GZIP || SPL_LZMA
+	default SPL_UBOOT_COMPRESSED_BINARY_FIT_USER_DEFINED_AREA
+
+config SPL_UBOOT_COMPRESSED_BINARY_FIT_USER_DEFINED_AREA
+	bool "compressed U-BOOT raw binary user-defined location"
+endchoice
+
+config SPL_UBOOT_COMPRESSED_BINARY_FIT_USER_DEF_ADDR
+	hex "Address of memory where compressed U-BOOT raw binary is stored"
+	depends on SPL_UBOOT_COMPRESSED_BINARY_FIT_USER_DEFINED_AREA
+	help
+	  The FIT image containing the compressed U-BOOT raw binary will be stored
+	  in an area defined at compilation time. This is the address for this area.
 endmenu
 
 config TPL
-- 
2.25.1


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

* [PATCH 03/10] rockchip: RAM location for the compressed U-BOOT raw binary
  2023-06-30 12:11 [PATCH 00/10] support for booting the compressed U-boot binary on Rockchip based SOC's Manoj Sai
  2023-06-30 12:11 ` [PATCH 01/10] Makefile: Add support to generate GZIP compressed raw u-boot binary Manoj Sai
  2023-06-30 12:11 ` [PATCH 02/10] spl: Kconfig: Address support for compressed U-BOOT raw binary Manoj Sai
@ 2023-06-30 12:11 ` Manoj Sai
  2023-07-02 15:34   ` Simon Glass
  2023-06-30 12:11 ` [PATCH 04/10] spl: fit: support for booting a GZIP-compressed U-boot " Manoj Sai
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 55+ messages in thread
From: Manoj Sai @ 2023-06-30 12:11 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: Da Xue, dsx724, Jagan Teki, Suniel Mahesh, Manoj Sai

Add the support that ,if compression support is enabled in SPL
a RAM location needs to be defined as the source address where
compressed U-BOOT raw binary will be stored.

spl_load_fit_image function takes care that, compressed U-Boot raw
binary which is placed at this address, will be uncompressed to default
CONFIG_SYS_TEXT_BASE location.

Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
---
 arch/arm/mach-rockchip/Kconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index 9d6d20bf8e..d8d9c1964d 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -520,6 +520,9 @@ config ROCKCHIP_SPI_IMAGE
 config LNX_KRNL_IMG_TEXT_OFFSET_BASE
 	default TEXT_BASE
 
+config SPL_UBOOT_COMPRESSED_BINARY_FIT_USER_DEF_ADDR
+	default 0x5000000 if ROCKCHIP_RK3399 || ROCKCHIP_RK3328
+
 source "arch/arm/mach-rockchip/px30/Kconfig"
 source "arch/arm/mach-rockchip/rk3036/Kconfig"
 source "arch/arm/mach-rockchip/rk3066/Kconfig"
-- 
2.25.1


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

* [PATCH 04/10] spl: fit: support for booting a GZIP-compressed U-boot raw binary
  2023-06-30 12:11 [PATCH 00/10] support for booting the compressed U-boot binary on Rockchip based SOC's Manoj Sai
                   ` (2 preceding siblings ...)
  2023-06-30 12:11 ` [PATCH 03/10] rockchip: RAM location for the " Manoj Sai
@ 2023-06-30 12:11 ` Manoj Sai
  2023-06-30 16:38   ` Xavier Drudis Ferran
  2023-06-30 12:11 ` [PATCH 05/10] Makefile: Add support to generate LZMA compressed raw u-boot binary Manoj Sai
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 55+ messages in thread
From: Manoj Sai @ 2023-06-30 12:11 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: Da Xue, dsx724, Jagan Teki, Suniel Mahesh, Manoj Sai

If GZIP Compression support is enabled, GZIP compressed U-Boot raw binary will
be at a specified RAM location which is defined at
UBOOT_COMPRESSED_BINARY_FIT_USER_DEF_ADDR  and will be assign it as
the source address.

gunzip function in spl_load_fit_image ,will decompress the GZIP compressed
U-Boot raw binary which is placed at source address to the default
CONFIG_SYS_TEXT_BASE location.

spl_load_fit_image function will load the decompressed U-Boot
raw binary, which is placed at the CONFIG_SYS_TEXT_BASE location.

Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
---
 common/spl/spl_fit.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 730639f756..e2101099ef 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -281,7 +281,12 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 			return 0;
 		}
 
-		src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
+		if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP)) {
+			src_ptr = map_sysmem(ALIGN(CONFIG_VAL(UBOOT_COMPRESSED_BINARY_FIT_USER_DEF_ADDR),
+						ARCH_DMA_MINALIGN), len);
+		} else {
+			src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
+		}
 		length = len;
 
 		overhead = get_aligned_image_overhead(info, offset);
@@ -319,11 +324,14 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 		board_fit_image_post_process(fit, node, &src, &length);
 
 	load_ptr = map_sysmem(load_addr, length);
-	if (IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP) {
-		size = length;
-		if (gunzip(load_ptr, CONFIG_SYS_BOOTM_LEN, src, &size)) {
-			puts("Uncompressing error\n");
-			return -EIO;
+
+	if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP)) {
+		if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP)) {
+			size = length;
+			if (gunzip(load_ptr, CONFIG_SYS_BOOTM_LEN, src, &size)) {
+				puts("Uncompressing error\n");
+				return -EIO;
+			}
 		}
 		length = size;
 	} else {
-- 
2.25.1


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

* [PATCH 05/10] Makefile: Add support to generate LZMA compressed raw u-boot binary
  2023-06-30 12:11 [PATCH 00/10] support for booting the compressed U-boot binary on Rockchip based SOC's Manoj Sai
                   ` (3 preceding siblings ...)
  2023-06-30 12:11 ` [PATCH 04/10] spl: fit: support for booting a GZIP-compressed U-boot " Manoj Sai
@ 2023-06-30 12:11 ` Manoj Sai
  2023-07-02 15:34   ` Simon Glass
  2023-06-30 12:11 ` [PATCH 06/10] spl: fit: support for booting a LZMA-compressed U-boot raw binary Manoj Sai
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 55+ messages in thread
From: Manoj Sai @ 2023-06-30 12:11 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: Da Xue, dsx724, Jagan Teki, Suniel Mahesh, Manoj Sai

Add support for generating LZMA compressed raw u-boot binary.

Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
---
 Makefile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Makefile b/Makefile
index 6e15ebd116..d4f453cce1 100644
--- a/Makefile
+++ b/Makefile
@@ -1315,6 +1315,9 @@ u-boot-nodtb.bin: u-boot FORCE
 ifeq ($(CONFIG_SPL_GZIP),y)
 	@gzip -k u-boot-nodtb.bin
 endif
+ifeq ($(CONFIG_SPL_LZMA),y)
+	@lzma -k u-boot-nodtb.bin
+endif
 
 u-boot.ldr:	u-boot
 		$(CREATE_LDR_ENV)
-- 
2.25.1


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

* [PATCH 06/10] spl: fit: support for booting a LZMA-compressed U-boot raw binary
  2023-06-30 12:11 [PATCH 00/10] support for booting the compressed U-boot binary on Rockchip based SOC's Manoj Sai
                   ` (4 preceding siblings ...)
  2023-06-30 12:11 ` [PATCH 05/10] Makefile: Add support to generate LZMA compressed raw u-boot binary Manoj Sai
@ 2023-06-30 12:11 ` Manoj Sai
  2023-07-02 15:34   ` Simon Glass
  2023-06-30 12:11 ` [PATCH 07/10] binman: Add support for u-boot-nodtb.bin.gz as an input binary Manoj Sai
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 55+ messages in thread
From: Manoj Sai @ 2023-06-30 12:11 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: Da Xue, dsx724, Jagan Teki, Suniel Mahesh, Manoj Sai

If LZMA Compression support is enabled, LZMA compressed U-Boot
raw binary will be at a specified RAM location which is defined
at UBOOT_COMPRESSED_BINARY_FIT_USER_DEF_ADDR and will be assign it as
the source address.

lzmaBuffToBuffDecompress function in spl_load_fit_image ,will decompress
the LZMA compressed U-Boot raw binary which is placed at source address
to the default CONFIG_SYS_TEXT_BASE location.

spl_load_fit_image function will load the decompressed U-Boot
raw binary, which is placed at the CONFIG_SYS_TEXT_BASE location.

Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
---
 common/spl/spl_fit.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index e2101099ef..b4e95d3fb5 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -17,6 +17,9 @@
 #include <asm/cache.h>
 #include <asm/global_data.h>
 #include <linux/libfdt.h>
+#include <lzma/LzmaTypes.h>
+#include <lzma/LzmaDec.h>
+#include <lzma/LzmaTools.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -239,14 +242,15 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 	bool external_data = false;
 
 	if (IS_ENABLED(CONFIG_SPL_FPGA) ||
-	    (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_GZIP))) {
+	    (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_GZIP)) ||
+	    (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_LZMA))) {
 		if (fit_image_get_type(fit, node, &type))
 			puts("Cannot get image type.\n");
 		else
 			debug("%s ", genimg_get_type_name(type));
 	}
 
-	if (IS_ENABLED(CONFIG_SPL_GZIP)) {
+	if (IS_ENABLED(CONFIG_SPL_GZIP) || IS_ENABLED(CONFIG_SPL_LZMA)) {
 		fit_image_get_comp(fit, node, &image_comp);
 		debug("%s ", genimg_get_comp_name(image_comp));
 	}
@@ -281,7 +285,8 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 			return 0;
 		}
 
-		if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP)) {
+		if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP) ||
+		    (IS_ENABLED(CONFIG_SPL_LZMA) && image_comp == IH_COMP_LZMA)) {
 			src_ptr = map_sysmem(ALIGN(CONFIG_VAL(UBOOT_COMPRESSED_BINARY_FIT_USER_DEF_ADDR),
 						ARCH_DMA_MINALIGN), len);
 		} else {
@@ -325,13 +330,20 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 
 	load_ptr = map_sysmem(load_addr, length);
 
-	if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP)) {
+	if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP) ||
+	    (IS_ENABLED(CONFIG_SPL_LZMA) && image_comp == IH_COMP_LZMA)) {
 		if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP)) {
 			size = length;
 			if (gunzip(load_ptr, CONFIG_SYS_BOOTM_LEN, src, &size)) {
 				puts("Uncompressing error\n");
 				return -EIO;
 			}
+		} else if ((IS_ENABLED(CONFIG_SPL_LZMA) && image_comp == IH_COMP_LZMA)) {
+			size = CONFIG_SYS_BOOTM_LEN;
+			if (lzmaBuffToBuffDecompress(load_ptr, &size, src, length)) {
+				puts("Uncompressing error\n");
+				return -EIO;
+			}
 		}
 		length = size;
 	} else {
-- 
2.25.1


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

* [PATCH 07/10] binman: Add support for u-boot-nodtb.bin.gz as an input binary
  2023-06-30 12:11 [PATCH 00/10] support for booting the compressed U-boot binary on Rockchip based SOC's Manoj Sai
                   ` (5 preceding siblings ...)
  2023-06-30 12:11 ` [PATCH 06/10] spl: fit: support for booting a LZMA-compressed U-boot raw binary Manoj Sai
@ 2023-06-30 12:11 ` Manoj Sai
  2023-07-02 15:34   ` Simon Glass
  2023-06-30 12:11 ` [PATCH 08/10] rockchip: Add GZIP compressed uboot raw binary to FIT image Manoj Sai
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 55+ messages in thread
From: Manoj Sai @ 2023-06-30 12:11 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: Da Xue, dsx724, Jagan Teki, Suniel Mahesh, Manoj Sai

Add an entry type for u-boot-nodtb.bin.gz, which is a GZIP compressed raw u-boot
binary and a simple test.

Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
---
 tools/binman/etype/u_boot_nodtb_gzip.py     | 28 +++++++++++++++++++++
 tools/binman/ftest.py                       |  5 ++++
 tools/binman/test/282_u_boot_nodtb_gzip.dts | 11 ++++++++
 3 files changed, 44 insertions(+)
 create mode 100644 tools/binman/etype/u_boot_nodtb_gzip.py
 create mode 100644 tools/binman/test/282_u_boot_nodtb_gzip.dts

diff --git a/tools/binman/etype/u_boot_nodtb_gzip.py b/tools/binman/etype/u_boot_nodtb_gzip.py
new file mode 100644
index 0000000000..e8afd3de57
--- /dev/null
+++ b/tools/binman/etype/u_boot_nodtb_gzip.py
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2023 Amarula Solutions India
+# Written by Suniel Mahesh <sunil@amarulasolutions.com>
+# Reference from Simon Glass <sjg@chromium.org>
+#
+# Entry-type module for 'u-boot-nodtb.bin.gz'
+#
+
+from binman.entry import Entry
+from binman.etype.blob import Entry_blob
+
+class Entry_u_boot_nodtb_gzip(Entry_blob):
+    """U-Boot compressed flat binary without device tree appended
+
+    Properties / Entry arguments:
+        - filename: Filename to include ('u-boot-nodtb.bin.gz')
+
+    This is the U-Boot compressed raw binary, before allowing it to relocate
+    itself at runtime it should be decompressed. It does not include a device
+    tree blob at the end of it so normally cannot work without it. You can add a
+    u-boot-dtb entry after this one, or use a u-boot entry instead, normally
+    expands to a section containing u-boot and u-boot-dtb
+    """
+    def __init__(self, section, etype, node):
+        super().__init__(section, etype, node)
+
+    def GetDefaultFilename(self):
+        return 'u-boot-nodtb.bin.gz'
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 43b4f850a6..933ebcbd35 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -42,6 +42,7 @@ from u_boot_pylib import tout
 # Contents of test files, corresponding to different entry types
 U_BOOT_DATA           = b'1234'
 U_BOOT_IMG_DATA       = b'img'
+U_BOOT_NODTB_GZ_DATA  = b'uboot nodtb gz'
 U_BOOT_SPL_DATA       = b'56780123456789abcdefghijklm'
 U_BOOT_TPL_DATA       = b'tpl9876543210fedcbazywvuts'
 U_BOOT_VPL_DATA       = b'vpl76543210fedcbazywxyz_'
@@ -6676,6 +6677,10 @@ fdt         fdtmap                Extract the devicetree blob from the fdtmap
                                 ['fit'])
         self.assertIn("Node '/fit': Missing tool: 'mkimage'", str(e.exception))
 
+    def testUBootnodtbBinGz(self):
+	"""Test that u-boot-nodtb.bin.gz can be put in a file"""
+	data = self._DoReadFile('279_u_boot_nodtb_gzip.dts')
+	self.assertEqual(U_BOOT_NODTB_GZ_DATA, data)
 
 if __name__ == "__main__":
     unittest.main()
diff --git a/tools/binman/test/282_u_boot_nodtb_gzip.dts b/tools/binman/test/282_u_boot_nodtb_gzip.dts
new file mode 100644
index 0000000000..79eecea202
--- /dev/null
+++ b/tools/binman/test/282_u_boot_nodtb_gzip.dts
@@ -0,0 +1,11 @@
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		u-boot-nodtb-bin-gz {
+		};
+	};
+};
-- 
2.25.1


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

* [PATCH 08/10] rockchip: Add GZIP compressed uboot raw binary to FIT image
  2023-06-30 12:11 [PATCH 00/10] support for booting the compressed U-boot binary on Rockchip based SOC's Manoj Sai
                   ` (6 preceding siblings ...)
  2023-06-30 12:11 ` [PATCH 07/10] binman: Add support for u-boot-nodtb.bin.gz as an input binary Manoj Sai
@ 2023-06-30 12:11 ` Manoj Sai
  2023-07-02 15:34   ` Simon Glass
  2023-06-30 12:11 ` [PATCH 09/10] binman: Add support for u-boot-nodtb.bin.lzma as an input binary Manoj Sai
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 55+ messages in thread
From: Manoj Sai @ 2023-06-30 12:11 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: Da Xue, dsx724, Jagan Teki, Suniel Mahesh, Manoj Sai

Add GZIP compressed uboot raw binary to FIT image.

Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
---
 arch/arm/dts/rockchip-u-boot.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi
index 2878b80926..6e95738923 100644
--- a/arch/arm/dts/rockchip-u-boot.dtsi
+++ b/arch/arm/dts/rockchip-u-boot.dtsi
@@ -48,11 +48,21 @@
 					type = "standalone";
 					os = "U-Boot";
 					arch = "arm64";
+#if defined(CONFIG_SPL_GZIP)
+					compression = "gzip";
+#else
 					compression = "none";
+#endif
 					load = <CONFIG_TEXT_BASE>;
 					entry = <CONFIG_TEXT_BASE>;
+#if defined(CONFIG_SPL_GZIP)
+					u-boot-nodtb-gzip {
+					};
+#else
 					u-boot-nodtb {
 					};
+#endif
+
 #ifdef CONFIG_SPL_FIT_SIGNATURE
 					hash {
 						algo = "sha256";
-- 
2.25.1


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

* [PATCH 09/10] binman: Add support for u-boot-nodtb.bin.lzma as an input binary
  2023-06-30 12:11 [PATCH 00/10] support for booting the compressed U-boot binary on Rockchip based SOC's Manoj Sai
                   ` (7 preceding siblings ...)
  2023-06-30 12:11 ` [PATCH 08/10] rockchip: Add GZIP compressed uboot raw binary to FIT image Manoj Sai
@ 2023-06-30 12:11 ` Manoj Sai
  2023-07-02 15:34   ` Simon Glass
  2023-06-30 12:11 ` [PATCH 10/10] rockchip: Add LZMA compressed uboot raw binary to FIT image Manoj Sai
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 55+ messages in thread
From: Manoj Sai @ 2023-06-30 12:11 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: Da Xue, dsx724, Jagan Teki, Suniel Mahesh, Manoj Sai

Add an entry type for u-boot-nodtb.bin.lzma, which is a LZMA compressed
raw u-boot binary and a simple test.

Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
---
 tools/binman/etype/283_u_boot_nodtb_lzma.dts | 11 ++++++++
 tools/binman/etype/u_boot_nodtb_lzma.py      | 28 ++++++++++++++++++++
 tools/binman/ftest.py                        |  6 +++++
 3 files changed, 45 insertions(+)
 create mode 100644 tools/binman/etype/283_u_boot_nodtb_lzma.dts
 create mode 100644 tools/binman/etype/u_boot_nodtb_lzma.py

diff --git a/tools/binman/etype/283_u_boot_nodtb_lzma.dts b/tools/binman/etype/283_u_boot_nodtb_lzma.dts
new file mode 100644
index 0000000000..d9a834acf6
--- /dev/null
+++ b/tools/binman/etype/283_u_boot_nodtb_lzma.dts
@@ -0,0 +1,11 @@
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		u-boot-nodtb-bin-lzma {
+		};
+	};
+};
diff --git a/tools/binman/etype/u_boot_nodtb_lzma.py b/tools/binman/etype/u_boot_nodtb_lzma.py
new file mode 100644
index 0000000000..c2874aa6e9
--- /dev/null
+++ b/tools/binman/etype/u_boot_nodtb_lzma.py
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2023 Amarula Solutions India
+# Written by Suniel Mahesh <sunil@amarulasolutions.com>
+# Reference from Simon Glass <sjg@chromium.org>
+#
+# Entry-type module for 'u-boot-nodtb.bin.lzma'
+#
+
+from binman.entry import Entry
+from binman.etype.blob import Entry_blob
+
+class Entry_u_boot_nodtb_lzma(Entry_blob):
+    """U-Boot compressed flat binary without device tree appended
+
+    Properties / Entry arguments:
+        - filename: Filename to include ('u-boot-nodtb.bin.lzma')
+
+    This is the U-Boot compressed raw binary, before allowing it to relocate
+    itself at runtime it should be decompressed. It does not include a device
+    tree blob at the end of it so normally cannot work without it. You can add a
+    u-boot-dtb entry after this one, or use a u-boot entry instead, normally
+    expands to a section containing u-boot and u-boot-dtb
+    """
+    def __init__(self, section, etype, node):
+        super().__init__(section, etype, node)
+
+    def GetDefaultFilename(self):
+        return 'u-boot-nodtb.bin.lzma'
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 933ebcbd35..d1715523d2 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -43,6 +43,7 @@ from u_boot_pylib import tout
 U_BOOT_DATA           = b'1234'
 U_BOOT_IMG_DATA       = b'img'
 U_BOOT_NODTB_GZ_DATA  = b'uboot nodtb gz'
+U_BOOT_NODTB_LZMA_DATA  = b'uboot nodtb lzma'
 U_BOOT_SPL_DATA       = b'56780123456789abcdefghijklm'
 U_BOOT_TPL_DATA       = b'tpl9876543210fedcbazywvuts'
 U_BOOT_VPL_DATA       = b'vpl76543210fedcbazywxyz_'
@@ -6682,5 +6683,10 @@ fdt         fdtmap                Extract the devicetree blob from the fdtmap
 	data = self._DoReadFile('279_u_boot_nodtb_gzip.dts')
 	self.assertEqual(U_BOOT_NODTB_GZ_DATA, data)
 
+   def testUBootnodtbBinLzma(self):
+	"""Test that u-boot-nodtb.bin.lzma can be put in a file"""
+	data = self._DoReadFile('280_u_boot_nodtb_lzma.dts')
+	self.assertEqual(U_BOOT_NODTB_LZMA_DATA, data)
+
 if __name__ == "__main__":
     unittest.main()
-- 
2.25.1


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

* [PATCH 10/10] rockchip: Add LZMA compressed uboot raw binary to FIT image
  2023-06-30 12:11 [PATCH 00/10] support for booting the compressed U-boot binary on Rockchip based SOC's Manoj Sai
                   ` (8 preceding siblings ...)
  2023-06-30 12:11 ` [PATCH 09/10] binman: Add support for u-boot-nodtb.bin.lzma as an input binary Manoj Sai
@ 2023-06-30 12:11 ` Manoj Sai
  2023-06-30 15:45 ` [PATCH 00/10] support for booting the compressed U-boot binary on Rockchip based SOC's Jonas Karlman
  2023-07-25  3:50 ` [PATCH v2 0/4] support for booting the compressed U-boot binary on Rockchip based ARM64 SOC's Manoj Sai
  11 siblings, 0 replies; 55+ messages in thread
From: Manoj Sai @ 2023-06-30 12:11 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: Da Xue, dsx724, Jagan Teki, Suniel Mahesh, Manoj Sai

Add LZMA compressed  uboot raw binary to FIT image.

Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
---
 arch/arm/dts/rockchip-u-boot.dtsi | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi
index 6e95738923..f8a6179c04 100644
--- a/arch/arm/dts/rockchip-u-boot.dtsi
+++ b/arch/arm/dts/rockchip-u-boot.dtsi
@@ -50,6 +50,8 @@
 					arch = "arm64";
 #if defined(CONFIG_SPL_GZIP)
 					compression = "gzip";
+#elif defined(CONFIG_SPL_LZMA)
+					compression = "lzma";
 #else
 					compression = "none";
 #endif
@@ -58,6 +60,9 @@
 #if defined(CONFIG_SPL_GZIP)
 					u-boot-nodtb-gzip {
 					};
+#elif defined(CONFIG_SPL_LZMA)
+					u-boot-nodtb-lzma {
+					};
 #else
 					u-boot-nodtb {
 					};
-- 
2.25.1


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

* Re: [PATCH 00/10] support for booting the compressed U-boot binary on Rockchip based SOC's
  2023-06-30 12:11 [PATCH 00/10] support for booting the compressed U-boot binary on Rockchip based SOC's Manoj Sai
                   ` (9 preceding siblings ...)
  2023-06-30 12:11 ` [PATCH 10/10] rockchip: Add LZMA compressed uboot raw binary to FIT image Manoj Sai
@ 2023-06-30 15:45 ` Jonas Karlman
  2023-07-25  3:50 ` [PATCH v2 0/4] support for booting the compressed U-boot binary on Rockchip based ARM64 SOC's Manoj Sai
  11 siblings, 0 replies; 55+ messages in thread
From: Jonas Karlman @ 2023-06-30 15:45 UTC (permalink / raw)
  To: Manoj Sai, Simon Glass, Philipp Tomsich, Kever Yang
  Cc: Da Xue, dsx724, Jagan Teki, Suniel Mahesh, u-boot

Hi,

On 2023-06-30 14:11, Manoj Sai wrote:
> This patchset adds the support on Rockchip based RK3399 and RK3328 SOC's 
> that  compress the U-BOOT proper along with dtb and ATF in FIT image format.
> Second stage bootloader(SPL) loads the compressed binaries, uncompress them and 
> handover control to the next stage.
>      
> The size difference observed between uncompressed and compressed FIT images is nearly 67
> to 70% and used two compression libraries,LZMA and GZIP. 

How much does this size difference and decompression affect boot times?

> 
> Patch 1/10  generate a GZIP-compressed raw U-boot binary using Makefile
> Patch 2/10  address to store compressed U-BOOT raw binary using Kconfig
> Patch 3/10  RAM location to store compressed U-BOOT raw binary for ROCKCHIP based RK3399 and RK3328 SOC's
> Patch 4/10  uncompress the gzip U-BOOT binary and load the binaries if gzip compression supoort is enabled
> Patch 5/10  generate a LZMA-compressed raw U-boot binary using Makefile
> Patch 6/10  uncompress the lzma U-BOOT binary and load the binaries if lzma compression supoort is enabled
> Patch 7/10  add u-boot-nodtb.bin.gz as an input binary in binman
> Patch 8/10  add the GZIP compressed uboot raw binary to FIT image
> Patch 9/10  add u-boot-nodtb.bin.lzma as an input binary in binman
> Patch 10/10 add the LZMA compressed uboot raw binary to FIT image

Instead of adding Makefile targets and custom binman etypes adding
support for on-the-fly compression to the fit etype if probably a better
option. E.g. when fit node has compression <> none, compress the data content
inside binman instead of relaying on binman nodes and Makefile output.

Regards,
Jonas

> 
> Manoj Sai (10):
>   Makefile: Add support to generate GZIP compressed raw u-boot binary
>   spl: Kconfig: Address support for compressed U-BOOT raw binary
>   rockchip: RAM location for the compressed U-BOOT raw binary
>   spl: fit: support for booting a GZIP-compressed U-boot raw binary
>   Makefile: Add support to generate LZMA compressed raw u-boot binary
>   spl: fit: support for booting a LZMA-compressed U-boot raw binary
>   binman: Add support for u-boot-nodtb.bin.gz as an input binary
>   rockchip: Add GZIP compressed uboot raw binary to FIT image
>   binman: Add support for u-boot-nodtb.bin.lzma as an input binary
>   rockchip: Add LZMA compressed uboot raw binary to FIT image
> 
>  Makefile                                     |  6 ++++
>  arch/arm/dts/rockchip-u-boot.dtsi            | 15 ++++++++
>  arch/arm/mach-rockchip/Kconfig               |  3 ++
>  common/spl/Kconfig                           | 15 ++++++++
>  common/spl/spl_fit.c                         | 36 +++++++++++++++-----
>  tools/binman/etype/283_u_boot_nodtb_lzma.dts | 11 ++++++
>  tools/binman/etype/u_boot_nodtb_gzip.py      | 28 +++++++++++++++
>  tools/binman/etype/u_boot_nodtb_lzma.py      | 28 +++++++++++++++
>  tools/binman/ftest.py                        | 11 ++++++
>  tools/binman/test/282_u_boot_nodtb_gzip.dts  | 11 ++++++
>  10 files changed, 156 insertions(+), 8 deletions(-)
>  create mode 100644 tools/binman/etype/283_u_boot_nodtb_lzma.dts
>  create mode 100644 tools/binman/etype/u_boot_nodtb_gzip.py
>  create mode 100644 tools/binman/etype/u_boot_nodtb_lzma.py
>  create mode 100644 tools/binman/test/282_u_boot_nodtb_gzip.dts
> 


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

* Re: [PATCH 04/10] spl: fit: support for booting a GZIP-compressed U-boot raw binary
  2023-06-30 12:11 ` [PATCH 04/10] spl: fit: support for booting a GZIP-compressed U-boot " Manoj Sai
@ 2023-06-30 16:38   ` Xavier Drudis Ferran
  0 siblings, 0 replies; 55+ messages in thread
From: Xavier Drudis Ferran @ 2023-06-30 16:38 UTC (permalink / raw)
  To: Manoj Sai
  Cc: Simon Glass, Philipp Tomsich, Kever Yang, u-boot, Da Xue, dsx724,
	Jagan Teki, Suniel Mahesh

El Fri, Jun 30, 2023 at 05:41:40PM +0530, Manoj Sai deia:
> If GZIP Compression support is enabled, GZIP compressed U-Boot raw binary will
> be at a specified RAM location which is defined at
> UBOOT_COMPRESSED_BINARY_FIT_USER_DEF_ADDR  and will be assign it as
> the source address.
> 
> gunzip function in spl_load_fit_image ,will decompress the GZIP compressed
> U-Boot raw binary which is placed at source address to the default
> CONFIG_SYS_TEXT_BASE location.
> 
> spl_load_fit_image function will load the decompressed U-Boot
> raw binary, which is placed at the CONFIG_SYS_TEXT_BASE location.
> 
> Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
> Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
> ---
>  common/spl/spl_fit.c | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
> index 730639f756..e2101099ef 100644
> --- a/common/spl/spl_fit.c
> +++ b/common/spl/spl_fit.c
> @@ -281,7 +281,12 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
>  			return 0;
>  		}
>  
> -		src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
> +		if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP)) {
> +			src_ptr = map_sysmem(ALIGN(CONFIG_VAL(UBOOT_COMPRESSED_BINARY_FIT_USER_DEF_ADDR),
> +						ARCH_DMA_MINALIGN), len);
> +		} else {
> +			src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
> +		}
>  		length = len;
>  
>  		overhead = get_aligned_image_overhead(info, offset);
> @@ -319,11 +324,14 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
>  		board_fit_image_post_process(fit, node, &src, &length);
>  
>  	load_ptr = map_sysmem(load_addr, length);
> -	if (IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP) {
> -		size = length;
> -		if (gunzip(load_ptr, CONFIG_SYS_BOOTM_LEN, src, &size)) {
> -			puts("Uncompressing error\n");
> -			return -EIO;
> +
> +	if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP)) {
> +		if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP)) {

You just repeated the same condition in a new if here ?

> +			size = length;
> +			if (gunzip(load_ptr, CONFIG_SYS_BOOTM_LEN, src, &size)) {
> +				puts("Uncompressing error\n");
> +				return -EIO;
> +			}
>  		}
>  		length = size;
>  	} else {
> -- 
> 2.25.1
> 

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

* Re: [PATCH 01/10] Makefile: Add support to generate GZIP compressed raw u-boot binary
  2023-06-30 12:11 ` [PATCH 01/10] Makefile: Add support to generate GZIP compressed raw u-boot binary Manoj Sai
@ 2023-07-02 15:34   ` Simon Glass
  2023-07-18  7:12     ` Manoj Sai
  0 siblings, 1 reply; 55+ messages in thread
From: Simon Glass @ 2023-07-02 15:34 UTC (permalink / raw)
  To: Manoj Sai
  Cc: Philipp Tomsich, Kever Yang, u-boot, Da Xue, dsx724, Jagan Teki,
	Suniel Mahesh

Hi Manoj,

On Fri, 30 Jun 2023 at 13:12, Manoj Sai
<abbaraju.manojsai@amarulasolutions.com> wrote:
>
> Add support for generating a GZIP-compressed raw U-boot binary.
>
> Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
> Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
> ---
>  Makefile | 3 +++
>  1 file changed, 3 insertions(+)

Please can you use binman to do that?

We are trying to remove the extra build rules in the Makefile.

>
> diff --git a/Makefile b/Makefile
> index 444baaefd0..6e15ebd116 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1312,6 +1312,9 @@ endif
>  u-boot-nodtb.bin: u-boot FORCE
>         $(call if_changed,objcopy_uboot)
>         $(BOARD_SIZE_CHECK)
> +ifeq ($(CONFIG_SPL_GZIP),y)
> +       @gzip -k u-boot-nodtb.bin
> +endif
>
>  u-boot.ldr:    u-boot
>                 $(CREATE_LDR_ENV)
> --
> 2.25.1
>

Regards,
Simon

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

* Re: [PATCH 02/10] spl: Kconfig: Address support for compressed U-BOOT raw binary
  2023-06-30 12:11 ` [PATCH 02/10] spl: Kconfig: Address support for compressed U-BOOT raw binary Manoj Sai
@ 2023-07-02 15:34   ` Simon Glass
  2023-07-25  3:48     ` Manoj Sai
  0 siblings, 1 reply; 55+ messages in thread
From: Simon Glass @ 2023-07-02 15:34 UTC (permalink / raw)
  To: Manoj Sai
  Cc: Philipp Tomsich, Kever Yang, u-boot, Da Xue, dsx724, Jagan Teki,
	Suniel Mahesh

Hi Manoj,

On Fri, 30 Jun 2023 at 13:12, Manoj Sai
<abbaraju.manojsai@amarulasolutions.com> wrote:
>
> Add the support that ,if compression support is enabled in SPL
> a location needs to be defined as the source address where
> compressed U-BOOT raw binary will be stored.
>
> spl_load_fit_image function takes care that, compressed U-Boot raw
> binary which is placed at this address, will be uncompressed to default
> CONFIG_SYS_TEXT_BASE location.
>
> Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
> Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
> ---
>  common/spl/Kconfig | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
>
> diff --git a/common/spl/Kconfig b/common/spl/Kconfig
> index 2c042ad306..5dd1f3c469 100644
> --- a/common/spl/Kconfig
> +++ b/common/spl/Kconfig
> @@ -1547,6 +1547,21 @@ config SPL_AT91_MCK_BYPASS
>           The external source has to provide a stable clock on the XIN pin.
>           If this option is disabled, the SoC expects a crystal oscillator
>           that needs driving on both XIN and XOUT lines.

blank line here

> +choice
> +       prompt "Location for compressed U-BOOT raw binary"

compressed U-Boot binary

> +       depends on SPL_GZIP || SPL_LZMA
> +       default SPL_UBOOT_COMPRESSED_BINARY_FIT_USER_DEFINED_AREA

missing help

This is too long and there is a lot ot redundancy.. How about SPL_GZIP_FROM_ADDR

> +
> +config SPL_UBOOT_COMPRESSED_BINARY_FIT_USER_DEFINED_AREA
> +       bool "compressed U-BOOT raw binary user-defined location"

missing help

blank line

> +endchoice

But you only have one thing in the choice, so can you just drop the
choice and use a bool instead?

> +
> +config SPL_UBOOT_COMPRESSED_BINARY_FIT_USER_DEF_ADDR

How about SPL_GZIP_LOADADDR?


> +       hex "Address of memory where compressed U-BOOT raw binary is stored"

U-Boot (please fix throughout)

> +       depends on SPL_UBOOT_COMPRESSED_BINARY_FIT_USER_DEFINED_AREA
> +       help
> +         The FIT image containing the compressed U-BOOT raw binary will be stored
> +         in an area defined at compilation time. This is the address for this area.
>  endmenu
>
>  config TPL
> --
> 2.25.1
>

Regards,
Simon

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

* Re: [PATCH 03/10] rockchip: RAM location for the compressed U-BOOT raw binary
  2023-06-30 12:11 ` [PATCH 03/10] rockchip: RAM location for the " Manoj Sai
@ 2023-07-02 15:34   ` Simon Glass
  0 siblings, 0 replies; 55+ messages in thread
From: Simon Glass @ 2023-07-02 15:34 UTC (permalink / raw)
  To: Manoj Sai
  Cc: Philipp Tomsich, Kever Yang, u-boot, Da Xue, dsx724, Jagan Teki,
	Suniel Mahesh

Hi Manoj,

On Fri, 30 Jun 2023 at 13:12, Manoj Sai
<abbaraju.manojsai@amarulasolutions.com> wrote:
>
> Add the support that ,if compression support is enabled in SPL
> a RAM location needs to be defined as the source address where
> compressed U-BOOT raw binary will be stored.
>
> spl_load_fit_image function takes care that, compressed U-Boot raw
> binary which is placed at this address, will be uncompressed to default
> CONFIG_SYS_TEXT_BASE location.

But isn't that where U-Boot runs from? So if you load it there, how
can you uncompress it to the same place?
Reviewed-by: Simon Glass <sjg@chromium.org>
Anyway I agree this is a sensible default.

>
> Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
> ---
>  arch/arm/mach-rockchip/Kconfig | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
> index 9d6d20bf8e..d8d9c1964d 100644
> --- a/arch/arm/mach-rockchip/Kconfig
> +++ b/arch/arm/mach-rockchip/Kconfig
> @@ -520,6 +520,9 @@ config ROCKCHIP_SPI_IMAGE
>  config LNX_KRNL_IMG_TEXT_OFFSET_BASE
>         default TEXT_BASE
>
> +config SPL_UBOOT_COMPRESSED_BINARY_FIT_USER_DEF_ADDR
> +       default 0x5000000 if ROCKCHIP_RK3399 || ROCKCHIP_RK3328
> +
>  source "arch/arm/mach-rockchip/px30/Kconfig"
>  source "arch/arm/mach-rockchip/rk3036/Kconfig"
>  source "arch/arm/mach-rockchip/rk3066/Kconfig"
> --
> 2.25.1
>

Reviewed-by: Simon Glass <sjg@chromium.org>

Regards,
Simon

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

* Re: [PATCH 05/10] Makefile: Add support to generate LZMA compressed raw u-boot binary
  2023-06-30 12:11 ` [PATCH 05/10] Makefile: Add support to generate LZMA compressed raw u-boot binary Manoj Sai
@ 2023-07-02 15:34   ` Simon Glass
  0 siblings, 0 replies; 55+ messages in thread
From: Simon Glass @ 2023-07-02 15:34 UTC (permalink / raw)
  To: Manoj Sai
  Cc: Philipp Tomsich, Kever Yang, u-boot, Da Xue, dsx724, Jagan Teki,
	Suniel Mahesh

Hi Manoj,

On Fri, 30 Jun 2023 at 13:12, Manoj Sai
<abbaraju.manojsai@amarulasolutions.com> wrote:
>
> Add support for generating LZMA compressed raw u-boot binary.
>
> Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
> Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
> ---
>  Makefile | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index 6e15ebd116..d4f453cce1 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1315,6 +1315,9 @@ u-boot-nodtb.bin: u-boot FORCE
>  ifeq ($(CONFIG_SPL_GZIP),y)
>         @gzip -k u-boot-nodtb.bin
>  endif
> +ifeq ($(CONFIG_SPL_LZMA),y)
> +       @lzma -k u-boot-nodtb.bin
> +endif
>
>  u-boot.ldr:    u-boot
>                 $(CREATE_LDR_ENV)
> --
> 2.25.1
>

Again, this should be in binman.

Regards,
Simon

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

* Re: [PATCH 06/10] spl: fit: support for booting a LZMA-compressed U-boot raw binary
  2023-06-30 12:11 ` [PATCH 06/10] spl: fit: support for booting a LZMA-compressed U-boot raw binary Manoj Sai
@ 2023-07-02 15:34   ` Simon Glass
  0 siblings, 0 replies; 55+ messages in thread
From: Simon Glass @ 2023-07-02 15:34 UTC (permalink / raw)
  To: Manoj Sai
  Cc: Philipp Tomsich, Kever Yang, u-boot, Da Xue, dsx724, Jagan Teki,
	Suniel Mahesh

Hi Manoj,

On Fri, 30 Jun 2023 at 13:12, Manoj Sai
<abbaraju.manojsai@amarulasolutions.com> wrote:
>
> If LZMA Compression support is enabled, LZMA compressed U-Boot
> raw binary will be at a specified RAM location which is defined
> at UBOOT_COMPRESSED_BINARY_FIT_USER_DEF_ADDR and will be assign it as
> the source address.
>
> lzmaBuffToBuffDecompress function in spl_load_fit_image ,will decompress
> the LZMA compressed U-Boot raw binary which is placed at source address
> to the default CONFIG_SYS_TEXT_BASE location.
>
> spl_load_fit_image function will load the decompressed U-Boot
> raw binary, which is placed at the CONFIG_SYS_TEXT_BASE location.
>
> Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
> Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
> ---
>  common/spl/spl_fit.c | 20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
> index e2101099ef..b4e95d3fb5 100644
> --- a/common/spl/spl_fit.c
> +++ b/common/spl/spl_fit.c
> @@ -17,6 +17,9 @@
>  #include <asm/cache.h>
>  #include <asm/global_data.h>
>  #include <linux/libfdt.h>
> +#include <lzma/LzmaTypes.h>
> +#include <lzma/LzmaDec.h>
> +#include <lzma/LzmaTools.h>
>
>  DECLARE_GLOBAL_DATA_PTR;
>
> @@ -239,14 +242,15 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
>         bool external_data = false;
>
>         if (IS_ENABLED(CONFIG_SPL_FPGA) ||
> -           (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_GZIP))) {
> +           (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_GZIP)) ||
> +           (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_LZMA))) {

This needs a refactor. You could do:

         if (IS_ENABLED(CONFIG_SPL_FPGA) ||
              (IS_ENABLED(CONFIG_SPL_OS_BOOT) &&
               (IS_ENABLED(CONFIG_SPL_GZIP) || IS_ENABLED(CONFIG_SPL_LZMA))

But I think it is better to creating a static inline functoin in spl.h, like:

static bool spl_compress_enabled()
{
    return IS_ENABLED(CONFIG_SPL_GZIP) || IS_ENABLED(CONFIG_SPL_LZMA);
}

and then use that in this patch.

>                 if (fit_image_get_type(fit, node, &type))
>                         puts("Cannot get image type.\n");
>                 else
>                         debug("%s ", genimg_get_type_name(type));
>         }
>
> -       if (IS_ENABLED(CONFIG_SPL_GZIP)) {
> +       if (IS_ENABLED(CONFIG_SPL_GZIP) || IS_ENABLED(CONFIG_SPL_LZMA)) {
>                 fit_image_get_comp(fit, node, &image_comp);
>                 debug("%s ", genimg_get_comp_name(image_comp));
>         }
> @@ -281,7 +285,8 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
>                         return 0;
>                 }
>
> -               if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP)) {
> +               if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP) ||
> +                   (IS_ENABLED(CONFIG_SPL_LZMA) && image_comp == IH_COMP_LZMA)) {
>                         src_ptr = map_sysmem(ALIGN(CONFIG_VAL(UBOOT_COMPRESSED_BINARY_FIT_USER_DEF_ADDR),

I think you should drop the ALIGN() and tell the user that the address
must be cached-aligned, in the Kconfig help, since it will be
confusing if it uses a different request from what was requested.

>                                                 ARCH_DMA_MINALIGN), len);
>                 } else {
> @@ -325,13 +330,20 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
>
>         load_ptr = map_sysmem(load_addr, length);
>
> -       if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP)) {
> +       if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP) ||
> +           (IS_ENABLED(CONFIG_SPL_LZMA) && image_comp == IH_COMP_LZMA)) {
>                 if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP)) {
>                         size = length;
>                         if (gunzip(load_ptr, CONFIG_SYS_BOOTM_LEN, src, &size)) {
>                                 puts("Uncompressing error\n");
>                                 return -EIO;
>                         }
> +               } else if ((IS_ENABLED(CONFIG_SPL_LZMA) && image_comp == IH_COMP_LZMA)) {
> +                       size = CONFIG_SYS_BOOTM_LEN;
> +                       if (lzmaBuffToBuffDecompress(load_ptr, &size, src, length)) {
> +                               puts("Uncompressing error\n");
> +                               return -EIO;
> +                       }
>                 }
>                 length = size;
>         } else {
> --
> 2.25.1
>

Can you use the existing image_decomp() instead?

Regards,
Simon

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

* Re: [PATCH 07/10] binman: Add support for u-boot-nodtb.bin.gz as an input binary
  2023-06-30 12:11 ` [PATCH 07/10] binman: Add support for u-boot-nodtb.bin.gz as an input binary Manoj Sai
@ 2023-07-02 15:34   ` Simon Glass
  0 siblings, 0 replies; 55+ messages in thread
From: Simon Glass @ 2023-07-02 15:34 UTC (permalink / raw)
  To: Manoj Sai
  Cc: Philipp Tomsich, Kever Yang, u-boot, Da Xue, dsx724, Jagan Teki,
	Suniel Mahesh

Hi Manoj,

On Fri, 30 Jun 2023 at 13:12, Manoj Sai
<abbaraju.manojsai@amarulasolutions.com> wrote:
>
> Add an entry type for u-boot-nodtb.bin.gz, which is a GZIP compressed raw u-boot
> binary and a simple test.
>

A better way to do this is to have binman do the compression.

> Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
> Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
> ---
>  tools/binman/etype/u_boot_nodtb_gzip.py     | 28 +++++++++++++++++++++
>  tools/binman/ftest.py                       |  5 ++++
>  tools/binman/test/282_u_boot_nodtb_gzip.dts | 11 ++++++++
>  3 files changed, 44 insertions(+)
>  create mode 100644 tools/binman/etype/u_boot_nodtb_gzip.py
>  create mode 100644 tools/binman/test/282_u_boot_nodtb_gzip.dts

Binman supports a 'compressed' property for blobs, so you should be able to add:

    compress = 'gzip';

to your node

>
> diff --git a/tools/binman/etype/u_boot_nodtb_gzip.py b/tools/binman/etype/u_boot_nodtb_gzip.py
> new file mode 100644
> index 0000000000..e8afd3de57
> --- /dev/null
> +++ b/tools/binman/etype/u_boot_nodtb_gzip.py
> @@ -0,0 +1,28 @@
> +# SPDX-License-Identifier: GPL-2.0+
> +# Copyright (c) 2023 Amarula Solutions India
> +# Written by Suniel Mahesh <sunil@amarulasolutions.com>
> +# Reference from Simon Glass <sjg@chromium.org>
> +#
> +# Entry-type module for 'u-boot-nodtb.bin.gz'
> +#
> +
> +from binman.entry import Entry
> +from binman.etype.blob import Entry_blob
> +
> +class Entry_u_boot_nodtb_gzip(Entry_blob):
> +    """U-Boot compressed flat binary without device tree appended
> +
> +    Properties / Entry arguments:
> +        - filename: Filename to include ('u-boot-nodtb.bin.gz')
> +
> +    This is the U-Boot compressed raw binary, before allowing it to relocate
> +    itself at runtime it should be decompressed. It does not include a device
> +    tree blob at the end of it so normally cannot work without it. You can add a
> +    u-boot-dtb entry after this one, or use a u-boot entry instead, normally
> +    expands to a section containing u-boot and u-boot-dtb
> +    """
> +    def __init__(self, section, etype, node):
> +        super().__init__(section, etype, node)
> +
> +    def GetDefaultFilename(self):
> +        return 'u-boot-nodtb.bin.gz'
> diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
> index 43b4f850a6..933ebcbd35 100644
> --- a/tools/binman/ftest.py
> +++ b/tools/binman/ftest.py
> @@ -42,6 +42,7 @@ from u_boot_pylib import tout
>  # Contents of test files, corresponding to different entry types
>  U_BOOT_DATA           = b'1234'
>  U_BOOT_IMG_DATA       = b'img'
> +U_BOOT_NODTB_GZ_DATA  = b'uboot nodtb gz'
>  U_BOOT_SPL_DATA       = b'56780123456789abcdefghijklm'
>  U_BOOT_TPL_DATA       = b'tpl9876543210fedcbazywvuts'
>  U_BOOT_VPL_DATA       = b'vpl76543210fedcbazywxyz_'
> @@ -6676,6 +6677,10 @@ fdt         fdtmap                Extract the devicetree blob from the fdtmap
>                                  ['fit'])
>          self.assertIn("Node '/fit': Missing tool: 'mkimage'", str(e.exception))
>
> +    def testUBootnodtbBinGz(self):
> +       """Test that u-boot-nodtb.bin.gz can be put in a file"""
> +       data = self._DoReadFile('279_u_boot_nodtb_gzip.dts')
> +       self.assertEqual(U_BOOT_NODTB_GZ_DATA, data)
>
>  if __name__ == "__main__":
>      unittest.main()
> diff --git a/tools/binman/test/282_u_boot_nodtb_gzip.dts b/tools/binman/test/282_u_boot_nodtb_gzip.dts
> new file mode 100644
> index 0000000000..79eecea202
> --- /dev/null
> +++ b/tools/binman/test/282_u_boot_nodtb_gzip.dts
> @@ -0,0 +1,11 @@
> +/dts-v1/;
> +
> +/ {
> +       #address-cells = <1>;
> +       #size-cells = <1>;
> +
> +       binman {
> +               u-boot-nodtb-bin-gz {
> +               };
> +       };
> +};
> --
> 2.25.1
>

If you still really want to add an entry type for a compressed U-Boot,
please let me know.

Regards,
Simon

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

* Re: [PATCH 08/10] rockchip: Add GZIP compressed uboot raw binary to FIT image
  2023-06-30 12:11 ` [PATCH 08/10] rockchip: Add GZIP compressed uboot raw binary to FIT image Manoj Sai
@ 2023-07-02 15:34   ` Simon Glass
  0 siblings, 0 replies; 55+ messages in thread
From: Simon Glass @ 2023-07-02 15:34 UTC (permalink / raw)
  To: Manoj Sai
  Cc: Philipp Tomsich, Kever Yang, u-boot, Da Xue, dsx724, Jagan Teki,
	Suniel Mahesh

Hi Manoj,

On Fri, 30 Jun 2023 at 13:12, Manoj Sai
<abbaraju.manojsai@amarulasolutions.com> wrote:
>
> Add GZIP compressed uboot raw binary to FIT image.
>
> Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
> Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
> ---
>  arch/arm/dts/rockchip-u-boot.dtsi | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi
> index 2878b80926..6e95738923 100644
> --- a/arch/arm/dts/rockchip-u-boot.dtsi
> +++ b/arch/arm/dts/rockchip-u-boot.dtsi
> @@ -48,11 +48,21 @@
>                                         type = "standalone";
>                                         os = "U-Boot";
>                                         arch = "arm64";
> +#if defined(CONFIG_SPL_GZIP)
> +                                       compression = "gzip";
> +#else
>                                         compression = "none";
> +#endif
>                                         load = <CONFIG_TEXT_BASE>;
>                                         entry = <CONFIG_TEXT_BASE>;
> +#if defined(CONFIG_SPL_GZIP)
> +                                       u-boot-nodtb-gzip {
> +                                       };
> +#else
>                                         u-boot-nodtb {

You should be able to do:

+#if defined(CONFIG_SPL_GZIP)
   compress = "gzip";
#endif

>                                         };
> +#endif
> +
>  #ifdef CONFIG_SPL_FIT_SIGNATURE
>                                         hash {
>                                                 algo = "sha256";
> --
> 2.25.1
>

Regards,
Simon

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

* Re: [PATCH 09/10] binman: Add support for u-boot-nodtb.bin.lzma as an input binary
  2023-06-30 12:11 ` [PATCH 09/10] binman: Add support for u-boot-nodtb.bin.lzma as an input binary Manoj Sai
@ 2023-07-02 15:34   ` Simon Glass
  0 siblings, 0 replies; 55+ messages in thread
From: Simon Glass @ 2023-07-02 15:34 UTC (permalink / raw)
  To: Manoj Sai
  Cc: Philipp Tomsich, Kever Yang, u-boot, Da Xue, dsx724, Jagan Teki,
	Suniel Mahesh

Hi Manoj,

On Fri, 30 Jun 2023 at 13:12, Manoj Sai
<abbaraju.manojsai@amarulasolutions.com> wrote:
>
> Add an entry type for u-boot-nodtb.bin.lzma, which is a LZMA compressed
> raw u-boot binary and a simple test.
>
> Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
> Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
> ---
>  tools/binman/etype/283_u_boot_nodtb_lzma.dts | 11 ++++++++
>  tools/binman/etype/u_boot_nodtb_lzma.py      | 28 ++++++++++++++++++++
>  tools/binman/ftest.py                        |  6 +++++
>  3 files changed, 45 insertions(+)
>  create mode 100644 tools/binman/etype/283_u_boot_nodtb_lzma.dts
>  create mode 100644 tools/binman/etype/u_boot_nodtb_lzma.py

The same comment applies to this patch.

>
> diff --git a/tools/binman/etype/283_u_boot_nodtb_lzma.dts b/tools/binman/etype/283_u_boot_nodtb_lzma.dts
> new file mode 100644
> index 0000000000..d9a834acf6
> --- /dev/null
> +++ b/tools/binman/etype/283_u_boot_nodtb_lzma.dts
> @@ -0,0 +1,11 @@
> +/dts-v1/;
> +
> +/ {
> +       #address-cells = <1>;
> +       #size-cells = <1>;
> +
> +       binman {
> +               u-boot-nodtb-bin-lzma {
> +               };
> +       };
> +};
> diff --git a/tools/binman/etype/u_boot_nodtb_lzma.py b/tools/binman/etype/u_boot_nodtb_lzma.py
> new file mode 100644
> index 0000000000..c2874aa6e9
> --- /dev/null
> +++ b/tools/binman/etype/u_boot_nodtb_lzma.py
> @@ -0,0 +1,28 @@
> +# SPDX-License-Identifier: GPL-2.0+
> +# Copyright (c) 2023 Amarula Solutions India
> +# Written by Suniel Mahesh <sunil@amarulasolutions.com>
> +# Reference from Simon Glass <sjg@chromium.org>
> +#
> +# Entry-type module for 'u-boot-nodtb.bin.lzma'
> +#
> +
> +from binman.entry import Entry
> +from binman.etype.blob import Entry_blob
> +
> +class Entry_u_boot_nodtb_lzma(Entry_blob):
> +    """U-Boot compressed flat binary without device tree appended
> +
> +    Properties / Entry arguments:
> +        - filename: Filename to include ('u-boot-nodtb.bin.lzma')
> +
> +    This is the U-Boot compressed raw binary, before allowing it to relocate
> +    itself at runtime it should be decompressed. It does not include a device
> +    tree blob at the end of it so normally cannot work without it. You can add a
> +    u-boot-dtb entry after this one, or use a u-boot entry instead, normally
> +    expands to a section containing u-boot and u-boot-dtb
> +    """
> +    def __init__(self, section, etype, node):
> +        super().__init__(section, etype, node)
> +
> +    def GetDefaultFilename(self):
> +        return 'u-boot-nodtb.bin.lzma'
> diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
> index 933ebcbd35..d1715523d2 100644
> --- a/tools/binman/ftest.py
> +++ b/tools/binman/ftest.py
> @@ -43,6 +43,7 @@ from u_boot_pylib import tout
>  U_BOOT_DATA           = b'1234'
>  U_BOOT_IMG_DATA       = b'img'
>  U_BOOT_NODTB_GZ_DATA  = b'uboot nodtb gz'
> +U_BOOT_NODTB_LZMA_DATA  = b'uboot nodtb lzma'
>  U_BOOT_SPL_DATA       = b'56780123456789abcdefghijklm'
>  U_BOOT_TPL_DATA       = b'tpl9876543210fedcbazywvuts'
>  U_BOOT_VPL_DATA       = b'vpl76543210fedcbazywxyz_'
> @@ -6682,5 +6683,10 @@ fdt         fdtmap                Extract the devicetree blob from the fdtmap
>         data = self._DoReadFile('279_u_boot_nodtb_gzip.dts')
>         self.assertEqual(U_BOOT_NODTB_GZ_DATA, data)
>
> +   def testUBootnodtbBinLzma(self):
> +       """Test that u-boot-nodtb.bin.lzma can be put in a file"""
> +       data = self._DoReadFile('280_u_boot_nodtb_lzma.dts')
> +       self.assertEqual(U_BOOT_NODTB_LZMA_DATA, data)
> +
>  if __name__ == "__main__":
>      unittest.main()
> --
> 2.25.1
>

Regards,
Simon

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

* Re: [PATCH 01/10] Makefile: Add support to generate GZIP compressed raw u-boot binary
  2023-07-02 15:34   ` Simon Glass
@ 2023-07-18  7:12     ` Manoj Sai
  2023-07-19  1:08       ` Simon Glass
  0 siblings, 1 reply; 55+ messages in thread
From: Manoj Sai @ 2023-07-18  7:12 UTC (permalink / raw)
  To: Simon Glass
  Cc: Philipp Tomsich, Kever Yang, u-boot, Da Xue, dsx724, Jagan Teki,
	Suniel Mahesh

Hi Simon,

Can you please suggest or briefly explain to me the steps to be
followed to generate the compressed u-boot-nodtb.bin.gz and
u-boot-nodtb.bin.lzma file  with the help of binman  ,
when compression support is enabled . Can you provide me with any
reference patch to get it done?

Thanks and regards,
Manoj sai
Amarula Solutions India Pvt. Ltd

On Sun, Jul 2, 2023 at 9:04 PM Simon Glass <sjg@chromium.org> wrote:
>
> Hi Manoj,
>
> On Fri, 30 Jun 2023 at 13:12, Manoj Sai
> <abbaraju.manojsai@amarulasolutions.com> wrote:
> >
> > Add support for generating a GZIP-compressed raw U-boot binary.
> >
> > Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
> > Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
> > ---
> >  Makefile | 3 +++
> >  1 file changed, 3 insertions(+)
>
> Please can you use binman to do that?
>
> We are trying to remove the extra build rules in the Makefile.
>
> >
> > diff --git a/Makefile b/Makefile
> > index 444baaefd0..6e15ebd116 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -1312,6 +1312,9 @@ endif
> >  u-boot-nodtb.bin: u-boot FORCE
> >         $(call if_changed,objcopy_uboot)
> >         $(BOARD_SIZE_CHECK)
> > +ifeq ($(CONFIG_SPL_GZIP),y)
> > +       @gzip -k u-boot-nodtb.bin
> > +endif
> >
> >  u-boot.ldr:    u-boot
> >                 $(CREATE_LDR_ENV)
> > --
> > 2.25.1
> >
>
> Regards,
> Simon

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

* Re: [PATCH 01/10] Makefile: Add support to generate GZIP compressed raw u-boot binary
  2023-07-18  7:12     ` Manoj Sai
@ 2023-07-19  1:08       ` Simon Glass
  0 siblings, 0 replies; 55+ messages in thread
From: Simon Glass @ 2023-07-19  1:08 UTC (permalink / raw)
  To: Manoj Sai
  Cc: Philipp Tomsich, Kever Yang, u-boot, Da Xue, dsx724, Jagan Teki,
	Suniel Mahesh

Hi Manoj,

On Tue, 18 Jul 2023 at 01:13, Manoj Sai
<abbaraju.manojsai@amarulasolutions.com> wrote:
>
> Hi Simon,
>
> Can you please suggest or briefly explain to me the steps to be
> followed to generate the compressed u-boot-nodtb.bin.gz and
> u-boot-nodtb.bin.lzma file  with the help of binman  ,
> when compression support is enabled . Can you provide me with any
> reference patch to get it done?

Yes, please see here:

https://u-boot.readthedocs.io/en/latest/develop/package/binman.html#compression

Regards,
Simon


>
> Thanks and regards,
> Manoj sai
> Amarula Solutions India Pvt. Ltd
>
> On Sun, Jul 2, 2023 at 9:04 PM Simon Glass <sjg@chromium.org> wrote:
> >
> > Hi Manoj,
> >
> > On Fri, 30 Jun 2023 at 13:12, Manoj Sai
> > <abbaraju.manojsai@amarulasolutions.com> wrote:
> > >
> > > Add support for generating a GZIP-compressed raw U-boot binary.
> > >
> > > Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
> > > Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
> > > ---
> > >  Makefile | 3 +++
> > >  1 file changed, 3 insertions(+)
> >
> > Please can you use binman to do that?
> >
> > We are trying to remove the extra build rules in the Makefile.
> >
> > >
> > > diff --git a/Makefile b/Makefile
> > > index 444baaefd0..6e15ebd116 100644
> > > --- a/Makefile
> > > +++ b/Makefile
> > > @@ -1312,6 +1312,9 @@ endif
> > >  u-boot-nodtb.bin: u-boot FORCE
> > >         $(call if_changed,objcopy_uboot)
> > >         $(BOARD_SIZE_CHECK)
> > > +ifeq ($(CONFIG_SPL_GZIP),y)
> > > +       @gzip -k u-boot-nodtb.bin
> > > +endif
> > >
> > >  u-boot.ldr:    u-boot
> > >                 $(CREATE_LDR_ENV)
> > > --
> > > 2.25.1
> > >
> >
> > Regards,
> > Simon

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

* Re: [PATCH 02/10] spl: Kconfig: Address support for compressed U-BOOT raw binary
  2023-07-02 15:34   ` Simon Glass
@ 2023-07-25  3:48     ` Manoj Sai
  0 siblings, 0 replies; 55+ messages in thread
From: Manoj Sai @ 2023-07-25  3:48 UTC (permalink / raw)
  To: Simon Glass
  Cc: Philipp Tomsich, Kever Yang, u-boot, Da Xue, dsx724, Jagan Teki,
	Suniel Mahesh

On Sun, Jul 2, 2023 at 9:04 PM Simon Glass <sjg@chromium.org> wrote:
>
> Hi Manoj,
>
> On Fri, 30 Jun 2023 at 13:12, Manoj Sai
> <abbaraju.manojsai@amarulasolutions.com> wrote:
> >
> > Add the support that ,if compression support is enabled in SPL
> > a location needs to be defined as the source address where
> > compressed U-BOOT raw binary will be stored.
> >
> > spl_load_fit_image function takes care that, compressed U-Boot raw
> > binary which is placed at this address, will be uncompressed to default
> > CONFIG_SYS_TEXT_BASE location.
> >
> > Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
> > Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
> > ---
> >  common/spl/Kconfig | 15 +++++++++++++++
> >  1 file changed, 15 insertions(+)
> >
> > diff --git a/common/spl/Kconfig b/common/spl/Kconfig
> > index 2c042ad306..5dd1f3c469 100644
> > --- a/common/spl/Kconfig
> > +++ b/common/spl/Kconfig
> > @@ -1547,6 +1547,21 @@ config SPL_AT91_MCK_BYPASS
> >           The external source has to provide a stable clock on the XIN pin.
> >           If this option is disabled, the SoC expects a crystal oscillator
> >           that needs driving on both XIN and XOUT lines.
>
> blank line here
>
> > +choice
> > +       prompt "Location for compressed U-BOOT raw binary"
>
> compressed U-Boot binary
>
> > +       depends on SPL_GZIP || SPL_LZMA
> > +       default SPL_UBOOT_COMPRESSED_BINARY_FIT_USER_DEFINED_AREA
>
> missing help
>
> This is too long and there is a lot ot redundancy.. How about SPL_GZIP_FROM_ADDR
>
> > +
> > +config SPL_UBOOT_COMPRESSED_BINARY_FIT_USER_DEFINED_AREA
> > +       bool "compressed U-BOOT raw binary user-defined location"
>
> missing help
>
> blank line
>
> > +endchoice
>
> But you only have one thing in the choice, so can you just drop the
> choice and use a bool instead?
>
> > +
> > +config SPL_UBOOT_COMPRESSED_BINARY_FIT_USER_DEF_ADDR
>
> How about SPL_GZIP_LOADADDR?
>
>
Hi simon ,

We modified to use the CONFIG_SYS_LOAD_ADDR as the source RAM address
to store the  compressed U-Boot
 binary which will be defined in a machine defconfig file in place of
defining a new RAM address and with the help of this change,
able to load and boot the compressed U-boot.

-spl_load_fit_image function , will uncompress the U-BOOT binary which
is placed in the CONFIG_SYS_LOAD_ADDR to
default CONFIG_SYS_TEXT_BASE location and able to load and boot the
compressed U-boot.

These two patches  will be removed in the next v2 patchset which are
related  to adding new RAM address to store compressed U-boot.
1) https://patchwork.ozlabs.org/project/uboot/patch/20230630121146.513345-3-abbaraju.manojsai@amaruasolutions.com/
2) https://patchwork.ozlabs.org/project/uboot/patch/20230630121146.513345-4-abbaraju.manojsai@amarulasolutions.com/

Regards,
A . Manoj sai

> > +       hex "Address of memory where compressed U-BOOT raw binary is stored"
>
> U-Boot (please fix throughout)
>
> > +       depends on SPL_UBOOT_COMPRESSED_BINARY_FIT_USER_DEFINED_AREA
> > +       help
> > +         The FIT image containing the compressed U-BOOT raw binary will be stored
> > +         in an area defined at compilation time. This is the address for this area.
> >  endmenu
> >
> >  config TPL
> > --
> > 2.25.1
> >
>
> Regards,
> Simon

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

* [PATCH v2 0/4] support for booting the compressed U-boot binary on Rockchip based ARM64 SOC's
  2023-06-30 12:11 [PATCH 00/10] support for booting the compressed U-boot binary on Rockchip based SOC's Manoj Sai
                   ` (10 preceding siblings ...)
  2023-06-30 15:45 ` [PATCH 00/10] support for booting the compressed U-boot binary on Rockchip based SOC's Jonas Karlman
@ 2023-07-25  3:50 ` Manoj Sai
  2023-07-25  3:50   ` [PATCH v2 1/4] rockchip: Add support to generate GZIP compressed U-boot binary Manoj Sai
                     ` (5 more replies)
  11 siblings, 6 replies; 55+ messages in thread
From: Manoj Sai @ 2023-07-25  3:50 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: Da Xue, dsx724, linux-amarula, Jagan Teki, Suniel Mahesh, Manoj Sai

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=y, Size: 4244 bytes --]

This patchset adds the support on Rockchip based ARM64 SOC's that  compress the U-BOOT proper along with dtb 
and ATF in FIT image format.Second stage bootloader(SPL) loads the compressed binaries, uncompress 
them and  handover control to the next stage.

Changes for V2 :-

- Removed the need to create gzip and lzma compressed U-boot-nodtb files using Makefile  and added a changeset 
that "compress" field to u-boot-nodtb node and "compression" field to  u-boot Node in the FIT image, with the help 
of this change binman will create the compressed Binaries.
  
Size Comparision between compressed and uncompressed binaries :-
  
  	size of uncompressed binary :- 9.4 MB (94,26,432 bytes)
         manoj:u-boot$ ls -lb u-boot-rockchip.bin 
        -rw-rw-r-- 1 manoj manoj 9426432 Jul 25 07:42 u-boot-rockchip.bin

       size of GZIP compressed binary :- 9.0 MB (89,85,088 bytes)
         manoj:u-boot$ ls -lb u-boot-rockchip.bin 
         -rw-rw-r-- 1 manoj manoj 8985088 Jul 25 07:42 u-boot-rockchip.bin

       size of LZMA compressed binary :- 9.0 MB (90,06,080 bytes)
         manoj:u-boot$ ls -lb u-boot-rockchip.bin 
         -rw-rw-r-- 1 manoj manoj 9006080 Jul 25 07:47 u-boot-rockchip.bin 

- modified to use the CONFIG_SYS_LOAD_ADDR as the source RAM address to store the  compressed U-Boot binary which 
will be defined in the machine defconfig file in place of creating a new RAM address for a specific board using Kconfig.
so patchset related to adding a new RAM address to store compressed binary has been removed in V2 patchset. 

- Removed the patchset related to adding  the u-boot-nodtb.bin.gz and u-boot-nodtb.bin.lzma as input binary to binman.


-- Test results of  Booting time using bootstage command in Uboot command prompt on roc-rk3399-pc board :-

1) Uncompressed U-BOOT : Total boot time ≈ 12.3 seconds 
=> bootstage  report
Timer summary in microseconds (10 records):
       Mark    Elapsed  Stage
          0          0  reset
  1,824,330  1,824,330  board_init_f
  2,921,678  1,097,348  board_init_r
  5,179,369  2,257,691  eth_common_init
  5,478,307    298,938  eth_initialize
  5,478,484        177  main_loop
  5,478,641        157  usb_start
 12,017,936  6,539,295  cli_loop

Accumulated time:
                15,899  dm_r
               694,371  dm_f

2) GZIP Compressed U-BOOT : Total boot time ≈ 13.5 seconds 
=>  bootstage  report
Timer summary in microseconds (10 records):
       Mark    Elapsed  Stage
          0          0  reset
  2,591,355  2,591,355  board_init_f
  3,689,407  1,098,052  board_init_r
  5,947,314  2,257,907  eth_common_init
  6,246,250    298,936  eth_initialize
  6,246,427        177  main_loop
  6,246,585        158  usb_start
 12,785,936  6,539,351  cli_loop

Accumulated time:
                15,902  dm_r
               694,779  dm_f

2) LZMA Compressed U-BOOT : Total boot time ≈ 23.5 seconds
=> bootstage report
Timer summary in microseconds (10 records):
       Mark    Elapsed  Stage
          0          0  reset
  6,376,405  6,376,405  board_init_f
  7,471,967  1,095,562  board_init_r
  9,726,257  2,254,290  eth_common_init
 10,024,873    298,616  eth_initialize
 10,025,049        176  main_loop
 10,025,208        159  usb_start
 16,564,906  6,539,698  cli_loop
 
Accumulated time:
                15,851  dm_r
               693,323  dm_f


Patch 1/4  generate a GZIP-compressed U-boot binary using binman if CONFIG_SPL_GZIP selected
Patch 2/4  generate a LZMA-compressed U-boot binary using binman if CONFIG_SPL_LZMA selected 
Patch 3/4  uncompress the gzip U-BOOT binary and load the binaries if gzip compression supoort is enabled
Patch 4/4  uncompress the lzma U-BOOT binary and load the binaries if lzma compression supoort is enabled

Manoj Sai (4):
  rockchip: Add support to generate GZIP compressed U-boot binary
  rockchip: Add support to generate LZMA compressed U-boot binary
  spl: fit: support for booting a GZIP-compressed U-boot binary
  spl: fit: support for booting a LZMA-compressed U-boot binary

 arch/arm/dts/rockchip-u-boot.dtsi | 11 +++++++++++
 common/spl/spl_fit.c              | 21 +++++++++++++++++----
 include/spl.h                     | 10 ++++++++++
 3 files changed, 38 insertions(+), 4 deletions(-)

-- 
2.25.1


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

* [PATCH v2 1/4] rockchip: Add support to generate GZIP compressed U-boot binary
  2023-07-25  3:50 ` [PATCH v2 0/4] support for booting the compressed U-boot binary on Rockchip based ARM64 SOC's Manoj Sai
@ 2023-07-25  3:50   ` Manoj Sai
  2023-07-27  0:53     ` Simon Glass
                       ` (2 more replies)
  2023-07-25  3:50   ` [PATCH v2 2/4] rockchip: Add support to generate LZMA " Manoj Sai
                     ` (4 subsequent siblings)
  5 siblings, 3 replies; 55+ messages in thread
From: Manoj Sai @ 2023-07-25  3:50 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: Da Xue, dsx724, linux-amarula, Jagan Teki, Suniel Mahesh, Manoj Sai

Add support for generating a GZIP-compressed U-boot binary with the
help of binman, if CONFIG_SPL_GZIP is selected.

Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
---
 arch/arm/dts/rockchip-u-boot.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi
index 2878b80926..524d638e5b 100644
--- a/arch/arm/dts/rockchip-u-boot.dtsi
+++ b/arch/arm/dts/rockchip-u-boot.dtsi
@@ -48,10 +48,17 @@
 					type = "standalone";
 					os = "U-Boot";
 					arch = "arm64";
+#if defined(CONFIG_SPL_GZIP)
+					compression = "gzip";
+#else
 					compression = "none";
+#endif
 					load = <CONFIG_TEXT_BASE>;
 					entry = <CONFIG_TEXT_BASE>;
 					u-boot-nodtb {
+#if defined(CONFIG_SPL_GZIP)
+						compress = "gzip";
+#endif
 					};
 #ifdef CONFIG_SPL_FIT_SIGNATURE
 					hash {
-- 
2.25.1


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

* [PATCH v2 2/4] rockchip: Add support to generate LZMA compressed U-boot binary
  2023-07-25  3:50 ` [PATCH v2 0/4] support for booting the compressed U-boot binary on Rockchip based ARM64 SOC's Manoj Sai
  2023-07-25  3:50   ` [PATCH v2 1/4] rockchip: Add support to generate GZIP compressed U-boot binary Manoj Sai
@ 2023-07-25  3:50   ` Manoj Sai
  2023-07-27  0:53     ` Simon Glass
  2023-07-28 10:09     ` Kever Yang
  2023-07-25  3:51   ` [PATCH v2 3/4] spl: fit: support for booting a GZIP-compressed " Manoj Sai
                     ` (3 subsequent siblings)
  5 siblings, 2 replies; 55+ messages in thread
From: Manoj Sai @ 2023-07-25  3:50 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: Da Xue, dsx724, linux-amarula, Jagan Teki, Suniel Mahesh, Manoj Sai

Add support for generating a LZMA-compressed U-boot binary with the
help of binman, if CONFIG_SPL_LZMA is selected.

Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
---
 arch/arm/dts/rockchip-u-boot.dtsi | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi
index 524d638e5b..34282bdfb2 100644
--- a/arch/arm/dts/rockchip-u-boot.dtsi
+++ b/arch/arm/dts/rockchip-u-boot.dtsi
@@ -50,6 +50,8 @@
 					arch = "arm64";
 #if defined(CONFIG_SPL_GZIP)
 					compression = "gzip";
+#elif defined(CONFIG_SPL_LZMA)
+					compression = "lzma";
 #else
 					compression = "none";
 #endif
@@ -58,6 +60,8 @@
 					u-boot-nodtb {
 #if defined(CONFIG_SPL_GZIP)
 						compress = "gzip";
+#elif defined(CONFIG_SPL_LZMA)
+						compress = "lzma";
 #endif
 					};
 #ifdef CONFIG_SPL_FIT_SIGNATURE
-- 
2.25.1


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

* [PATCH v2 3/4] spl: fit: support for booting a GZIP-compressed U-boot binary
  2023-07-25  3:50 ` [PATCH v2 0/4] support for booting the compressed U-boot binary on Rockchip based ARM64 SOC's Manoj Sai
  2023-07-25  3:50   ` [PATCH v2 1/4] rockchip: Add support to generate GZIP compressed U-boot binary Manoj Sai
  2023-07-25  3:50   ` [PATCH v2 2/4] rockchip: Add support to generate LZMA " Manoj Sai
@ 2023-07-25  3:51   ` Manoj Sai
  2023-07-27  0:53     ` Simon Glass
                       ` (2 more replies)
  2023-07-25  3:51   ` [PATCH v2 4/4] spl: fit: support for booting a LZMA-compressed " Manoj Sai
                     ` (2 subsequent siblings)
  5 siblings, 3 replies; 55+ messages in thread
From: Manoj Sai @ 2023-07-25  3:51 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: Da Xue, dsx724, linux-amarula, Jagan Teki, Suniel Mahesh, Manoj Sai

If GZIP Compression support is enabled, GZIP compressed U-Boot binary
will be at a specified RAM location which is defined at
CONFIG_SYS_LOAD_ADDR and will be assign it as the source address.

gunzip function in spl_load_fit_image ,will decompress the GZIP
compressed U-Boot binary which is placed at
source address(CONFIG_SYS_LOAD_ADDR)  to the default
CONFIG_SYS_TEXT_BASE location.

spl_load_fit_image function will load the decompressed U-Boot
binary, which is placed at the CONFIG_SYS_TEXT_BASE location.

Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
---
 common/spl/spl_fit.c |  7 +++++--
 include/spl.h        | 10 ++++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 730639f756..d728ac71fc 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -239,7 +239,7 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 	bool external_data = false;
 
 	if (IS_ENABLED(CONFIG_SPL_FPGA) ||
-	    (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_GZIP))) {
+	    (IS_ENABLED(CONFIG_SPL_OS_BOOT) && spl_decompression_enabled())) {
 		if (fit_image_get_type(fit, node, &type))
 			puts("Cannot get image type.\n");
 		else
@@ -281,7 +281,10 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 			return 0;
 		}
 
-		src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
+		if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP))
+			src_ptr = map_sysmem(ALIGN(CONFIG_SYS_LOAD_ADDR, ARCH_DMA_MINALIGN), len);
+		else
+			src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
 		length = len;
 
 		overhead = get_aligned_image_overhead(info, offset);
diff --git a/include/spl.h b/include/spl.h
index 92bcaa90a4..088479e357 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -897,4 +897,14 @@ struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size);
 
 void board_boot_order(u32 *spl_boot_list);
 void spl_save_restore_data(void);
+
+/*
+ * spl_decompression_enabled() - check decompression support is enabled for SPL build
+ *
+ * Returns  true  if decompression support is enabled, else False
+ */
+static inline bool spl_decompression_enabled(void)
+{
+	return (IS_ENABLED(CONFIG_SPL_GZIP) || IS_ENABLED(CONFIG_SPL_LZMA));
+}
 #endif
-- 
2.25.1


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

* [PATCH v2 4/4] spl: fit: support for booting a LZMA-compressed U-boot binary
  2023-07-25  3:50 ` [PATCH v2 0/4] support for booting the compressed U-boot binary on Rockchip based ARM64 SOC's Manoj Sai
                     ` (2 preceding siblings ...)
  2023-07-25  3:51   ` [PATCH v2 3/4] spl: fit: support for booting a GZIP-compressed " Manoj Sai
@ 2023-07-25  3:51   ` Manoj Sai
  2023-07-27  0:53     ` Simon Glass
  2023-07-27 11:13     ` Jonas Karlman
  2023-07-27 11:21   ` [PATCH v2 0/4] support for booting the compressed U-boot binary on Rockchip based ARM64 SOC's Jonas Karlman
  2023-09-10 18:24   ` [PATCH v3 " Manoj Sai
  5 siblings, 2 replies; 55+ messages in thread
From: Manoj Sai @ 2023-07-25  3:51 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: Da Xue, dsx724, linux-amarula, Jagan Teki, Suniel Mahesh, Manoj Sai

If LZMA Compression support is enabled, LZMA compressed U-Boot
binary will be placed at a specified RAM location which is
defined at CONFIG_SYS_LOAD_ADDR and will be assigned  as the
source address.

image_decomp() function, will decompress the LZMA compressed
U-Boot binary which is placed at source address(CONFIG_SYS_LOAD_ADDR)
to the default CONFIG_SYS_TEXT_BASE location.

spl_load_fit_image function will load the decompressed U-Boot
binary, which is placed at the CONFIG_SYS_TEXT_BASE location.

Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
---
 common/spl/spl_fit.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index d728ac71fc..208d2f761e 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -246,7 +246,7 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 			debug("%s ", genimg_get_type_name(type));
 	}
 
-	if (IS_ENABLED(CONFIG_SPL_GZIP)) {
+	if (IS_ENABLED(CONFIG_SPL_GZIP) || IS_ENABLED(CONFIG_SPL_LZMA)) {
 		fit_image_get_comp(fit, node, &image_comp);
 		debug("%s ", genimg_get_comp_name(image_comp));
 	}
@@ -280,8 +280,8 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 				    __func__, fit_get_name(fit, node, NULL));
 			return 0;
 		}
-
-		if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP))
+		if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP) ||
+		    (IS_ENABLED(CONFIG_SPL_LZMA) && image_comp == IH_COMP_LZMA))
 			src_ptr = map_sysmem(ALIGN(CONFIG_SYS_LOAD_ADDR, ARCH_DMA_MINALIGN), len);
 		else
 			src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
@@ -329,6 +329,16 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 			return -EIO;
 		}
 		length = size;
+	} else if (IS_ENABLED(CONFIG_SPL_LZMA) && image_comp == IH_COMP_LZMA) {
+		size = CONFIG_SYS_BOOTM_LEN;
+		ulong loadEnd;
+
+		if (image_decomp(IH_COMP_LZMA, CONFIG_SYS_LOAD_ADDR, 0, 0,
+				 load_ptr, src, length, size, &loadEnd)) {
+			puts("Uncompressing error\n");
+			return -EIO;
+		}
+		length = loadEnd - CONFIG_SYS_LOAD_ADDR;
 	} else {
 		memcpy(load_ptr, src, length);
 	}
-- 
2.25.1


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

* Re: [PATCH v2 1/4] rockchip: Add support to generate GZIP compressed U-boot binary
  2023-07-25  3:50   ` [PATCH v2 1/4] rockchip: Add support to generate GZIP compressed U-boot binary Manoj Sai
@ 2023-07-27  0:53     ` Simon Glass
  2023-07-28 10:09     ` Kever Yang
  2023-08-12  3:03     ` Kever Yang
  2 siblings, 0 replies; 55+ messages in thread
From: Simon Glass @ 2023-07-27  0:53 UTC (permalink / raw)
  To: Manoj Sai
  Cc: Philipp Tomsich, Kever Yang, u-boot, Da Xue, dsx724,
	linux-amarula, Jagan Teki, Suniel Mahesh

On Mon, 24 Jul 2023 at 21:51, Manoj Sai
<abbaraju.manojsai@amarulasolutions.com> wrote:
>
> Add support for generating a GZIP-compressed U-boot binary with the
> help of binman, if CONFIG_SPL_GZIP is selected.
>
> Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
> ---
>  arch/arm/dts/rockchip-u-boot.dtsi | 7 +++++++
>  1 file changed, 7 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

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

* Re: [PATCH v2 2/4] rockchip: Add support to generate LZMA compressed U-boot binary
  2023-07-25  3:50   ` [PATCH v2 2/4] rockchip: Add support to generate LZMA " Manoj Sai
@ 2023-07-27  0:53     ` Simon Glass
  2023-07-28 10:09     ` Kever Yang
  1 sibling, 0 replies; 55+ messages in thread
From: Simon Glass @ 2023-07-27  0:53 UTC (permalink / raw)
  To: Manoj Sai
  Cc: Philipp Tomsich, Kever Yang, u-boot, Da Xue, dsx724,
	linux-amarula, Jagan Teki, Suniel Mahesh

On Mon, 24 Jul 2023 at 21:51, Manoj Sai
<abbaraju.manojsai@amarulasolutions.com> wrote:
>
> Add support for generating a LZMA-compressed U-boot binary with the
> help of binman, if CONFIG_SPL_LZMA is selected.
>
> Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
> ---
>  arch/arm/dts/rockchip-u-boot.dtsi | 4 ++++
>  1 file changed, 4 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

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

* Re: [PATCH v2 3/4] spl: fit: support for booting a GZIP-compressed U-boot binary
  2023-07-25  3:51   ` [PATCH v2 3/4] spl: fit: support for booting a GZIP-compressed " Manoj Sai
@ 2023-07-27  0:53     ` Simon Glass
  2023-07-27 11:03     ` Jonas Karlman
  2023-07-28 10:09     ` Kever Yang
  2 siblings, 0 replies; 55+ messages in thread
From: Simon Glass @ 2023-07-27  0:53 UTC (permalink / raw)
  To: Manoj Sai
  Cc: Philipp Tomsich, Kever Yang, u-boot, Da Xue, dsx724,
	linux-amarula, Jagan Teki, Suniel Mahesh

On Mon, 24 Jul 2023 at 21:51, Manoj Sai
<abbaraju.manojsai@amarulasolutions.com> wrote:
>
> If GZIP Compression support is enabled, GZIP compressed U-Boot binary
> will be at a specified RAM location which is defined at
> CONFIG_SYS_LOAD_ADDR and will be assign it as the source address.
>
> gunzip function in spl_load_fit_image ,will decompress the GZIP
> compressed U-Boot binary which is placed at
> source address(CONFIG_SYS_LOAD_ADDR)  to the default
> CONFIG_SYS_TEXT_BASE location.
>
> spl_load_fit_image function will load the decompressed U-Boot
> binary, which is placed at the CONFIG_SYS_TEXT_BASE location.
>
> Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
> Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
> ---
>  common/spl/spl_fit.c |  7 +++++--
>  include/spl.h        | 10 ++++++++++
>  2 files changed, 15 insertions(+), 2 deletions(-)
>

Reviewed-by: Simon Glass <sjg@chromium.org>

We could really use sandbox_spl test cases for these sorts of thing.

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

* Re: [PATCH v2 4/4] spl: fit: support for booting a LZMA-compressed U-boot binary
  2023-07-25  3:51   ` [PATCH v2 4/4] spl: fit: support for booting a LZMA-compressed " Manoj Sai
@ 2023-07-27  0:53     ` Simon Glass
  2023-07-27 11:13     ` Jonas Karlman
  1 sibling, 0 replies; 55+ messages in thread
From: Simon Glass @ 2023-07-27  0:53 UTC (permalink / raw)
  To: Manoj Sai
  Cc: Philipp Tomsich, Kever Yang, u-boot, Da Xue, dsx724,
	linux-amarula, Jagan Teki, Suniel Mahesh

On Mon, 24 Jul 2023 at 21:51, Manoj Sai
<abbaraju.manojsai@amarulasolutions.com> wrote:
>
> If LZMA Compression support is enabled, LZMA compressed U-Boot
> binary will be placed at a specified RAM location which is
> defined at CONFIG_SYS_LOAD_ADDR and will be assigned  as the
> source address.
>
> image_decomp() function, will decompress the LZMA compressed
> U-Boot binary which is placed at source address(CONFIG_SYS_LOAD_ADDR)
> to the default CONFIG_SYS_TEXT_BASE location.
>
> spl_load_fit_image function will load the decompressed U-Boot
> binary, which is placed at the CONFIG_SYS_TEXT_BASE location.
>
> Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
> Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
> ---
>  common/spl/spl_fit.c | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

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

* Re: [PATCH v2 3/4] spl: fit: support for booting a GZIP-compressed U-boot binary
  2023-07-25  3:51   ` [PATCH v2 3/4] spl: fit: support for booting a GZIP-compressed " Manoj Sai
  2023-07-27  0:53     ` Simon Glass
@ 2023-07-27 11:03     ` Jonas Karlman
  2023-07-28 10:11       ` Kever Yang
  2023-07-28 10:09     ` Kever Yang
  2 siblings, 1 reply; 55+ messages in thread
From: Jonas Karlman @ 2023-07-27 11:03 UTC (permalink / raw)
  To: Manoj Sai, Simon Glass, Philipp Tomsich, Kever Yang
  Cc: Da Xue, dsx724, linux-amarula, Jagan Teki, Suniel Mahesh, u-boot

On 2023-07-25 05:51, Manoj Sai wrote:
> If GZIP Compression support is enabled, GZIP compressed U-Boot binary
> will be at a specified RAM location which is defined at
> CONFIG_SYS_LOAD_ADDR and will be assign it as the source address.
> 
> gunzip function in spl_load_fit_image ,will decompress the GZIP
> compressed U-Boot binary which is placed at
> source address(CONFIG_SYS_LOAD_ADDR)  to the default
> CONFIG_SYS_TEXT_BASE location.
> 
> spl_load_fit_image function will load the decompressed U-Boot
> binary, which is placed at the CONFIG_SYS_TEXT_BASE location.
> 
> Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
> Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
> ---
>  common/spl/spl_fit.c |  7 +++++--
>  include/spl.h        | 10 ++++++++++
>  2 files changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
> index 730639f756..d728ac71fc 100644
> --- a/common/spl/spl_fit.c
> +++ b/common/spl/spl_fit.c
> @@ -239,7 +239,7 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
>  	bool external_data = false;
>  
>  	if (IS_ENABLED(CONFIG_SPL_FPGA) ||
> -	    (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_GZIP))) {
> +	    (IS_ENABLED(CONFIG_SPL_OS_BOOT) && spl_decompression_enabled())) {
>  		if (fit_image_get_type(fit, node, &type))
>  			puts("Cannot get image type.\n");
>  		else
> @@ -281,7 +281,10 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
>  			return 0;
>  		}
>  
> -		src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
> +		if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP))

Should probably use the new spl_decompression_enabled() instead of
IS_ENABLED(CONFIG_SPL_GZIP) and the extra wrapping parentheses should
not be needed.

> +			src_ptr = map_sysmem(ALIGN(CONFIG_SYS_LOAD_ADDR, ARCH_DMA_MINALIGN), len);
> +		else
> +			src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
>  		length = len;
>  
>  		overhead = get_aligned_image_overhead(info, offset);
> diff --git a/include/spl.h b/include/spl.h
> index 92bcaa90a4..088479e357 100644
> --- a/include/spl.h
> +++ b/include/spl.h
> @@ -897,4 +897,14 @@ struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size);
>  
>  void board_boot_order(u32 *spl_boot_list);
>  void spl_save_restore_data(void);
> +
> +/*
> + * spl_decompression_enabled() - check decompression support is enabled for SPL build
> + *
> + * Returns  true  if decompression support is enabled, else False
> + */
> +static inline bool spl_decompression_enabled(void)
> +{
> +	return (IS_ENABLED(CONFIG_SPL_GZIP) || IS_ENABLED(CONFIG_SPL_LZMA));

IS_ENABLED(CONFIG_SPL_LZMA) should probably be added in the patch that
add support for LZMA and the wrapping parentheses should not be needed.

Regards,
Jonas

> +}
>  #endif


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

* Re: [PATCH v2 4/4] spl: fit: support for booting a LZMA-compressed U-boot binary
  2023-07-25  3:51   ` [PATCH v2 4/4] spl: fit: support for booting a LZMA-compressed " Manoj Sai
  2023-07-27  0:53     ` Simon Glass
@ 2023-07-27 11:13     ` Jonas Karlman
  1 sibling, 0 replies; 55+ messages in thread
From: Jonas Karlman @ 2023-07-27 11:13 UTC (permalink / raw)
  To: Manoj Sai, Simon Glass, Philipp Tomsich, Kever Yang
  Cc: Da Xue, dsx724, linux-amarula, Jagan Teki, Suniel Mahesh, u-boot

On 2023-07-25 05:51, Manoj Sai wrote:
> If LZMA Compression support is enabled, LZMA compressed U-Boot
> binary will be placed at a specified RAM location which is
> defined at CONFIG_SYS_LOAD_ADDR and will be assigned  as the
> source address.
> 
> image_decomp() function, will decompress the LZMA compressed
> U-Boot binary which is placed at source address(CONFIG_SYS_LOAD_ADDR)
> to the default CONFIG_SYS_TEXT_BASE location.
> 
> spl_load_fit_image function will load the decompressed U-Boot
> binary, which is placed at the CONFIG_SYS_TEXT_BASE location.
> 
> Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
> Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
> ---
>  common/spl/spl_fit.c | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
> index d728ac71fc..208d2f761e 100644
> --- a/common/spl/spl_fit.c
> +++ b/common/spl/spl_fit.c
> @@ -246,7 +246,7 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
>  			debug("%s ", genimg_get_type_name(type));
>  	}
>  
> -	if (IS_ENABLED(CONFIG_SPL_GZIP)) {
> +	if (IS_ENABLED(CONFIG_SPL_GZIP) || IS_ENABLED(CONFIG_SPL_LZMA)) {

This should probably change to use new spl_decompression_enabled(),
such change should be made in the GZIP patch.

>  		fit_image_get_comp(fit, node, &image_comp);
>  		debug("%s ", genimg_get_comp_name(image_comp));
>  	}
> @@ -280,8 +280,8 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
>  				    __func__, fit_get_name(fit, node, NULL));
>  			return 0;
>  		}
> -
> -		if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP))
> +		if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP) ||
> +		    (IS_ENABLED(CONFIG_SPL_LZMA) && image_comp == IH_COMP_LZMA))

Could probably be simplified to something like:

  if (spl_decompression_enabled() &&
      (image_comp == IH_COMP_GZIP || image_comp == IH_COMP_LZMA))

Also what happens if I run a SPL without compression enabled, but have a
FIT with image parts that is compressed?

Regards,
Jonas

>  			src_ptr = map_sysmem(ALIGN(CONFIG_SYS_LOAD_ADDR, ARCH_DMA_MINALIGN), len);
>  		else
>  			src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
> @@ -329,6 +329,16 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
>  			return -EIO;
>  		}
>  		length = size;
> +	} else if (IS_ENABLED(CONFIG_SPL_LZMA) && image_comp == IH_COMP_LZMA) {
> +		size = CONFIG_SYS_BOOTM_LEN;
> +		ulong loadEnd;
> +
> +		if (image_decomp(IH_COMP_LZMA, CONFIG_SYS_LOAD_ADDR, 0, 0,
> +				 load_ptr, src, length, size, &loadEnd)) {
> +			puts("Uncompressing error\n");
> +			return -EIO;
> +		}
> +		length = loadEnd - CONFIG_SYS_LOAD_ADDR;
>  	} else {
>  		memcpy(load_ptr, src, length);
>  	}


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

* Re: [PATCH v2 0/4] support for booting the compressed U-boot binary on Rockchip based ARM64 SOC's
  2023-07-25  3:50 ` [PATCH v2 0/4] support for booting the compressed U-boot binary on Rockchip based ARM64 SOC's Manoj Sai
                     ` (3 preceding siblings ...)
  2023-07-25  3:51   ` [PATCH v2 4/4] spl: fit: support for booting a LZMA-compressed " Manoj Sai
@ 2023-07-27 11:21   ` Jonas Karlman
  2023-08-28  4:44     ` Manoj Sai
  2023-09-10 18:24   ` [PATCH v3 " Manoj Sai
  5 siblings, 1 reply; 55+ messages in thread
From: Jonas Karlman @ 2023-07-27 11:21 UTC (permalink / raw)
  To: Manoj Sai, Simon Glass, Philipp Tomsich, Kever Yang
  Cc: Da Xue, dsx724, linux-amarula, Jagan Teki, Suniel Mahesh, u-boot

On 2023-07-25 05:50, Manoj Sai wrote:
> This patchset adds the support on Rockchip based ARM64 SOC's that  compress the U-BOOT proper along with dtb 
> and ATF in FIT image format.Second stage bootloader(SPL) loads the compressed binaries, uncompress 
> them and  handover control to the next stage.
> 
> Changes for V2 :-
> 
> - Removed the need to create gzip and lzma compressed U-boot-nodtb files using Makefile  and added a changeset 
> that "compress" field to u-boot-nodtb node and "compression" field to  u-boot Node in the FIT image, with the help 
> of this change binman will create the compressed Binaries.
>   
> Size Comparision between compressed and uncompressed binaries :-
>   
>   	size of uncompressed binary :- 9.4 MB (94,26,432 bytes)
>          manoj:u-boot$ ls -lb u-boot-rockchip.bin 
>         -rw-rw-r-- 1 manoj manoj 9426432 Jul 25 07:42 u-boot-rockchip.bin
> 
>        size of GZIP compressed binary :- 9.0 MB (89,85,088 bytes)
>          manoj:u-boot$ ls -lb u-boot-rockchip.bin 
>          -rw-rw-r-- 1 manoj manoj 8985088 Jul 25 07:42 u-boot-rockchip.bin
> 
>        size of LZMA compressed binary :- 9.0 MB (90,06,080 bytes)
>          manoj:u-boot$ ls -lb u-boot-rockchip.bin 
>          -rw-rw-r-- 1 manoj manoj 9006080 Jul 25 07:47 u-boot-rockchip.bin 
> 
> - modified to use the CONFIG_SYS_LOAD_ADDR as the source RAM address to store the  compressed U-Boot binary which 
> will be defined in the machine defconfig file in place of creating a new RAM address for a specific board using Kconfig.
> so patchset related to adding a new RAM address to store compressed binary has been removed in V2 patchset. 
> 
> - Removed the patchset related to adding  the u-boot-nodtb.bin.gz and u-boot-nodtb.bin.lzma as input binary to binman.
> 
> 
> -- Test results of  Booting time using bootstage command in Uboot command prompt on roc-rk3399-pc board :-
> 
> 1) Uncompressed U-BOOT : Total boot time ≈ 12.3 seconds 
> => bootstage  report
> Timer summary in microseconds (10 records):
>        Mark    Elapsed  Stage
>           0          0  reset
>   1,824,330  1,824,330  board_init_f
>   2,921,678  1,097,348  board_init_r
>   5,179,369  2,257,691  eth_common_init
>   5,478,307    298,938  eth_initialize
>   5,478,484        177  main_loop
>   5,478,641        157  usb_start
>  12,017,936  6,539,295  cli_loop
> 
> Accumulated time:
>                 15,899  dm_r
>                694,371  dm_f
> 
> 2) GZIP Compressed U-BOOT : Total boot time ≈ 13.5 seconds 
> =>  bootstage  report
> Timer summary in microseconds (10 records):
>        Mark    Elapsed  Stage
>           0          0  reset
>   2,591,355  2,591,355  board_init_f
>   3,689,407  1,098,052  board_init_r
>   5,947,314  2,257,907  eth_common_init
>   6,246,250    298,936  eth_initialize
>   6,246,427        177  main_loop
>   6,246,585        158  usb_start
>  12,785,936  6,539,351  cli_loop
> 
> Accumulated time:
>                 15,902  dm_r
>                694,779  dm_f
> 
> 2) LZMA Compressed U-BOOT : Total boot time ≈ 23.5 seconds
> => bootstage report
> Timer summary in microseconds (10 records):
>        Mark    Elapsed  Stage
>           0          0  reset
>   6,376,405  6,376,405  board_init_f
>   7,471,967  1,095,562  board_init_r
>   9,726,257  2,254,290  eth_common_init
>  10,024,873    298,616  eth_initialize
>  10,025,049        176  main_loop
>  10,025,208        159  usb_start
>  16,564,906  6,539,698  cli_loop
>  
> Accumulated time:
>                 15,851  dm_r
>                693,323  dm_f
> 
> 
> Patch 1/4  generate a GZIP-compressed U-boot binary using binman if CONFIG_SPL_GZIP selected
> Patch 2/4  generate a LZMA-compressed U-boot binary using binman if CONFIG_SPL_LZMA selected 
> Patch 3/4  uncompress the gzip U-BOOT binary and load the binaries if gzip compression supoort is enabled
> Patch 4/4  uncompress the lzma U-BOOT binary and load the binaries if lzma compression supoort is enabled

Boot times seem very slow with compression enabled, please try with
caches enabled, see RFC patch at [1]. Enable caches have a huge impact
for FIT checksum validation using CONFIG_SPL_FIT_SIGNATURE=y.

Possible to also include ZSTD support?

nit: patch 1 and 2 should come after patch 3 and 4.

[1] https://patchwork.ozlabs.org/project/uboot/patch/20230702110055.3686457-1-jonas@kwiboo.se/

Regards,
Jonas

> 
> Manoj Sai (4):
>   rockchip: Add support to generate GZIP compressed U-boot binary
>   rockchip: Add support to generate LZMA compressed U-boot binary
>   spl: fit: support for booting a GZIP-compressed U-boot binary
>   spl: fit: support for booting a LZMA-compressed U-boot binary
> 
>  arch/arm/dts/rockchip-u-boot.dtsi | 11 +++++++++++
>  common/spl/spl_fit.c              | 21 +++++++++++++++++----
>  include/spl.h                     | 10 ++++++++++
>  3 files changed, 38 insertions(+), 4 deletions(-)
> 


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

* Re: [PATCH v2 1/4] rockchip: Add support to generate GZIP compressed U-boot binary
  2023-07-25  3:50   ` [PATCH v2 1/4] rockchip: Add support to generate GZIP compressed U-boot binary Manoj Sai
  2023-07-27  0:53     ` Simon Glass
@ 2023-07-28 10:09     ` Kever Yang
  2023-08-12  3:03     ` Kever Yang
  2 siblings, 0 replies; 55+ messages in thread
From: Kever Yang @ 2023-07-28 10:09 UTC (permalink / raw)
  To: Manoj Sai, Simon Glass, Philipp Tomsich, u-boot
  Cc: Da Xue, dsx724, linux-amarula, Jagan Teki, Suniel Mahesh


On 2023/7/25 11:50, Manoj Sai wrote:
> Add support for generating a GZIP-compressed U-boot binary with the
> help of binman, if CONFIG_SPL_GZIP is selected.
>
> Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>

Thanks,
- Kever
> ---
>   arch/arm/dts/rockchip-u-boot.dtsi | 7 +++++++
>   1 file changed, 7 insertions(+)
>
> diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi
> index 2878b80926..524d638e5b 100644
> --- a/arch/arm/dts/rockchip-u-boot.dtsi
> +++ b/arch/arm/dts/rockchip-u-boot.dtsi
> @@ -48,10 +48,17 @@
>   					type = "standalone";
>   					os = "U-Boot";
>   					arch = "arm64";
> +#if defined(CONFIG_SPL_GZIP)
> +					compression = "gzip";
> +#else
>   					compression = "none";
> +#endif
>   					load = <CONFIG_TEXT_BASE>;
>   					entry = <CONFIG_TEXT_BASE>;
>   					u-boot-nodtb {
> +#if defined(CONFIG_SPL_GZIP)
> +						compress = "gzip";
> +#endif
>   					};
>   #ifdef CONFIG_SPL_FIT_SIGNATURE
>   					hash {

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

* Re: [PATCH v2 2/4] rockchip: Add support to generate LZMA compressed U-boot binary
  2023-07-25  3:50   ` [PATCH v2 2/4] rockchip: Add support to generate LZMA " Manoj Sai
  2023-07-27  0:53     ` Simon Glass
@ 2023-07-28 10:09     ` Kever Yang
  1 sibling, 0 replies; 55+ messages in thread
From: Kever Yang @ 2023-07-28 10:09 UTC (permalink / raw)
  To: Manoj Sai, Simon Glass, Philipp Tomsich, u-boot
  Cc: Da Xue, dsx724, linux-amarula, Jagan Teki, Suniel Mahesh


On 2023/7/25 11:50, Manoj Sai wrote:
> Add support for generating a LZMA-compressed U-boot binary with the
> help of binman, if CONFIG_SPL_LZMA is selected.
>
> Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>

Thanks,
- Kever
> ---
>   arch/arm/dts/rockchip-u-boot.dtsi | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi
> index 524d638e5b..34282bdfb2 100644
> --- a/arch/arm/dts/rockchip-u-boot.dtsi
> +++ b/arch/arm/dts/rockchip-u-boot.dtsi
> @@ -50,6 +50,8 @@
>   					arch = "arm64";
>   #if defined(CONFIG_SPL_GZIP)
>   					compression = "gzip";
> +#elif defined(CONFIG_SPL_LZMA)
> +					compression = "lzma";
>   #else
>   					compression = "none";
>   #endif
> @@ -58,6 +60,8 @@
>   					u-boot-nodtb {
>   #if defined(CONFIG_SPL_GZIP)
>   						compress = "gzip";
> +#elif defined(CONFIG_SPL_LZMA)
> +						compress = "lzma";
>   #endif
>   					};
>   #ifdef CONFIG_SPL_FIT_SIGNATURE

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

* Re: [PATCH v2 3/4] spl: fit: support for booting a GZIP-compressed U-boot binary
  2023-07-25  3:51   ` [PATCH v2 3/4] spl: fit: support for booting a GZIP-compressed " Manoj Sai
  2023-07-27  0:53     ` Simon Glass
  2023-07-27 11:03     ` Jonas Karlman
@ 2023-07-28 10:09     ` Kever Yang
  2 siblings, 0 replies; 55+ messages in thread
From: Kever Yang @ 2023-07-28 10:09 UTC (permalink / raw)
  To: Manoj Sai, Simon Glass, Philipp Tomsich, u-boot
  Cc: Da Xue, dsx724, linux-amarula, Jagan Teki, Suniel Mahesh


On 2023/7/25 11:51, Manoj Sai wrote:
> If GZIP Compression support is enabled, GZIP compressed U-Boot binary
> will be at a specified RAM location which is defined at
> CONFIG_SYS_LOAD_ADDR and will be assign it as the source address.
>
> gunzip function in spl_load_fit_image ,will decompress the GZIP
> compressed U-Boot binary which is placed at
> source address(CONFIG_SYS_LOAD_ADDR)  to the default
> CONFIG_SYS_TEXT_BASE location.
>
> spl_load_fit_image function will load the decompressed U-Boot
> binary, which is placed at the CONFIG_SYS_TEXT_BASE location.
>
> Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
> Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>

Thanks,
- Kever
> ---
>   common/spl/spl_fit.c |  7 +++++--
>   include/spl.h        | 10 ++++++++++
>   2 files changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
> index 730639f756..d728ac71fc 100644
> --- a/common/spl/spl_fit.c
> +++ b/common/spl/spl_fit.c
> @@ -239,7 +239,7 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
>   	bool external_data = false;
>   
>   	if (IS_ENABLED(CONFIG_SPL_FPGA) ||
> -	    (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_GZIP))) {
> +	    (IS_ENABLED(CONFIG_SPL_OS_BOOT) && spl_decompression_enabled())) {
>   		if (fit_image_get_type(fit, node, &type))
>   			puts("Cannot get image type.\n");
>   		else
> @@ -281,7 +281,10 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
>   			return 0;
>   		}
>   
> -		src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
> +		if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP))
> +			src_ptr = map_sysmem(ALIGN(CONFIG_SYS_LOAD_ADDR, ARCH_DMA_MINALIGN), len);
> +		else
> +			src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
>   		length = len;
>   
>   		overhead = get_aligned_image_overhead(info, offset);
> diff --git a/include/spl.h b/include/spl.h
> index 92bcaa90a4..088479e357 100644
> --- a/include/spl.h
> +++ b/include/spl.h
> @@ -897,4 +897,14 @@ struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size);
>   
>   void board_boot_order(u32 *spl_boot_list);
>   void spl_save_restore_data(void);
> +
> +/*
> + * spl_decompression_enabled() - check decompression support is enabled for SPL build
> + *
> + * Returns  true  if decompression support is enabled, else False
> + */
> +static inline bool spl_decompression_enabled(void)
> +{
> +	return (IS_ENABLED(CONFIG_SPL_GZIP) || IS_ENABLED(CONFIG_SPL_LZMA));
> +}
>   #endif

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

* Re: [PATCH v2 3/4] spl: fit: support for booting a GZIP-compressed U-boot binary
  2023-07-27 11:03     ` Jonas Karlman
@ 2023-07-28 10:11       ` Kever Yang
  0 siblings, 0 replies; 55+ messages in thread
From: Kever Yang @ 2023-07-28 10:11 UTC (permalink / raw)
  To: Jonas Karlman, Manoj Sai, Simon Glass, Philipp Tomsich
  Cc: Da Xue, dsx724, linux-amarula, Jagan Teki, Suniel Mahesh, u-boot

Hi Manoj,

     Could update a new patch version and address the comment from Jonas?


Thanks,

- Kever

On 2023/7/27 19:03, Jonas Karlman wrote:
> On 2023-07-25 05:51, Manoj Sai wrote:
>> If GZIP Compression support is enabled, GZIP compressed U-Boot binary
>> will be at a specified RAM location which is defined at
>> CONFIG_SYS_LOAD_ADDR and will be assign it as the source address.
>>
>> gunzip function in spl_load_fit_image ,will decompress the GZIP
>> compressed U-Boot binary which is placed at
>> source address(CONFIG_SYS_LOAD_ADDR)  to the default
>> CONFIG_SYS_TEXT_BASE location.
>>
>> spl_load_fit_image function will load the decompressed U-Boot
>> binary, which is placed at the CONFIG_SYS_TEXT_BASE location.
>>
>> Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
>> Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
>> ---
>>   common/spl/spl_fit.c |  7 +++++--
>>   include/spl.h        | 10 ++++++++++
>>   2 files changed, 15 insertions(+), 2 deletions(-)
>>
>> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
>> index 730639f756..d728ac71fc 100644
>> --- a/common/spl/spl_fit.c
>> +++ b/common/spl/spl_fit.c
>> @@ -239,7 +239,7 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
>>   	bool external_data = false;
>>   
>>   	if (IS_ENABLED(CONFIG_SPL_FPGA) ||
>> -	    (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_GZIP))) {
>> +	    (IS_ENABLED(CONFIG_SPL_OS_BOOT) && spl_decompression_enabled())) {
>>   		if (fit_image_get_type(fit, node, &type))
>>   			puts("Cannot get image type.\n");
>>   		else
>> @@ -281,7 +281,10 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
>>   			return 0;
>>   		}
>>   
>> -		src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
>> +		if ((IS_ENABLED(CONFIG_SPL_GZIP) && image_comp == IH_COMP_GZIP))
> Should probably use the new spl_decompression_enabled() instead of
> IS_ENABLED(CONFIG_SPL_GZIP) and the extra wrapping parentheses should
> not be needed.
>
>> +			src_ptr = map_sysmem(ALIGN(CONFIG_SYS_LOAD_ADDR, ARCH_DMA_MINALIGN), len);
>> +		else
>> +			src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
>>   		length = len;
>>   
>>   		overhead = get_aligned_image_overhead(info, offset);
>> diff --git a/include/spl.h b/include/spl.h
>> index 92bcaa90a4..088479e357 100644
>> --- a/include/spl.h
>> +++ b/include/spl.h
>> @@ -897,4 +897,14 @@ struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size);
>>   
>>   void board_boot_order(u32 *spl_boot_list);
>>   void spl_save_restore_data(void);
>> +
>> +/*
>> + * spl_decompression_enabled() - check decompression support is enabled for SPL build
>> + *
>> + * Returns  true  if decompression support is enabled, else False
>> + */
>> +static inline bool spl_decompression_enabled(void)
>> +{
>> +	return (IS_ENABLED(CONFIG_SPL_GZIP) || IS_ENABLED(CONFIG_SPL_LZMA));
> IS_ENABLED(CONFIG_SPL_LZMA) should probably be added in the patch that
> add support for LZMA and the wrapping parentheses should not be needed.
>
> Regards,
> Jonas
>
>> +}
>>   #endif

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

* Re: [PATCH v2 1/4] rockchip: Add support to generate GZIP compressed U-boot binary
  2023-07-25  3:50   ` [PATCH v2 1/4] rockchip: Add support to generate GZIP compressed U-boot binary Manoj Sai
  2023-07-27  0:53     ` Simon Glass
  2023-07-28 10:09     ` Kever Yang
@ 2023-08-12  3:03     ` Kever Yang
  2 siblings, 0 replies; 55+ messages in thread
From: Kever Yang @ 2023-08-12  3:03 UTC (permalink / raw)
  To: Manoj Sai, Simon Glass, Philipp Tomsich, u-boot
  Cc: Da Xue, dsx724, linux-amarula, Jagan Teki, Suniel Mahesh

Hi Manoj,

     This patch need rebase, and could you please address the comment 
from Jonas in new version is possible.


Thanks,

- Kever

On 2023/7/25 11:50, Manoj Sai wrote:
> Add support for generating a GZIP-compressed U-boot binary with the
> help of binman, if CONFIG_SPL_GZIP is selected.
>
> Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
> ---
>   arch/arm/dts/rockchip-u-boot.dtsi | 7 +++++++
>   1 file changed, 7 insertions(+)
>
> diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi
> index 2878b80926..524d638e5b 100644
> --- a/arch/arm/dts/rockchip-u-boot.dtsi
> +++ b/arch/arm/dts/rockchip-u-boot.dtsi
> @@ -48,10 +48,17 @@
>   					type = "standalone";
>   					os = "U-Boot";
>   					arch = "arm64";
> +#if defined(CONFIG_SPL_GZIP)
> +					compression = "gzip";
> +#else
>   					compression = "none";
> +#endif
>   					load = <CONFIG_TEXT_BASE>;
>   					entry = <CONFIG_TEXT_BASE>;
>   					u-boot-nodtb {
> +#if defined(CONFIG_SPL_GZIP)
> +						compress = "gzip";
> +#endif
>   					};
>   #ifdef CONFIG_SPL_FIT_SIGNATURE
>   					hash {

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

* Re: [PATCH v2 0/4] support for booting the compressed U-boot binary on Rockchip based ARM64 SOC's
  2023-07-27 11:21   ` [PATCH v2 0/4] support for booting the compressed U-boot binary on Rockchip based ARM64 SOC's Jonas Karlman
@ 2023-08-28  4:44     ` Manoj Sai
  0 siblings, 0 replies; 55+ messages in thread
From: Manoj Sai @ 2023-08-28  4:44 UTC (permalink / raw)
  To: Jonas Karlman
  Cc: Simon Glass, Philipp Tomsich, Kever Yang, Da Xue, dsx724,
	linux-amarula, Jagan Teki, Suniel Mahesh, u-boot

On Thu, Jul 27, 2023 at 4:51 PM Jonas Karlman <jonas@kwiboo.se> wrote:
>
> On 2023-07-25 05:50, Manoj Sai wrote:
> > This patchset adds the support on Rockchip based ARM64 SOC's that  compress the U-BOOT proper along with dtb
> > and ATF in FIT image format.Second stage bootloader(SPL) loads the compressed binaries, uncompress
> > them and  handover control to the next stage.
> >
> > Changes for V2 :-
> >
> > - Removed the need to create gzip and lzma compressed U-boot-nodtb files using Makefile  and added a changeset
> > that "compress" field to u-boot-nodtb node and "compression" field to  u-boot Node in the FIT image, with the help
> > of this change binman will create the compressed Binaries.
> >
> > Size Comparision between compressed and uncompressed binaries :-
> >
> >       size of uncompressed binary :- 9.4 MB (94,26,432 bytes)
> >          manoj:u-boot$ ls -lb u-boot-rockchip.bin
> >         -rw-rw-r-- 1 manoj manoj 9426432 Jul 25 07:42 u-boot-rockchip.bin
> >
> >        size of GZIP compressed binary :- 9.0 MB (89,85,088 bytes)
> >          manoj:u-boot$ ls -lb u-boot-rockchip.bin
> >          -rw-rw-r-- 1 manoj manoj 8985088 Jul 25 07:42 u-boot-rockchip.bin
> >
> >        size of LZMA compressed binary :- 9.0 MB (90,06,080 bytes)
> >          manoj:u-boot$ ls -lb u-boot-rockchip.bin
> >          -rw-rw-r-- 1 manoj manoj 9006080 Jul 25 07:47 u-boot-rockchip.bin
> >
> > - modified to use the CONFIG_SYS_LOAD_ADDR as the source RAM address to store the  compressed U-Boot binary which
> > will be defined in the machine defconfig file in place of creating a new RAM address for a specific board using Kconfig.
> > so patchset related to adding a new RAM address to store compressed binary has been removed in V2 patchset.
> >
> > - Removed the patchset related to adding  the u-boot-nodtb.bin.gz and u-boot-nodtb.bin.lzma as input binary to binman.
> >
> >
> > -- Test results of  Booting time using bootstage command in Uboot command prompt on roc-rk3399-pc board :-
> >
> > 1) Uncompressed U-BOOT : Total boot time ≈ 12.3 seconds
> > => bootstage  report
> > Timer summary in microseconds (10 records):
> >        Mark    Elapsed  Stage
> >           0          0  reset
> >   1,824,330  1,824,330  board_init_f
> >   2,921,678  1,097,348  board_init_r
> >   5,179,369  2,257,691  eth_common_init
> >   5,478,307    298,938  eth_initialize
> >   5,478,484        177  main_loop
> >   5,478,641        157  usb_start
> >  12,017,936  6,539,295  cli_loop
> >
> > Accumulated time:
> >                 15,899  dm_r
> >                694,371  dm_f
> >
> > 2) GZIP Compressed U-BOOT : Total boot time ≈ 13.5 seconds
> > =>  bootstage  report
> > Timer summary in microseconds (10 records):
> >        Mark    Elapsed  Stage
> >           0          0  reset
> >   2,591,355  2,591,355  board_init_f
> >   3,689,407  1,098,052  board_init_r
> >   5,947,314  2,257,907  eth_common_init
> >   6,246,250    298,936  eth_initialize
> >   6,246,427        177  main_loop
> >   6,246,585        158  usb_start
> >  12,785,936  6,539,351  cli_loop
> >
> > Accumulated time:
> >                 15,902  dm_r
> >                694,779  dm_f
> >
> > 2) LZMA Compressed U-BOOT : Total boot time ≈ 23.5 seconds
> > => bootstage report
> > Timer summary in microseconds (10 records):
> >        Mark    Elapsed  Stage
> >           0          0  reset
> >   6,376,405  6,376,405  board_init_f
> >   7,471,967  1,095,562  board_init_r
> >   9,726,257  2,254,290  eth_common_init
> >  10,024,873    298,616  eth_initialize
> >  10,025,049        176  main_loop
> >  10,025,208        159  usb_start
> >  16,564,906  6,539,698  cli_loop
> >
> > Accumulated time:
> >                 15,851  dm_r
> >                693,323  dm_f
> >
> >
> > Patch 1/4  generate a GZIP-compressed U-boot binary using binman if CONFIG_SPL_GZIP selected
> > Patch 2/4  generate a LZMA-compressed U-boot binary using binman if CONFIG_SPL_LZMA selected
> > Patch 3/4  uncompress the gzip U-BOOT binary and load the binaries if gzip compression supoort is enabled
> > Patch 4/4  uncompress the lzma U-BOOT binary and load the binaries if lzma compression supoort is enabled
>
> Boot times seem very slow with compression enabled, please try with
> caches enabled, see RFC patch at [1]. Enable caches have a huge impact
> for FIT checksum validation using CONFIG_SPL_FIT_SIGNATURE=y.
>
> Possible to also include ZSTD support?
>

Hi Jonas ,
Enabled zstd support , facing build issues related to zstd . Had you
faced this build error , pasted below :

aarch64-linux-gnu-ld.bfd: lib/zstd/decompress/zstd_decompress.o: in
function `ZSTD_DDictHashSet_getIndex':
/media/manoj/7d4c36e9-ddbb-4e7a-bd1e-cb96766bde37/ssd-Workspace/libreCompTask/tasks/compression-Task/mainline-apply-Uboot-cmp-2023/testfldr/u-boot/lib/zstd/decompress/zstd_decompress.c:88:
undefined reference to `xxh64'
aarch64-linux-gnu-ld.bfd: lib/zstd/decompress/zstd_decompress.o: in
function `ZSTD_decodeFrameHeader':
/media/manoj/7d4c36e9-ddbb-4e7a-bd1e-cb96766bde37/ssd-Workspace/libreCompTask/tasks/compression-Task/mainline-apply-Uboot-cmp-2023/testfldr/u-boot/lib/zstd/decompress/zstd_decompress.c:666:
undefined reference to `xxh64_reset'
aarch64-linux-gnu-ld.bfd: lib/zstd/decompress/zstd_decompress.o: in
function `ZSTD_decompressFrame':
/media/manoj/7d4c36e9-ddbb-4e7a-bd1e-cb96766bde37/ssd-Workspace/libreCompTask/tasks/compression-Task/mainline-apply-Uboot-cmp-2023/testfldr/u-boot/lib/zstd/decompress/zstd_decompress.c:888:
undefined reference to `xxh64_update'
aarch64-linux-gnu-ld.bfd:
/media/manoj/7d4c36e9-ddbb-4e7a-bd1e-cb96766bde37/ssd-Workspace/libreCompTask/tasks/compression-Task/mainline-apply-Uboot-cmp-2023/testfldr/u-boot/lib/zstd/decompress/zstd_decompress.c:904:
undefined reference to `xxh64_digest'
make[1]: *** [scripts/Makefile.spl:527: spl/u-boot-spl] Error 1
make: *** [Makefile:2059: spl/u-boot-spl] Error 2

I'm missing anything to enable in configs ? any suggestions to these build error

Thanks and Regards ,
A.manojsai

> nit: patch 1 and 2 should come after patch 3 and 4.
>
> [1] https://patchwork.ozlabs.org/project/uboot/patch/20230702110055.3686457-1-jonas@kwiboo.se/
>
> Regards,
> Jonas
>
> >
> > Manoj Sai (4):
> >   rockchip: Add support to generate GZIP compressed U-boot binary
> >   rockchip: Add support to generate LZMA compressed U-boot binary
> >   spl: fit: support for booting a GZIP-compressed U-boot binary
> >   spl: fit: support for booting a LZMA-compressed U-boot binary
> >
> >  arch/arm/dts/rockchip-u-boot.dtsi | 11 +++++++++++
> >  common/spl/spl_fit.c              | 21 +++++++++++++++++----
> >  include/spl.h                     | 10 ++++++++++
> >  3 files changed, 38 insertions(+), 4 deletions(-)
> >
>

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

* [PATCH v3 0/4] support for booting the compressed U-boot binary on Rockchip based ARM64 SOC's
  2023-07-25  3:50 ` [PATCH v2 0/4] support for booting the compressed U-boot binary on Rockchip based ARM64 SOC's Manoj Sai
                     ` (4 preceding siblings ...)
  2023-07-27 11:21   ` [PATCH v2 0/4] support for booting the compressed U-boot binary on Rockchip based ARM64 SOC's Jonas Karlman
@ 2023-09-10 18:24   ` Manoj Sai
  2023-09-10 18:24     ` [PATCH v3 1/4] spl: fit: support for booting a GZIP-compressed U-boot binary Manoj Sai
                       ` (5 more replies)
  5 siblings, 6 replies; 55+ messages in thread
From: Manoj Sai @ 2023-09-10 18:24 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: dsx724, Jagan Teki, Suniel Mahesh, Manoj Sai

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=y, Size: 4647 bytes --]

This patchset adds the support on Rockchip based ARM64 SOC's that  compress the U-BOOT proper along with dtb
and ATF in FIT image format.Second stage bootloader(SPL) loads the compressed binaries, uncompress
them and  handover control to the next stage.

Changes for V3 :-

1. Replaced spl_decompression_enabled() function instead of checking IS_ENABLED(CONFIG_SPL_GZIP)
   and IS_ENABLED(CONFIG_SPL_LZMA) in spl_fit.c

2. Removed extra wrapping parentheses in spl_decompression_enabled().

Size Comparision between compressed and uncompressed binaries :-

       size of uncompressed binary    :- 9.0M (94,21,824 bytes)
         manoj:u-boot$ ls -lb u-boot-rockchip.bin
        -rw-rw-r-- 1 manoj manoj 9421824 Sep 10 22:22 u-boot-rockchip.bin

       size of GZIP compressed binary :- 8.6M (89,85,088 bytes)
         manoj:u-boot$ ls -lb u-boot-rockchip.bin
         -rw-rw-r-- 1 manoj manoj 8985088 Jul 25 07:42 u-boot-rockchip.bin

       size of LZMA compressed binary :- 8.6 M (90,06,592 bytes)
         manoj:u-boot$ ls -lb u-boot-rockchip.bin
         -rw-rw-r-- 1 manoj manoj 9006592 Jul 25 07:47 u-boot-rockchip.bin

Test results of  Booting time using bootstage command in Uboot command prompt on roc-rk3399-pc board :-

1) Uncompressed U-BOOT : Total boot time ≈ 12.063971 seconds
=> bootstage report
Timer summary in microseconds (10 records):
       Mark    Elapsed  Stage
          0          0  reset
  1,833,884  1,833,884  board_init_f
  2,959,528  1,125,644  board_init_r
  5,224,521  2,264,993  eth_common_init
  5,523,428    298,907  eth_initialize
  5,523,606        178  main_loop
  5,523,764        158  usb_start
 12,063,971  6,540,207  cli_loop

2) GZIP Compressed U-BOOT : Total time ≈ 12.824968 seconds

=> bootstage report
Timer summary in microseconds (10 records):
       Mark    Elapsed  Stage
          0          0  reset
  2,594,709  2,594,709  board_init_f
  3,719,969  1,125,260  board_init_r
  5,985,450  2,265,481  eth_common_init
  6,284,371    298,921  eth_initialize
  6,284,549        178  main_loop
  6,284,708        159  usb_start
 12,824,968  6,540,260  cli_loop

3) LZMA Compressed U-BOOT : Total time ≈ 17.025004 seconds

=> bootstage report
Timer summary in microseconds (10 records):
       Mark    Elapsed  Stage
          0          0  reset
  6,852,254  6,852,254  board_init_f
  7,940,143  1,087,889  board_init_r
 10,190,458  2,250,315  eth_common_init
 10,487,254    296,796  eth_initialize
 10,487,432        178  main_loop
 10,487,590        158  usb_start
 17,025,004  6,537,414  cli_loop


As per suggestion from Mr.Jonas Karlman (jonas@kwiboo.se) through Patchset V2,that check boot time
with enabling CONFIG_SPL_FIT_SIGNATURE that might impact boot time.

Tried to check the boot time with CONFIG_FIT_SIGNATURE enabled, I didnt find any significant
boot time improvement  with enabling CONFIG_SPL_FIT_SIGNATURE.

Comparision of GZIP and LZMA compressed U-boot Boot time with and without Enable of CONFIG_FIT_SIGNATURE :-

- GZIP Compressed U-BOOT  and CONFIG_FIT_SIGNATURE enabled  :-  Total time ≈ 13.283998 seconds

=> bootstage report
Timer summary in microseconds (10 records):
       Mark    Elapsed  Stage
          0          0  reset
  3,052,571  3,052,571  board_init_f
  4,179,787  1,127,216  board_init_r
  6,445,472  2,265,685  eth_common_init
  6,744,416    298,944  eth_initialize
  6,744,593        177  main_loop
  6,744,751        158  usb_start
 13,283,998  6,539,247  cli_loop

- GZIP Compressed U-BOOT and CONFIG_FIT_SIGNATURE disabled  :- Total time ≈ 12.824968 seconds


- LZMA Compressed U-BOOT  and CONFIG_FIT_SIGNATURE enabled  :-  Total time ≈ 17.005996 seconds

   => bootstage report
Timer summary in microseconds (10 records):
       Mark    Elapsed  Stage
          0          0  reset
  6,775,071  6,775,071  board_init_f
  7,902,443  1,127,372  board_init_r
 10,167,546  2,265,103  eth_common_init
 10,466,418    298,872  eth_initialize
 10,466,595        177  main_loop
 10,466,753        158  usb_start
 17,005,996  6,539,243  cli_loop

- LZMA Compressed U-BOOT  and CONFIG_FIT_SIGNATURE disabled  :- Total time ≈ 17.025004 seconds

Manoj Sai (4):
  spl: fit: support for booting a GZIP-compressed U-boot binary
  spl: fit: support for booting a LZMA-compressed U-boot binary
  rockchip: Add support to generate GZIP compressed U-boot binary
  rockchip: Add support to generate LZMA compressed U-boot binary

 arch/arm/dts/rockchip-u-boot.dtsi | 11 +++++++++++
 common/spl/spl_fit.c              | 20 +++++++++++++++++---
 include/spl.h                     | 10 ++++++++++
 3 files changed, 38 insertions(+), 3 deletions(-)

--
2.25.1


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

* [PATCH v3 1/4] spl: fit: support for booting a GZIP-compressed U-boot binary
  2023-09-10 18:24   ` [PATCH v3 " Manoj Sai
@ 2023-09-10 18:24     ` Manoj Sai
  2023-09-10 18:24     ` [PATCH v3 2/4] spl: fit: support for booting a LZMA-compressed " Manoj Sai
                       ` (4 subsequent siblings)
  5 siblings, 0 replies; 55+ messages in thread
From: Manoj Sai @ 2023-09-10 18:24 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: dsx724, Jagan Teki, Suniel Mahesh, Manoj Sai

If GZIP Compression support is enabled, GZIP compressed U-Boot binary
will be at a specified RAM location which is defined at
CONFIG_SYS_LOAD_ADDR and will be assign it as the source address.

gunzip function in spl_load_fit_image ,will decompress the GZIP
compressed U-Boot binary which is placed at
source address(CONFIG_SYS_LOAD_ADDR)  to the default
CONFIG_SYS_TEXT_BASE location.

spl_load_fit_image function will load the decompressed U-Boot
binary, which is placed at the CONFIG_SYS_TEXT_BASE location.

Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
Changes in v3:
 - Replaced spl_decompression_enabled() function instead of
   checking IS_ENABLED(CONFIG_SPL_GZIP).

 - Removed checking IS_ENABLED(CONFIG_SPL_LZMA) in spl_decompression_enabled()
   function.

Changes in v2:
 - New patch for v2

 common/spl/spl_fit.c |  9 ++++++---
 include/spl.h        | 10 ++++++++++
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 730639f756..eb97259f57 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -239,14 +239,14 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 	bool external_data = false;
 
 	if (IS_ENABLED(CONFIG_SPL_FPGA) ||
-	    (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_GZIP))) {
+	    (IS_ENABLED(CONFIG_SPL_OS_BOOT) && spl_decompression_enabled())) {
 		if (fit_image_get_type(fit, node, &type))
 			puts("Cannot get image type.\n");
 		else
 			debug("%s ", genimg_get_type_name(type));
 	}
 
-	if (IS_ENABLED(CONFIG_SPL_GZIP)) {
+	if (spl_decompression_enabled()) {
 		fit_image_get_comp(fit, node, &image_comp);
 		debug("%s ", genimg_get_comp_name(image_comp));
 	}
@@ -281,7 +281,10 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 			return 0;
 		}
 
-		src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
+		if (spl_decompression_enabled() && image_comp == IH_COMP_GZIP)
+			src_ptr = map_sysmem(ALIGN(CONFIG_SYS_LOAD_ADDR, ARCH_DMA_MINALIGN), len);
+		else
+			src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
 		length = len;
 
 		overhead = get_aligned_image_overhead(info, offset);
diff --git a/include/spl.h b/include/spl.h
index 93e906431e..3a7e448cc7 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -897,4 +897,14 @@ struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size);
 
 void board_boot_order(u32 *spl_boot_list);
 void spl_save_restore_data(void);
+
+/*
+ * spl_decompression_enabled() - check decompression support is enabled for SPL build
+ *
+ * Returns  true  if decompression support is enabled, else False
+ */
+static inline bool spl_decompression_enabled(void)
+{
+	return IS_ENABLED(CONFIG_SPL_GZIP);
+}
 #endif
-- 
2.25.1


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

* [PATCH v3 2/4] spl: fit: support for booting a LZMA-compressed U-boot binary
  2023-09-10 18:24   ` [PATCH v3 " Manoj Sai
  2023-09-10 18:24     ` [PATCH v3 1/4] spl: fit: support for booting a GZIP-compressed U-boot binary Manoj Sai
@ 2023-09-10 18:24     ` Manoj Sai
  2023-09-10 18:24     ` [PATCH v3 3/4] rockchip: Add support to generate GZIP compressed " Manoj Sai
                       ` (3 subsequent siblings)
  5 siblings, 0 replies; 55+ messages in thread
From: Manoj Sai @ 2023-09-10 18:24 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: dsx724, Jagan Teki, Suniel Mahesh, Manoj Sai

If LZMA Compression support is enabled, LZMA compressed U-Boot
binary will be placed at a specified RAM location which is
defined at CONFIG_SYS_LOAD_ADDR and will be assigned  as the
source address.

image_decomp() function, will decompress the LZMA compressed
U-Boot binary which is placed at source address(CONFIG_SYS_LOAD_ADDR)
to the default CONFIG_SYS_TEXT_BASE location.

spl_load_fit_image function will load the decompressed U-Boot
binary, which is placed at the CONFIG_SYS_TEXT_BASE location.

Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
---
Changes in v3:
 - added IS_ENABLED(CONFIG_SPL_LZMA) to spl_decompression_enabled() function.
 - Removed extra parentheses.

Changes in v2:
 - New patch for v2

 common/spl/spl_fit.c | 13 ++++++++++++-
 include/spl.h        |  2 +-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index eb97259f57..75895ef15c 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -281,7 +281,8 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 			return 0;
 		}
 
-		if (spl_decompression_enabled() && image_comp == IH_COMP_GZIP)
+		if (spl_decompression_enabled() &&
+		    (image_comp == IH_COMP_GZIP || image_comp == IH_COMP_LZMA))
 			src_ptr = map_sysmem(ALIGN(CONFIG_SYS_LOAD_ADDR, ARCH_DMA_MINALIGN), len);
 		else
 			src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
@@ -329,6 +330,16 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 			return -EIO;
 		}
 		length = size;
+	} else if (IS_ENABLED(CONFIG_SPL_LZMA) && image_comp == IH_COMP_LZMA) {
+		size = CONFIG_SYS_BOOTM_LEN;
+		ulong loadEnd;
+
+		if (image_decomp(IH_COMP_LZMA, CONFIG_SYS_LOAD_ADDR, 0, 0,
+				 load_ptr, src, length, size, &loadEnd)) {
+			puts("Uncompressing error\n");
+			return -EIO;
+		}
+		length = loadEnd - CONFIG_SYS_LOAD_ADDR;
 	} else {
 		memcpy(load_ptr, src, length);
 	}
diff --git a/include/spl.h b/include/spl.h
index 3a7e448cc7..9de93a34cd 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -905,6 +905,6 @@ void spl_save_restore_data(void);
  */
 static inline bool spl_decompression_enabled(void)
 {
-	return IS_ENABLED(CONFIG_SPL_GZIP);
+	return IS_ENABLED(CONFIG_SPL_GZIP) || IS_ENABLED(CONFIG_SPL_LZMA);
 }
 #endif
-- 
2.25.1


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

* [PATCH v3 3/4] rockchip: Add support to generate GZIP compressed U-boot binary
  2023-09-10 18:24   ` [PATCH v3 " Manoj Sai
  2023-09-10 18:24     ` [PATCH v3 1/4] spl: fit: support for booting a GZIP-compressed U-boot binary Manoj Sai
  2023-09-10 18:24     ` [PATCH v3 2/4] spl: fit: support for booting a LZMA-compressed " Manoj Sai
@ 2023-09-10 18:24     ` Manoj Sai
  2023-09-10 18:24     ` [PATCH v3 4/4] rockchip: Add support to generate LZMA " Manoj Sai
                       ` (2 subsequent siblings)
  5 siblings, 0 replies; 55+ messages in thread
From: Manoj Sai @ 2023-09-10 18:24 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: dsx724, Jagan Teki, Suniel Mahesh, Manoj Sai

Add support for generating a GZIP-compressed U-boot binary with the
help of binman, if CONFIG_SPL_GZIP is selected.

Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
---
Changes in v3:
 - None

Changes in v2:
 - New patch for v2

 arch/arm/dts/rockchip-u-boot.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi
index be2658e8ef..8f248f941f 100644
--- a/arch/arm/dts/rockchip-u-boot.dtsi
+++ b/arch/arm/dts/rockchip-u-boot.dtsi
@@ -56,10 +56,17 @@
 #else
 					arch = "arm";
 #endif
+#if defined(CONFIG_SPL_GZIP)
+					compression = "gzip";
+#else
 					compression = "none";
+#endif
 					load = <CONFIG_TEXT_BASE>;
 					entry = <CONFIG_TEXT_BASE>;
 					u-boot-nodtb {
+#if defined(CONFIG_SPL_GZIP)
+					compress = "gzip";
+#endif
 					};
 #ifdef CONFIG_SPL_FIT_SIGNATURE
 					hash {
-- 
2.25.1


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

* [PATCH v3 4/4] rockchip: Add support to generate LZMA compressed U-boot binary
  2023-09-10 18:24   ` [PATCH v3 " Manoj Sai
                       ` (2 preceding siblings ...)
  2023-09-10 18:24     ` [PATCH v3 3/4] rockchip: Add support to generate GZIP compressed " Manoj Sai
@ 2023-09-10 18:24     ` Manoj Sai
  2023-09-10 19:03     ` [PATCH v3 0/4] support for booting the compressed U-boot binary on Rockchip based ARM64 SOC's Jonas Karlman
  2023-09-17 19:26     ` [PATCH v4 " Manoj Sai
  5 siblings, 0 replies; 55+ messages in thread
From: Manoj Sai @ 2023-09-10 18:24 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: dsx724, Jagan Teki, Suniel Mahesh, Manoj Sai

Add support for generating a LZMA-compressed U-boot binary with the
help of binman, if CONFIG_SPL_LZMA is selected.

Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
---
Changes in v3:
 - None

Changes in v2:
 - New patch for v2

 arch/arm/dts/rockchip-u-boot.dtsi | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi
index 8f248f941f..c8c928c7e5 100644
--- a/arch/arm/dts/rockchip-u-boot.dtsi
+++ b/arch/arm/dts/rockchip-u-boot.dtsi
@@ -58,6 +58,8 @@
 #endif
 #if defined(CONFIG_SPL_GZIP)
 					compression = "gzip";
+#elif defined(CONFIG_SPL_LZMA)
+					compression = "lzma";
 #else
 					compression = "none";
 #endif
@@ -66,6 +68,8 @@
 					u-boot-nodtb {
 #if defined(CONFIG_SPL_GZIP)
 					compress = "gzip";
+#elif defined(CONFIG_SPL_LZMA)
+					compress = "lzma";
 #endif
 					};
 #ifdef CONFIG_SPL_FIT_SIGNATURE
-- 
2.25.1


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

* Re: [PATCH v3 0/4] support for booting the compressed U-boot binary on Rockchip based ARM64 SOC's
  2023-09-10 18:24   ` [PATCH v3 " Manoj Sai
                       ` (3 preceding siblings ...)
  2023-09-10 18:24     ` [PATCH v3 4/4] rockchip: Add support to generate LZMA " Manoj Sai
@ 2023-09-10 19:03     ` Jonas Karlman
  2023-09-17 19:26     ` [PATCH v4 " Manoj Sai
  5 siblings, 0 replies; 55+ messages in thread
From: Jonas Karlman @ 2023-09-10 19:03 UTC (permalink / raw)
  To: Manoj Sai, Simon Glass, Philipp Tomsich, Kever Yang
  Cc: dsx724, Jagan Teki, Suniel Mahesh, u-boot

Hi,

On 2023-09-10 20:24, Manoj Sai wrote:
> This patchset adds the support on Rockchip based ARM64 SOC's that  compress the U-BOOT proper along with dtb
> and ATF in FIT image format.Second stage bootloader(SPL) loads the compressed binaries, uncompress
> them and  handover control to the next stage.
> 
> Changes for V3 :-
> 
> 1. Replaced spl_decompression_enabled() function instead of checking IS_ENABLED(CONFIG_SPL_GZIP)
>    and IS_ENABLED(CONFIG_SPL_LZMA) in spl_fit.c
> 
> 2. Removed extra wrapping parentheses in spl_decompression_enabled().
> 
> Size Comparision between compressed and uncompressed binaries :-
> 
>        size of uncompressed binary    :- 9.0M (94,21,824 bytes)
>          manoj:u-boot$ ls -lb u-boot-rockchip.bin
>         -rw-rw-r-- 1 manoj manoj 9421824 Sep 10 22:22 u-boot-rockchip.bin
> 
>        size of GZIP compressed binary :- 8.6M (89,85,088 bytes)
>          manoj:u-boot$ ls -lb u-boot-rockchip.bin
>          -rw-rw-r-- 1 manoj manoj 8985088 Jul 25 07:42 u-boot-rockchip.bin
> 
>        size of LZMA compressed binary :- 8.6 M (90,06,592 bytes)
>          manoj:u-boot$ ls -lb u-boot-rockchip.bin
>          -rw-rw-r-- 1 manoj manoj 9006592 Jul 25 07:47 u-boot-rockchip.bin
> 
> Test results of  Booting time using bootstage command in Uboot command prompt on roc-rk3399-pc board :-
> 
> 1) Uncompressed U-BOOT : Total boot time ≈ 12.063971 seconds
> => bootstage report
> Timer summary in microseconds (10 records):
>        Mark    Elapsed  Stage
>           0          0  reset
>   1,833,884  1,833,884  board_init_f
>   2,959,528  1,125,644  board_init_r
>   5,224,521  2,264,993  eth_common_init
>   5,523,428    298,907  eth_initialize
>   5,523,606        178  main_loop
>   5,523,764        158  usb_start
>  12,063,971  6,540,207  cli_loop
> 
> 2) GZIP Compressed U-BOOT : Total time ≈ 12.824968 seconds
> 
> => bootstage report
> Timer summary in microseconds (10 records):
>        Mark    Elapsed  Stage
>           0          0  reset
>   2,594,709  2,594,709  board_init_f
>   3,719,969  1,125,260  board_init_r
>   5,985,450  2,265,481  eth_common_init
>   6,284,371    298,921  eth_initialize
>   6,284,549        178  main_loop
>   6,284,708        159  usb_start
>  12,824,968  6,540,260  cli_loop
> 
> 3) LZMA Compressed U-BOOT : Total time ≈ 17.025004 seconds
> 
> => bootstage report
> Timer summary in microseconds (10 records):
>        Mark    Elapsed  Stage
>           0          0  reset
>   6,852,254  6,852,254  board_init_f
>   7,940,143  1,087,889  board_init_r
>  10,190,458  2,250,315  eth_common_init
>  10,487,254    296,796  eth_initialize
>  10,487,432        178  main_loop
>  10,487,590        158  usb_start
>  17,025,004  6,537,414  cli_loop
> 
> 
> As per suggestion from Mr.Jonas Karlman (jonas@kwiboo.se) through Patchset V2,that check boot time
> with enabling CONFIG_SPL_FIT_SIGNATURE that might impact boot time.
> 
> Tried to check the boot time with CONFIG_FIT_SIGNATURE enabled, I didnt find any significant
> boot time improvement  with enabling CONFIG_SPL_FIT_SIGNATURE.

I may not have been that clear in my last mail, it is the following
rfc/patch that may improve performance. That prfc/patch does improve
performance for sha256 validation when CONFIG_SPL_FIT_SIGNATURE is
enabled.

[RFC] rockchip: spl: Enable caches to speed up checksum validation
https://patchwork.ozlabs.org/project/uboot/patch/20230702110055.3686457-1-jonas@kwiboo.se/

Would be great to get confirmation if D-cache enabled in SPL also
benefit this series, and not just checksum validation.
(that rfc/patch unfortunately did not get much feedback)

Regards,
Jonas

> 
> Comparision of GZIP and LZMA compressed U-boot Boot time with and without Enable of CONFIG_FIT_SIGNATURE :-
> 
> - GZIP Compressed U-BOOT  and CONFIG_FIT_SIGNATURE enabled  :-  Total time ≈ 13.283998 seconds
> 
> => bootstage report
> Timer summary in microseconds (10 records):
>        Mark    Elapsed  Stage
>           0          0  reset
>   3,052,571  3,052,571  board_init_f
>   4,179,787  1,127,216  board_init_r
>   6,445,472  2,265,685  eth_common_init
>   6,744,416    298,944  eth_initialize
>   6,744,593        177  main_loop
>   6,744,751        158  usb_start
>  13,283,998  6,539,247  cli_loop
> 
> - GZIP Compressed U-BOOT and CONFIG_FIT_SIGNATURE disabled  :- Total time ≈ 12.824968 seconds
> 
> 
> - LZMA Compressed U-BOOT  and CONFIG_FIT_SIGNATURE enabled  :-  Total time ≈ 17.005996 seconds
> 
>    => bootstage report
> Timer summary in microseconds (10 records):
>        Mark    Elapsed  Stage
>           0          0  reset
>   6,775,071  6,775,071  board_init_f
>   7,902,443  1,127,372  board_init_r
>  10,167,546  2,265,103  eth_common_init
>  10,466,418    298,872  eth_initialize
>  10,466,595        177  main_loop
>  10,466,753        158  usb_start
>  17,005,996  6,539,243  cli_loop
> 
> - LZMA Compressed U-BOOT  and CONFIG_FIT_SIGNATURE disabled  :- Total time ≈ 17.025004 seconds
> 
> Manoj Sai (4):
>   spl: fit: support for booting a GZIP-compressed U-boot binary
>   spl: fit: support for booting a LZMA-compressed U-boot binary
>   rockchip: Add support to generate GZIP compressed U-boot binary
>   rockchip: Add support to generate LZMA compressed U-boot binary
> 
>  arch/arm/dts/rockchip-u-boot.dtsi | 11 +++++++++++
>  common/spl/spl_fit.c              | 20 +++++++++++++++++---
>  include/spl.h                     | 10 ++++++++++
>  3 files changed, 38 insertions(+), 3 deletions(-)
> 
> --
> 2.25.1
> 


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

* [PATCH v4 0/4] support for booting the compressed U-boot binary on Rockchip based ARM64 SOC's
  2023-09-10 18:24   ` [PATCH v3 " Manoj Sai
                       ` (4 preceding siblings ...)
  2023-09-10 19:03     ` [PATCH v3 0/4] support for booting the compressed U-boot binary on Rockchip based ARM64 SOC's Jonas Karlman
@ 2023-09-17 19:26     ` Manoj Sai
  2023-09-17 19:26       ` [PATCH v4 1/4] spl: fit: support for booting a GZIP-compressed U-boot binary Manoj Sai
                         ` (3 more replies)
  5 siblings, 4 replies; 55+ messages in thread
From: Manoj Sai @ 2023-09-17 19:26 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: dsx724, Jagan Teki, Suniel Mahesh, Manoj Sai

This patchset adds the support on Rockchip based ARM64 SOC's that  compress the U-BOOT proper along with dtb
and ATF in FIT image format.Second stage bootloader(SPL) loads the compressed binaries, uncompress
them and  handover control to the next stage.

Changes for V3 :-

1. Replaced spl_decompression_enabled() function instead of checking IS_ENABLED(CONFIG_SPL_GZIP)
   and IS_ENABLED(CONFIG_SPL_LZMA) in spl_fit.c.

2. Removed extra wrapping parentheses in spl_decompression_enabled().

Changes for V4 :-

1. As per the suggestion from Mr.Jonas Karlman (jonas@kwiboo.se) from  PATCH v2 and v3 ,check boot time
   with the following RFC patch  with CONFIG_SPL_FIT_SIGNATURE enabled that might impact boot time and
   As seen there is an improvement in boot time with both compress enabled and disabled ,
   I have added the logs of it below.

    [RFC] rockchip: spl: Enable caches to speed up checksum validation
    https://patchwork.ozlabs.org/project/uboot/patch/20230702110055.3686457-1-jonas@kwiboo.se/

Size Comparision between compressed and uncompressed binaries :-

       size of uncompressed binary    :- 9.0M (94,21,824 bytes)
         manoj:u-boot$ ls -lb u-boot-rockchip.bin
        -rw-rw-r-- 1 manoj manoj 9421824 Sep 10 22:22 u-boot-rockchip.bin

       size of GZIP compressed binary :- 8.6M (89,85,088 bytes)
         manoj:u-boot$ ls -lb u-boot-rockchip.bin
         -rw-rw-r-- 1 manoj manoj 8985088 Jul 25 07:42 u-boot-rockchip.bin

       size of LZMA compressed binary :- 8.6 M (90,06,592 bytes)
         manoj:u-boot$ ls -lb u-boot-rockchip.bin
         -rw-rw-r-- 1 manoj manoj 9006592 Jul 25 07:47 u-boot-rockchip.bin

Test results of  Booting time using bootstage command in Uboot command prompt on roc-rk3399-pc board :-

1) Uncompressed U-BOOT : Total boot time = 12.063971 seconds
=> bootstage report
Timer summary in microseconds (10 records):
       Mark    Elapsed  Stage
          0          0  reset
  1,833,884  1,833,884  board_init_f
  2,959,528  1,125,644  board_init_r
  5,224,521  2,264,993  eth_common_init
  5,523,428    298,907  eth_initialize
  5,523,606        178  main_loop
  5,523,764        158  usb_start
 12,063,971  6,540,207  cli_loop

2) GZIP Compressed U-BOOT : Total time = 12.824968 seconds

=> bootstage report
Timer summary in microseconds (10 records):
       Mark    Elapsed  Stage
          0          0  reset
  2,594,709  2,594,709  board_init_f
  3,719,969  1,125,260  board_init_r
  5,985,450  2,265,481  eth_common_init
  6,284,371    298,921  eth_initialize
  6,284,549        178  main_loop
  6,284,708        159  usb_start
 12,824,968  6,540,260  cli_loop

3) LZMA Compressed U-BOOT : Total time = 17.025004 seconds

=> bootstage report
Timer summary in microseconds (10 records):
       Mark    Elapsed  Stage
          0          0  reset
  6,852,254  6,852,254  board_init_f
  7,940,143  1,087,889  board_init_r
 10,190,458  2,250,315  eth_common_init
 10,487,254    296,796  eth_initialize
 10,487,432        178  main_loop
 10,487,590        158  usb_start
 17,025,004  6,537,414  cli_loop



Test results of  booting time using RFC patch from Mr.Jonas Karlman(jonas@kwiboo.se)
with CONFIG_SPL_FIT_SIGNATURE enabled  on  roc-rk3399-pc board :-

1. Uncompressed U-BOOT : Total boot time =  10.728 seconds
=> bootstage report
Timer summary in microseconds (10 records):
       Mark    Elapsed  Stage
          0          0  reset
    477,024    477,024  board_init_f
  1,623,670  1,146,646  board_init_r
  3,889,493  2,265,823  eth_common_init
  4,188,402    298,909  eth_initialize
  4,188,579        177  main_loop
  4,188,738        159  usb_start
 10,728,000  6,539,262  cli_loop

2. GZIP Compressed U-BOOT : Total time =  10.708 seconds
=> bootstage report
Timer summary in microseconds (10 records):
       Mark    Elapsed  Stage
          0          0  reset
    457,663    457,663  board_init_f
  1,604,222  1,146,559  board_init_r
  3,869,505  2,265,283  eth_common_init
  4,168,410    298,905  eth_initialize
  4,168,587        177  main_loop
  4,168,745        158  usb_start
 10,707,997  6,539,252  cli_loop

3. LZMA Compressed U-BOOT : Total time =   10.86 seconds
=> bootstage report
Timer summary in microseconds (10 records):
       Mark    Elapsed  Stage
          0          0  reset
    612,427    612,427  board_init_f
  1,756,176  1,143,749  board_init_r
  4,021,522  2,265,346  eth_common_init
  4,320,433    298,911  eth_initialize
  4,320,610        177  main_loop
  4,320,768        158  usb_start
 10,860,001  6,539,233  cli_loop

As I can seen there is an improvement in boot time with Enable caches in SPL to speed up FIT checksum validation,
with the following RFC patch from  Mr.Jonas.
[RFC] rockchip: spl: Enable caches to speed up checksum validation
https://patchwork.ozlabs.org/project/uboot/patch/20230702110055.3686457-1-jonas@kwiboo.se/

Manoj Sai (4):
  spl: fit: support for booting a GZIP-compressed U-boot binary
  spl: fit: support for booting a LZMA-compressed U-boot binary
  rockchip: Add support to generate GZIP compressed U-boot binary
  rockchip: Add support to generate LZMA compressed U-boot binary

 arch/arm/dts/rockchip-u-boot.dtsi | 11 +++++++++++
 common/spl/spl_fit.c              | 20 +++++++++++++++++---
 include/spl.h                     | 10 ++++++++++
 3 files changed, 38 insertions(+), 3 deletions(-)

-- 
2.25.1


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

* [PATCH v4 1/4] spl: fit: support for booting a GZIP-compressed U-boot binary
  2023-09-17 19:26     ` [PATCH v4 " Manoj Sai
@ 2023-09-17 19:26       ` Manoj Sai
  2023-09-18 14:45         ` Tom Rini
  2023-09-17 19:26       ` [PATCH v4 2/4] spl: fit: support for booting a LZMA-compressed " Manoj Sai
                         ` (2 subsequent siblings)
  3 siblings, 1 reply; 55+ messages in thread
From: Manoj Sai @ 2023-09-17 19:26 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: dsx724, Jagan Teki, Suniel Mahesh, Manoj Sai

If GZIP Compression support is enabled, GZIP compressed U-Boot binary
will be at a specified RAM location which is defined at
CONFIG_SYS_LOAD_ADDR and will be assign it as the source address.

gunzip function in spl_load_fit_image ,will decompress the GZIP
compressed U-Boot binary which is placed at
source address(CONFIG_SYS_LOAD_ADDR)  to the default
CONFIG_SYS_TEXT_BASE location.

spl_load_fit_image function will load the decompressed U-Boot
binary, which is placed at the CONFIG_SYS_TEXT_BASE location.

Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
Changes in v4:
 - None

Changes in v3:
 - Replaced spl_decompression_enabled() function instead of
   checking IS_ENABLED(CONFIG_SPL_GZIP).

 - Removed checking IS_ENABLED(CONFIG_SPL_LZMA) in spl_decompression_enabled()
   function.

Changes in v2:
 - New patch for v2

 common/spl/spl_fit.c |  9 ++++++---
 include/spl.h        | 10 ++++++++++
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 730639f756..eb97259f57 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -239,14 +239,14 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 	bool external_data = false;
 
 	if (IS_ENABLED(CONFIG_SPL_FPGA) ||
-	    (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_GZIP))) {
+	    (IS_ENABLED(CONFIG_SPL_OS_BOOT) && spl_decompression_enabled())) {
 		if (fit_image_get_type(fit, node, &type))
 			puts("Cannot get image type.\n");
 		else
 			debug("%s ", genimg_get_type_name(type));
 	}
 
-	if (IS_ENABLED(CONFIG_SPL_GZIP)) {
+	if (spl_decompression_enabled()) {
 		fit_image_get_comp(fit, node, &image_comp);
 		debug("%s ", genimg_get_comp_name(image_comp));
 	}
@@ -281,7 +281,10 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 			return 0;
 		}
 
-		src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
+		if (spl_decompression_enabled() && image_comp == IH_COMP_GZIP)
+			src_ptr = map_sysmem(ALIGN(CONFIG_SYS_LOAD_ADDR, ARCH_DMA_MINALIGN), len);
+		else
+			src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
 		length = len;
 
 		overhead = get_aligned_image_overhead(info, offset);
diff --git a/include/spl.h b/include/spl.h
index 93e906431e..3a7e448cc7 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -897,4 +897,14 @@ struct legacy_img_hdr *spl_get_load_buffer(ssize_t offset, size_t size);
 
 void board_boot_order(u32 *spl_boot_list);
 void spl_save_restore_data(void);
+
+/*
+ * spl_decompression_enabled() - check decompression support is enabled for SPL build
+ *
+ * Returns  true  if decompression support is enabled, else False
+ */
+static inline bool spl_decompression_enabled(void)
+{
+	return IS_ENABLED(CONFIG_SPL_GZIP);
+}
 #endif
-- 
2.25.1


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

* [PATCH v4 2/4] spl: fit: support for booting a LZMA-compressed U-boot binary
  2023-09-17 19:26     ` [PATCH v4 " Manoj Sai
  2023-09-17 19:26       ` [PATCH v4 1/4] spl: fit: support for booting a GZIP-compressed U-boot binary Manoj Sai
@ 2023-09-17 19:26       ` Manoj Sai
  2023-09-18 14:45         ` Tom Rini
  2023-09-17 19:26       ` [PATCH v4 3/4] rockchip: Add support to generate GZIP compressed " Manoj Sai
  2023-09-17 19:26       ` [PATCH v4 4/4] rockchip: Add support to generate LZMA " Manoj Sai
  3 siblings, 1 reply; 55+ messages in thread
From: Manoj Sai @ 2023-09-17 19:26 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: dsx724, Jagan Teki, Suniel Mahesh, Manoj Sai

If LZMA Compression support is enabled, LZMA compressed U-Boot
binary will be placed at a specified RAM location which is
defined at CONFIG_SYS_LOAD_ADDR and will be assigned  as the
source address.

image_decomp() function, will decompress the LZMA compressed
U-Boot binary which is placed at source address(CONFIG_SYS_LOAD_ADDR)
to the default CONFIG_SYS_TEXT_BASE location.

spl_load_fit_image function will load the decompressed U-Boot
binary, which is placed at the CONFIG_SYS_TEXT_BASE location.

Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
---
Changes in v4:
 - None

Changes in v3:
 - added IS_ENABLED(CONFIG_SPL_LZMA) to spl_decompression_enabled() function.
 - Removed extra parentheses.

Changes in v2:
 - New patch for v2

 common/spl/spl_fit.c | 13 ++++++++++++-
 include/spl.h        |  2 +-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index eb97259f57..75895ef15c 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -281,7 +281,8 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 			return 0;
 		}
 
-		if (spl_decompression_enabled() && image_comp == IH_COMP_GZIP)
+		if (spl_decompression_enabled() &&
+		    (image_comp == IH_COMP_GZIP || image_comp == IH_COMP_LZMA))
 			src_ptr = map_sysmem(ALIGN(CONFIG_SYS_LOAD_ADDR, ARCH_DMA_MINALIGN), len);
 		else
 			src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);
@@ -329,6 +330,16 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
 			return -EIO;
 		}
 		length = size;
+	} else if (IS_ENABLED(CONFIG_SPL_LZMA) && image_comp == IH_COMP_LZMA) {
+		size = CONFIG_SYS_BOOTM_LEN;
+		ulong loadEnd;
+
+		if (image_decomp(IH_COMP_LZMA, CONFIG_SYS_LOAD_ADDR, 0, 0,
+				 load_ptr, src, length, size, &loadEnd)) {
+			puts("Uncompressing error\n");
+			return -EIO;
+		}
+		length = loadEnd - CONFIG_SYS_LOAD_ADDR;
 	} else {
 		memcpy(load_ptr, src, length);
 	}
diff --git a/include/spl.h b/include/spl.h
index 3a7e448cc7..9de93a34cd 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -905,6 +905,6 @@ void spl_save_restore_data(void);
  */
 static inline bool spl_decompression_enabled(void)
 {
-	return IS_ENABLED(CONFIG_SPL_GZIP);
+	return IS_ENABLED(CONFIG_SPL_GZIP) || IS_ENABLED(CONFIG_SPL_LZMA);
 }
 #endif
-- 
2.25.1


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

* [PATCH v4 3/4] rockchip: Add support to generate GZIP compressed U-boot binary
  2023-09-17 19:26     ` [PATCH v4 " Manoj Sai
  2023-09-17 19:26       ` [PATCH v4 1/4] spl: fit: support for booting a GZIP-compressed U-boot binary Manoj Sai
  2023-09-17 19:26       ` [PATCH v4 2/4] spl: fit: support for booting a LZMA-compressed " Manoj Sai
@ 2023-09-17 19:26       ` Manoj Sai
  2023-09-17 19:26       ` [PATCH v4 4/4] rockchip: Add support to generate LZMA " Manoj Sai
  3 siblings, 0 replies; 55+ messages in thread
From: Manoj Sai @ 2023-09-17 19:26 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: dsx724, Jagan Teki, Suniel Mahesh, Manoj Sai

Add support for generating a GZIP-compressed U-boot binary with the
help of binman, if CONFIG_SPL_GZIP is selected.

Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
---
Changes in v4:
 - None

Changes in v3:
 - None

Changes in v2:
 - New patch for v2

 arch/arm/dts/rockchip-u-boot.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi
index be2658e8ef..8f248f941f 100644
--- a/arch/arm/dts/rockchip-u-boot.dtsi
+++ b/arch/arm/dts/rockchip-u-boot.dtsi
@@ -56,10 +56,17 @@
 #else
 					arch = "arm";
 #endif
+#if defined(CONFIG_SPL_GZIP)
+					compression = "gzip";
+#else
 					compression = "none";
+#endif
 					load = <CONFIG_TEXT_BASE>;
 					entry = <CONFIG_TEXT_BASE>;
 					u-boot-nodtb {
+#if defined(CONFIG_SPL_GZIP)
+					compress = "gzip";
+#endif
 					};
 #ifdef CONFIG_SPL_FIT_SIGNATURE
 					hash {
-- 
2.25.1


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

* [PATCH v4 4/4] rockchip: Add support to generate LZMA compressed U-boot binary
  2023-09-17 19:26     ` [PATCH v4 " Manoj Sai
                         ` (2 preceding siblings ...)
  2023-09-17 19:26       ` [PATCH v4 3/4] rockchip: Add support to generate GZIP compressed " Manoj Sai
@ 2023-09-17 19:26       ` Manoj Sai
  3 siblings, 0 replies; 55+ messages in thread
From: Manoj Sai @ 2023-09-17 19:26 UTC (permalink / raw)
  To: Simon Glass, Philipp Tomsich, Kever Yang, u-boot
  Cc: dsx724, Jagan Teki, Suniel Mahesh, Manoj Sai

Add support for generating a LZMA-compressed U-boot binary with the
help of binman, if CONFIG_SPL_LZMA is selected.

Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
---
Changes in v4:
 - None

Changes in v3:
 - None

Changes in v2:
 - New patch for v2

 arch/arm/dts/rockchip-u-boot.dtsi | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi
index 8f248f941f..c8c928c7e5 100644
--- a/arch/arm/dts/rockchip-u-boot.dtsi
+++ b/arch/arm/dts/rockchip-u-boot.dtsi
@@ -58,6 +58,8 @@
 #endif
 #if defined(CONFIG_SPL_GZIP)
 					compression = "gzip";
+#elif defined(CONFIG_SPL_LZMA)
+					compression = "lzma";
 #else
 					compression = "none";
 #endif
@@ -66,6 +68,8 @@
 					u-boot-nodtb {
 #if defined(CONFIG_SPL_GZIP)
 					compress = "gzip";
+#elif defined(CONFIG_SPL_LZMA)
+					compress = "lzma";
 #endif
 					};
 #ifdef CONFIG_SPL_FIT_SIGNATURE
-- 
2.25.1


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

* Re: [PATCH v4 1/4] spl: fit: support for booting a GZIP-compressed U-boot binary
  2023-09-17 19:26       ` [PATCH v4 1/4] spl: fit: support for booting a GZIP-compressed U-boot binary Manoj Sai
@ 2023-09-18 14:45         ` Tom Rini
  0 siblings, 0 replies; 55+ messages in thread
From: Tom Rini @ 2023-09-18 14:45 UTC (permalink / raw)
  To: Manoj Sai
  Cc: Simon Glass, Philipp Tomsich, Kever Yang, u-boot, dsx724,
	Jagan Teki, Suniel Mahesh

[-- Attachment #1: Type: text/plain, Size: 899 bytes --]

On Mon, Sep 18, 2023 at 12:56:25AM +0530, Manoj Sai wrote:

> If GZIP Compression support is enabled, GZIP compressed U-Boot binary
> will be at a specified RAM location which is defined at
> CONFIG_SYS_LOAD_ADDR and will be assign it as the source address.
> 
> gunzip function in spl_load_fit_image ,will decompress the GZIP
> compressed U-Boot binary which is placed at
> source address(CONFIG_SYS_LOAD_ADDR)  to the default
> CONFIG_SYS_TEXT_BASE location.
> 
> spl_load_fit_image function will load the decompressed U-Boot
> binary, which is placed at the CONFIG_SYS_TEXT_BASE location.
> 
> Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
> Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

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

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

* Re: [PATCH v4 2/4] spl: fit: support for booting a LZMA-compressed U-boot binary
  2023-09-17 19:26       ` [PATCH v4 2/4] spl: fit: support for booting a LZMA-compressed " Manoj Sai
@ 2023-09-18 14:45         ` Tom Rini
  0 siblings, 0 replies; 55+ messages in thread
From: Tom Rini @ 2023-09-18 14:45 UTC (permalink / raw)
  To: Manoj Sai
  Cc: Simon Glass, Philipp Tomsich, Kever Yang, u-boot, dsx724,
	Jagan Teki, Suniel Mahesh

[-- Attachment #1: Type: text/plain, Size: 891 bytes --]

On Mon, Sep 18, 2023 at 12:56:26AM +0530, Manoj Sai wrote:

> If LZMA Compression support is enabled, LZMA compressed U-Boot
> binary will be placed at a specified RAM location which is
> defined at CONFIG_SYS_LOAD_ADDR and will be assigned  as the
> source address.
> 
> image_decomp() function, will decompress the LZMA compressed
> U-Boot binary which is placed at source address(CONFIG_SYS_LOAD_ADDR)
> to the default CONFIG_SYS_TEXT_BASE location.
> 
> spl_load_fit_image function will load the decompressed U-Boot
> binary, which is placed at the CONFIG_SYS_TEXT_BASE location.
> 
> Signed-off-by: Manoj Sai <abbaraju.manojsai@amarulasolutions.com>
> Signed-off-by: Suniel Mahesh <sunil@amarulasolutions.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Kever Yang <kever.yang@rock-chips.com>

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

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

end of thread, other threads:[~2023-09-18 14:46 UTC | newest]

Thread overview: 55+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-30 12:11 [PATCH 00/10] support for booting the compressed U-boot binary on Rockchip based SOC's Manoj Sai
2023-06-30 12:11 ` [PATCH 01/10] Makefile: Add support to generate GZIP compressed raw u-boot binary Manoj Sai
2023-07-02 15:34   ` Simon Glass
2023-07-18  7:12     ` Manoj Sai
2023-07-19  1:08       ` Simon Glass
2023-06-30 12:11 ` [PATCH 02/10] spl: Kconfig: Address support for compressed U-BOOT raw binary Manoj Sai
2023-07-02 15:34   ` Simon Glass
2023-07-25  3:48     ` Manoj Sai
2023-06-30 12:11 ` [PATCH 03/10] rockchip: RAM location for the " Manoj Sai
2023-07-02 15:34   ` Simon Glass
2023-06-30 12:11 ` [PATCH 04/10] spl: fit: support for booting a GZIP-compressed U-boot " Manoj Sai
2023-06-30 16:38   ` Xavier Drudis Ferran
2023-06-30 12:11 ` [PATCH 05/10] Makefile: Add support to generate LZMA compressed raw u-boot binary Manoj Sai
2023-07-02 15:34   ` Simon Glass
2023-06-30 12:11 ` [PATCH 06/10] spl: fit: support for booting a LZMA-compressed U-boot raw binary Manoj Sai
2023-07-02 15:34   ` Simon Glass
2023-06-30 12:11 ` [PATCH 07/10] binman: Add support for u-boot-nodtb.bin.gz as an input binary Manoj Sai
2023-07-02 15:34   ` Simon Glass
2023-06-30 12:11 ` [PATCH 08/10] rockchip: Add GZIP compressed uboot raw binary to FIT image Manoj Sai
2023-07-02 15:34   ` Simon Glass
2023-06-30 12:11 ` [PATCH 09/10] binman: Add support for u-boot-nodtb.bin.lzma as an input binary Manoj Sai
2023-07-02 15:34   ` Simon Glass
2023-06-30 12:11 ` [PATCH 10/10] rockchip: Add LZMA compressed uboot raw binary to FIT image Manoj Sai
2023-06-30 15:45 ` [PATCH 00/10] support for booting the compressed U-boot binary on Rockchip based SOC's Jonas Karlman
2023-07-25  3:50 ` [PATCH v2 0/4] support for booting the compressed U-boot binary on Rockchip based ARM64 SOC's Manoj Sai
2023-07-25  3:50   ` [PATCH v2 1/4] rockchip: Add support to generate GZIP compressed U-boot binary Manoj Sai
2023-07-27  0:53     ` Simon Glass
2023-07-28 10:09     ` Kever Yang
2023-08-12  3:03     ` Kever Yang
2023-07-25  3:50   ` [PATCH v2 2/4] rockchip: Add support to generate LZMA " Manoj Sai
2023-07-27  0:53     ` Simon Glass
2023-07-28 10:09     ` Kever Yang
2023-07-25  3:51   ` [PATCH v2 3/4] spl: fit: support for booting a GZIP-compressed " Manoj Sai
2023-07-27  0:53     ` Simon Glass
2023-07-27 11:03     ` Jonas Karlman
2023-07-28 10:11       ` Kever Yang
2023-07-28 10:09     ` Kever Yang
2023-07-25  3:51   ` [PATCH v2 4/4] spl: fit: support for booting a LZMA-compressed " Manoj Sai
2023-07-27  0:53     ` Simon Glass
2023-07-27 11:13     ` Jonas Karlman
2023-07-27 11:21   ` [PATCH v2 0/4] support for booting the compressed U-boot binary on Rockchip based ARM64 SOC's Jonas Karlman
2023-08-28  4:44     ` Manoj Sai
2023-09-10 18:24   ` [PATCH v3 " Manoj Sai
2023-09-10 18:24     ` [PATCH v3 1/4] spl: fit: support for booting a GZIP-compressed U-boot binary Manoj Sai
2023-09-10 18:24     ` [PATCH v3 2/4] spl: fit: support for booting a LZMA-compressed " Manoj Sai
2023-09-10 18:24     ` [PATCH v3 3/4] rockchip: Add support to generate GZIP compressed " Manoj Sai
2023-09-10 18:24     ` [PATCH v3 4/4] rockchip: Add support to generate LZMA " Manoj Sai
2023-09-10 19:03     ` [PATCH v3 0/4] support for booting the compressed U-boot binary on Rockchip based ARM64 SOC's Jonas Karlman
2023-09-17 19:26     ` [PATCH v4 " Manoj Sai
2023-09-17 19:26       ` [PATCH v4 1/4] spl: fit: support for booting a GZIP-compressed U-boot binary Manoj Sai
2023-09-18 14:45         ` Tom Rini
2023-09-17 19:26       ` [PATCH v4 2/4] spl: fit: support for booting a LZMA-compressed " Manoj Sai
2023-09-18 14:45         ` Tom Rini
2023-09-17 19:26       ` [PATCH v4 3/4] rockchip: Add support to generate GZIP compressed " Manoj Sai
2023-09-17 19:26       ` [PATCH v4 4/4] rockchip: Add support to generate LZMA " Manoj Sai

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.