[ Prev ] [ Index ] [ Next ]

3. i2cdump

The i2cdump command provides the user a way to examine the registers within an I2C device.

Background: I2C device index register
Since the majority of I2C devices have more than a single 8-bit register to interract with, they will utilize an index register,
that is written first, prior to reading or writing any of the registers on the device.
Thus, when you want to access register 5 within the DS3231 RTC, the value 5 is written first, then a read is performed to read the
contents of register 5.
The same is especially true for writing to a register. The first byte of data following the device's I2C addres is used
to position the index register. The following data byte is then written into the desired register on the chip.
For many devices, its index register will auto-increment, allowing multiple registers, to be written to, or read from,
one after the other. This is very helpful with memory devices where blocks of data are typically trasferred back and forth.
With these devices, large quantities of data may be read with a single Linux I2C read transfer.
This is typically NOT the case for writes, since the device often has to perform an erase sequence first.
In this case, data enters a buffer on-board the device which gets written after the erase completes.
Writes are thus limited to the size of the internal buffer, and often must be aligned on address "page" boundaries.

The program, i2cdump, assumes the I2C device has a single byte index register.
Thus, devices with no index register as well as those with two byte index registers don't work well with this tool.

Display the register contents of the DS3231

$ i2cdump -y 1 0x68 b
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: 51 51 21 01 14 01 17 00 00 00 00 00 00 00 1c 88    QQ!????.......??
10: 00 16 80 XX XX XX XX XX XX XX XX XX XX XX XX XX    .??XXXXXXXXXXXXX
20: XX XX XX XX XX XX XX XX XX XX XX XX 80 80 80 80    XXXXXXXXXXXX????
30: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
40: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
50: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
60: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
70: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
80: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
90: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
a0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
b0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
c0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
d0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
e0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
f0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX

Display register contents of the DS3231, only showing indexed registers 0-f

$ i2cdump -y -r 0-0xF 1 0x68 b
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: 51 51 21 01 14 01 17 00 00 00 00 00 00 00 1c 88    QQ!????.......??


Home Page