I'm new to OpenWrt so I apologize in advance if this post is in the wrong part of the forum. I've done plenty of Googling in an attempt to find a solution to my problem but to no avail; if anyone has some troubleshooting tips (I'm not sure whether my issue is likely to be hardware, OpenWrt or owserver related), any advice would be very much appreciated.
Objective: connect a DS2482-800 1-Wire bus master to a WRT54G-TM (I believe this is simply a re-branded WRT54GL) via I2C using GPIOs (currently 4 and 7) with kmod-i2c-gpio-custom. Connect 1-Wire sensors (temperature, humidity etc.) to the DS2482-800 and use owserver to make the devices on the bus available to other computers on the LAN.
Hardware: I've soldered wires to GPIO 7 (configured as SCL) and GPIO 4 (SDA), and connected these to a circuit consisting of an NXP "PCA9517D,118" I2C voltage level translator to translate signals from 3.3V to 5V. The SCL and SDA lines from the WRT54G-TM are pulled up to +3.3V with 10k ohm resistors. SCL and SDA coming out of the level translator are pulled up to +5V with another set of 10k ohm resistors. The DS2482-800 is connected to the 5V side. At the moment the whole setup (the WRT54G included) is being powered by a modified desktop computer PSU so everything shares a common ground.
This circuit works fine with a Raspberry Pi, so I recreated it to test with the WRT54G-TM; there are some pictures of the circuit here: http://www.flickr.com/photos/chris1h1/s … 219900090/.
Relevant data sheets are here: PCA9517 and DS2482-800.
Software: I used the Backfire (10.03.1) brcm47xx image generator (the I2C packages don't seem to be available for brcm-2.4) to make an image with the "Broadcom-b43" profile including kmod-i2c-algo-bit, kmod-i2c-gpio-custom, i2c-tools, owserver and owshell. I added configuration files for network, wireless etc. but nothing fancy. Both owserver and owshell are version 2.8p4-2. Once the image was flashed I connected the GPIO lines to the circuit and performed the following steps:
insmod i2c-gpio-custom bus0=0,4,7
dmesg | grep gpio
Result:
i2c-gpio i2c-gpio.0: using pins 4 (SDA) and 7 (SCL)
Let's see if there's an I2C device:
ls /dev/i2c*
Yep:
root@wrt54g-tm:~# ls /dev/i2c*
/dev/i2c-0
Check to see whether the DS2482-800 I2C 1-Wire bus master has been detected:
i2cdetect -y 0
Result: something looks to be there:
root@wrt54g-tm:~# i2cdetect -y 0
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- 24 -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Let's see if owserver can connect to the bus master:
owserver --i2c=/dev/i2c-0 -p 4304 --error_level=9 --foreground
Not ideal:
root@wrt54g-tm:~# owserver --i2c=/dev/i2c-0 -p 4304 --error_level=9 --foreground
CONNECT: ow_avahi_link.c:OW_Load_avahi_library(72) No Avahi support. Library libavahi-client couldn't be loaded
CONNECT: ow_dnssd.c:OW_Load_dnssd_library(136) Zeroconf/Bonjour is disabled since dnssd library isn't found
CALL: ow_parsename.c:FS_ParsedName_anywhere(90) path=[]
DEBUG: owlib.c:SetupTemperatureLimits(79) Globals temp limits 0C 100C (for simulated adapters)
CONNECT: ow_ds2482.c:DS2482_detect_single(363) Found an i2c device at /dev/i2c-0 address 18
DEBUG: ow_ds2482.c:DS2482_readstatus(475) problem min=1 max=2 i=0 ret=-1
CONNECT: ow_ds2482.c:DS2482_detect_single(390) i2c device at (null) address 18 cannot be reset. Not a DS2482.
CONNECT: ow_ds2482.c:DS2482_detect_single(363) Found an i2c device at /dev/i2c-0 address 19
Segmentation fault
Notice that the reported address differs from the original i2cdetect output above, and changes within the owserver output. Output from subsequent runs of
i2cdetect -y 0
is now all over the place; sometimes no devices are detected, sometimes two or three devices are reportedly detected. The address(es) change each time.
Is this likely a hardware issue, an issue with OpenWrt's I2C over GPIO, or an issue with owserver? Any hints regarding where to start troubleshooting or how to troubleshoot will be gratefully received.
Thanks.