Manual Page Search Parameters

I2C(8) System Manager's Manual I2C(8)

i2ctest I2C bus and slave devices

i2c -a address [-f device] [-d r|w] [-w 0|8|16|16LE|16BE] [-o offset] [-c count] [-m tr|ss|rs|no] [-b] [-v]

i2c -h

i2c -i [-v] [cmd ...] [-]

i2c -r [-f device] [-v]

i2c -s [-f device] [-n skip_addr] [-v]

The i2c utility can be used to perform raw data transfers (read or write) to devices on an I2C bus. It can also scan the bus for available devices and reset the I2C controller.

The options are as follows:

address
7-bit address on the I2C device to operate on (hex).
binary mode - when performing a read operation, the data read from the device is output in binary format on stdout.
count
number of bytes to transfer (decimal).
r|w
transfer direction: r - read, w - write. Data to be written is read from stdin as binary bytes.
device
I2C bus to use (default is /dev/iic0).
Interpreted mode
Help
tr|ss|rs|no
addressing mode, i.e., I2C bus operations performed after the offset for the transfer has been written to the device and before the actual read/write operation.
tr
complete-transfer
ss
stop then start
rs
repeated start
no
none
Some I2C bus hardware does not provide control over the individual start, repeat-start, and stop operations. Such hardware can only perform a complete transfer of the offset and the data as a single operation. The tr mode creates control structures describing the transfer and submits them to the driver as a single complete transaction. This mode works on all types of I2C hardware.
skip_addr
address(es) to be skipped during bus scan. One or more addresses ([0x]xx) or ranges of addresses ([0x]xx-[0x]xx or [0x]xx..[0x]xx) separated by commas or colons.
offset
offset within the device for data transfer (hex). The default is zero. Use “-w 0” to disable writing of the offset to the slave.
reset the controller.
scan the bus for devices.
be verbose.
0|8|16|16LE|16BE
device offset width (in bits). This is used to determine how to pass offset specified with -o to the slave. Zero means that the offset is ignored and not passed to the slave at all. The endianness defaults to little-endian.

When started with -i any remaining arguments are interpreted as commands, and if the last argument is '-', or there are no arguments, commands will (also) be read from stdin.

Available commands:

'r' bus address [0|8|16|16LE|16BE] offset count
Read command, count bytes are read and hexdumped to stdout.
'w' bus address [0|8|16|16LE|16BE] offset hexstring
Write command, hexstring (white-space is allowed) is written to device.
'p' anything
Print command, the entire line is printed to stdout. (This can be used for synchronization.)

All numeric fields accept canonical decimal/octal/hex notation.

Without the -v option, all errors are fatal with non-zero exit status.

With the -v option, no errors are fatal, and all commands will return either "OK\n" or "ERROR\n" on stdout. In case of error, detailed diagnostics will precede that on stderr.

Blank lines and lines starting with '#' are ignored.

Many systems store critical low-level information in I2C memories, and may contain other I2C devices, such as temperature or voltage sensors. Reading these can disturb the firmware's operation and writing to them can "brick" the hardware.

iic(4), iicbus(4), smbus(4)

The i2c utility appeared in FreeBSD 8.0.

The i2c utility and this manual page were written by Bartlomiej Sieka <tur@semihalf.com> and Michal Hajduk <mih@semihalf.com>.

Poul-Henning Kamp <phk@FreeBSD.org> added interpreted mode.

May 22, 2019 dev