Joakim Tjernlund wrote:
Jeff Angielski <j...@theptrgroup.com> wrote on 2010/03/17 16:10:50:
Joakim Tjernlund wrote:
Wolfgang Denk <w...@denx.de> wrote on 2010/03/17 12:57:31:
Dear Joakim Tjernlund,

In message <OFF4AB0804.BE309218-ONC12576E9.003A69DF-C12576E9.
003b4...@transmode.se> you wrote:
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.
Wenn...
    Signed-off-by: Joakim Tjernlund <joakim.tjernl...@transmode.se>


Looks as if this were your very own commit. Do you have a fix in the
works?
I know, but I don't have anything ATM. I am too busy debugging serious
customer problems.

     Jocke
This appears to work for me on my big endian PowerPC target.  Perhaps
somebody with a little endian target can verify it does not break their
env tools.

diff --git a/lib_generic/crc32.c b/lib_generic/crc32.c
index 468b397..27335a3 100644
--- a/lib_generic/crc32.c
+++ b/lib_generic/crc32.c
@@ -163,7 +163,7 @@ const uint32_t * ZEXPORT get_crc_table()
  #endif

  /*
========================================================================= */
-# ifdef __LITTLE_ENDIAN
+# if __BYTE_ORDER == __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)


I THINK this will work. Looking at include/linux/byteorder/big_endian.h it says:
#define __BYTE_ORDER    __BIG_ENDIAN
so it seems like the __BYTE_ORDER logic is in place in u-boot.
Someone with a LE CPU should confirm this.

Mind doing a proper patch?


See attached file.




--
Jeff Angielski
The PTR Group
www.theptrgroup.com
>From 45c007e857990bd01f13c5dbbe61e6f9fc75f390 Mon Sep 17 00:00:00 2001
From: Jeff Angielski <j...@theptrgroup.com>
Date: Wed, 17 Mar 2010 15:09:26 -0400
Subject: [PATCH] env: fix endian ordering in crc table

The crc table was being built as little endian for big endian
targets.  This would cause fw_printenv to always fail with
"Warning: Bad CRC, using default environment" messages.
Signed-off-by: Jeff Angielski <j...@theptrgroup.com>
---
 lib_generic/crc32.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib_generic/crc32.c b/lib_generic/crc32.c
index 468b397..27335a3 100644
--- a/lib_generic/crc32.c
+++ b/lib_generic/crc32.c
@@ -163,7 +163,7 @@ const uint32_t * ZEXPORT get_crc_table()
 #endif
 
 /* ========================================================================= */
-# ifdef __LITTLE_ENDIAN
+# if __BYTE_ORDER == __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)
-- 
1.6.3.3

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to