From patchwork Sun May 26 22:51:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 246491 X-Patchwork-Delegate: afleming@freescale.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 13CBD2C0091 for ; Mon, 27 May 2013 08:59:57 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B874E4A029; Mon, 27 May 2013 00:59:53 +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 bn7t4hj0FAyg; Mon, 27 May 2013 00:59:53 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8347D4A021; Mon, 27 May 2013 00:59:52 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8E8E44A023 for ; Mon, 27 May 2013 00:59:46 +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 bFFLSOnWZ75F for ; Mon, 27 May 2013 00:59:41 +0200 (CEST) X-Greylist: delayed 400 seconds by postgrey-1.27 at theia; Mon, 27 May 2013 00:59:38 CEST X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 BL_NJABL=SKIP(-1.5) (only DNSBL check requested) Received: from gate.alliedtelesyn.co.nz (gate.alliedtelesyn.co.nz [202.49.72.33]) by theia.denx.de (Postfix) with SMTP id CD9C84A01C for ; Mon, 27 May 2013 00:59:37 +0200 (CEST) Received: (qmail 17354 invoked from network); 26 May 2013 22:52:54 -0000 Received: from mmarshal3.atlnz.lc (10.32.18.43) by gate-int.alliedtelesyn.co.nz with SMTP; 26 May 2013 22:52:54 -0000 Received: from alliedtelesyn.co.nz (Not Verified[10.32.16.32]) by mmarshal3.atlnz.lc with MailMarshal (v7, 1, 0, 4874) id ; Mon, 27 May 2013 10:52:53 +1200 Received: from MAIL/SpoolDir by alliedtelesyn.co.nz (Mercury 1.48); 27 May 13 10:57:28 +1200 Received: from SpoolDir by MAIL (Mercury 1.48); 27 May 13 10:56:54 +1200 Received: from chrisp-dl.ws.atlnz.lc (10.33.22.46) by alliedtelesyn.co.nz (Mercury 1.48) with ESMTP; 27 May 13 10:56:27 +1200 Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 22A081FF4B2; Mon, 27 May 2013 10:51:52 +1200 (NZST) From: Chris Packham To: afleming@freescale.com Date: Mon, 27 May 2013 10:51:46 +1200 Message-Id: <1369608706-22425-1-git-send-email-judge.packham@gmail.com> X-Mailer: git-send-email 1.7.9.5 Cc: u-boot@lists.denx.de, Chris Packham , Shaohui.Xie@freescale.com Subject: [U-Boot] [PATCH] powerpc/CoreNet: Allow pbl images to take u-boot images != 512K 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 From: Chris Packham Instead of assuming that SYS_TEXT_BASE is 0xFFF80000 calculate the initial pbl command offset by subtracting the image size from the top of the 24-bit address range. Also increase the size of the memory buffer to accommodate a larger output image. Signed-off-by: Chris Packham --- Hi, I was trying to get a SPIFLASH image working for my board based on a P2040 and found that the pblimage tool assumes that u-boot.bin is always 512K. In my case it's actually larger. This patch is my attempt to allow for an arbitrary u-boot.bin image size. Thanks, Chris tools/pblimage.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/tools/pblimage.c b/tools/pblimage.c index 508a747..3582ada 100644 --- a/tools/pblimage.c +++ b/tools/pblimage.c @@ -26,18 +26,14 @@ #include "pblimage.h" /* - * The PBL can load up to 64 bytes at a time, so we split the U-Boot - * image into 64 byte chunks. PBL needs a command for each piece, of - * the form "81xxxxxx", where "xxxxxx" is the offset. SYS_TEXT_BASE - * is 0xFFF80000 for PBL boot, and PBL only cares about low 24-bit, - * so it starts from 0x81F80000. + * Initialize to an invalid value. */ -static uint32_t next_pbl_cmd = 0x81F80000; +static uint32_t next_pbl_cmd = 0x82000000; /* * need to store all bytes in memory for calculating crc32, then write the * bytes to image file for PBL boot. */ -static unsigned char mem_buf[600000]; +static unsigned char mem_buf[1000000]; static unsigned char *pmem_buf = mem_buf; static int pbl_size; static char *fname = "Unknown"; @@ -52,6 +48,28 @@ static union #define ENDIANNESS ((char)endian_test.l) +/* + * The PBL can load up to 64 bytes at a time, so we split the U-Boot + * image into 64 byte chunks. PBL needs a command for each piece, of + * the form "81xxxxxx", where "xxxxxx" is the offset. Calculate the + * start offset by subtracting the size of the u-boot image from the + * top of the allowable 24-bit range. + */ +static void init_next_pbl_cmd(FILE *fp_uboot) +{ + struct stat st; + int fd = fileno(fp_uboot); + size_t size; + + if (fstat(fd, &st) == -1) { + printf("Error: Could not determine u-boot image size. %s\n", + strerror(errno)); + exit(EXIT_FAILURE); + } + + next_pbl_cmd = 0x82000000 - st.st_size; +} + static void generate_pbl_cmd(void) { uint32_t val = next_pbl_cmd; @@ -80,6 +98,7 @@ static void pbl_fget(size_t size, FILE *stream) /* load split u-boot with PBI command 81xxxxxx. */ static void load_uboot(FILE *fp_uboot) { + init_next_pbl_cmd(fp_uboot); while (next_pbl_cmd < 0x82000000) { generate_pbl_cmd(); pbl_fget(64, fp_uboot);