大内高手社区

标题: Linux 内核 i2c-tools 命令 [打印本页]

作者: 诸葛钢铁    时间: 2022-7-11 14:58
标题: Linux 内核 i2c-tools 命令
本文基于RockPi 4A Debian系统介绍i2c设备的调试工具i2c-tools。i2c-tools的相关命令常用于linux系统读写i2c设备寄存器的在线调试。

安装命令:
apt-get updateapt-get install i2c-tools

linux版本代码下载路径:
https://mirrors.edge.kernel.org/pub/software/utils/i2c-tools/

一、i2cdetect

1、命令

  root@linaro-alip:/# i2cdetect
  Error: No i2c-bus specified!
  Usage: i2cdetect [-y] [-a] [-q|-r] I2CBUS [FIRST LAST]
  i2cdetect -F I2CBUS
  i2cdetect -l
  I2CBUS is an integer or an I2C bus name
  If provided, FIRST and LAST limit the probing range.

2、用法

  ## 列出i2c总线
  root@linaro-alip:/# i2cdetect -l
  i2c-0 i2c rk3x-i2c
  I2C adapter
  i2c-1 i2c rk3x-i2c
  I2C adapter
  i2c-9 i2c DesignWare
  HDMI I2C
  adapter
  ## 列出某个i2c总线上的i2c设备
  root@linaro-alip:/# i2cdetect -y 0
  0 1 2 3 4 5 6 7 8 9 a b c d e f
  00: -- -- -- -- -- -- -- -- -- -- -- -- --
  10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
  20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  40: UU UU -- -- -- -- -- -- -- -- -- -- -- -- -- --
  50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  70: -- -- -- -- -- -- -- --

二、i2cdump

1、命令

  root@linaro-alip:~# i2cdump
  Error: No i2c-bus specified!
  Usage: i2cdump [-f] [-y] [-r first-last]
  I2CBUS ADDRESS [MODE [BANK [BANKREG]]] I2CBUS is an integer or an I2C bus name
  ADDRESS is an integer (0x03 - 0x77)
  MODE is one of:
  b (byte, default)
  w (word)
  W (word on even register addresses)
  s (SMBus block)
  i (I2C block)
  c (consecutive byte)
  Append p for SMBus PEC

2、用法

  ## 显示I2C 0号总线上0x1b设备的寄存器值。
  MODE为byte,可省略。
  root@linaro-alip:~# i2cdump -f -y 0 0x1b b
  0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
  00: 12 50 08 21 01 13 01 00 00 00 00 01 01 00 00 00 ?P?!???....??...
  10: 80 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ??..............
  20: 01 17 00 6f ff 00 00 00 10 00 ff 0f ff 02 19 0f ??.o....?..?.???
  30: 00 00 19 07 00 00 02 03 00 00 09 00 00 00 00 0a ..??..??..?....?
  40: 00 0c 00 0c 00 07 00 01 00 0c 00 00 00 5f 00 03 .?.?.?.?.?..._.?
  50: 06 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ??..............
  60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
  70: 00 cf 03 00 28 00 0c 1c 80 19 00 34 12 00 71 00 .??.(.????.4?.q.
  80: 10 50 1f ac 00 40 10 01 40 00 08 00 09 09 00 00 ?P??.@??@.?.??..
  90: 55 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 U...............
  a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
  b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
  c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
  d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
  e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
  f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................

【免责声明】本文系转载,文章来源于公众号Linux爱好者,作者Linux爱好者。转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。如涉及作品内容、版权和其它问题,请在30日内与联系我们,我们会予以更改或删除相关文章,以保证您的权益!






欢迎光临 大内高手社区 (https://bbs.tedu.cn/) Powered by Discuz! X3.4