From mboxrd@z Thu Jan 1 00:00:00 1970 From: Allen Martin Date: Fri, 5 Apr 2013 16:32:59 -0700 Subject: [U-Boot] [PATCH] crc32: Correct endianness of crc32 result In-Reply-To: <1365203470-9099-1-git-send-email-sjg@chromium.org> References: <1365203470-9099-1-git-send-email-sjg@chromium.org> Message-ID: <20130405233259.GA17449@badger> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Fri, Apr 05, 2013 at 04:11:10PM -0700, Simon Glass 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: > > Peach # crc32 40000000 100 > CRC32 for 40000000 ... 400000ff ==> 0d968558 > > but instead with the hash library we see: > > Peach # crc32 40000000 100 > CRC32 for 40000000 ... 400000ff ==> 5885960d > > Correct this. > > Signed-off-by: Simon Glass > Reviewed-by: Vadim Bendebury > --- > lib/crc32.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/lib/crc32.c b/lib/crc32.c > index 76205da..94720bf 100644 > --- a/lib/crc32.c > +++ b/lib/crc32.c > @@ -10,6 +10,7 @@ > > #ifndef USE_HOSTCC > #include > +#include > #endif > #include > #include > @@ -256,5 +257,10 @@ void crc32_wd_buf(const unsigned char *input, unsigned int ilen, > uint32_t crc; > > crc = crc32_wd(0, input, ilen, chunk_sz); > +#ifdef USE_HOSTCC > + crc = htobe32(crc); > memcpy(output, &crc, sizeof(crc)); > +#else > + put_unaligned_be32(crc, output); > +#endif > } > -- > 1.8.1.3 > Tested on Tegra114 Dalmore, verified crc32 comes out as expected now. Reviewed-by: Allen Martin Tested-by: Allen Martin -- nvpublic