From patchwork Thu Feb 23 08:50:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Behme Dirk (CM/ESO2)" X-Patchwork-Id: 142571 X-Patchwork-Delegate: sbabic@denx.de 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 48EF4B6EE8 for ; Thu, 23 Feb 2012 19:50:41 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id ADF392807F; Thu, 23 Feb 2012 09:50:39 +0100 (CET) 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 WGVfozumas5b; Thu, 23 Feb 2012 09:50:39 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6060928078; Thu, 23 Feb 2012 09:50:37 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BA63A28078 for ; Thu, 23 Feb 2012 09:50:34 +0100 (CET) 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 A2N015BqLw27 for ; Thu, 23 Feb 2012 09:50:34 +0100 (CET) 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 smtp2-v.fe.bosch.de (smtp2-v.fe.bosch.de [139.15.237.6]) by theia.denx.de (Postfix) with ESMTPS id 157BD28077 for ; Thu, 23 Feb 2012 09:50:32 +0100 (CET) Received: from vsmta11.fe.internet.bosch.com (unknown [10.4.98.30]) by imta23.fe.bosch.de (Postfix) with ESMTP id 295245820838 for ; Thu, 23 Feb 2012 09:50:30 +0100 (CET) Received: from localhost (vsgw2.fe.internet.bosch.com [10.4.98.13]) by vsmta11.fe.internet.bosch.com (Postfix) with SMTP id 1DEB64E082FF for ; Thu, 23 Feb 2012 09:50:30 +0100 (CET) Received: from FE-HUB1001.de.bosch.com (10.4.103.109) by fe-hub01.de.bosch.com (10.3.153.37) with Microsoft SMTP Server (TLS) id 8.3.213.0; Thu, 23 Feb 2012 09:50:21 +0100 Received: from hi-z5661.hi.de.bosch.com (10.34.217.179) by FE-HUB1001.de.bosch.com (10.4.103.109) with Microsoft SMTP Server id 14.1.355.2; Thu, 23 Feb 2012 09:50:21 +0100 Received: from localhost.localdomain (localhost [127.0.0.1]) by hi-z5661.hi.de.bosch.com (Postfix) with ESMTP id 0946340BC9; Thu, 23 Feb 2012 09:50:21 +0100 (CET) From: Dirk Behme To: Date: Thu, 23 Feb 2012 09:50:19 +0100 Message-ID: <1329987019-24379-1-git-send-email-dirk.behme@de.bosch.com> X-Mailer: git-send-email 1.7.0.4 MIME-Version: 1.0 Cc: Dirk Behme Subject: [U-Boot] [PATCH v2] imximage: Remove overwriting of flash_offset 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: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de The flash header supports different flash offsets for different boot devices. E.g. parallel NOR or OneNAND use a different offset than FLASH_OFFSET_STANDARD (== 0x400). The flash offset is correctly read from the configuration in parse_cfg_cmd(). But is then overwritten wrongly in set_imx_hdr_v1/2(). Fix this by removing this overwriting. Use the flash offset correctly read from the configuration, instead. If there is no flash_offset read from the configuration file, i.e. the BOOT_FROM tag is missing, exit with an error message. Signed-off-by: Dirk Behme CC: Jason Liu CC: Stefano Babic Tested-by: Stefano Babic --- Changes in v2: Make the BOOT_FROM field mandatory, i.e. exit with an error message if there is no valid flash_offset set. Do the same handling in header v1 and v2, not only in v2. Note: This is tested only for header v2. tools/imximage.c | 18 ++++++++++++++---- tools/imximage.h | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/tools/imximage.c b/tools/imximage.c index 1e0f5d4..03a7716 100644 --- a/tools/imximage.c +++ b/tools/imximage.c @@ -216,8 +216,12 @@ static void set_imx_hdr_v1(struct imx_header *imxhdr, uint32_t dcd_len, dcd_v1_t *dcd_v1 = &hdr_v1->dcd_table; uint32_t base_offset; - /* Set default offset */ - imxhdr->flash_offset = FLASH_OFFSET_STANDARD; + /* Exit if there is no BOOT_FROM field specifying the flash_offset */ + if(imxhdr->flash_offset == FLASH_OFFSET_UNDEFINED) { + fprintf(stderr, "Error: Header v1: No BOOT_FROM tag in %s\n", + params->imagename); + exit(EXIT_FAILURE); + } /* Set magic number */ fhdr_v1->app_code_barker = APP_CODE_BARKER; @@ -253,8 +257,12 @@ static void set_imx_hdr_v2(struct imx_header *imxhdr, uint32_t dcd_len, imx_header_v2_t *hdr_v2 = &imxhdr->header.hdr_v2; flash_header_v2_t *fhdr_v2 = &hdr_v2->fhdr; - /* Set default offset */ - imxhdr->flash_offset = FLASH_OFFSET_STANDARD; + /* Exit if there is no BOOT_FROM field specifying the flash_offset */ + if(imxhdr->flash_offset == FLASH_OFFSET_UNDEFINED) { + fprintf(stderr, "Error: Header v2: No BOOT_FROM tag in %s\n", + params->imagename); + exit(EXIT_FAILURE); + } /* Set magic number */ fhdr_v2->header.tag = IVT_HEADER_TAG; /* 0xD1 */ @@ -525,6 +533,8 @@ static void imximage_set_header(void *ptr, struct stat *sbuf, int ifd, * set up function ptr group to V1 by default. */ imximage_version = IMXIMAGE_V1; + /* Be able to detect if the cfg file has no BOOT_FROM tag */ + imxhdr->flash_offset = FLASH_OFFSET_UNDEFINED; set_hdr_func(imxhdr); /* Parse dcd configuration file */ diff --git a/tools/imximage.h b/tools/imximage.h index d784a8d..34f293d 100644 --- a/tools/imximage.h +++ b/tools/imximage.h @@ -32,6 +32,7 @@ #define HEADER_OFFSET 0x400 #define CMD_DATA_STR "DATA" +#define FLASH_OFFSET_UNDEFINED 0xFFFFFFFF #define FLASH_OFFSET_STANDARD 0x400 #define FLASH_OFFSET_NAND FLASH_OFFSET_STANDARD #define FLASH_OFFSET_SD FLASH_OFFSET_STANDARD