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] imx-usb-loader: Align uploaded file length
Date: Thu, 24 May 2018 12:22:57 +0200	[thread overview]
Message-ID: <20180524102257.14171-1-s.hauer@pengutronix.de> (raw)

At least i.MX25 does not properly upload a non word aligned file length.
Align the uploaded length to word length to make sure the end of the
file is also transferred properly.

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

diff --git a/scripts/imx/imx-usb-loader.c b/scripts/imx/imx-usb-loader.c
index 43dde8b7f2..cbb17cbab9 100644
--- a/scripts/imx/imx-usb-loader.c
+++ b/scripts/imx/imx-usb-loader.c
@@ -40,6 +40,8 @@
 
 #define get_min(a, b) (((a) < (b)) ? (a) : (b))
 
+#define ALIGN(x, a)        (((x) + (a) - 1) & ~((a) - 1))
+
 #define FT_APP	0xaa
 #define FT_CSF	0xcc
 #define FT_DCD	0xee
@@ -412,7 +414,7 @@ static int read_file(const char *name, unsigned char **buffer, unsigned *size)
 		return -2;
 	}
 
-	buf = malloc(fsize);
+	buf = malloc(ALIGN(fsize, 4));
 	if (!buf) {
 		printf("error, out of memory\n");
 		fclose(xfile);
@@ -762,6 +764,8 @@ static int load_file(void *buf, unsigned len, unsigned dladdr, unsigned char typ
 	void *p;
 	int cnt;
 
+	len = ALIGN(len, 4);
+
 	dl_command.addr = htonl(dladdr);
 	dl_command.cnt = htonl(len);
 	dl_command.rsvd = type;
-- 
2.17.0


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

                 reply	other threads:[~2018-05-24 10:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20180524102257.14171-1-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