i2c speed

Post Reply
fvolk
Posts: 609
Joined: Sun Jun 05, 2016 11:04 pm
languages_spoken: english
ODROIDs: C2, C4, H2
Has thanked: 0
Been thanked: 74 times
Contact:

i2c speed

Post by fvolk »

I fumble around with hardware again...

1)

normal image:

Code: Select all

$ uname -a
Linux odroid 4.9.241-70 #1 SMP PREEMPT Sat Apr 24 15:17:51 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux
$ ls /sys/bus/i2c/devices/i2c-0/device/sp*
/sys/bus/i2c/devices/i2c-0/device/speed
tobetter's kernel:

Code: Select all

$ uname -a
Linux c4 5.10.27+ #1 SMP PREEMPT Wed Apr 7 11:56:08 CEST 2021 aarch64 GNU/Linux
$ ls /sys/bus/i2c/devices/i2c-0/device/sp*
ls: cannot access '/sys/bus/i2c/devices/i2c-0/device/sp*': No such file or directory
...what am I missing?
(but both i2c buses work fine)


2) max speed

What the defines max speed? C4? attached device? what is "normal"?
OLED seems to work fine up until echo 3000000 > /sys/bus/i2c/devices/i2c-1/device/speed


Thank you! :-)

brad
Posts: 1420
Joined: Tue Mar 29, 2016 1:22 pm
languages_spoken: english
ODROIDs: C2 N1 N2 N2+ H2 H2+ (64 bit ftw)
Location: Australia
Has thanked: 128 times
Been thanked: 208 times
Contact:

Re: i2c speed

Post by brad »

Clock speed is defined in the devicetree for mainline. eg for i2c interface pins 3 & 5 on C4 it is 400k and pins 27/28 it is 100k

https://github.com/tobetter/linux/blob/ ... 4.dts#L475

They are in standard fast speed and low speed modes respectively but you could probably change to non standard speeds (ie some of the higher speeds modes if you wish although i'm not sure of max)

fvolk
Posts: 609
Joined: Sun Jun 05, 2016 11:04 pm
languages_spoken: english
ODROIDs: C2, C4, H2
Has thanked: 0
Been thanked: 74 times
Contact:

Re: i2c speed

Post by fvolk »

upgraded to 5.10.32, no speed setting at runtime :-(
but yeah, repeatedly editing dtb and reboot... is not optimal for figuring out speed limit of component
hmm...
meanwhile I read up on i2c, max. speed depends also on length and quality of cable, up to 1m is possible - will try

User avatar
tobetter
Posts: 7803
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: Many
Location: Paju, South Korea
Has thanked: 431 times
Been thanked: 1208 times
Contact:

Re: i2c speed

Post by tobetter »

fvolk wrote:
Thu Apr 29, 2021 5:17 am
upgraded to 5.10.32, no speed setting at runtime :-(
but yeah, repeatedly editing dtb and reboot... is not optimal for figuring out speed limit of component
hmm...
meanwhile I read up on i2c, max. speed depends also on length and quality of cable, up to 1m is possible - will try
Can you share which functions or library you are using to access I2C? What do you have with "uname -a" ?

fvolk
Posts: 609
Joined: Sun Jun 05, 2016 11:04 pm
languages_spoken: english
ODROIDs: C2, C4, H2
Has thanked: 0
Been thanked: 74 times
Contact:

Re: i2c speed

Post by fvolk »

tobetter wrote:
Thu Apr 29, 2021 9:49 am
Can you share which functions or library you are using to access I2C? What do you have with "uname -a" ?
I'm using a kernel build from your tree:
Linux c4 5.10.32+ #3 SMP PREEMPT Sun Apr 25 19:25:11 CEST 2021 aarch64 GNU/Linux

I'm using https://github.com/BLavery/lib_oled96 to drive a 0.96 OLED,
because it works and only requires minimal dependencies - python3-pil and python3-smbus.
I'm considering a non-Python solution for the future...

Everything works, the point is just with higher I2C frequency OLED refresh is also higher.
I'm a hardware newbie, so I just want to find the highest frequency that's stable and reasonable :-)

Currently I test first on Odroid standard image with
Linux odroid 4.9.241-70 #1 SMP PREEMPT Sat Apr 24 15:17:51 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux
because there I2C speed can de adjusted after boot with echo commands according to Odroid C4 Wiki,
and then replug everything and move to the other C4 installation with current 5.10 kernel.

But probably I'm just stupid and missed a kernel option when building myself the 5.10 kernel,
to get the /sys/bus/i2c/devices/i2c-0/device/speed for adjustment?

User avatar
tobetter
Posts: 7803
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: Many
Location: Paju, South Korea
Has thanked: 431 times
Been thanked: 1208 times
Contact:

Re: i2c speed

Post by tobetter »

fvolk wrote:
Thu Apr 29, 2021 4:10 pm
tobetter wrote:
Thu Apr 29, 2021 9:49 am
Can you share which functions or library you are using to access I2C? What do you have with "uname -a" ?
I'm using a kernel build from your tree:
Linux c4 5.10.32+ #3 SMP PREEMPT Sun Apr 25 19:25:11 CEST 2021 aarch64 GNU/Linux

I'm using https://github.com/BLavery/lib_oled96 to drive a 0.96 OLED,
because it works and only requires minimal dependencies - python3-pil and python3-smbus.
I'm considering a non-Python solution for the future...

Everything works, the point is just with higher I2C frequency OLED refresh is also higher.
I'm a hardware newbie, so I just want to find the highest frequency that's stable and reasonable :-)

Currently I test first on Odroid standard image with
Linux odroid 4.9.241-70 #1 SMP PREEMPT Sat Apr 24 15:17:51 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux
because there I2C speed can de adjusted after boot with echo commands according to Odroid C4 Wiki,
and then replug everything and move to the other C4 installation with current 5.10 kernel.

But probably I'm just stupid and missed a kernel option when building myself the 5.10 kernel,
to get the /sys/bus/i2c/devices/i2c-0/device/speed for adjustment?
Thank you for sharing...let me see if the speed can be adjustable through sys node.
By the way, are you planning to use the display for sysinfo or terminal?
For the non-Python solution, would it be good to use like legacy terminal or running an app with SDL?

fvolk
Posts: 609
Joined: Sun Jun 05, 2016 11:04 pm
languages_spoken: english
ODROIDs: C2, C4, H2
Has thanked: 0
Been thanked: 74 times
Contact:

Re: i2c speed

Post by fvolk »

I just want to drive a status display that shows notifications when something happened, otherwise it stays dark. No need for a real terminal.
Python has the disadvantage of numerous dependencies for such a simple task https://xkcd.com/1987/

Currently testing with 2x 0.96" OLED.
I will order also 1.3" OLEDs and try with an I2C multiplexer - should be able to drive then more than two I2C things on one bus - but with less speed?
oled2.jpg
oled2.jpg (113.45 KiB) Viewed 145 times

brad
Posts: 1420
Joined: Tue Mar 29, 2016 1:22 pm
languages_spoken: english
ODROIDs: C2 N1 N2 N2+ H2 H2+ (64 bit ftw)
Location: Australia
Has thanked: 128 times
Been thanked: 208 times
Contact:

Re: i2c speed

Post by brad »

Interesting project the displays look very smart :)

I suspect it would be possible to add the device (via an overlay) into the devicetree and manage it like a normal framebuffer device without the python dependencies. Then it might be possible to use it as a normal display or using some framebuffer commands such as fbi to display images or text or turn it on and off.

Here is an example for rpi for an overlay which could maybe be adapted to enable it as frambuffer device - https://github.com/raspberrypi/firmware/issues/1098

I wonder if the oled board has pin to select i2c address then you could likely add multiple boards to the same bus. I guess the max speed needs to be determined for best performance by testing. Hopefully tobetter can find an easy method to change this for testing. There may also be other options to connect more boards via normal GPIO pins and bit banging more i2c interfaces (although this way would likely be limited in the speed).

fvolk
Posts: 609
Joined: Sun Jun 05, 2016 11:04 pm
languages_spoken: english
ODROIDs: C2, C4, H2
Has thanked: 0
Been thanked: 74 times
Contact:

Re: i2c speed

Post by fvolk »

Thanks for the suggestion, but I would prefer a non-devicetree solution as currently the code is portable between C4 and H2, and I would like to keep it that way :-)
I aim for a portable, single standalone binary solution that just talks to /dev/i2c* - once it runs, it runs...

Post Reply

Return to “Hardware and peripherals”

Who is online

Users browsing this forum: No registered users and 2 guests