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 3/3] scripts: imx-usb-loader: dladdr is unused, remove it
Date: Thu, 13 Feb 2020 11:43:35 +0100	[thread overview]
Message-ID: <20200213104335.6057-3-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20200213104335.6057-1-s.hauer@pengutronix.de>

The download address is the same as the place we put the header to, so
we can drop the calculation of dladdr and use header_addr directly.

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

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

diff --git a/scripts/imx/imx-usb-loader.c b/scripts/imx/imx-usb-loader.c
index d6c62820c3..08affe72c7 100644
--- a/scripts/imx/imx-usb-loader.c
+++ b/scripts/imx/imx-usb-loader.c
@@ -1259,7 +1259,7 @@ static int perform_dcd(unsigned char *p, const unsigned char *file_start,
 }
 
 static int get_dl_start(const unsigned char *p, const unsigned char *file_start,
-		unsigned cnt, unsigned *dladdr, unsigned *max_length, unsigned *plugin,
+		unsigned cnt, unsigned *max_length, unsigned *plugin,
 		unsigned *header_addr)
 {
 	const unsigned char *file_end = file_start + cnt;
@@ -1271,7 +1271,6 @@ static int get_dl_start(const unsigned char *p, const unsigned char *file_start,
 		unsigned char* dcd;
 		int err = get_dcd_range_old(ohdr, file_start, cnt, &dcd, &dcd_end);
 
-		*dladdr = ohdr->app_dest;
 		*header_addr = ohdr->dcd_ptr_ptr - offsetof(struct imx_flash_header, dcd);
 		*plugin = 0;
 		if (err >= 0)
@@ -1284,7 +1283,6 @@ static int get_dl_start(const unsigned char *p, const unsigned char *file_start,
 		unsigned char *bd;
 		struct imx_flash_header_v2 *hdr = (struct imx_flash_header_v2 *)p;
 
-		*dladdr = hdr->self;
 		*header_addr = hdr->self;
 		bd = hdr->boot_data_ptr + cvt_dest_to_src;
 		if ((bd < file_start) || ((bd + 4) > file_end)) {
@@ -1292,7 +1290,6 @@ static int get_dl_start(const unsigned char *p, const unsigned char *file_start,
 			return -1;
 		}
 
-		*dladdr = ((struct imx_boot_data *)bd)->start;
 		*max_length = ((struct imx_boot_data *)bd)->size;
 		*plugin = ((struct imx_boot_data *)bd)->plugin;
 		((struct imx_boot_data *)bd)->plugin = 0;
@@ -1304,7 +1301,7 @@ static int get_dl_start(const unsigned char *p, const unsigned char *file_start,
 }
 
 static int process_header(struct usb_work *curr, unsigned char *buf, int cnt,
-		unsigned *p_dladdr, unsigned *p_max_length, unsigned *p_plugin,
+		unsigned *p_max_length, unsigned *p_plugin,
 		unsigned *p_header_addr)
 {
 	int ret;
@@ -1319,7 +1316,7 @@ static int process_header(struct usb_work *curr, unsigned char *buf, int cnt,
 		if (!is_header(p))
 			continue;
 
-		ret = get_dl_start(p, buf, cnt, p_dladdr, p_max_length, p_plugin, p_header_addr);
+		ret = get_dl_start(p, buf, cnt, p_max_length, p_plugin, p_header_addr);
 		if (ret < 0) {
 			printf("!!get_dl_start returned %i\n", ret);
 			return ret;
@@ -1362,7 +1359,6 @@ static int do_irom_download(struct usb_work *curr, int verify)
 	unsigned char *buf = NULL;
 	unsigned char *image;
 	unsigned char *verify_buffer = NULL;
-	unsigned dladdr = 0;
 	unsigned max_length;
 	unsigned plugin = 0;
 	unsigned header_addr = 0;
@@ -1373,8 +1369,7 @@ static int do_irom_download(struct usb_work *curr, int verify)
 
 	max_length = fsize;
 
-	ret = process_header(curr, buf, fsize,
-			&dladdr, &max_length, &plugin, &header_addr);
+	ret = process_header(curr, buf, fsize, &max_length, &plugin, &header_addr);
 	if (ret < 0)
 		goto cleanup;
 
@@ -1386,14 +1381,6 @@ static int do_irom_download(struct usb_work *curr, int verify)
 		goto cleanup;
 	}
 
-	if (!dladdr) {
-		printf("unknown load address\n");
-		ret = -3;
-		goto cleanup;
-	}
-
-	dladdr = header_addr;
-
 	image = buf + header_offset;
 	fsize -= header_offset;
 
@@ -1417,9 +1404,9 @@ static int do_irom_download(struct usb_work *curr, int verify)
 	}
 
 	printf("loading binary file(%s) to 0x%08x, fsize=%u type=%d...\n",
-			curr->filename, dladdr, fsize, type);
+			curr->filename, header_addr, fsize, type);
 
-	ret = load_file(image, fsize, dladdr, type);
+	ret = load_file(image, fsize, header_addr, type);
 	if (ret < 0)
 		goto cleanup;
 
@@ -1428,7 +1415,7 @@ static int do_irom_download(struct usb_work *curr, int verify)
 	if (verify) {
 		printf("verifying file...\n");
 
-		ret = verify_memory(image, fsize, dladdr);
+		ret = verify_memory(image, fsize, header_addr);
 		if (ret < 0) {
 			printf("verifying failed\n");
 			goto cleanup;
@@ -1442,7 +1429,7 @@ static int do_irom_download(struct usb_work *curr, int verify)
 			 * so we load part of the image again with type FT_APP
 			 * this time.
 			 */
-			ret = load_file(verify_buffer, 64, dladdr, FT_APP);
+			ret = load_file(verify_buffer, 64, header_addr, FT_APP);
 			if (ret < 0)
 				goto cleanup;
 
-- 
2.25.0


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

      parent 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 ` [PATCH 2/3] scripts: imx-usb-loader: download address is always the header address Sascha Hauer
2020-02-13 10:43 ` Sascha Hauer [this message]

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-3-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