public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] tools: mksunxiboot: Fix problems on big endian systems
Date: Mon, 16 Feb 2015 20:40:19 +0100	[thread overview]
Message-ID: <54E247A3.2010807@redhat.com> (raw)
In-Reply-To: <1423371927-955-1-git-send-email-siarhei.siamashka@gmail.com>

Hi,

On 08-02-15 06:05, Siarhei Siamashka wrote:
> Now my PS3 can be also used to build u-boot for sunxi devices.
>
> Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>

Thanks, applied to u-boot-sunxi/next and included in the pull-req
which I've just send out.

Regards,

Hans

> ---
>   tools/mksunxiboot.c | 14 ++++++++------
>   1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/tools/mksunxiboot.c b/tools/mksunxiboot.c
> index 1f0fbae..0035f6e 100644
> --- a/tools/mksunxiboot.c
> +++ b/tools/mksunxiboot.c
> @@ -43,19 +43,19 @@ int gen_check_sum(struct boot_file_head *head_p)
>   	uint32_t i;
>   	uint32_t sum;
>
> -	length = head_p->length;
> +	length = le32_to_cpu(head_p->length);
>   	if ((length & 0x3) != 0)	/* must 4-byte-aligned */
>   		return -1;
>   	buf = (uint32_t *)head_p;
> -	head_p->check_sum = STAMP_VALUE;	/* fill stamp */
> +	head_p->check_sum = cpu_to_le32(STAMP_VALUE);	/* fill stamp */
>   	loop = length >> 2;
>
>   	/* calculate the sum */
>   	for (i = 0, sum = 0; i < loop; i++)
> -		sum += buf[i];
> +		sum += le32_to_cpu(buf[i]);
>
>   	/* write back check sum */
> -	head_p->check_sum = sum;
> +	head_p->check_sum = cpu_to_le32(sum);
>
>   	return 0;
>   }
> @@ -125,10 +125,12 @@ int main(int argc, char *argv[])
>   	memcpy(img.header.magic, BOOT0_MAGIC, 8);	/* no '0' termination */
>   	img.header.length =
>   		ALIGN(file_size + sizeof(struct boot_file_head), BLOCK_SIZE);
> +	img.header.b_instruction = cpu_to_le32(img.header.b_instruction);
> +	img.header.length = cpu_to_le32(img.header.length);
>   	gen_check_sum(&img.header);
>
> -	count = write(fd_out, &img, img.header.length);
> -	if (count != img.header.length) {
> +	count = write(fd_out, &img, le32_to_cpu(img.header.length));
> +	if (count != le32_to_cpu(img.header.length)) {
>   		perror("Writing output");
>   		return EXIT_FAILURE;
>   	}
>

      reply	other threads:[~2015-02-16 19:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-08  5:05 [U-Boot] [PATCH] tools: mksunxiboot: Fix problems on big endian systems Siarhei Siamashka
2015-02-16 19:40 ` Hans de Goede [this message]

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=54E247A3.2010807@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=u-boot@lists.denx.de \
    /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