[U-Boot] [PATCH] crc32: Correct endianness of crc32 result

Simon Glass sjg at chromium.org
Wed Apr 17 01:16:06 CEST 2013


Hi Tom,

On Tue, Apr 16, 2013 at 4:00 PM, Tom Rini <trini at ti.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 04/16/2013 05:57 PM, Simon Glass wrote:
>> Hi Wolfgang,
>>
>> On Sat, Apr 6, 2013 at 12:04 AM, Wolfgang Denk <wd at denx.de> wrote:
>>> Dear Simon Glass,
>>>
>>> In message <1365203470-9099-1-git-send-email-sjg at chromium.org>
>>> you wrote:
>>>> When crc32 is handled by the hash library, it requires the data
>>>> to be in big-endian format, since it reads it byte-wise. Thus
>>>> at present the 'crc32' command reports incorrect data. For
>>>> example, previously we might see:
>>>
>>>
>>>> +#ifdef USE_HOSTCC +     crc = htobe32(crc); memcpy(output,
>>>> &crc, sizeof(crc)); +#else +     put_unaligned_be32(crc,
>>>> output); +#endif
>>>
>>> Why is this depending on USE_HOSTCC, and not on the endianess?
>>
>> We always want big-endian in this case, since the bytes have to
>> date been written that way by the crc32 command.
>
> In other words, this code is executed on both the host and the target,
> and there's not a uniform endian sanitizer function.

Well to be honest, I don't think the code is needed on the host, and I
could put the #ifdef around the whole function. I just thought that
might be a bit short-sighted.

Regards,
Simon


More information about the U-Boot mailing list