This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

PROCESSOR-SDK-DRA8X-TDA4X: Execution of I2C test using Linux SDK

Part Number: PROCESSOR-SDK-DRA8X-TDA4X

Hi,

I saw that there are examples like pdk/packages/ti/drv/i2c/test/eeprom_read available in the RTOS SDK. I want to create and run a similar test (or a loopback test), but using the Linux SDK, to check the functioning of the I2C. The board I'm using is the j721e_evm.

I went through the documentation mentioned on the page: http://software-dl.ti.com/jacinto7/esd/processor-sdk-linux-jacinto7/latest/exports/docs/linux/Foundational_Components/Kernel/Kernel_Drivers/I2C.html

But I'm still unclear as to how this can help me. I found it mentioned that the i2c related files in the SDK are based on the documentation on www.kernel.org. However, I'm unsure of how these functions can help me in controlling the registers mentioned in the Technical Reference Manual.

Is there a more detailed documentation which I can look at, which would help me to understand the correct functions and libraries to use to set different modes, initialise, transfer data over I2C?

Thanks.

  • Hi Massimo,

    The TRM mentions i2c controller registers which are programmed by the i2c driver.
    The link: http://software-dl.ti.com/jacinto7/esd/processor-sdk-linux-jacinto7/latest/exports/docs/linux/Foundational_Components/Kernel/Kernel_Drivers/I2C.html

    gives i2c debug tools for the slaves which are generally the ones that need a lot of testing.

    Say you connect a PMIC on bus 0 of i2c.

    i2cdump -fy -y 0x0 pmic_slave_id will give you all the registers of the PMIC on that slave_id.

    Similarly i2cset can be used to write the slave pmic's registers.

    What exactly are you looking for?

    Best Regards,
    Keerthy

  • Thank you for the response.

    Following is what I am attempting to do:

    From the Technical Reference Manual of the board, I found that there are 10 multi-master I2C controllers available. So what I wanted to do, was to use any one of these to communicate with the EEPROM (read and write some random data).

    I found out the list of buses available using the i2cdetect -l command as mentioned on your documentation. However, this did not give me a clear picture as to which of these was already connected to the EEPROM. So, I checked the individual i2c buses, using the command "i2cdetect -y <0-7>" to check the memory allocation for each (For some reason, I am only able to see 8 devices through the Linux Kernel, not 10)

    In two cases, I found that there were some devices on certain memory locations:

    1. For bus 0, at 0x50, 0x51

    2. For bus 2, at 0x50, 0x51 and 0x54

    When I cross-verified with the "User's Guide" documentation, I saw that the I2C addresses mentioned for EEPROM were 0x50 0x53 and 0x54, all for WKUP_I2C0, and 0x50 and 0x51 for BOOT EEPROM.

    So, am I correct in assuming that I will be able to communicate with the EEPROM using one of these two buses?

    Since I wasn't sure, I wrote the following C code, to attempt to write some data to the EEPROM, and read it back.

    #include <linux/i2c-dev.h>
    #include <sys/ioctl.h>
    #include <stdio.h>
    #include <fcntl.h>
    #include <unistd.h>
    
    int main()
    {
    __u8 reg = 0x00;
    __s32 res;
    char buf[10];
    buf[0] = reg;
    buf[1] = 0x43;
    //buf[2] = 0x65;
    char buf_r[10];
    
        int file;
        int adapter_nr = 2;
        char filename[20];
        int i;
        
        file = open("/dev/i2c-2", O_RDWR);
        if(file < 0)
        {
            perror ("unopened");
        }
    
        int addr = 0x50;
        if(ioctl(file, I2C_SLAVE, addr) < 0)
        {
            perror("issue in file");
        }
    
    
        if(write(file, buf, 2) != 2)
        {
            perror("unable to write");        
        }
    
        printf("Data written :");
        for(i = 0; i<2; i++)
        {
                   printf("%x ", buf[i]);
        }
        lseek(file, 0, SEEK_SET);
        
        if(read(file, buf_r, 2) != 2)
        {
            perror ("unable to read");
        }
        else
        {    
            printf("\nresponse read: ");
            for(i=0; i<2; i++)
            {
                   printf("%x ", buf_r[i]);
            }
            
        }
        printf("\n");
    }
    

    When I run the above code, I notice that the data I attempted to write and the data being read are not the same. From what I can understand, it might be because of one of two reasons:

    1. The bus I'm using is incorrect, and therefore the address 0x50 is not correct.

    2. In order to write the data, I have to alter some of the I2C registered mentioned in the Technical Reference Manual for the TDA4VM. However, this would mean I have to initialize the I2C and do a little low-level programming, as mentioned in this document.

     Is my understanding correct? If so, what can I do to ensure data transfer?

     

    Thank you.

  • Hi Massimo,

    I will get in touch with experts and come back with more comprehensive answer.

    I will get back to you by next week. Apologies for the delay.

    Best Regards,
    Keerthy

  • Hi Massimo,

    Both EEPROMs are write protected.  The configuration EEPROM protection is dip switch controlled.  The boot EEPROM protection is GPIO controlled.
    Hence you see that you are not able to read back what you write.

    Best Regards,
    Keerthy