Jump to content

NanoPi Duo2 I2C Problem


ab0tj

Recommended Posts

Hi all,

 

I am trying to use a MCP3426 I2C ADC chip with my NanoPi Duo2. I have compiled a custom kernel with the mcp3426 driver in it, but I can't get it to load. The problem seems to be that the chip uses address 0x68 which is the same address that the commonly used DS1307 RTC chip uses. I have blacklisted the ds1307 module which has stopped that module from loading, but somehow '/sys/bus/i2c/devices/0-0068/name' still claims to be a ds1307.  'echo mcp3426 0x68 > /sys/class/i2c-dev/i2c-0/device/new_device' results in a "Invalid argument error" with 'i2c i2c-0: Failed to register i2c client mcp3426 at 0x68 (-16)' being logged in dmesg, and apparently the -16 error means that address is already in use. 'echo 0x68 > /sys/bus/i2c/devices/i2c-0/delete_device' results in 'i2c i2c-0: delete_device: Can't find device in list'.

 

I should add that I can read the ADC using i2cget, but I would like to use the Linux iio interface.

Any ideas on where to go from here?

 

Thanks,
Alex

Edited by ab0tj
Add detail
Link to comment
Share on other sites

Just now, Igor said:

Have you enable I2C in armbian-config? What do you get by scanning I2C busses?

 

Yes, I2C works otherwise.

# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: 20 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

 

Link to comment
Share on other sites

In case anyone else comes across this, I answered my own question... I solved this by making a custom overlay:

/dts-v1/;
/plugin/;

/ {
        fragment@0 {
                target = <&i2c0>;
                __overlay__ {
                        #address-cells = <1>;
                        #size-cells = <0>;
                        adc@68 {
                                compatible = "microchip,mcp3426";
                                reg = <0x68>;
                                status = "okay";
                        };
                };
        };
};

I still see "i2c i2c-0: Failed to register i2c client ds1307 at 0x68 (-16)" in dmesg, so something still seems to be trying to instantiate a ds1307. Maybe that's part of the base image? But at least my overlay claims that address before ds1307 can get to it.

Link to comment
Share on other sites

1 hour ago, ab0tj said:

I still see "i2c i2c-0: Failed to register i2c client ds1307 at 0x68 (-16)" in dmesg, so something still seems to be trying to instantiate a ds1307. Maybe that's part of the base image?

It seems it have been added during April for a specific NanoPi which has this RTC onboard, but by mistake, it has been added to all NanoPi !

We will probably fix that soon ...

Link to comment
Share on other sites

5 minutes ago, martinayotte said:

It seems it have been added during April for a specific NanoPi which has this RTC onboard, but by mistake, it has been added to all NanoPi !

We will probably fix that soon ...

Thanks, that explains it!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines