24rf08 update
great news,
I reproduced the 24rf08 corruption on a PIIX4 and have a tentative fix.
The eeprom (which, as a refresher, looks like a standard 24c08 eeprom at addresses 0x54 - 0x57 with an additional control bank at 0x5c) is getting corrupted by sensors-detect.
After the detection with a quick write, it gets probed with the detection routines 10 times (3 LM78 variants, 6 w83781d variants, and eeprom).
The first one of these (LM78) reads location 0x48.
Unlike any other eeprom we've seen, a quick write is not benign for these eeproms - it takes it as a start of a write.
So the following read of chip 0x54 at location 0x48 completes the write -
and location 0xa8 (= 0x54 << 1) gets 0x48 written to it.
And so there are 4 corruptions total:
- at bank 0x54, 0x48 is written to location 0xa8;
- at bank 0x55, 0x48 is written to location 0xaa;
- at bank 0x56, 0x48 is written to location 0xac;
- at bank 0x57, 0x48 is written to location 0xae.
There is no corruption at bank 0x5c.
If I take out the LM78 and W83781D probes (these chips are most unlikely to be at these locations anyway, should probably fix this) then the eeprom probe corrupts the chip in the same locations, writing 0x00.
So any read (from any chip!) after a quick write corrupts the chip.
The fix is to change the quick write to "quick write" a 1 instead of a 0;
this works; it presumably makes the 24RF08 take it as the start of a read instead of
a write. I guess this should be safer in general. It still works on the machines I've tried.
I did try putting a 2 second delay between the quick write and the detection
routine - didn't help.
I also repeatedly tried the following things to see if they would corrupt the chip,
nothing did - i2cdetect (which also uses quick write with a 0!), i2cdump,
eeprom, w83781d.
I'll check in the change to sensors-detect, would you please try it and see if
it still works for your chips.
mds
Good work guys! Nice to have narrowed it down to a broken I2C implementation on a particular chip. Detection has always been difficult task to make absolutely safe.
It also seems to match what Joe from Australia described, and what we were suspecting.
So to recap (from my understanding of where we stand), is this true?
- The only corruption that happens with this chip is in sensors-detect?
- If sensors-detect is run to avoid 0x54-0x58, the problem is avoided?
- We have a working patch for sensors-detect which works identically as before, but avoids the corruption (and detects the chip as eeproms)?
- The regular eeprom.o driver does not corrupt the chip, and works as expected?
- There are no complications with the 'protection' address of the chip and probing?
Phil
Quoted 30 lines · Mark D. Studebaker
yes. I get it, makes sense now.
Quoted 27 lines · Ky?sti M?lkki
Quoted 6 lines · Mark D. Studebaker
Quoted 4 lines · Ky?sti M?lkki
Two successive Write Quick "0" become Write Byte, only changing the reference for Read Byte transactions. This is i2cdetect operation and causes no corruption.
Quoted 8 lines
Quoted 5 lines
S
0x54Wr [A] <P><S>0x55Wr [A] PIf this is the case, latter of the two Write Quick commands is always acknowledged by 24rf08, and does not reflect a client at that address.
If this were the case I would not get a detection at
0x54and I would get a detection at0x58. But I correctly get a detection at 0x54-0x57. This is true whether I use Write Quick "0" or Write Quick "1".You would get a detection at
0x54, since at that point 24rf08 acknowledges its address. You would not get a detection at0x58, since there was an even number of Write Quicks.Scan range
0x57to0x58.--
Ky?sti M?lkki
[email protected]
Signature · 3 lines
Philip Edelbrock -- IS Manager -- Edge Design, Corvallis, OR [email protected] -- http://www.netroedge.com/~phil PGP F16: 01 D2 FD 01 B5 46 F4 F0 3A 8B 9D 7E 14 7F FB 7A
Excellent analysis! Comments in line...
Quoted 11 lines · Ky?sti M?lkki
Quoted 7 lines · Mark D. Studebaker
Unlike any other eeprom we've seen, a quick write is not benign for these eeproms - it takes it as a start of a write.
So the following read of chip0x54at location0x48completes the write -
and location0xa8(=0x54<< 1) gets0x48written to it.So any read (from any chip!) after a quick write corrupts the chip.
Quoted 8 lines
If I understood you correctly, crucial sequence is:
Write Quick "0"
S0x54Wr [A] PRead Byte Data
S0x54Wr [A]0x48[A] S0x54Rd [A] [Data] NA P
yes
Quoted 1 line
Further reads without quick write do not corrupt eeprom ?
correct
Quoted 1 line
And the Write Quick address could be from
0x54to0x57?
correct
Quoted 9 lines
Suppose 24rf08 has a poorly designed state machine that does not check for Start and Stop conditions right after acknowledging its address. Below I mark these <S> and <P>, respectively.
The sequence above becomes Write Byte Data + Read Byte. It returns the data just written in the referenced location (
0xa8).
S0x54Wr [A] <P><S>0x54Wr [A]0x48[A] S0x54Rd [A] [0x48] NA P
probably
Quoted 5 lines
Maybe i2c/doc/smbus-protocol has a typo :
SMBus Write Byte : S Addr Wr [A] Data NA P
IMO : S Addr Wr [A] Data [A] P
agreed. fixed.
Quoted 9 lines
Two successive Write Quick "0" become Write Byte, only changing the reference for Read Byte transactions. This is i2cdetect operation and causes no corruption.
S
0x54Wr [A] <P><S>0x55Wr [A] PIf this is the case, latter of the two Write Quick commands is always acknowledged by 24rf08, and does not reflect a client at that address.
If this were the case I would not get a detection at 0x54 and I would get a detection at 0x58. But I correctly get a detection at 0x54-0x57. This is true whether I use Write Quick "0" or Write Quick "1".
Quoted 3 lines
It also means 2 x Write Quick would reset the state machine and prevent corruption...
Tested and verified.
Quoted 14 lines
Quoted 3 lines
I also repeatedly tried the following things to see if they would corrupt the chip,
nothing did - i2cdetect (which also uses quick write with a 0!),I know my Matrix Orbital LCD w/ old BIOS forces SCL down forever with quick write "1" (aka read address). It takes power-off to release it.
Quoted 1 line
cvs log
i2cdetect.c----------------------------
revision 1.5
date: 1999/07/21 09:35:40; author: kmalkki; state: Exp; lines: +1 -1 (Ky?sti)
Quoted 6 lines
* Use write-address to detect devices on the bus.
Simple clients that you can't read, don't ack the read address. I believe every client has to ack their write address?
----------------------------
Yack. I tested further and hung the bus on my Iopener. Probably the clock chip.
So using Write Quick "1" won't work.
Quoted 3 lines
--
Ky?sti M?lkki
[email protected]
So if we add a second Write Quick "0" - only in the range 54-57 is necessary -
that sounds like a good fix. Agreed?
yes. I get it, makes sense now.
Quoted 27 lines · Ky?sti M?lkki
Quoted 6 lines · Mark D. Studebaker
Quoted 4 lines · Ky?sti M?lkki
Two successive Write Quick "0" become Write Byte, only changing the reference for Read Byte transactions. This is i2cdetect operation and causes no corruption.
Quoted 8 lines
Quoted 5 lines
S
0x54Wr [A] <P><S>0x55Wr [A] PIf this is the case, latter of the two Write Quick commands is always acknowledged by 24rf08, and does not reflect a client at that address.
If this were the case I would not get a detection at
0x54and I would get a detection at0x58. But I correctly get a detection at 0x54-0x57. This is true whether I use Write Quick "0" or Write Quick "1".You would get a detection at
0x54, since at that point 24rf08 acknowledges its address. You would not get a detection at0x58, since there was an even number of Write Quicks.Scan range
0x57to0x58.--
Ky?sti M?lkki
[email protected]
in-line
Quoted 5 lines · [email protected] wrote:
Good work guys! Nice to have narrowed it down to a broken I2C implementation on a particular chip. Detection has always been difficult task to make absolutely safe.
Quoted 8 lines
It also seems to match what Joe from Australia described, and what we were suspecting.
So to recap (from my understanding of where we stand), is this true?
- The only corruption that happens with this chip is in sensors-detect?
true on my system.
Quoted 2 lines
- If sensors-detect is run to avoid 0x54-0x58, the problem is avoided?
0x54-57.
Quoted 4 lines
- We have a working patch for sensors-detect which works identically as before, but avoids the corruption (and detects the chip as eeproms)?
true. But (of course) on an IBM system, sensors-detect won't get that far
because of the DMI detection.
Quoted 3 lines
- The regular eeprom.o driver does not corrupt the chip, and works as expected?
true, with one exception.
The eeprom driver doesn't work perfectly because the chip treats 00-7f as one 'bank' and 80-ff as a second bank. When you don't reset the address, reads wrap at the end of a bank. So eeprom shows the 00-7f contents at both 00-7f and 80-ff. i2cdump works correctly because it sends the address for each read. This had me going for a while...
Quoted 3 lines
- There are no complications with the 'protection' address of the chip and probing?
true. I don't know if that's because the 0x5c address location works, or because its memory only goes from 00 - 1f, and the corruption would happen at b8 (= 5c << 1)
Quoted 38 lines
Phil
Quoted 30 lines · Mark D. Studebaker
yes. I get it, makes sense now.
Quoted 27 lines · Ky?sti M?lkki
Quoted 6 lines · Mark D. Studebaker
Quoted 4 lines · Ky?sti M?lkki
Two successive Write Quick "0" become Write Byte, only changing the reference for Read Byte transactions. This is i2cdetect operation and causes no corruption.
Quoted 8 lines
Quoted 5 lines
S
0x54Wr [A] <P><S>0x55Wr [A] PIf this is the case, latter of the two Write Quick commands is always acknowledged by 24rf08, and does not reflect a client at that address.
If this were the case I would not get a detection at
0x54and I would get a detection at0x58. But I correctly get a detection at 0x54-0x57. This is true whether I use Write Quick "0" or Write Quick "1".You would get a detection at
0x54, since at that point 24rf08 acknowledges its address. You would not get a detection at0x58, since there was an even number of Write Quicks.Scan range
0x57to0x58.--
Ky?sti M?lkki
[email protected]--
Philip Edelbrock -- IS Manager -- Edge Design, Corvallis, OR
[email protected] -- http://www.netroedge.com/~phil
PGP F16: 01 D2 FD 01 B5 46 F4 F0 3A 8B 9D 7E 14 7F FB 7A
Quoted 7 lines · Mark D. Studebaker
Unlike any other eeprom we've seen, a quick write is not benign for these eeproms - it takes it as a start of a write.
So the following read of chip0x54at location0x48completes the write -
and location0xa8(=0x54<< 1) gets0x48written to it.So any read (from any chip!) after a quick write corrupts the chip.
If I understood you correctly, crucial sequence is:
Write Quick "0"
S 0x54 Wr [A] P
Read Byte Data
S 0x54 Wr [A] 0x48 [A] S 0x54 Rd [A] [Data] NA P
Further reads without quick write do not corrupt eeprom ? And the Write Quick address could be from 0x54 to 0x57 ?
Suppose 24rf08 has a poorly designed state machine that does not check for Start and Stop conditions right after acknowledging its address. Below I mark these <S> and <P>, respectively.
The sequence above becomes Write Byte Data + Read Byte. It returns the data just written in the referenced location (0xa8).
S 0x54 Wr [A] <P><S> 0x54 Wr [A] 0x48 [A] S 0x54 Rd [A] [0x48] NA P
Maybe i2c/doc/smbus-protocol has a typo :
SMBus Write Byte : S Addr Wr [A] Data NA P
IMO : S Addr Wr [A] Data [A] P
Two successive Write Quick "0" become Write Byte, only changing the reference for Read Byte transactions. This is i2cdetect operation and causes no corruption.
S 0x54 Wr [A] <P><S> 0x55 Wr?[A] P
If this is the case, latter of the two Write Quick commands is always acknowledged by 24rf08, and does not reflect a client at that address.
It also means 2 x Write Quick would reset the state machine and prevent corruption...
Quoted 3 lines
I also repeatedly tried the following things to see if they would corrupt the chip,
nothing did - i2cdetect (which also uses quick write with a 0!),
I know my Matrix Orbital LCD w/ old BIOS forces SCL down forever with quick write "1" (aka read address). It takes power-off to release it.
Quoted 1 line
cvs log
i2cdetect.c
----------------------------
revision 1.5
date: 1999/07/21 09:35:40; author: kmalkki; state: Exp; lines: +1 -1 (Ky?sti)
* Use write-address to detect devices on the bus.
Simple clients that you can't read, don't ack the read address. I believe every client has to ack their write address?
----------------------------
Signature · 2 lines
Ky?sti M?lkki [email protected]
Quoted 6 lines · Mark D. Studebaker
Quoted 4 lines · Ky?sti M?lkki
Two successive Write Quick "0" become Write Byte, only changing the reference for Read Byte transactions. This is i2cdetect operation and causes no corruption.
Quoted 8 lines
Quoted 5 lines
S
0x54Wr [A] <P><S>0x55Wr [A] PIf this is the case, latter of the two Write Quick commands is always acknowledged by 24rf08, and does not reflect a client at that address.
If this were the case I would not get a detection at
0x54and I would get a detection at0x58. But I correctly get a detection at 0x54-0x57. This is true whether I use Write Quick "0" or Write Quick "1".
You would get a detection at 0x54, since at that point 24rf08 acknowledges its address. You would not get a detection at 0x58, since there was an even number of Write Quicks.
Scan range 0x57 to 0x58.
Signature · 2 lines
Ky?sti M?lkki [email protected]
Quoted 11 lines · Mark D. Studebaker
Quoted 6 lines · Ky?sti M?lkki
Two successive Write Quick "0" become Write Byte, only changing the reference for Read Byte transactions. This is i2cdetect operation and causes no corruption.
It also means 2 x Write Quick would reset the state machine and prevent corruption...
So if we add a second Write Quick "0" - only in the range 54-57 is necessary - that sounds like a good fix. Agreed?
That's good first aid.
To be Really Safe (TM), one must not release adapter lock in between. EEPs could still corrupt if you have a sensor module loaded and you run i2cdetect.
Also sensor clients' attach_adapter uses Write Quick, often followed by Read Byte Data. Currently only eeprom.o is left in the mentioned range. So maybe i2c-core deserves an option of doubling, preventing or faking Write Quick's in the range.
I don't know about SMBus, but i2c defines multi-master topology. Unless we can force SCL low between the two Quicks, some embedded controller can still screw things up for us.
Signature · 2 lines
Ky?sti M?lkki [email protected]