How to snoop I2C bus communications: Difference between revisions
(Created page with "== I2C bus snooping == Viewing the I2C communications being done can be useful in finding errors. The data transferred by the system over the I2C bus can be snooped using the kernel's <code>FTRACE</code>. The following settings should be enabled in the kernel in order to access the I2C logs (these are enabled by default in Jetpacks): <pre> CONFIG_FTRACE CONFIG_ENABLE_DEFAULT_TRACERS </pre> To enable the i2c tracing, use the following command: <pre> echo 1 >/sys/kernel...") |
|||
Line 43: | Line 43: | ||
== References == | == References == | ||
* [https://linuxtv.org/wiki/index.php/Bus_snooping/sniffing LinuxTvWiki - Bus snooping/sniffing] | * [https://linuxtv.org/wiki/index.php/Bus_snooping/sniffing LinuxTvWiki - Bus snooping/sniffing] | ||
[[Category:Whitepaper]] |
Latest revision as of 20:38, 24 April 2024
I2C bus snooping
Viewing the I2C communications being done can be useful in finding errors. The data transferred by the system over the I2C bus can be snooped using the kernel's FTRACE
.
The following settings should be enabled in the kernel in order to access the I2C logs (these are enabled by default in Jetpacks):
CONFIG_FTRACE CONFIG_ENABLE_DEFAULT_TRACERS
To enable the i2c tracing, use the following command:
echo 1 >/sys/kernel/debug/tracing/events/i2c/enable
Note: by default, this will trace the traffic through all I2C buses on the system. To filter for a desired I2C bus use:
echo adapter_nr==<N> >/sys/kernel/debug/tracing/events/i2c/filter
Where <N> is the desired I2C bus number.
The trace output can be viewed by using:
cat /sys/kernel/debug/tracing/trace
This will look something like:
... i2c_write: i2c-5 #0 a=044 f=0000 l=2 [02-14] ... i2c_read: i2c-5 #1 a=044 f=0001 l=4 ... i2c_reply: i2c-5 #1 a=044 f=0001 l=4 [33-00-00-00] ... i2c_result: i2c-5 n=2 ret=2
Where the components of the logs are:
- i2c-<adapter-nr>
- #<message-array-index>
- a=<addr>
- f=<flags>
- l=<datalen>
- n=<message-array-size>
- ret=<result>
- [<data-transferred>]