mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 2/3] scripts: imx-usb-loader: download address is always the header address
Date: Thu, 13 Feb 2020 11:43:34 +0100	[thread overview]
Message-ID: <20200213104335.6057-2-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20200213104335.6057-1-s.hauer@pengutronix.de>

We always have to upload the image beginning with the header, we have
to skip everything that is before the header.
In MODE_BULK this is explicit, but in HID mode this is obfuscated by
doing several calculations with helper variables. Drop this and simplify
code.

Tested on i.MX51, i.MX53 and i.MX6

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 scripts/imx/imx-usb-loader.c | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/scripts/imx/imx-usb-loader.c b/scripts/imx/imx-usb-loader.c
index ebe0eea050..d6c62820c3 100644
--- a/scripts/imx/imx-usb-loader.c
+++ b/scripts/imx/imx-usb-loader.c
@@ -1359,7 +1359,6 @@ static int do_irom_download(struct usb_work *curr, int verify)
 	unsigned char type;
 	unsigned fsize = 0;
 	unsigned header_offset;
-	unsigned file_base;
 	unsigned char *buf = NULL;
 	unsigned char *image;
 	unsigned char *verify_buffer = NULL;
@@ -1367,7 +1366,6 @@ static int do_irom_download(struct usb_work *curr, int verify)
 	unsigned max_length;
 	unsigned plugin = 0;
 	unsigned header_addr = 0;
-	unsigned skip = 0;
 
 	ret = read_file(curr->filename, &buf, &fsize);
 	if (ret < 0)
@@ -1394,20 +1392,10 @@ static int do_irom_download(struct usb_work *curr, int verify)
 		goto cleanup;
 	}
 
-	file_base = header_addr - header_offset;
+	dladdr = header_addr;
 
-	if (usb_id->mach_id->mode == MODE_BULK) {
-		/* No jump command, dladdr should point to header */
-		dladdr = header_addr;
-	}
-
-	skip = dladdr - file_base;
-
-	image = buf + skip;
-	fsize -= skip;
-
-	if (fsize > max_length)
-		fsize = max_length;
+	image = buf + header_offset;
+	fsize -= header_offset;
 
 	type = FT_APP;
 
@@ -1428,8 +1416,8 @@ static int do_irom_download(struct usb_work *curr, int verify)
 		}
 	}
 
-	printf("loading binary file(%s) to 0x%08x, skip=0x%x, fsize=%u type=%d...\n",
-			curr->filename, dladdr, skip, fsize, type);
+	printf("loading binary file(%s) to 0x%08x, fsize=%u type=%d...\n",
+			curr->filename, dladdr, fsize, type);
 
 	ret = load_file(image, fsize, dladdr, type);
 	if (ret < 0)
-- 
2.25.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2020-02-13 10:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-13 10:43 [PATCH 1/3] scripts: imx-usb-loader: remove unnecessary check Sascha Hauer
2020-02-13 10:43 ` Sascha Hauer [this message]
2020-02-13 10:43 ` [PATCH 3/3] scripts: imx-usb-loader: dladdr is unused, remove it Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200213104335.6057-2-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox