All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mikhail Kshevetskiy <mikhail.kshevetskiy@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V3 3/3] arm/davinci: spl - add compressed u-boot image support
Date: Mon,  9 Jul 2012 22:53:40 +0400	[thread overview]
Message-ID: <1341860020-11507-3-git-send-email-mikhail.kshevetskiy@gmail.com> (raw)
In-Reply-To: <1341860020-11507-1-git-send-email-mikhail.kshevetskiy@gmail.com>

Motivation:
 * we have a board with 128 Kb spi flash, so normal u-boot.ais does not
   fit on it.

This patch add support of compressed 2-nd u-boot stage. To create a compressed
ais image its required:
 * define CONFIG_SPL_GUNZIP_SUPPORT --- enable compressed ais image supports
 * define CONFIG_SPL_GUNZIP_MAX_SIZE --- define a maximum size of compressed
   u-boot part
 * define CONFIG_SPL_GUNZIP_LOAD_ADDR --- memory address to load compressed
   u-boot part (CONFIG_SPL_GUNZIP_LOAD_ADDR region should not overlap with
   CONFIG_SYS_TEXT_BASE region)
 * use: make u-boot-gzip.ais to get a compressed ais image

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@gmail.com>
---
Change for v3:
 * split MMC+SPL+no partition table support bugfix to separate patch
   series (series 3/3)
Change for v2:
 * fix checkpatch warnings
 * fix merge conflict with upstream u-boot sources
 * improve patch description
---
 Makefile                                       |   14 ++++++++++++++
 arch/arm/cpu/arm926ejs/davinci/spl.c           |    7 +++++++
 arch/arm/cpu/arm926ejs/davinci/spl_mmc.c       |    7 ++++++-
 arch/arm/cpu/arm926ejs/davinci/spl_nand.c      |    7 ++++++-
 arch/arm/cpu/arm926ejs/davinci/spl_spi_flash.c |    7 ++++++-
 arch/arm/cpu/arm926ejs/davinci/spl_ymodem.c    |    4 ++++
 lib/Makefile                                   |    1 +
 spl/Makefile                                   |    1 +
 8 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 85e36ec..cf16824 100644
--- a/Makefile
+++ b/Makefile
@@ -452,6 +452,20 @@ $(obj)u-boot.ais:       $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
 			$(obj)u-boot.ais
 		rm $(obj)spl/u-boot-spl{,-pad}.ais
 
+$(obj)u-boot-gzip.ais:       $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
+		$(obj)tools/mkimage -s -n /dev/null -T aisimage \
+			-e $(CONFIG_SPL_TEXT_BASE) \
+			-d $(obj)spl/u-boot-spl.bin \
+			$(obj)spl/u-boot-spl.ais
+		$(OBJCOPY) ${OBJCFLAGS} -I binary \
+			--pad-to=$(CONFIG_SPL_MAX_SIZE) -O binary \
+			$(obj)spl/u-boot-spl.ais $(obj)spl/u-boot-spl-pad.ais
+		cp $(obj)u-boot.bin $(obj)spl/u-boot.bin
+		gzip $(obj)spl/u-boot.bin
+		cat $(obj)spl/u-boot-spl-pad.ais $(obj)spl/u-boot.bin.gz > \
+			$(obj)u-boot-gzip.ais
+		rm $(obj)spl/u-boot-spl{,-pad}.ais $(obj)spl/u-boot.bin.gz
+
 $(obj)u-boot.sb:       $(obj)u-boot.bin $(obj)spl/u-boot-spl.bin
 		elftosb -zdf imx28 -c $(TOPDIR)/board/$(BOARDDIR)/u-boot.bd \
 			-o $(obj)u-boot.sb
diff --git a/arch/arm/cpu/arm926ejs/davinci/spl.c b/arch/arm/cpu/arm926ejs/davinci/spl.c
index 50b4bbc..041df5b 100644
--- a/arch/arm/cpu/arm926ejs/davinci/spl.c
+++ b/arch/arm/cpu/arm926ejs/davinci/spl.c
@@ -111,6 +111,7 @@ u32 davinci_boot_device(void){
 
 void board_init_r(gd_t *id, ulong dummy)
 {
+	int size;
 	u32 boot_device;
 	void (*uboot)(void) __noreturn;
 
@@ -159,6 +160,12 @@ void board_init_r(gd_t *id, ulong dummy)
 		break;
 	}
 
+#ifdef CONFIG_SPL_GUNZIP_SUPPORT
+	size = CONFIG_SPL_GUNZIP_MAX_SIZE;
+	gunzip((void *)CONFIG_SYS_TEXT_BASE, 512 * 1024,
+		(void *)CONFIG_SPL_GUNZIP_LOAD_ADDR, &size);
+#endif
+
 	puts("Jump to U-Boot image...\n");
 	uboot = (void *) CONFIG_SYS_TEXT_BASE;
 	(*uboot)();
diff --git a/arch/arm/cpu/arm926ejs/davinci/spl_mmc.c b/arch/arm/cpu/arm926ejs/davinci/spl_mmc.c
index 1a551e9..fa67f1a 100644
--- a/arch/arm/cpu/arm926ejs/davinci/spl_mmc.c
+++ b/arch/arm/cpu/arm926ejs/davinci/spl_mmc.c
@@ -28,7 +28,12 @@ void spl_mmc_load_image(void)
 	ret = mmc->block_dev.block_read(0,
 				CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR,
 				CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS,
-				(void *) CONFIG_SYS_TEXT_BASE);
+#ifndef CONFIG_SPL_GUNZIP_SUPPORT
+				(void *) CONFIG_SYS_TEXT_BASE
+#else
+				(void *) CONFIG_SPL_GUNZIP_LOAD_ADDR
+#endif
+				);
 	if (ret < 0) {
 		printf("spl: mmc blk read err - %d\n", ret);
 		hang();
diff --git a/arch/arm/cpu/arm926ejs/davinci/spl_nand.c b/arch/arm/cpu/arm926ejs/davinci/spl_nand.c
index bad1e8f..4bf3e6a 100644
--- a/arch/arm/cpu/arm926ejs/davinci/spl_nand.c
+++ b/arch/arm/cpu/arm926ejs/davinci/spl_nand.c
@@ -6,6 +6,11 @@ void spl_nand_load_image(void)
 	nand_init();
 	nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
 			CONFIG_SYS_NAND_U_BOOT_SIZE,
-			(void *) CONFIG_SYS_TEXT_BASE);
+#ifndef CONFIG_SPL_GUNZIP_SUPPORT
+			(void *) CONFIG_SYS_TEXT_BASE
+#else
+			(void *) CONFIG_SPL_GUNZIP_LOAD_ADDR
+#endif
+			);
 	debug("Loaded %d bytes from NAND flash\n", CONFIG_SYS_NAND_U_BOOT_SIZE);
 }
diff --git a/arch/arm/cpu/arm926ejs/davinci/spl_spi_flash.c b/arch/arm/cpu/arm926ejs/davinci/spl_spi_flash.c
index d6fadcd..76d4d51 100644
--- a/arch/arm/cpu/arm926ejs/davinci/spl_spi_flash.c
+++ b/arch/arm/cpu/arm926ejs/davinci/spl_spi_flash.c
@@ -15,7 +15,12 @@ void spl_spi_flash_load_image(void)
 
 	ret = spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS,
 				CONFIG_SYS_SPI_U_BOOT_SIZE,
-				(void *) CONFIG_SYS_TEXT_BASE);
+#ifndef CONFIG_SPL_GUNZIP_SUPPORT
+				(void *) CONFIG_SYS_TEXT_BASE
+#else
+				(void *) CONFIG_SPL_GUNZIP_LOAD_ADDR
+#endif
+				);
 	if (ret < 0) {
 		printf("spl: spi flash read err - %d\n", ret);
 		hang();
diff --git a/arch/arm/cpu/arm926ejs/davinci/spl_ymodem.c b/arch/arm/cpu/arm926ejs/davinci/spl_ymodem.c
index b8c4db1..857436f 100644
--- a/arch/arm/cpu/arm926ejs/davinci/spl_ymodem.c
+++ b/arch/arm/cpu/arm926ejs/davinci/spl_ymodem.c
@@ -24,7 +24,11 @@ void spl_ymodem_load_image(void)
 	info.mode = xyzModem_ymodem;
 	res = xyzModem_stream_open(&info, &err);
 	if (!res) {
+#ifndef CONFIG_SPL_GUNZIP_SUPPORT
 		store_addr = CONFIG_SYS_TEXT_BASE;
+#else
+		store_addr = CONFIG_SPL_GUNZIP_LOAD_ADDR;
+#endif
 		while ((res = xyzModem_stream_read(
 					(char *)store_addr, 1024, &err)) > 0) {
 			store_addr += res;
diff --git a/lib/Makefile b/lib/Makefile
index c60c380..5a259ed 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -58,6 +58,7 @@ endif
 
 ifdef CONFIG_SPL_BUILD
 COBJS-$(CONFIG_SPL_YMODEM_SUPPORT) += crc16.o
+COBJS-$(CONFIG_SPL_GUNZIP_SUPPORT) += gunzip.o
 endif
 COBJS-y += crc32.o
 COBJS-y += ctype.o
diff --git a/spl/Makefile b/spl/Makefile
index ea7d475..d11d8b2 100644
--- a/spl/Makefile
+++ b/spl/Makefile
@@ -52,6 +52,7 @@ LIBS-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += drivers/mtd/spi/libspi_flash.o
 LIBS-$(CONFIG_SPL_SPI_SUPPORT) += drivers/spi/libspi.o
 LIBS-$(CONFIG_SPL_FAT_SUPPORT) += fs/fat/libfat.o
 LIBS-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/libgeneric.o
+LIBS-$(CONFIG_SPL_GUNZIP_SUPPORT) += lib/zlib/libz.o
 LIBS-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/libpower.o
 LIBS-$(CONFIG_SPL_NAND_SUPPORT) += drivers/mtd/nand/libnand.o
 LIBS-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/libonenand.o
-- 
1.7.10.4

  parent reply	other threads:[~2012-07-09 18:53 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-09 18:53 [U-Boot] [PATCH V3 1/3] MMC: u-boot-spl may be compiled without partition support Mikhail Kshevetskiy
2012-07-09 18:53 ` [U-Boot] [PATCH V3 2/3] arm/davinci: spl - boot device selection Mikhail Kshevetskiy
2012-07-09 19:41   ` Tom Rini
2012-07-09 19:57     ` Mikhail Kshevetskiy
2012-07-09 20:08       ` Tom Rini
2012-07-09 20:10         ` Mikhail Kshevetskiy
2012-07-10 18:39   ` Sughosh Ganu
2012-07-10 19:20     ` Mikhail Kshevetskiy
2012-07-11  6:38       ` Sughosh Ganu
2012-07-11  8:19         ` Tom Rini
2012-07-11 10:40           ` Sughosh Ganu
2012-07-11 10:46             ` Tom Rini
2012-07-11 11:05               ` Sughosh Ganu
2012-07-11 11:43                 ` Tom Rini
2012-07-11 12:08                   ` Sughosh Ganu
2012-07-11 12:15                     ` Tom Rini
2012-07-09 18:53 ` Mikhail Kshevetskiy [this message]
2012-07-10 18:49   ` [U-Boot] [PATCH V3 3/3] arm/davinci: spl - add compressed u-boot image support Sughosh Ganu
2012-07-10 19:29     ` Mikhail Kshevetskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1341860020-11507-3-git-send-email-mikhail.kshevetskiy@gmail.com \
    --to=mikhail.kshevetskiy@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.