From patchwork Wed Nov 28 01:31:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Troy Kisky X-Patchwork-Id: 202338 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 9BE7E2C0087 for ; Wed, 28 Nov 2012 12:32:38 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1FFA74A095; Wed, 28 Nov 2012 02:32:32 +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 dDg5gw-q7Dco; Wed, 28 Nov 2012 02:32:31 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7CF764A0B8; Wed, 28 Nov 2012 02:32:05 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0F7D74A0AF for ; Wed, 28 Nov 2012 02:31:59 +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 1oy0u-I3qomY for ; Wed, 28 Nov 2012 02:31:57 +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 mail-pa0-f44.google.com (mail-pa0-f44.google.com [209.85.220.44]) by theia.denx.de (Postfix) with ESMTPS id 03F924A094 for ; Wed, 28 Nov 2012 02:31:53 +0100 (CET) Received: by mail-pa0-f44.google.com with SMTP id hz11so6994242pad.3 for ; Tue, 27 Nov 2012 17:31:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=HUOlkS7Gs8Se90bAO3qUaJfyH1UQNXtMfhoM/4CzkJA=; b=jxSe2udUMU2DibY6jVLG51kRo81D8BgQ0LBPa8+yxwYurkbMsNk8d1pj/gV/fflPHP +vyaT/Fp8GERJI/rvBKHrRIZbvhGF1pDvERdm4AWMJihz0nRgVk6Uyg39iDmuPEVI/EW xPPXxAUtIhKM7NVF2YvKPmkOwl17uuUq6JIhsFtCXwsv1W92o3E+vrOLzxaY8MhdU//V V2TNfzSvOtTAEgpSmt6pcO0y1zTD+0ltzP6WGL0FVYAAz5vDgUGI1ce38NTMeTe2cVTT fIiI1J3t8KLg92qRTteGHgGT5R+21IKtDddwgbNjTFm2lRQcpxdNBgqydAVjPPQeFWOf +jfg== Received: by 10.68.202.72 with SMTP id kg8mr53942422pbc.134.1354066310055; Tue, 27 Nov 2012 17:31:50 -0800 (PST) Received: from officeserver-2 ([70.96.116.236]) by mx.google.com with ESMTPS id mt15sm11496912pbc.49.2012.11.27.17.31.47 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 27 Nov 2012 17:31:48 -0800 (PST) Received: from tkisky by officeserver-2 with local (Exim 4.76) (envelope-from ) id 1TdWVB-0007ko-GL; Tue, 27 Nov 2012 18:31:49 -0700 From: Troy Kisky To: sbabic@denx.de Date: Tue, 27 Nov 2012 18:31:33 -0700 Message-Id: <1354066303-29762-2-git-send-email-troy.kisky@boundarydevices.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1354066303-29762-1-git-send-email-troy.kisky@boundarydevices.com> References: <1349315254-21151-9-git-send-email-troy.kisky@boundarydevices.com> <1354066303-29762-1-git-send-email-troy.kisky@boundarydevices.com> X-Gm-Message-State: ALoCoQl9CmuRcOX+bgaLTrkM7nWEF8VmO2HO8pf41eNSCH7ID7lq3NxHOwAC465eX7XaDhbU4zBQ Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH V4 01/11] imximage: mx53 needs transfer length a multiple of 512 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 The mx53 ROM will truncate the length at a multiple of 512. Transferring too much is not a problem, so round up. Problem reported by Stefano Babic. Signed-off-by: Troy Kisky Acked-by: Jason Liu --- tools/imximage.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/imximage.c b/tools/imximage.c index 63f88b6..7e54e97 100644 --- a/tools/imximage.c +++ b/tools/imximage.c @@ -494,6 +494,8 @@ static void imximage_print_header(const void *ptr) } } +#define ALIGN(a, b) (((a) + (b) - 1) & ~((b) - 1)) + static void imximage_set_header(void *ptr, struct stat *sbuf, int ifd, struct mkimage_params *params) { @@ -515,7 +517,13 @@ static void imximage_set_header(void *ptr, struct stat *sbuf, int ifd, /* Set the imx header */ (*set_imx_hdr)(imxhdr, dcd_len, params->ep, imxhdr->flash_offset); - *header_size_ptr = sbuf->st_size + imxhdr->flash_offset; + /* + * ROM bug alert + * mx53 only loads 512 byte multiples. + * The remaining fraction of a block bytes would + * not be loaded. + */ + *header_size_ptr = ALIGN(sbuf->st_size + imxhdr->flash_offset, 512); } int imximage_check_params(struct mkimage_params *params)