[U-Boot] [PATCH V2 8/8] arm/davinci: spl - add compressed u-boot image support
Mikhail Kshevetskiy
mikhail.kshevetskiy at gmail.com
Mon Jul 9 05:31:33 CEST 2012
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 at gmail.com>
---
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
More information about the U-Boot
mailing list