Commit b5e7586a73d4eb7b0aa9c597f293a584a2a1800a

Authored by Michael Heimpold
Committed by Stefano Babic
1 parent 1a8150d4b1

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>

Showing 1 changed file with 10 additions and 9 deletions Side-by-side Diff

... ... @@ -7,6 +7,7 @@
7 7 * SPDX-License-Identifier: GPL-2.0+
8 8 */
9 9  
  10 +#include <endian.h>
10 11 #include <fcntl.h>
11 12 #include <sys/stat.h>
12 13 #include <sys/types.h>
... ... @@ -556,15 +557,15 @@
556 557  
557 558 cb = (struct mx28_sd_config_block *)buf;
558 559  
559   - cb->signature = 0x00112233;
560   - cb->primary_boot_tag = 0x1;
561   - cb->secondary_boot_tag = 0x1;
562   - cb->num_copies = 1;
563   - cb->drv_info[0].chip_num = 0x0;
564   - cb->drv_info[0].drive_type = 0x0;
565   - cb->drv_info[0].tag = 0x1;
566   - cb->drv_info[0].first_sector_number = sd_sector + 4;
567   - cb->drv_info[0].sector_count = (size - 4) / 512;
  560 + cb->signature = htole32(0x00112233);
  561 + cb->primary_boot_tag = htole32(0x1);
  562 + cb->secondary_boot_tag = htole32(0x1);
  563 + cb->num_copies = htole32(1);
  564 + cb->drv_info[0].chip_num = htole32(0x0);
  565 + cb->drv_info[0].drive_type = htole32(0x0);
  566 + cb->drv_info[0].tag = htole32(0x1);
  567 + cb->drv_info[0].first_sector_number = htole32(sd_sector + 4);
  568 + cb->drv_info[0].sector_count = htole32((size - 4) / 512);
568 569  
569 570 wr_size = write(outfd, buf, size);
570 571 if (wr_size != size) {