From patchwork Sun May 1 17:10:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teddy Reed X-Patchwork-Id: 617182 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 3qyYqV31Sfz9t4g for ; Mon, 2 May 2016 03:11:02 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=ZhRQFv4C; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 09054A7606; Sun, 1 May 2016 19:11:00 +0200 (CEST) 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 8H1nuero4FbS; Sun, 1 May 2016 19:10:59 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 51A4AA7557; Sun, 1 May 2016 19:10:59 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E5BC3A7557 for ; Sun, 1 May 2016 19:10:56 +0200 (CEST) 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 47KpI2h29cH2 for ; Sun, 1 May 2016 19:10:56 +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-pf0-f194.google.com (mail-pf0-f194.google.com [209.85.192.194]) by theia.denx.de (Postfix) with ESMTPS id 680D24BB1A for ; Sun, 1 May 2016 19:10:52 +0200 (CEST) Received: by mail-pf0-f194.google.com with SMTP id p185so19307058pfb.3 for ; Sun, 01 May 2016 10:10:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version :content-transfer-encoding; bh=StiG9rIgsetvZ5IfpxQxHb+zXvckMVizJ3rZ7K/4Bmw=; b=ZhRQFv4CC0wUQCzf8iQL5GvY2915/vztT7077Qr+7zCIVsRyEgOkR13MQ6H24KvYIp NE7Z3zWe3KAVwu6vL37i9qcCo3wZvNQBNzODkBsJRikc1Cxr7lAqijX41eSQ/bAmn0cu 4+zzhRYEBYCzcfbXjS2cbuKH34K3PAKCS+IP2mCWcEvIbBQJjPB6klkJmPujpzl6TFmx 3K1MYBWK5+vFzZqvfJ4Ppq949NxKzQRzndZT7R86LAKpJjLH/pgLG0bVNJHj5Grkgl// yZUz0Hop8YNxSolhNxvEthLLTeCLBjUi0sbyhhYbXZ84o0HIKKcwzaGWb/UZYkIwBVzl 5geQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-transfer-encoding; bh=StiG9rIgsetvZ5IfpxQxHb+zXvckMVizJ3rZ7K/4Bmw=; b=hUqxjopPNfc2LEPuogd7dUSjmhcpKdrQDEJ6kLYko3gcDEqspiU1ABJfZep3zxdbpY V5jv4Kg8ZSOq8ulSXzxsbLTKrZgX5YQYnJObEoFPdrWX6lhOUMv6vN+qvunmrYOv+yd5 qP5rvU9eUT2xAIT6ss+r/ZQPEwP9TM+PwPozPUZGvnA2bzQZhsZhNmqnx5tb3oXJ1CYF RHBM89We4SOwbOfF6BYRVVX/eKWGCqfu3EGwCHwDbn5S64+42insPRgWuHB24rBsIw4D qZUm1P+S5CWER/E2HgJYIZkxPLGeUDGqekjPqR8bA6PCuTQz2Mq0EncHxxC+0QOcRWJZ zvmw== X-Gm-Message-State: AOPr4FVJDCQJgmkkRQsaKDj1PTWGOG+w5MSlmBTiP5JjlAyBC8N286jwXvTXvttotdN+qQ== X-Received: by 10.98.101.199 with SMTP id z190mr45418050pfb.1.1462122650221; Sun, 01 May 2016 10:10:50 -0700 (PDT) Received: from maverics (c-24-6-55-56.hsd1.ca.comcast.net. [24.6.55.56]) by smtp.gmail.com with ESMTPSA id h5sm45842033pat.0.2016.05.01.10.10.49 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 01 May 2016 10:10:49 -0700 (PDT) Date: Sun, 1 May 2016 10:10:11 -0700 From: Teddy Reed To: u-boot@lists.denx.de Message-Id: <20160501101011.72db83f05e19477399fd669e@gmail.com> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Subject: [U-Boot] [PATCH] mkimage: fit: spl: Add an optional static offset for external data X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" When building a FIT with external data (-E), an SPL may require absolute positioning for executing the external firmware. To acheive this use the (-p) switch which will replace the amended "data-offset" with "data-position" indicating the absolute position of external data. It is considered an error if the requested absolute position overlaps with the initial data required for the compact FIT. Signed-off-by: Teddy Reed Cc: Simon Glass --- tools/fit_image.c | 19 ++++++++++++++++++- tools/imagetool.h | 1 + tools/mkimage.c | 9 ++++++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/tools/fit_image.c b/tools/fit_image.c index ddefa72..98610bf 100644 --- a/tools/fit_image.c +++ b/tools/fit_image.c @@ -417,7 +417,13 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname) ret = -EPERM; goto err_munmap; } - fdt_setprop_u32(fdt, node, "data-offset", buf_ptr); + if (params->external_offset > 0) { + /* An external offset positions the data absolutely. */ + fdt_setprop_u32(fdt, node, "data-position", + params->external_offset + buf_ptr); + } else { + fdt_setprop_u32(fdt, node, "data-offset", buf_ptr); + } fdt_setprop_u32(fdt, node, "data-size", len); buf_ptr += (len + 3) & ~3; @@ -438,6 +444,17 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname) ret = -EIO; goto err; } + + /* Check if an offset for the external data was set. */ + if (params->external_offset > 0) { + if (params->external_offset < new_size) { + debug("External offset %x overlaps FIT length %x", + params->external_offset, new_size); + ret = -EINVAL; + goto err; + } + new_size = params->external_offset; + } if (lseek(fd, new_size, SEEK_SET) < 0) { debug("%s: Failed to seek to end of file: %s\n", __func__, strerror(errno)); diff --git a/tools/imagetool.h b/tools/imagetool.h index 24f8f4b..7862fa3 100644 --- a/tools/imagetool.h +++ b/tools/imagetool.h @@ -73,6 +73,7 @@ struct image_tool_params { struct content_info *content_head; /* List of files to include */ struct content_info *content_tail; bool external_data; /* Store data outside the FIT */ + unsigned int external_offset; /* Add padding to external data */ }; /* diff --git a/tools/mkimage.c b/tools/mkimage.c index 2931783..85e4781 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -138,7 +138,7 @@ static void process_args(int argc, char **argv) expecting = IH_TYPE_COUNT; /* Unknown */ while ((opt = getopt(argc, argv, - "-a:A:bcC:d:D:e:Ef:Fk:K:ln:O:rR:sT:vVx")) != -1) { + "-a:A:bcC:d:D:e:Ef:Fk:K:ln:p:O:rR:sT:vVx")) != -1) { switch (opt) { case 'a': params.addr = strtoull(optarg, &ptr, 16); @@ -213,6 +213,13 @@ static void process_args(int argc, char **argv) if (params.os < 0) usage("Invalid operating system"); break; + case 'p': + params.external_offset = strtoull(optarg, &ptr, 16); + if (*ptr) { + fprintf(stderr, "%s: invalid offset size %s\n", + params.cmdname, optarg); + exit(EXIT_FAILURE); + } case 'r': params.require_keys = 1; break;