kzhang Posted January 8, 2020 Posted January 8, 2020 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.
Igor Posted January 8, 2020 Posted January 8, 2020 48 minutes ago, kzhang said: The wiringOP library is from https://github.com/orangepi-xunlong/WiringOP Talk to their authors or do some forum searching for our implementation. Please change the title - I2C works while 3rd party application doesn't.
kzhang Posted January 8, 2020 Author Posted January 8, 2020 Thanks for pointing out "our implementation", rather than using the wiringOP library, Igor. Can you share any clue of documents or instructions? Appreciated.
Igor Posted January 8, 2020 Posted January 8, 2020 5 minutes ago, kzhang said: Can you share any clue of documents or instructions? Appreciated. I have nothing to do with this.
kzhang Posted January 8, 2020 Author Posted January 8, 2020 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$
kzhang Posted January 9, 2020 Author Posted January 9, 2020 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:~$
Recommended Posts