OpenWrt Forum Archive

Topic: I2C support on WRTnode card

The content of this topic has been archived on 30 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,
   I started to play with the WRTnode boards. This board is based on MT7620N chip. I can say that it is a very interesting board, you have access to all the pins you ever dreamed of, the footprint of the board is half of a credit card.
  It is nice also that on WRTnode board you can test your firmware using USB flash boot, simply put on a fat32 USB flash drive the firmware you want to try (put the .bin on the root of the USB flash and rename it 'uimage') and WRTnode will boot that firmware os you won;t risk to brick you board.
  Right now I work to setup the I2C on the WRTnode, there is a wiki explaining step by step the process (http://wiki.wrtnode.com/index.php?title … 2c_support), but something is not working on my setup. So I looked into OpenWRT documentation, I found and tried a few things related to OpenWRT and I2C:

*things I found (hope that it is correct, I don't intend to mislead people, please correct me if I'm wrong)
-various modules are loaded at the boot time (you can check them in folder  /lib/modules/3.10.44), use command lsmod | grep i2c to check what i2c part was loaded

-i2c is present as a device if is listed in /dev (should be i2c-0)

-modules are loaded following a specific order, this is visible in /etc/modules.d (use ls after getting in that directory)

*things I tried
-add i2c support as described in WRTnode wiki

-insert i2c-tools package at the kernel compilation time:
./scripts/feeds install i2c-tools

-then run:
make menuconfig

-go to Utilities --> <*> i2ctools, add i2c-tools, save and exit

-make

-you should get a .bin file with i2c support. Just a mention: the blue LED on the WRTnode is not lit using this .bin file, check you SSID presence

(-get a USB memory stick, format it to fat32, copy the .bin on it and rename it to 'uimage', connect the USB stick to the WRTnode using the USB special cable delivered with the card, WRTnode card will boot the image 'uimage' from the USB memory stick and you don't have to flash the image directly on your WRTnode and maybe brick it)

-after boot, connect via webbrowser (web GUI LuCI interface) and check in System -> Software what i2c packages are loaded on the WRTnode

-for me are available i2c-tools, kmod-i2c-algo-bit, kmod-i2c-core, kmod-i2c-gpio, kmod-i2c-gpio-custom, kmod-i2c-ralink, libi2c

-connect to WRTnode via SSH

-insert module i2c-dev - but here is no happy end:
insmod i2c-dev.ko
Failed to find i2c-dev. Maybe it is a built in module ?

-i2c found in /dev:
root@OpenWrt:/etc/modules.d# cd /dev
root@OpenWrt:/dev# ls
bus                 log                 mtd2ro              mtdblock0           network_throughput  snd                 zero
console             mem                 mtd3                mtdblock1           null                tty
cpu_dma_latency     mtd0                mtd3ro              mtdblock2           ppp                 ttyS0
full                mtd0ro              mtd4                mtdblock3           ptmx                ttyS1
fuse                mtd1                mtd4ro              mtdblock4           pts                 urandom
i2c-0               mtd1ro              mtd5                mtdblock5           random              watchdog
kmsg                mtd2                mtd5ro              network_latency     shm                 watchdog0

-i2c found in /lib/modules/3.10.44:
root@OpenWrt:~# cd /lib/modules/3.10.44
root@OpenWrt:/lib/modules/3.10.44# ls
arc4.ko               i2c-gpio-custom.ko    mbcache.ko            pppoe.ko              snd-usbmidi-lib.ko    xt_REDIRECT.ko
cdc-acm.ko            i2c-gpio.ko           nf_conntrack.ko       pppox.ko              snd.ko                xt_TCPMSS.ko
crc-ccitt.ko          input-core.ko         nf_conntrack_ftp.ko   ralink_eeprom_api.ko  soundcore.ko          xt_comment.ko
crc-itu-t.ko          ip6_tables.ko         nf_conntrack_ipv4.ko  rt2860v2_ap.ko        usb-common.ko         xt_conntrack.ko
crc16.ko              ip6t_REJECT.ko        nf_conntrack_ipv6.ko  scsi_mod.ko           usb-storage.ko        xt_limit.ko
crypto_blkcipher.ko   ip6table_filter.ko    nf_conntrack_irc.ko   sd_mod.ko             usbcore.ko            xt_mac.ko
crypto_hash.ko        ip6table_mangle.ko    nf_defrag_ipv4.ko     slhc.ko               usbserial.ko          xt_mark.ko
dwc2.ko               ip6table_raw.ko       nf_defrag_ipv6.ko     snd-compress.ko       uvcvideo.ko           xt_multiport.ko
dwc2_platform.ko      ip_tables.ko          nf_nat.ko             snd-hwdep.ko          v4l2-common.ko        xt_nat.ko
eeprom_93cx6.ko       ipt_MASQUERADE.ko     nf_nat_ftp.ko         snd-mixer-oss.ko      vfat.ko               xt_state.ko
ehci-hcd.ko           ipt_REJECT.ko         nf_nat_ipv4.ko        snd-page-alloc.ko     videobuf2-core.ko     xt_tcpudp.ko
ehci-platform.ko      iptable_filter.ko     nf_nat_irc.ko         snd-pcm-oss.ko        videobuf2-memops.ko   xt_time.ko
ext4.ko               iptable_mangle.ko     nls_base.ko           snd-pcm.ko            videobuf2-vmalloc.ko
fat.ko                iptable_nat.ko        nls_utf8.ko           snd-rawmidi.ko        videodev.ko
ftdi_sio.ko           iptable_raw.ko        ntfs.ko               snd-seq-device.ko     x_tables.ko
fuse.ko               ipv6.ko               ppp_async.ko          snd-timer.ko          xt_CT.ko
i2c-algo-bit.ko       jbd2.ko               ppp_generic.ko        snd-usb-audio.ko      xt_LOG.ko

-i2c found in /etc/modules.d:
root@OpenWrt:/lib/modules/3.10.44# cd /etc/modules.d
root@OpenWrt:/etc/modules.d# ls
02-crypto-hash      25-nls-utf8         40-scsi-core        55-i2c-algo-bit     ipt-conntrack       lib-crc-itu-t       usb-audio
09-crypto-arc4      30-fs-ext4          40-usb2             59-i2c-gpio         ipt-core            lib-crc16           usb-serial
20-eeprom-93cx6     30-fs-ntfs          42-ip6tables        60-video-core       ipt-nat             ppp                 usb-serial-ftdi
20-ipv6             30-fs-vfat          50-wifi             65-video-videobuf2  ipt-nathelper       pppoe               usb-storage
20-usb-core         30-sound-core       54-usb-dwc2         80-fuse             lib-crc-ccitt       usb-acm             video-uvc

-other i2c commands:
root@OpenWrt:~# i2cdetect -l
i2c-0    i2c           10000900.i2c                        I2C adapter
root@OpenWrt:~# i2cdetect -F 0
Functionalities implemented by /dev/i2c-0:
I2C                              yes
SMBus Quick Command              yes
SMBus Send Byte                  yes
SMBus Receive Byte               yes
SMBus Write Byte                 yes
SMBus Read Byte                  yes
SMBus Write Word                 yes
SMBus Read Word                  yes
SMBus Process Call               yes
SMBus Block Write                yes
SMBus Block Read                 no
SMBus Block Process Call         no
SMBus PEC                        yes
I2C Block Write                  yes
I2C Block Read                   yes

-I hooked up a BMP180 sensor on the i2c pins, but seems like with or without it, the i2c bus is full of devices:
root@OpenWrt:~# i2cdetect 0
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-0.
I will probe address range 0x03-0x77.
Continue? [Y/n] y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
10: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
20: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
30: 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f
40: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
50: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
60: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f
70: 70 71 72 73 74 75 76 77   

There are some questions from my side:
Apparently I need some i2c modules to load at boot time, how can I convince i2c-core, i2c-gpio-custom to load at boot time?
Why i2c-dev.ko is not present and what determines a .ko to be present?
Which files on the /trunk directory (where make command is used) are the ones used for configuration of what packages to be compiled in kernel, maybe there is not done something?

Thanks!
Have a nice day! smile

"i2c device interface" checked in the kernel config added i2c-dev.ko as built-in. i2c-gpio-custom not needed for your hardware config, ralink hardware i2c driver built-in too.

Ok, that is clear now! Any idea about debugging this I2C topic? I saw people having the same problem either on WRTnode wither on the same chipset (MT7620N).

Thanks!
Have a nice day!

Are you modified dts file ?

Yes, I followed every step. Initially I modified WRTnode.dts file, a second try was to use directly the file offered from the wiki (I was afraid about some indentation, some hidden details).
I am pretty sure that it is something strange like last time (n.b. 10 minutes boot time, solved after I used / manufactured a new set of cables), but my problem is that I don't know where to look for.
I decided to give the WRTnode to another friend, he will cross compile and check what is going on, maybe he will be lucky than I am.
It is frustrating to have such problems and other people around you to say 'Hmmm, strange, I did exactly the same and works just great!' smile
But this is the beauty of embedded world, you learn every day things and end up but making something interesting.
Thanks!

Softwarewise you seem to be on the right way, since i2cdetect runs smoothly. The problem about having virtually the bus full of devices may be on the hardware side. Check cables, soldering, resistors, pins. If you know how to do it, you could even hook up a LED to the pins and check if it flashes, while running i2cdetect.

The discussion might have continued from here.