From patchwork Mon Jul 9 18:53:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikhail Kshevetskiy X-Patchwork-Id: 169937 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id BBDD12C01D3 for ; Tue, 10 Jul 2012 05:23:38 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AD1D3280FD; Mon, 9 Jul 2012 21:23:08 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HYTVzzkXYEaO; Mon, 9 Jul 2012 21:23:08 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7634C2815E; Mon, 9 Jul 2012 21:22:29 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 35D0728125 for ; Mon, 9 Jul 2012 20:53:48 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CPSHUMSQ79jY for ; Mon, 9 Jul 2012 20:53:47 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-bk0-f44.google.com (mail-bk0-f44.google.com [209.85.214.44]) by theia.denx.de (Postfix) with ESMTPS id 6F32628118 for ; Mon, 9 Jul 2012 20:53:47 +0200 (CEST) Received: by mail-bk0-f44.google.com with SMTP id y7so2968027bkt.3 for ; Mon, 09 Jul 2012 11:53:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=e5MzyepC5aDGJkQvy/272s1US8/1p1oV51LS55OGFL8=; b=XvcabKKX8pcf5QgBwj07rgsVshxjDmhn2Nk+UtxCbyGifSdmUsmTlU/RnMdoTIlgrB wZtPw2dza6Vqnp49tgkhd6+BYQGBMUodQcBmmRbfRLYmAAS9Me9vi/yCYKKHAdQTkfUH oZdlpn8zZcTFate5w3tSRxScfbuFYh4jcq4Cp6Gd3p7TrBTMAvJaYg+JXt42+GPGZhym t+FWV6w6/E3gX/zNYl//HV8GQuufPK/uNjDLSTGEAlvDrOfEOreJhnAyzM7Kpyqeul4/ W1SMlqHKKggpDoMg2vi1OW1ZENQxV4OK5nzDU/6y8bU95lw/l6xK6ZUqk5u4goOaUQx5 B4Eg== Received: by 10.152.147.33 with SMTP id th1mr42433531lab.9.1341860027197; Mon, 09 Jul 2012 11:53:47 -0700 (PDT) Received: from weasel.lan ([217.71.235.199]) by mx.google.com with ESMTPS id sy1sm48040439lab.13.2012.07.09.11.53.46 (version=SSLv3 cipher=OTHER); Mon, 09 Jul 2012 11:53:46 -0700 (PDT) From: Mikhail Kshevetskiy To: u-boot@lists.denx.de Date: Mon, 9 Jul 2012 22:53:40 +0400 Message-Id: <1341860020-11507-3-git-send-email-mikhail.kshevetskiy@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1341860020-11507-1-git-send-email-mikhail.kshevetskiy@gmail.com> References: <1341860020-11507-1-git-send-email-mikhail.kshevetskiy@gmail.com> X-Mailman-Approved-At: Mon, 09 Jul 2012 21:22:17 +0200 Cc: Tom Rini , Christian Riesch Subject: [U-Boot] [PATCH V3 3/3] arm/davinci: spl - add compressed u-boot image support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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 --- 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