All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] bug when using environment in an i2c eeprom and SPI is enabled?
Date: Thu, 16 Jul 2009 09:35:34 +0200	[thread overview]
Message-ID: <4A5ED846.90305@denx.de> (raw)

Hello Wolfgang,

I actually try to use Environment on an I2C EEprom with SPI enabled,
and found in include/common.h the following defines @line 326ff:

/*
 * Set this up regardless of board
 * type, to prevent errors.
 */
#if defined(CONFIG_SPI) || !defined(CONFIG_SYS_I2C_EEPROM_ADDR)
# define CONFIG_SYS_DEF_EEPROM_ADDR 0
#else
# define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR
#endif /* CONFIG_SPI || !defined(CONFIG_SYS_I2C_EEPROM_ADDR) */

So, it seems to me, that, if SPI is enabled, it is not possible
to use an I2C EEprom with an address != 0, because in
common/env_eeprom.c @line79 in env_init():

       /* read old CRC */a
        eeprom_read (CONFIG_SYS_DEF_EEPROM_ADDR,
                     CONFIG_ENV_OFFSET+offsetof(env_t,crc),
                     (uchar *)&crc, sizeof(ulong));

CONFIG_SYS_DEF_EEPROM_ADDR is fix used ...

I tried to use "git blame" to find out where this comes from,
but this is in code since the "initial revision" ... so I ask
here on the mailinglist, if somebody knows, if this is a
feature or a bug?

BTW, I think it should be:

diff --git a/include/common.h b/include/common.h
index 9e4b859..411563b 100644
--- a/include/common.h
+++ b/include/common.h
@@ -327,7 +327,7 @@ extern void  pic_write (uchar reg, uchar val);
  * Set this up regardless of board
  * type, to prevent errors.
  */
-#if defined(CONFIG_SPI) || !defined(CONFIG_SYS_I2C_EEPROM_ADDR)
+#if defined(CONFIG_SPI) && !defined(CONFIG_SYS_I2C_EEPROM_ADDR)
 # define CONFIG_SYS_DEF_EEPROM_ADDR 0
 #else
 # define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR

What do you think?

thanks
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

             reply	other threads:[~2009-07-16  7:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-16  7:35 Heiko Schocher [this message]
2009-07-16 11:51 ` [U-Boot] bug when using environment in an i2c eeprom and SPI is enabled? Wolfgang Denk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A5ED846.90305@denx.de \
    --to=hs@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.