summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2018-05-24 11:59:02 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2018-05-24 12:00:08 +0200
commitb28e0798c0be2bdebd7f3d8f4dd1020866e759a9 (patch)
treea7568d10f20a2e2d401f4c20a54d2789f02a6b59 /scripts
parentf53a60ed8063c21f7c2589204b469cd36aba36bf (diff)
downloadbarebox-b28e0798c0be2bdebd7f3d8f4dd1020866e759a9.tar.gz
barebox-b28e0798c0be2bdebd7f3d8f4dd1020866e759a9.tar.xz
imx-usb-loader: Align uploaded file length
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>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/imx/imx-usb-loader.c6
1 files changed, 5 insertions, 1 deletions
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;