summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMichael Heimpold <mhei@heimpold.de>2015-09-01 23:58:44 +0200
committerStefano Babic <sbabic@denx.de>2015-09-13 10:19:40 +0200
commitb5e7586a73d4eb7b0aa9c597f293a584a2a1800a (patch)
treeaea5c2ee7d7770ad882457478623112ba08c39c9 /tools
parent1a8150d4b16fbafa6f1d207ddb85eda7dc399e2d (diff)
mxs: mxsboot: fix endianess for sd boot images
Running mxsboot on a big-endian system produces a sd image which cannot be started by the i.MX28 ROM. It complains on the debug uart as following: 0x8020a009 0x80502008 0x8020a009 0x80502008 ... Enforcing all fields within the BCB to little-endian make the image bootable again. Signed-off-by: Michael Heimpold <mhei@heimpold.de> Acked-by: Stefano Babic <sbabic@denx.de> Acked-by: Marek Vasut <marex@denx.de>
Diffstat (limited to 'tools')
-rw-r--r--tools/mxsboot.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/tools/mxsboot.c b/tools/mxsboot.c
index 15eec9179d6..3434c81792c 100644
--- a/tools/mxsboot.c
+++ b/tools/mxsboot.c
@@ -7,6 +7,7 @@
* SPDX-License-Identifier: GPL-2.0+
*/
+#include <endian.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -556,15 +557,15 @@ static int mx28_create_sd_image(int infd, int outfd)
cb = (struct mx28_sd_config_block *)buf;
- cb->signature = 0x00112233;
- cb->primary_boot_tag = 0x1;
- cb->secondary_boot_tag = 0x1;
- cb->num_copies = 1;
- cb->drv_info[0].chip_num = 0x0;
- cb->drv_info[0].drive_type = 0x0;
- cb->drv_info[0].tag = 0x1;
- cb->drv_info[0].first_sector_number = sd_sector + 4;
- cb->drv_info[0].sector_count = (size - 4) / 512;
+ cb->signature = htole32(0x00112233);
+ cb->primary_boot_tag = htole32(0x1);
+ cb->secondary_boot_tag = htole32(0x1);
+ cb->num_copies = htole32(1);
+ cb->drv_info[0].chip_num = htole32(0x0);
+ cb->drv_info[0].drive_type = htole32(0x0);
+ cb->drv_info[0].tag = htole32(0x1);
+ cb->drv_info[0].first_sector_number = htole32(sd_sector + 4);
+ cb->drv_info[0].sector_count = htole32((size - 4) / 512);
wr_size = write(outfd, buf, size);
if (wr_size != size) {