EDIT: I was being a moron and was grep'ing "i2c" packages and neglected to install one. It is all good now after:
#opkg install kmod-gpio-pcf857x
I started off with the 6416A which came loaded with GL's modified Barrier Breaker image installed. I need 7 GPIOs for the project I am working on that I am trying to use a travel router for. I was able to get those GPIOs using a pcf8574 on that model without a hitch and it works flawless.
The problem is that in that model there is poor USB negotiation in it and the external wifi adapter I need to use with it only works 100% of the time if I plug a USB hub in between the router and adapter. The hub can be unpowered or powered, doesn't matter - so it is not a power issue, it is with the initial negotiation.
I get the same result with the adapter on the AR150 which isn't surprising since it is runs the same SoC.
I tried the MT300N and it performed great for what I need it for and works fine with the adapter. The problem is I2C does not appear to be implemented properly or there is a tricky way required to get it working I have not yet determined. But, I'm leaning towards it being an issue in the CC distro itself as opposed to the variances in the chipsets, because I can't get it working on the AR150 which runs CC (I've tried the GL image and a standard OpenWRT image) but has basically the same hardware as the 6416.
On the MT300N I've tried the GL version and the standard OpenWRT also, and I get close, but it appears that "gpiochip_add" never runs. I chose GPIO 2 and 44 on this one for the data and clock and confirmed they functioned as expected as regular GPIOs testing the input and output.
#insmod i2c-gpio-custom bus0=0,2,44
dmesg seems to indicate no problem with this except for possible the first line ("not parsing pinctrl DT" ?)
[ 99.100000] i2c-gpio i2c-gpio.0: no of_node; not parsing pinctrl DT
[ 99.100000] rt2880-pinmux pinctrl: request pin 2 (io2) for pio:2
[ 99.100000] rt2880-pinmux pinctrl: request pin 44 (io44) for pio:44
[ 99.100000] i2c-gpio i2c-gpio.0: using pins 2 (SDA) and 44 (SCL)
#i2cdetect 0
reports the device was found at 0x20 (no new errors or logs in dmesg). this is expected as this is the address this same expander runs on just fine with the 6416 with BB.
#echo pcf8574 0x20 > /sys/bus/i2c/devices/i2c-0/new_device
dmesg reports it seems OK with [ 268.870000] i2c i2c-0: new_device: Instantiated device pcf8574 at 0x20
But the dmesg is missing an important part, “gpiochip_add” is missing in that log that tells us it created a new chip for the expander and what new GPIOs were registered on the device. If it were working like it should it would say something like this as it does on the 6416: “gpiochip_add: registered GPIOs 56 to 63 on device: pcf8574″
I have been at this for days with no luck. I tried installing every i2c and gpio related package available even beyond the ones I've needed in the past on other models/distros, doing it one by one and rebooting just to see if that would solve it.
I am truly hoping someone can offer a solution to getting 7+ GPIOs (in and out) on a MT300N. At this point though I have feeling it might be more centered around CC missing I2C functionality or errors, so if anyone can comment on getting a port expander to work on CC that might be a start.
I have not tried the trunk (DD) yet but that is going to be my next step if I can't make headway with some expert guidance in this forum. I haven't jumped straight to that just yet since this project requires a stable and well tested install and the trunk is not probably the match for the needs. I'm also considering trying to build a BB image for the MT300N but before I waste more time down rabbit holes I want to see if someone can point me in a better direction.
TIA for any help!
(Last edited by bizee on 24 Jan 2017, 05:12)