Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Orange Pi 3: I2C works while 3rd party application doesn't

Featured Replies

Hi,

 

I am facing an i2c problem on orange pi 3.

 

The i2c0 is enabled in armbian-config.

 

The i2cdetect output is correct, as I know my two slave boards connecting to gpio pin3 (SDA) and pin5(SCL) have the addresses 0x20 and 0x23. 

pi@orangepi3:~$ sudo i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: 20 -- -- 23 -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
pi@orangepi3:~$ 
 

However, when I use wiringOP library to access(read and write) slave i2c chip(mcp23008) registers, it always return -1.

 

int main(int argc, char** argv)
{
    int fd_s1 = wiringPiI2CSetup(SLAVE_1_DEVICE_ID); //0x20
    if (fd_s1 == -1)
    {
        std::cout << "Failed to init I2C Slave 1 communication." << std::endl;
        return -1;
    }

    int fd_s2 = wiringPiI2CSetup(SLAVE_2_DEVICE_ID); //0x23
    if (fd_s2 == -1)
    {
        std::cout << "Failed to init I2C Slave 2 communication." << std::endl;
        return -1;
    }

    std::cout << "I2C communication successfully setup." << std::endl;

    int reg_read;
    reg_read = wiringPiI2CReadReg8(fd_s1, REG_IODIR); //The register address is correct, as this code ran on raspberry Pi correctly
    std::cout << reg_read << std::endl;
}

 

Run output:

I2C communication successfully setup.

-1

 

The wiringOP library is from https://github.com/orangepi-xunlong/WiringOP

 

In the wiringPi library (in wiringOP), the code in wiringPiI2C.c shows that all APIs return -1, if the ioctl system call returns fault.

 

Not sure what I should investigate next step to solve this problem.

 

Thanks.

  • Author

Thanks for pointing out "our implementation", rather than using the wiringOP library, Igor.

 

Can you share any clue of documents or instructions? Appreciated.

 

 

  • Author

No problem, thanks Igor, does the dmesg output look good?

 

pi@orangepi3:/boot$ dmesg |grep i2c
[    2.239314] i2c /dev entries driver
[    2.939717] sun50i-h6-pinctrl 300b000.pinctrl: pin-121 (5002000.i2c) status -517
[    2.939730] mv64xxx_i2c 5002000.i2c: Error applying setting, reverse things back
[    2.942492] axp20x-i2c 2-0036: AXP20x variant AXP806 found
[    2.955643] input: axp20x-pek as /devices/platform/soc/7081400.i2c/i2c-2/2-0036/axp221-pek/input/input0
[    2.962852] sun50i-h6-pinctrl 300b000.pinctrl: pin-121 (5002000.i2c) status -517
[    2.962864] mv64xxx_i2c 5002000.i2c: Error applying setting, reverse things back
[    2.981545] axp20x-i2c 2-0036: AXP20X driver loaded
pi@orangepi3:/boot$ 
 

  • Author

Here is all the information I got from Armbian buster on Orangepi 3. Please give your advice if you have any. Thanks.

 

pi@orangepi3:~$ sudo i2cdetect -l
[sudo] password for pi: 
i2c-1    i2c           DesignWare HDMI                     I2C adapter
i2c-2    i2c           mv64xxx_i2c adapter                 I2C adapter
i2c-0    i2c           mv64xxx_i2c adapter                 I2C adapter
pi@orangepi3:~$ dmesg |grep i2c
[    2.239498] i2c /dev entries driver
[    2.944372] sun50i-h6-pinctrl 300b000.pinctrl: pin-121 (5002000.i2c) status -517
[    2.944384] mv64xxx_i2c 5002000.i2c: Error applying setting, reverse things back
[    2.945285] axp20x-i2c 2-0036: AXP20x variant AXP806 found
[    2.952116] input: axp20x-pek as /devices/platform/soc/7081400.i2c/i2c-2/2-0036/axp221-pek/input/input0
[    2.960280] sun50i-h6-pinctrl 300b000.pinctrl: pin-121 (5002000.i2c) status -517
[    2.960293] mv64xxx_i2c 5002000.i2c: Error applying setting, reverse things back
[    2.968835] axp20x-i2c 2-0036: AXP20X driver loaded
pi@orangepi3:~$ sudo i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: 20 -- -- 23 -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
pi@orangepi3:~$ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: 30 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
pi@orangepi3:~$ sudo i2cdetect -y 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- UU -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
pi@orangepi3:~$ 
 

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.