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 <sjg@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@google.com>
* For conditions of distribution and use, see copyright notice in zlib.h
*/
-#ifndef USE_HOSTCC
+#ifdef USE_HOSTCC
+#include <arpa/inet.h>
+#else
#include <common.h>
#endif
#include <compiler.h>
uint32_t crc;
crc = crc32_wd(0, input, ilen, chunk_sz);
+ crc = htonl(crc);
memcpy(output, &crc, sizeof(crc));
}