Port-arm archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Clock error on bootup - NSLU2



Steve Woodford wrote:
It is looking less likely to be a hardware problem. I'll try to find some time to fire up a current kernel on an NSLU2 over the next few days to see if I can reproduce the problem.

I instrumented a copy of src/sys/dev/i2c/i2c_bitbang.c with printf and learned two things. First, the write function is always returning an error from the bottom of the function at the line marked by >>>>>.

int
i2c_bitbang_write_byte(void *v, uint8_t val, int flags,
   i2c_bitbang_ops_t ops)
{
   uint32_t bit;
   uint8_t mask;
   int error;

   for (mask = 0x80; mask != 0; mask >>= 1) {
       bit = (val & mask) ? SDA : 0;

       DIR(OUTPUT);
       SETBITS(bit      );
       delay(1);    /* data setup time (250 nS) */
       SETBITS(bit | SCL);

       if (i2c_wait_for_scl(v, ops))
           return EIO;
       delay(4);    /* clock high time (4.0 uS) */

       DIR(OUTPUT);
       SETBITS(bit      );
       delay(5);    /* clock low time (4.7 uS) */
   }

   DIR(OUTPUT);
   SETBITS(SDA      );
   delay(5);
   SETBITS(SDA | SCL);

   if (i2c_wait_for_scl(v, ops) != 0)
       return EIO;
   delay(4);

   DIR(INPUT);
>>>>>    error = (READ & SDA) ? EIO : 0;

   DIR(OUTPUT);
   SETBITS(SDA      );
   delay(5);

   if (flags & I2C_F_STOP)
       (void) i2c_bitbang_send_stop(v, flags, ops);

   return (error);
}

Since this occurs at the end of the write, I changed the return(error) to a return (0). At this point, I stopped getting the error message during bootup that says
   xrtc0: xrtc_clock_read: failed to read rtc at 0x0

I then traced out the bytes that were read and written to the clock during bootup. In what follow, ibbix-2 means that the function i2c_bitbang_initiate_xfer was called and exited by calling i2c_bitbang_write_byte (ibbwb). ibbwb-3 means that the write function would have returned an error (see above), but I forced it to return 0 instead. Entering ibbrb means that the function i2c_bitbang_read_byte was called, and the value that was read is printed just before the function returns.

ibbix-2
entering ibbwb with 222: ibbwb-3
entering ibbwb with 0: ibbwb-3
entering ibbwb with 48: ibbwb-3
ibbix-2
entering ibbwb with 223: ibbwb-3
entering ibbrb: read 255
ibbix-2
ntering ibbwb with 222: ibbwb-3
entering ibbwb with 0: ibbwb-3
entering ibbwb with 49: ibbwb-3
ibbix-2
entering ibbwb with 223: ibbwb-3
entering ibbrb: read 255
ibbix-2
entering ibbwb with 222: ibbwb-3
entering ibbwb with 0: ibbwb-3
entering ibbwb with 50: ibbwb-3
ibbix-2
entering ibbwb with 223: ibbwb-3
entering ibbrb: read 255
ibbix-2
entering ibbwb with 222: ibbwb-3
entering ibbwb with 0: ibbwb-3
entering ibbwb with 51: ibbwb-3
ibbix-2
entering ibbwb with 223: ibbwb-3
entering ibbrb: read 255
ibbix-2
entering ibbwb with 222: ibbwb-3
entering ibbwb with 0: ibbwb-3
entering ibbwb with 52: ibbwb-3
ibbix-2
entering ibbwb with 223: ibbwb-3
entering ibbrb: read 255
ibbix-2
entering ibbwb with 222: ibbwb-3
entering ibbwb with 0: ibbwb-3
entering ibbwb with 53: ibbwb-3
ibbix-2
entering ibbwb with 223: ibbwb-3
entering ibbrb: read 255
ibbix-2
entering ibbwb with 222: ibbwb-3
entering ibbwb with 0: ibbwb-3
entering ibbwb with 54: ibbwb-3
ibbix-2
entering ibbwb with 223: ibbwb-3
entering ibbrb: read 255
ibbix-2
entering ibbwb with 222: ibbwb-3
entering ibbwb with 0: ibbwb-3
entering ibbwb with 55: ibbwb-3
ibbix-2
entering ibbwb with 223: ibbwb-3
entering ibbrb: read 255
ibbix-2
entering ibbwb with 222: ibbwb-3
entering ibbwb with 0: ibbwb-3
entering ibbwb with 48: ibbwb-3
ibbix-2
entering ibbwb with 223: ibbwb-3
entering ibbrb: read 255
ibbix-2
entering ibbwb with 222: ibbwb-3
entering ibbwb with 0: ibbwb-3
entering ibbwb with 49: ibbwb-3
ibbix-2
entering ibbwb with 223: ibbwb-3
entering ibbrb: read 255
ibbix-2
entering ibbwb with 222: ibbwb-3
entering ibbwb with 0: ibbwb-3
entering ibbwb with 50: ibbwb-3
ibbix-2
entering ibbwb with 223: ibbwb-3
entering ibbrb: read 255
ibbix-2
entering ibbwb with 222: ibbwb-3
entering ibbwb with 0: ibbwb-3
entering ibbwb with 51: ibbwb-3
ibbix-2
entering ibbwb with 223: ibbwb-3
entering ibbrb: read 255
ibbix-2
entering ibbwb with 222: ibbwb-3
entering ibbwb with 0: ibbwb-3
entering ibbwb with 52: ibbwb-3
ibbix-2
entering ibbwb with 223: ibbwb-3
entering ibbrb: read 255
ibbix-2
entering ibbwb with 222: ibbwb-3
entering ibbwb with 0: ibbwb-3
entering ibbwb with 53: ibbwb-3
ibbix-2
entering ibbwb with 223: ibbwb-3
entering ibbrb: read 255
ibbix-2
entering ibbwb with 222: ibbwb-3
entering ibbwb with 0: ibbwb-3
entering ibbwb with 54: ibbwb-3
ibbix-2
entering ibbwb with 223: ibbwb-3
entering ibbrb: read 255
ibbix-2
entering ibbwb with 222: ibbwb-3
entering ibbwb with 0: ibbwb-3
entering ibbwb with 55: ibbwb-3
ibbix-2
entering ibbwb with 223: ibbwb-3
entering ibbrb: read 255
WARNING: preposterous TOD clock time
WARNING: using filesystem time
WARNING: CHECK AND RESET THE DATE!

So, it looks like the sequence is
write 222 0 48
write 223 read 255
write 222 0 49
write 223 read 255
write 222 0 50
write 223 read 255
write 222 0 51
write 223 read 255
write 222 0 52
write 223 read 255
write 222 0 53
write 223 read 255
write 222 0 54
write 223 read 255
write 222 0 55
write 223 read 255
and repeat.
222 is 0xDE and 223 and 0xDF, while the address of the clock is 0x6F. I'm not an expert on either I2C or the real time clock, so hopefully this will make more sense to somebody else than it does to me.

Regards, Don




Home | Main Index | Thread Index | Old Index