[U-Boot] cross compiling fw_printenv on big endian
Joakim Tjernlund
joakim.tjernlund at transmode.se
Wed Mar 17 11:47:44 CET 2010
>
> Hi Jeff,
>
> > I seem to be having a problem with fw_printenv on my PowerPC 85xx target
> > whereby I constantly get CRC32 errors:
> >
> > # fw_printenv
> > Warning: Bad CRC, using default environment
> >
> > I tracked this down to the fact that u-boot/lib_generic/crc32.c is
> > getting compiled with the __LITTLE_ENDIAN defined even though I have
> > CROSS_COMPILE setup correctly [e.g. I can build u-boot.bin just fine].
>
> This makes little sense to me, as then the crc version used in U-Boot
> would also use a wrong endianness. Are you sure this happens? Las time
> I used the tool it worked for me without any such hacks.
hmm, I recently discovered that normal user space headers always define
both __LITTLE_ENDIAN and __BIG_ENDIAN so therefore a
# ifdef __LITTLE_ENDIAN
# define DO_CRC(x) crc = tab[(crc ^ (x)) & 255] ^ (crc >> 8)
# else
# define DO_CRC(x) crc = tab[((crc >> 24) ^ (x)) & 255] ^ (crc << 8)
# endif
Wont work. One have to use
#if __BYTE_ORDER == __LITTLE_ENDIAN
instead.
Problem is that I don't think u-boot #defines __BYTE_ORDER so
that would have to be added too for all archs:
#define __BYTE_ORDER __LITTLE_ENDIAN
or
#define __BYTE_ORDER __BIG_ENDIAN
More information about the U-Boot
mailing list