Manipulate I2C bus speed

Post Reply
ttsolov
Posts: 8
Joined: Wed Jul 11, 2018 4:00 am
languages_spoken: english, russian
ODROIDs: XU4
Location: California, USA
Contact:

Manipulate I2C bus speed

Unread post by ttsolov » Wed Jul 11, 2018 4:04 am

Hi,
is it possible to set different I2C bus speed under Android?

Thanks in advance.

User avatar
odroid
Site Admin
Posts: 29651
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: Manipulate I2C bus speed

Unread post by odroid » Wed Jul 11, 2018 9:46 am

You need to modify the DeviceTree file in the Kernel source to adjust the I2C clock speed.

snorky35
Posts: 26
Joined: Thu Nov 26, 2015 5:32 am
languages_spoken: english
ODROIDs: C1+ C2 XU4
Contact:

Re: Manipulate I2C bus speed

Unread post by snorky35 » Fri Jul 13, 2018 6:01 pm

Hi guys,

I'm also in the same case : i would like to modify I2C speed from 400kHz (measured) to 100kHz as my PN512 is not detected using :

Code: Select all

i2cdetect -y 5
in adb shell.
I changed in "kernel/hardkernel/odroidxu3/arch/arm/boot/dts/exynos5422-odroidxu3.dts" the frequency with :

Code: Select all

i2c_1: i2c@12C70000 {
    samsung,i2c-max-bus-freq = <100000>;
    status = "okay";
};
But when i build (from scratch, clean build) and deploy, using an oscilloscope, i still have 400kHz (approx. 363kHz measured).
Is there something i'm doing wrong ?

(Moreover, i was not able to find where i2c_1 is mapped to /dev/i2c-5)

User avatar
odroid
Site Admin
Posts: 29651
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: Manipulate I2C bus speed

Unread post by odroid » Fri Jul 13, 2018 6:07 pm

Do you use Pin16/14 on 30pin header?
The device node number is different in Android Kernel 3.0 from generic Ubuntu Kernel 4.x.
Please look into this wiki page carefully.
https://wiki.odroid.com/old_product/acc ... nboard/i2c

snorky35
Posts: 26
Joined: Thu Nov 26, 2015 5:32 am
languages_spoken: english
ODROIDs: C1+ C2 XU4
Contact:

Re: Manipulate I2C bus speed

Unread post by snorky35 » Fri Jul 13, 2018 9:25 pm

Yes, i'm using pins 16 & 14 for respectively SDA and SCL, and i'm using Lineage OS 14.1 from voodik

Code: Select all

odroidxu3:/ # ll /sys/class/i2c-dev/                                                                                                                                                                          
total 0
drwxr-xr-x  2 root root 0 2018-07-13 12:19 .
drwxr-xr-x 50 root root 0 2018-07-13 12:19 ..
lrwxrwxrwx  1 root root 0 2018-07-13 12:23 i2c-0 -> ../../devices/12ca0000.hsi2c/i2c-0/i2c-dev/i2c-0
lrwxrwxrwx  1 root root 0 2018-07-13 12:23 i2c-1 -> ../../devices/12cb0000.hsi2c/i2c-1/i2c-dev/i2c-1
lrwxrwxrwx  1 root root 0 2018-07-13 12:23 i2c-2 -> ../../devices/12e00000.hsi2c/i2c-2/i2c-dev/i2c-2
lrwxrwxrwx  1 root root 0 2018-07-13 12:23 i2c-3 -> ../../devices/i2c_gpio.8/i2c-3/i2c-dev/i2c-3
lrwxrwxrwx  1 root root 0 2018-07-13 12:23 i2c-4 -> ../../devices/12c60000.i2c/i2c-4/i2c-dev/i2c-4
lrwxrwxrwx  1 root root 0 2018-07-13 12:23 i2c-5 -> ../../devices/12c70000.i2c/i2c-5/i2c-dev/i2c-5
From what i can see, the section that i did modify (i2c_1 : I2C@12c70000) is mapped to /dev /i2c-5, so i don't understand why the SCL clock speed is still about 400kHz as you can see on the picture below
20180713_154908.jpg
20180713_154908.jpg (141.45 KiB) Viewed 700 times

User avatar
odroid
Site Admin
Posts: 29651
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: Manipulate I2C bus speed

Unread post by odroid » Sat Jul 14, 2018 10:24 am

I think you should modify i2c-4 entry instead of i2c-5. lrwxrwxrwx 1 root root 0 2018-07-13 12:23 i2c-4 -> ../../devices/12c60000.i2c/i2c-4/i2c-dev/i2c-4

snorky35
Posts: 26
Joined: Thu Nov 26, 2015 5:32 am
languages_spoken: english
ODROIDs: C1+ C2 XU4
Contact:

Re: Manipulate I2C bus speed

Unread post by snorky35 » Wed Jul 18, 2018 12:59 am

I've tried everything that is possible, even buy making tests using a Linux image, but with no more luck.
I will buy a level shifter and make a try, maybe the PN512 does not support I2C @ 1.8V (was not very clear in the datasheet)
I will let you know ... thank you for your help

User avatar
odroid
Site Admin
Posts: 29651
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: Manipulate I2C bus speed

Unread post by odroid » Wed Jul 18, 2018 9:06 am

We will try I2C 100Khz setting in Android 4.4 and let you know.

User avatar
tobetter
Posts: 2623
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Contact:

Re: Manipulate I2C bus speed

Unread post by tobetter » Fri Jul 20, 2018 8:38 pm

snorky35 wrote:I've tried everything that is possible, even buy making tests using a Linux image, but with no more luck.
I will buy a level shifter and make a try, maybe the PN512 does not support I2C @ 1.8V (was not very clear in the datasheet)
I will let you know ... thank you for your help
I've tried to change the max frequency in DTS like yours and this gives me to run i2c at 61.27kHz.

Code: Select all

diff --git a/arch/arm/boot/dts/exynos5422-odroidxu3.dts b/arch/arm/boot/dts/exynos5422-odroidxu3.dts
index 51f2ff6fa007..f394c740dbfb 100755
--- a/arch/arm/boot/dts/exynos5422-odroidxu3.dts
+++ b/arch/arm/boot/dts/exynos5422-odroidxu3.dts
@@ -433,7 +433,7 @@
        };
 
        i2c_1: i2c@12C70000 {
-               samsung,i2c-max-bus-freq = <400000>;
+               samsung,i2c-max-bus-freq = <100000>;
                status = "okay";
        };
Could you try this command if the value is affected? If your change is applied properly, this command will show you up 0x1b6a0 which is 100000 in decimal.

Code: Select all

# od -x /proc/device-tree/i2c@12C70000/samsung,i2c-max-bus-freq
0000000     0100    a086                                                
0000004

ttsolov
Posts: 8
Joined: Wed Jul 11, 2018 4:00 am
languages_spoken: english, russian
ODROIDs: XU4
Location: California, USA
Contact:

Re: Manipulate I2C bus speed

Unread post by ttsolov » Thu Aug 30, 2018 10:51 am

Finally got some time to build the whole system (CM-14.1 ... I guess this question is for @voodik)
After updating the kernel (only change is I2C speed) system seems to work except network (eth and wlan).
After updating system image I'm stuck in boot loop ...
Hopefully the attached u-boot logs helps :?:

Cheers
Attachments
log-after-system-update.rtf
(112.5 KiB) Downloaded 6 times
log-after-kernel-update.rtf
(98.49 KiB) Downloaded 6 times

User avatar
tobetter
Posts: 2623
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Contact:

Re: Manipulate I2C bus speed

Unread post by tobetter » Thu Aug 30, 2018 11:03 am

ttsolov wrote:Finally got some time to build the whole system (CM-14.1 ... I guess this question is for @voodik)
After updating the kernel (only change is I2C speed) system seems to work except network (eth and wlan).
After updating system image I'm stuck in boot loop ...
Hopefully the attached u-boot logs helps :?:

Cheers
From the log, log-after-kernel-update.rtf, I've found this.
[ 0.000000] [c0] Linux version 3.10.9-gca7dc64-dirty (tsanko@tsanko-VirtualBox) (gcc version 4.8 (GCC) ) #2 SMP PREEMPT Sun Aug 26 18:44:50 PDT 2018
and
odroidxu3:/ $ [ 17.247639] [c4] ax88179_178a: version magic '3.10.9-g2ad6f3b6da8a-dirty SMP preempt mod_unload ARMv7 p2v8 ' should be '3.10.9-gca7dc64-dirty SMP preempt mod_unload ARMv7 p2v8 '
[ 17.262262] [c4] rt2x00usb: version magic '3.10.9-g2ad6f3b6da8a-dirty SMP preempt mod_unload ARMv7 p2v8 ' should be '3.10.9-gca7dc64-dirty SMP preempt mod_unload ARMv7 p2v8 '
[ 17.277782] [c6] saa7115: version magic '3.10.9-g2ad6f3b6da8a-dirty SMP preempt mod_unload ARMv7 p2v8 ' should be '3.10.9-gca7dc64-dirty SMP preempt mod_unload ARMv7 p2v8 '
[ 17.293733] [c6] snd_usb_audio: version magic '3.10.9-g2ad6f3b6da8a-dirty SMP preempt mod_unload ARMv7 p2v8 ' should be '3.10.9-gca7dc64-dirty SMP preempt mod_unload ARMv7 p2v8 '
So what's the problem now for your ethernet and wlan is that their driver version magic 3.10.9-g2ad6f3b6da8a-dirty is not matching with the kernel's one 3.10.9-gca7dc64-dirty, so they cannot be loaded on boot. What you have to do is to copy their driver binaries to your ODROID-XU4 as well.

In addition, the other log log-after-system-update.rtf is worse, it cannot found a root file system.
[ 13.604517] [c6] Failed to execute /init. Attempting defaults...
[ 13.612552] [c7] Kernel panic - not syncing: No init found. Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.

ttsolov
Posts: 8
Joined: Wed Jul 11, 2018 4:00 am
languages_spoken: english, russian
ODROIDs: XU4
Location: California, USA
Contact:

Re: Manipulate I2C bus speed

Unread post by ttsolov » Thu Aug 30, 2018 12:23 pm

Thank you very much tobetter ... I'll copy the drivers tomorrow and see if I can run without updating the system image.
Build process finished ok ... I have no idea why these problems arise

User avatar
tobetter
Posts: 2623
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Contact:

Re: Manipulate I2C bus speed

Unread post by tobetter » Thu Aug 30, 2018 12:35 pm

ttsolov wrote:Thank you very much tobetter ... I'll copy the drivers tomorrow and see if I can run without updating the system image.
Build process finished ok ... I have no idea why these problems arise
That's normal if you didn't update system image after reflashing the kernel image since the version magic of kernel image is keeping change whenever you build it. Just let us know if it works.

ttsolov
Posts: 8
Joined: Wed Jul 11, 2018 4:00 am
languages_spoken: english, russian
ODROIDs: XU4
Location: California, USA
Contact:

Re: Manipulate I2C bus speed

Unread post by ttsolov » Sat Sep 01, 2018 6:37 am

@tobetter ... The newly generated modules are pushed to system image and I can't just replace the old ones. I noticed one strange thing - system image (build Alpha1.9) is >800MB ... but my build (based on Alpha1.9) is 540MB. Pretty sure this is the problem.

User avatar
rooted
Posts: 6256
Joined: Fri Dec 19, 2014 9:12 am
languages_spoken: english
Location: Gulf of Mexico, US
Contact:

Re: Manipulate I2C bus speed

Unread post by rooted » Sat Sep 01, 2018 9:33 am

ttsolov wrote:@tobetter ... The newly generated modules are pushed to system image and I can't just replace the old ones. I noticed one strange thing - system image (build Alpha1.9) is >800MB ... but my build (based on Alpha1.9) is 540MB. Pretty sure this is the problem.
You will need to mount /system rw.

Code: Select all

mount -o remount,rw /system

Post Reply

Return to “Android”

Who is online

Users browsing this forum: No registered users and 1 guest