Hello,
since kernel 4.9,
dmesg | grep bcm2708_i2c
is not working anymore, to determine i2c speed/Baudrate.
Any idea, to get this info?
-
- Posts: 216
- Joined: Tue May 01, 2012 8:47 am
- Location: Germany (old europe)
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 10318
- Joined: Wed Dec 04, 2013 11:27 am
- Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.
Re: i2c speed
It's using the upstream i2c_bcm2835 driver.
Look at /sys/class/i2c-adapter/i2c-1/of_node/clock-frequency. It's binary, so use xxd or similar to read it.
Look at /sys/class/i2c-adapter/i2c-1/of_node/clock-frequency. It's binary, so use xxd or similar to read it.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.
I'm not interested in doing contracts for bespoke functionality - please don't ask.
-
- Posts: 216
- Joined: Tue May 01, 2012 8:47 am
- Location: Germany (old europe)
Re: i2c speed
Thanks for this hint. Is it possible that you post an example, to get via xxd a readable value.
Re: i2c speed
This is super ugly, but I think it works. I bet somebody will come along and post something better.
Code: Select all
pi@raspberrypi:~ $ var="$(xxd /sys/class/i2c-adapter/i2c-1/of_node/clock-frequency | awk -F': ' '{print $2}')"
pi@raspberrypi:~ $ var=${var//[[:blank:].]/}
pi@raspberrypi:~ $ printf "%d\n" 0x$var
100000
-
- Posts: 216
- Joined: Tue May 01, 2012 8:47 am
- Location: Germany (old europe)
Re: i2c speed
is there also a command to get the spi bus speed for newer kernel?
-
- Posts: 216
- Joined: Tue May 01, 2012 8:47 am
- Location: Germany (old europe)
Re: i2c speed
is that xxd /sys/class/spidev/spidev0.0/device/of_node/spi-max-frequency ?
Re: i2c speed
Thanks, but this was not working for all speedsktb wrote:This is super ugly, but I think it works. I bet somebody will come along and post something better.
Here is a little less ugly solution

Code: Select all
echo 0x$(xxd /sys/class/i2c-adapter/i2c-1/of_node/clock-frequency | cut -f 2,3 -d ' ' --output-delimiter='') | xargs printf "%d\n"