[U-Boot] [PATCH 8/8] arm/davinci: spl - add compressed u-boot image support
Mikhail Kshevetskiy
mikhail.kshevetskiy at gmail.com
Tue Jun 12 23:15:52 CEST 2012
we have a board with 128 Kb spi flash, so normal u-boot.ais does not fit on it.
Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy at gmail.com>
---
Makefile | 14 ++++++++++++++
arch/arm/cpu/arm926ejs/davinci/spl.c | 6 ++++++
arch/arm/cpu/arm926ejs/davinci/spl_mmc.c | 9 +++++++--
arch/arm/cpu/arm926ejs/davinci/spl_nand.c | 9 +++++++--
arch/arm/cpu/arm926ejs/davinci/spl_spi_flash.c | 7 ++++++-
arch/arm/cpu/arm926ejs/davinci/spl_ymodem.c | 4 ++++
lib/Makefile | 2 ++
spl/Makefile | 1 +
8 files changed, 47 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
index 0197239..1cd6f03 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 a8c318c..f6ddea3 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,11 @@ 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 520ecd1..ce8b57b 100644
--- a/arch/arm/cpu/arm926ejs/davinci/spl_mmc.c
+++ b/arch/arm/cpu/arm926ejs/davinci/spl_mmc.c
@@ -26,8 +26,13 @@ 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);
+ CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS,
+#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..da5358c 100644
--- a/arch/arm/cpu/arm926ejs/davinci/spl_nand.c
+++ b/arch/arm/cpu/arm926ejs/davinci/spl_nand.c
@@ -5,7 +5,12 @@ 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);
+ CONFIG_SYS_NAND_U_BOOT_SIZE,
+#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 2d5b045..710429f 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 be6786b..0844ff4 100644
--- a/arch/arm/cpu/arm926ejs/davinci/spl_ymodem.c
+++ b/arch/arm/cpu/arm926ejs/davinci/spl_ymodem.c
@@ -23,7 +23,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 1e8478f..3acffd9 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -59,6 +59,8 @@ endif
ifdef CONFIG_SPL_BUILD
COBJS-$(CONFIG_SPL_YMODEM_SUPPORT) += crc16.o
+COBJS-$(CONFIG_SPL_GUNZIP_SUPPORT) += crc32.o
+COBJS-$(CONFIG_SPL_GUNZIP_SUPPORT) += gunzip.o
endif
COBJS-y += ctype.o
COBJS-y += div64.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
More information about the U-Boot
mailing list