public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] mxs: mxsboot: fix endianess for sd boot images
@ 2015-09-01 21:58 Michael Heimpold
  2015-09-02  7:42 ` Stefano Babic
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Heimpold @ 2015-09-01 21:58 UTC (permalink / raw)
  To: u-boot

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>
---
 tools/mxsboot.c |   19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/tools/mxsboot.c b/tools/mxsboot.c
index 185b327..8284e95 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>
@@ -569,15 +570,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) {
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] mxs: mxsboot: fix endianess for sd boot images
  2015-09-01 21:58 [U-Boot] [PATCH] mxs: mxsboot: fix endianess for sd boot images Michael Heimpold
@ 2015-09-02  7:42 ` Stefano Babic
  2015-09-02  8:03   ` Marek Vasut
  0 siblings, 1 reply; 3+ messages in thread
From: Stefano Babic @ 2015-09-02  7:42 UTC (permalink / raw)
  To: u-boot

Hi Michael,

On 01/09/2015 23:58, Michael Heimpold wrote:
> 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:

I confess that I never tested mxsboot and/or mkimage on a big endian
host. I am expecting there are similar issues with mkimage and imximage,
too....

> 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>
> ---
>  tools/mxsboot.c |   19 ++++++++++---------
>  1 file changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/mxsboot.c b/tools/mxsboot.c
> index 185b327..8284e95 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>
> @@ -569,15 +570,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) {
> 

Looks ok to me !

Acked-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] mxs: mxsboot: fix endianess for sd boot images
  2015-09-02  7:42 ` Stefano Babic
@ 2015-09-02  8:03   ` Marek Vasut
  0 siblings, 0 replies; 3+ messages in thread
From: Marek Vasut @ 2015-09-02  8:03 UTC (permalink / raw)
  To: u-boot

On Wednesday, September 02, 2015 at 09:42:03 AM, Stefano Babic wrote:
> Hi Michael,
> 
> On 01/09/2015 23:58, Michael Heimpold wrote:
> > 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:
> I confess that I never tested mxsboot and/or mkimage on a big endian

Me neither.

> host. I am expecting there are similar issues with mkimage and imximage,
> too....

Fix it and send patch :b

Acked-by: Marek Vasut <marex@denx.de>

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-09-02  8:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-01 21:58 [U-Boot] [PATCH] mxs: mxsboot: fix endianess for sd boot images Michael Heimpold
2015-09-02  7:42 ` Stefano Babic
2015-09-02  8:03   ` Marek Vasut

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox