bug when using environment in an i2c eeprom and SPI is enabled?
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:
include/common.h +1 -1
@@ -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
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Dear Heiko Schocher,
Quoted 3 lines · In message <[email protected]> you wrote:
I actually try to use Environment on an I2C EEprom with SPI enabled, and found in
include/common.hthe following defines @line 326ff:
I'm not surprised...
Quoted 3 lines
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 inenv_init():
Actually you are most probably not supposed to use any I2C EEPROM at all.
Quoted 4 lines
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?
I think this is a deficiency of the original implementation which assumed that if there was an EEPROM, it was either attached to the I2C or to the SPI bus, and that SPI would never be used in U-Boot for anything else than reading an EEPROM.
Please consider it a bug...
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de An armed society is a polite society.