I2C interface needs a long time to initialize

Leo
Leo New Member Posts: 9
Hi,

I am using UP-Board and installed Ubuntu 16.04 LTS. I connect a LM75B temp sensor to i2c-1 SDAL SCAL (pin 2 and 3), and it takes long time until the sensor can be detected on I2C bus.

I am using for example "i2cdetect -y -r 8 0x40 0x4f" command, and after 20-30 minutes, I can see the address of LM75B appear in the output.

Is this normal? What can I do to fix this?

Thanks

Comments

  • Nicola Lunghi
    Nicola Lunghi Emutex Posts: 131 mod
    edited November 2017
    Hi

    try this:
    sudo i2cdetect -y -r 1

    (the i2c channel on pin 2-3 is usually attached to /dev/i2c-1 not 8 )

    Regards
    Nicola Lunghi
  • Leo
    Leo New Member Posts: 9
    Hi nicola,

    thanks for the reply. i2c-8 is the correct device in my case using Ubuntu 16.04. As i believe the device should refer to the PCI device 8086:22c2. Here is some more output:

    root@up-UP-CHT01:/home/up# cat /sys/bus/i2c/devices/i2c-8/device/device
    0x22c2
    root@up-UP-CHT01:/home/up# cat /sys/bus/i2c/devices/i2c-8/device/vendor
    0x8086

    Again, the issue is that I need to wait around 20-30 minutes before i2cdetect shows the correct result.

    Do you have any other idea what could cause this delay?
  • Nicola Lunghi
    Nicola Lunghi Emutex Posts: 131 mod
    edited November 2017
    Hi
    as I was saying on the UP board the ACPI id correspondig to the i2c pins on pin 2,3 on the hat is
    808622C1:01
    
    so again i2c-8 is not the correct device

    execute the following in a terminal
    sudo find /sys/devices/pci0000:00 -name 'i2c-*'
    

    and find the i2c device corresponding to 808622C1:01

    Regards
    Nicola Lunghi
  • Leo
    Leo New Member Posts: 9
    Hi Nicola,

    I am setting the device to "PCI mode" rather than "ACPI mode" in BIOS setting. So here is the output of your command:
    root@up-UP-CHT01:/home/up# find /sys/devices/pci0000:00 -name 'i2c-*'
    /sys/devices/pci0000:00/0000:00:18.6/i2c-11
    /sys/devices/pci0000:00/0000:00:18.6/i2c-11/i2c-dev
    /sys/devices/pci0000:00/0000:00:18.6/i2c-11/i2c-dev/i2c-11
    /sys/devices/pci0000:00/0000:00:18.2/i2c-8
    /sys/devices/pci0000:00/0000:00:18.2/i2c-8/i2c-dev
    /sys/devices/pci0000:00/0000:00:18.2/i2c-8/i2c-dev/i2c-8
    /sys/devices/pci0000:00/0000:00:02.0/i2c-3
    /sys/devices/pci0000:00/0000:00:02.0/i2c-3/i2c-dev
    /sys/devices/pci0000:00/0000:00:02.0/i2c-3/i2c-dev/i2c-3
    /sys/devices/pci0000:00/0000:00:02.0/i2c-1
    /sys/devices/pci0000:00/0000:00:02.0/i2c-1/i2c-dev
    /sys/devices/pci0000:00/0000:00:02.0/i2c-1/i2c-dev/i2c-1
    /sys/devices/pci0000:00/0000:00:02.0/i2c-4
    /sys/devices/pci0000:00/0000:00:02.0/i2c-4/i2c-dev
    /sys/devices/pci0000:00/0000:00:02.0/i2c-4/i2c-dev/i2c-4
    /sys/devices/pci0000:00/0000:00:02.0/i2c-2
    /sys/devices/pci0000:00/0000:00:02.0/i2c-2/i2c-dev
    /sys/devices/pci0000:00/0000:00:02.0/i2c-2/i2c-dev/i2c-2
    /sys/devices/pci0000:00/0000:00:02.0/i2c-0
    /sys/devices/pci0000:00/0000:00:02.0/i2c-0/i2c-dev
    /sys/devices/pci0000:00/0000:00:02.0/i2c-0/i2c-dev/i2c-0
    /sys/devices/pci0000:00/0000:00:02.0/i2c-5
    /sys/devices/pci0000:00/0000:00:02.0/i2c-5/i2c-dev
    /sys/devices/pci0000:00/0000:00:02.0/i2c-5/i2c-dev/i2c-5
    /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-DP-1/i2c-6
    /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-DP-1/i2c-6/i2c-dev
    /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-DP-1/i2c-6/i2c-dev/i2c-6
    /sys/devices/pci0000:00/0000:00:18.7/i2c-12
    /sys/devices/pci0000:00/0000:00:18.7/i2c-12/i2c-dev
    /sys/devices/pci0000:00/0000:00:18.7/i2c-12/i2c-dev/i2c-12
    /sys/devices/pci0000:00/0000:00:18.5/i2c-10
    /sys/devices/pci0000:00/0000:00:18.5/i2c-10/i2c-dev
    /sys/devices/pci0000:00/0000:00:18.5/i2c-10/i2c-dev/i2c-10
    /sys/devices/pci0000:00/0000:00:18.3/i2c-9
    /sys/devices/pci0000:00/0000:00:18.3/i2c-9/i2c-dev
    /sys/devices/pci0000:00/0000:00:18.3/i2c-9/i2c-dev/i2c-9
    /sys/devices/pci0000:00/0000:00:18.1/i2c-7
    /sys/devices/pci0000:00/0000:00:18.1/i2c-7/i2c-dev
    /sys/devices/pci0000:00/0000:00:18.1/i2c-7/i2c-dev/i2c-7

    I think the connection is already correct, because after 20-30 minutes I can have the slave device read from i2c-8:
    root@up-UP-CHT01:/home/up# i2cdetect -y -r 8 0x40 0x4f
    0 1 2 3 4 5 6 7 8 9 a b c d e f
    00:
    10:
    20:
    30:
    40: -- -- -- -- -- -- -- -- 48 -- -- -- 4c -- -- --
    50:
    60:
    70:
    root@up-UP-CHT01:/home/up# i2cdump -y -r 0x00-0x03 8 0x48
    No size specified (using byte-data access)
    0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
    00: 1f 00 4b 50 ?.KP
    root@up-UP-CHT01:/home/up# i2cdump -y -r 0x00-0x0A 8 0x4C
    No size specified (using byte-data access)
    0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
    00: 00 00 00 00 00 00 00 00 01 00 00 ........?..

    Basically I have LM75B (slave address 0x48) and MMA7660 (slave address 0x4C) connected to i2c-1.

    Are you sure that i2c-1 correspond to 22C1 and not 22C2? I thought that i2c-0 connected to 22C1 and i2c-1 to 22C2. According to the z8000 datasheet, 22C1 is I2C Port 1 (first I2C port), and 22C2 is I2C port 2. There is I2C Port 0 in the register list.
  • Nicola Lunghi
    Nicola Lunghi Emutex Posts: 131 mod
    Hi
    I don't have an UP board with me at the moment (and usually I remember that the I2c mode is set to ACPI)
    with ACPI enabled
    808622C1:01 -> i2c pin 2,3
    808622C1:00 -> ID_SD, ID_SC
    
  • Leo
    Leo New Member Posts: 9
    Hi Nicola,

    I tried to reset the BIOS setting to the default ACPI mode, but still not immediate response from the I2C slaves in the bus:
    root@up-UP-CHT01:/home/up# find /sys/devices/pci0000:00 -name 'i2c-*'
    /sys/devices/pci0000:00/808622C1:01/i2c-8
    /sys/devices/pci0000:00/808622C1:01/i2c-8/i2c-dev
    /sys/devices/pci0000:00/808622C1:01/i2c-8/i2c-dev/i2c-8
    /sys/devices/pci0000:00/0000:00:02.0/i2c-3
    /sys/devices/pci0000:00/0000:00:02.0/i2c-3/i2c-dev
    /sys/devices/pci0000:00/0000:00:02.0/i2c-3/i2c-dev/i2c-3
    /sys/devices/pci0000:00/0000:00:02.0/i2c-1
    /sys/devices/pci0000:00/0000:00:02.0/i2c-1/i2c-dev
    /sys/devices/pci0000:00/0000:00:02.0/i2c-1/i2c-dev/i2c-1
    /sys/devices/pci0000:00/0000:00:02.0/i2c-4
    /sys/devices/pci0000:00/0000:00:02.0/i2c-4/i2c-dev
    /sys/devices/pci0000:00/0000:00:02.0/i2c-4/i2c-dev/i2c-4
    /sys/devices/pci0000:00/0000:00:02.0/i2c-2
    /sys/devices/pci0000:00/0000:00:02.0/i2c-2/i2c-dev
    /sys/devices/pci0000:00/0000:00:02.0/i2c-2/i2c-dev/i2c-2
    /sys/devices/pci0000:00/0000:00:02.0/i2c-0
    /sys/devices/pci0000:00/0000:00:02.0/i2c-0/i2c-dev
    /sys/devices/pci0000:00/0000:00:02.0/i2c-0/i2c-dev/i2c-0
    /sys/devices/pci0000:00/0000:00:02.0/i2c-5
    /sys/devices/pci0000:00/0000:00:02.0/i2c-5/i2c-dev
    /sys/devices/pci0000:00/0000:00:02.0/i2c-5/i2c-dev/i2c-5
    /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-DP-1/i2c-6
    /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-DP-1/i2c-6/i2c-dev
    /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-DP-1/i2c-6/i2c-dev/i2c-6
    /sys/devices/pci0000:00/808622C1:04/i2c-10
    /sys/devices/pci0000:00/808622C1:04/i2c-10/i2c-dev
    /sys/devices/pci0000:00/808622C1:04/i2c-10/i2c-dev/i2c-10
    /sys/devices/pci0000:00/808622C1:02/i2c-9
    /sys/devices/pci0000:00/808622C1:02/i2c-9/i2c-ADC081C:00
    /sys/devices/pci0000:00/808622C1:02/i2c-9/i2c-dev
    /sys/devices/pci0000:00/808622C1:02/i2c-9/i2c-dev/i2c-9
    /sys/devices/pci0000:00/808622C1:00/i2c-7
    /sys/devices/pci0000:00/808622C1:00/i2c-7/i2c-dev
    /sys/devices/pci0000:00/808622C1:00/i2c-7/i2c-dev/i2c-7
    /sys/devices/pci0000:00/808622C1:05/i2c-11
    /sys/devices/pci0000:00/808622C1:05/i2c-11/i2c-dev
    /sys/devices/pci0000:00/808622C1:05/i2c-11/i2c-dev/i2c-11
    root@up-UP-CHT01:/home/up# i2cdetect -y -r 8 0x40 0x4f
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    00:
    10:
    20:
    30:
    40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    50:
    60:
    70:
    

    Any idea why it takes so long for the I2C to be enabled?
  • Nicola Lunghi
    Nicola Lunghi Emutex Posts: 131 mod
    1) try the detect with no devices connected; also look for error in dmesg during the scan
    2) submit us the result of the sysinfo script as sayd here https://up-community.org/wiki/Software#Requesting_support_for_Linux_OS

    Regards
    Nicola Lunghi
  • Leo
    Leo New Member Posts: 9
    Hi Nicola,

    here are the debug and dmesg log files. Anyway the sysinfo.sh is not completely finished. See the following:
    root@up-UP-CHT01:/home/up/up_debug# ./sysinfo.sh > debug.log
    No LSB modules are available.
    
    WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
    
    aplay: device_list:268: no soundcards found...
    tail: cannot open '/sys/kernel/debug/regmap/AA*/*' for reading: No such file or directory
    tail: cannot open '/etc/apt/sources.list.d/*' for reading: No such file or directory
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ImportError: No module named mraa
    root@up-UP-CHT01:/home/up/up_debug#
    
  • Nicola Lunghi
    Nicola Lunghi Emutex Posts: 131 mod
    You are using a regular Ubuntu Kernel not a kernel for UP board so the GPIO cannot work.

    Please install a supported Ubuntu kernel for up board following this guide

    https://up-community.org/wiki/Ubuntu#Ubuntu_16.04.1_LTS_.28Xenial_Xerus.29

    or wait for more updated kernel (soon to be released on our ppa

    Regards
    Nicola Lunghi
  • Leo
    Leo New Member Posts: 9
    Hi Nicola,

    thanks for the hints. It works that the I2C slaves can be read directly after boot. However, one last question: this works only in ACPI mode, how to make this works with PCI mode? Tried to change the setting in BIOS, but then the i2c is assigned as i2c-8 again, and the I2C slaves doesn't work after boot:
    root@up-UP-CHT01:/home/up# uname -r
    4.4.0-2-upboard
    root@up-UP-CHT01:/home/up# find /sys/devices/pci0000:00 -name 'i2c-*'
    /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-DP-1/i2c-6
    /sys/devices/pci0000:00/0000:00:02.0/i2c-0
    /sys/devices/pci0000:00/0000:00:02.0/i2c-0/i2c-dev
    /sys/devices/pci0000:00/0000:00:02.0/i2c-0/i2c-dev/i2c-0
    /sys/devices/pci0000:00/0000:00:02.0/i2c-1
    /sys/devices/pci0000:00/0000:00:02.0/i2c-1/i2c-dev
    /sys/devices/pci0000:00/0000:00:02.0/i2c-1/i2c-dev/i2c-1
    /sys/devices/pci0000:00/0000:00:02.0/i2c-2
    /sys/devices/pci0000:00/0000:00:02.0/i2c-2/i2c-dev
    /sys/devices/pci0000:00/0000:00:02.0/i2c-2/i2c-dev/i2c-2
    /sys/devices/pci0000:00/0000:00:02.0/i2c-3
    /sys/devices/pci0000:00/0000:00:02.0/i2c-3/i2c-dev
    /sys/devices/pci0000:00/0000:00:02.0/i2c-3/i2c-dev/i2c-3
    /sys/devices/pci0000:00/0000:00:02.0/i2c-4
    /sys/devices/pci0000:00/0000:00:02.0/i2c-4/i2c-dev
    /sys/devices/pci0000:00/0000:00:02.0/i2c-4/i2c-dev/i2c-4
    /sys/devices/pci0000:00/0000:00:02.0/i2c-5
    /sys/devices/pci0000:00/0000:00:02.0/i2c-5/i2c-dev
    /sys/devices/pci0000:00/0000:00:02.0/i2c-5/i2c-dev/i2c-5
    /sys/devices/pci0000:00/0000:00:02.0/i2c-6
    /sys/devices/pci0000:00/0000:00:02.0/i2c-6/i2c-dev
    /sys/devices/pci0000:00/0000:00:02.0/i2c-6/i2c-dev/i2c-6
    /sys/devices/pci0000:00/0000:00:18.1/i2c-7
    /sys/devices/pci0000:00/0000:00:18.1/i2c-7/i2c-dev
    /sys/devices/pci0000:00/0000:00:18.1/i2c-7/i2c-dev/i2c-7
    /sys/devices/pci0000:00/0000:00:18.2/i2c-8
    /sys/devices/pci0000:00/0000:00:18.2/i2c-8/i2c-dev
    /sys/devices/pci0000:00/0000:00:18.2/i2c-8/i2c-dev/i2c-8
    /sys/devices/pci0000:00/0000:00:18.3/i2c-9
    /sys/devices/pci0000:00/0000:00:18.3/i2c-9/i2c-dev
    /sys/devices/pci0000:00/0000:00:18.3/i2c-9/i2c-dev/i2c-9
    /sys/devices/pci0000:00/0000:00:18.5/i2c-10
    /sys/devices/pci0000:00/0000:00:18.5/i2c-10/i2c-dev
    /sys/devices/pci0000:00/0000:00:18.5/i2c-10/i2c-dev/i2c-10
    /sys/devices/pci0000:00/0000:00:18.6/i2c-11
    /sys/devices/pci0000:00/0000:00:18.6/i2c-11/i2c-dev
    /sys/devices/pci0000:00/0000:00:18.6/i2c-11/i2c-dev/i2c-11
    /sys/devices/pci0000:00/0000:00:18.7/i2c-12
    /sys/devices/pci0000:00/0000:00:18.7/i2c-12/i2c-dev
    /sys/devices/pci0000:00/0000:00:18.7/i2c-12/i2c-dev/i2c-12
    root@up-UP-CHT01:/home/up# cat /sys/bus/i2c/devices/i2c-8/device/vendor
    0x8086
    root@up-UP-CHT01:/home/up# cat /sys/bus/i2c/devices/i2c-8/device/device
    0x22c2
    root@up-UP-CHT01:/home/up# i2cdetect -y -r 8 0x40 0x4f
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    00:
    10:
    20:
    30:
    40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    50:
    60:
    70:
    

    I need to make PCI working because I want to run another OS (dual partition with Ubuntu) but it requires PCI mode devices.
  • Nicola Lunghi
    Nicola Lunghi Emutex Posts: 131 mod
    Hi
    the SOC i2c pins are connected via a CPLD to the external GPIO pin
    The CPLD pin is configured by our custom linux driver.
    Currently our driver support only ACPI names.
    If you want to support also PCI mode you need to modify the kernel driver to do that.
    I suggest you to study the 4.9 kernel sources at https://github.com/emutex/ubilinux-kernel
    Also we are open for commercial support/driver development if your project requires it.
    Ask a quotation at info@emutex.com if you need more information about it

    Best Regards
    Nicola Lunghi
  • Leo
    Leo New Member Posts: 9
    Hi Nicola,

    thanks for the info. Would it be possible to share which are the source code for the CPLD drivers? That would be helpful.

    Thanks.
  • Leo
    Leo New Member Posts: 9
    Hi Nicola,

    could you point to the source code used for controlling the CPLD if it is available in github?

    We would need this to be able to use the board.

    Thanks.
  • Nicola Lunghi
    Nicola Lunghi Emutex Posts: 131 mod
    Hi
    the source code of the CPLD is not yet open source.
    You can contact AAEON to obtain it https://up-community.org/professional-services

    Regards
    Nicola Lunghi
Privacy Policy