Go to previous topic
Go to next topic
Last Post 15 Apr 2013 11:11 AM by  jemiah.a@logicpd.com
Article: DM37 Linux - Newer I2Ctools
 0 Replies
Author Messages
New Member
New Member

15 Apr 2013 11:11 AM
    The version of I2CTools included with the current DM37 Linux BSP is old and doesn't support block transfers which could be a problem for I2C devices needing multi-byte reads/writes.

    The procedure for getting a newer version of the tools is pretty simple. You can down load the source here:

    To ensure the correct build environment use the ltib shell:

    logic@logic-desktop:~/logic/Logic_BSPs/Linux_3.0/REL-ltib-DM3730-2.3-2$ ./ltib -m shell
    Entering ltib shell mode, type 'exit' to quit

    Once you're in the shell, switch to where you downloaded and extracted the source.

    LTIB> cd /home/logic/logic/Logic_BSPs/Linux_3.0/REL-ltib-DM3730-2.3-2/rpm/BUILD/temp/i2c-tools-3.1.0
    LTIB> ls
    CHANGES COPYING Makefile README eeprom eepromer include py-smbus stub tools version.h

    The makefile for I2CTools is very simple. If your build environment is setup properly you only need to call make:

    LTIB> make
    gcc -O2 -Wall -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wnested-externs -Winline -W -Wundef -Wmissing-prototypes -Iinclude -c tools/i2cdetect.c -o tools/i2cdetect.o
    gcc -O2 -Wall -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wnested-externs -Winline -W -Wundef -Wmissing-prototypes -Iinclude -c tools/i2cbusses.c -o tools/i2cbusses.o
    gcc -O2 -Wall -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wnested-externs -Winline -W -Wundef -Wmissing-prototypes -Iinclude -c tools/i2cdump.c -o tools/i2cdump.o
    gcc -O2 -Wall -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wnested-externs -Winline -W -Wundef -Wmissing-prototypes -Iinclude -c tools/util.c -o tools/util.o
    gcc -O2 -Wall -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wnested-externs -Winline -W -Wundef -Wmissing-prototypes -Iinclude -c tools/i2cset.c -o tools/i2cset.o
    gcc -O2 -Wall -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wnested-externs -Winline -W -Wundef -Wmissing-prototypes -Iinclude -c tools/i2cget.c -o tools/i2cget.o
    gcc -o tools/i2cdetect tools/i2cdetect.o tools/i2cbusses.o
    gcc -o tools/i2cset tools/i2cset.o tools/i2cbusses.o tools/util.o
    gcc -o tools/i2cget tools/i2cget.o tools/i2cbusses.o tools/util.o
    gcc -o tools/i2cdump tools/i2cdump.o tools/i2cbusses.o tools/util.o

    You'll find the resulting binaries (i2cdetect, i2cdump, i2cget, i2cset) in the ...i2c-tools-3.1.0/tools directory. Add them to your rootfs when you rebuild LTIB or simply copy them to your system with an SD card. You can overwrite the built in versions which are in /usr/sbin/. If you use an SD card to transfer the files don't for get to use 'chmod +x' on each one to set the executable flag.

    Do a quick check to ensure that you've updated everything properly and you'll see the new options listed:

    DM-37x# i2cset
    Usage: i2cset [-f] [-y] [-m MASK] I2CBUS CHIP-ADDRESS DATA-ADDRESS [VALUE] ... [MODE]
    I2CBUS is an integer or an I2C bus name
    ADDRESS is an integer (0x03 - 0x77)
    MODE is one of:
    c (byte, no value)
    b (byte data, default)
    w (word data)
    i (I2C block data)
    s (SMBus block data)
    Append p for SMBus PEC