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.

SK-TDA4VM: Reading out the WKUP_I2C EEPROM memory data

Part Number: SK-TDA4VM


Tool/software:

Hi,

I would like to read out the data in the EEPROM. I am using the following code. Before each read I write to this address the offset from which I want to read the data, the output is still 0xff. I will provide my code:

#!/bin/bash

I2C_BUS=0 
EEPROM_ADDR=0x51

echo "Reading EEPROM at address $EEPROM_ADDR on bus $I2C_BUS"

# Function to perform a dummy write and then read data
read_eeprom() {
local offset=$1
local length=$2

# Perform dummy write to set the EEPROM's internal read pointer
i2cset -y $I2C_BUS $EEPROM_ADDR 0x00 #$offset

# Read data starting from the specified offset
for i in $(seq 0 $((length - 1))); do
value=$(i2cget -y $I2C_BUS $EEPROM_ADDR)
printf "0x%02X " $((offset + i))
printf "Value: %s\n" "$value"
done
echo
}

# MAGIC (4 Bytes)
echo "MAGIC: "
read_eeprom 0x00 4

# M_TYPE (1 Byte)
echo "M_TYPE: "
read_eeprom 0x04 1

# M_LENGTH (2 Bytes)
echo "M_LENGTH: "
read_eeprom 0x05 2

# B_TYPE (1 Byte)
echo "B_TYPE: "
read_eeprom 0x07 1

# B_LENGTH (2 Bytes)
echo "B_LENGTH: "
read_eeprom 0x08 2

# B_NAME (16 Bytes)
echo "B_NAME: "
read_eeprom 0x0A 16

# DESIGN_REV (2 Bytes)
echo "DESIGN_REV: "
read_eeprom 0x1A 2

# PROC_NBR (4 Bytes)
echo "PROC_NBR: "
read_eeprom 0x1C 4

# VARIANT (2 Bytes)
echo "VARIANT: "
read_eeprom 0x20 2

# PCB_REV (2 Bytes)
echo "PCB_REV: "
read_eeprom 0x22 2

# SCHBOM_REV (2 Bytes)
echo "SCHBOM_REV: "
read_eeprom 0x24 2

# SWR_REV (2 Bytes)
echo "SWR_REV: "
read_eeprom 0x26 2

# VENDORID (2 Bytes)
echo "VENDORID: "
read_eeprom 0x28 2

# BUILD_WK (2 Bytes)
echo "BUILD_WK: "
read_eeprom 0x2A 2

# BUILD_YR (2 Bytes)
echo "BUILD_YR: "
read_eeprom 0x2C 2

# BOARDID (6 Bytes)
echo "BOARDID: "
read_eeprom 0x2E 6

# SERIAL_NBR (4 Bytes)
echo "SERIAL_NBR: "
read_eeprom 0x34 4

# DDR_INFO (Variable Length - Assuming here to read 4 bytes as an example)
echo "DDR_INFO: "
read_eeprom 0x38 4

# MAC_ADDR (6 Bytes for typical MAC address)
echo "MAC_ADDR: "
read_eeprom 0x3C 6

# END_LIST
echo "END_LIST: "
read_eeprom 0x42 1

Regards,
Tamas

  • Hi Tamas,

    Try running i2cdump -f -y 'bus_num' 'slave_id' where bus_num is the i2c bus ID for the bus where EEPROM resides & slave_id is the EEPROM slave ID.

    Thank you,

    Fabiana

  • Hi Fabiana,

    Here is the output:

    root@tda4vm-sk:/opt/vision_apps# i2cdump -f -y 0 0x51
    No size specified (using byte-data access)
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
    00: 55 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    U...............
    10: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    20: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    30: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    40: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    50: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    60: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    70: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    90: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    b0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    c0: ff ff ff ff ff ff ff ff 00 ff ff ff ff ff ff ff    ................
    d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    root@tda4vm-sk:/opt/vision_apps#

    Regards,
    Tamas

  • Hi Tamas,

    I believe that is EEPROM you are trying to read.

    Can you execute the below command in Linux to double the i2c bus number corresponding to Linux flow:

    'dmesg | grep i2c'

    - Keerthy

  • Hi Keerthy,

    The output of the dmesg | grep i2c is the following:
    root@tda4vm-sk:/opt/edgeai-gst-apps# dmesg | grep i2c
    [    0.771578] i2c_dev: i2c /dev entries driver
    [    0.954439] omap_i2c 42120000.i2c: bus 0 rev0.12 at 100 kHz
    [    0.981438] i2c i2c-1: Added multiplexed i2c bus 2
    [    0.986423] i2c i2c-1: Added multiplexed i2c bus 3
    [    0.999081] omap_i2c 2000000.i2c: bus 1 rev0.12 at 400 kHz
    [    1.005156] omap_i2c 2010000.i2c: bus 4 rev0.12 at 100 kHz
    [    1.033648] i2c i2c-5: Added multiplexed i2c bus 6
    [    1.038634] i2c i2c-5: Added multiplexed i2c bus 7
    [    1.051348] i2c i2c-5: Failed to register i2c client pca9543 at 0x70 (-16)
    [    1.058376] i2c i2c-5: of_i2c: Failure registering /bus@100000/i2c@2030000/i2c-mux@70
    [    1.066381] i2c i2c-5: Failed to create I2C device for /bus@100000/i2c@2030000/i2c-mux@70
    [    1.074746] omap_i2c 2030000.i2c: bus 5 rev0.12 at 400 kHz
    [    1.080936] omap_i2c 2050000.i2c: bus 8 rev0.12 at 400 kHz
    [    4.963477] IMX568+ - regmap i2c init ok!
    [    6.282998] IMX568+ - regmap i2c init ok!
    root@tda4vm-sk:/opt/edgeai-gst-apps#

    Regards,
    Tamas

  • Tamas,

    Seems like i2cdump is somehow not getting the correct values. So using the Linux driver should work:

    https://stackoverflow.com/questions/29932003/reading-and-writing-eeprom-via-i2c-with-linux

    "Alternatively, you could access it via the kernel at24.c driver, if you're able to compile and install a different kernel device tree for your Raspberry Pi.

    The kernel device tree needs to specify the EEPROM's type and address, and which I²C bus it's connected to. I'm not sure about Raspberry Pi, but for the BeagleBone Black EEPROM it goes like this:

    &i2c0 {
        eeprom: eeprom@50 {
            compatible = "at,24c32";
            reg = <0x50>;
        };
    };
    

    For your device you'd specify compatible = "at,24c256";

    Ensure the kernel config specifies CONFIG_EEPROM_AT24=y (or =m).

    Then you should be able to access the EEPROM memory from userspace at something like /sys/bus/i2c/devices/0-0050/eeprom or /sys/bus/i2c/drivers/at24/0-0050/eeprom."

    - Keerthy

  • Hi Keerthy,

    Modifying the k3-j721e-sk.dts device tree file the following error appears:

      DTC     arch/arm64/boot/dts/ti/k3-j721e-sk.dtb
    Error: arch/arm64/boot/dts/ti/k3-j721e-sk.dts:675.1-6 Label or path i2c0 not found
    FATAL ERROR: Syntax error parsing input tree
    make[3]: *** [scripts/Makefile.lib:424: arch/arm64/boot/dts/ti/k3-j721e-sk.dtb] Error 1
    make[2]: *** [scripts/Makefile.build:502: arch/arm64/boot/dts/ti] Error 2
    make[1]: *** [Makefile:1467: ti/k3-j721e-sk.dtb] Error 2
    

    Furthermore, this error prevents the build of the k3-j7321e-sk.dtb to be build.

    Regards,
    Tamas

  • Tamas,

    That's not the exact solution. It was a reference dts. You need to add the eeprom mode under wkup_i2c0. Please try that and let me know. 

    Your slave id also should be 0x51.

    Best regards,

    Keerthy 

  • Thanks for clarifying. I made the modifications:

    &wkup_i2c0 {
    	pinctrl-names = "default";
    	pinctrl-0 = <&wkup_i2c0_pins_default>;
    	status = "okay";
    
    	eeprom: eeprom@51 {
    		compatible = "at,24c256";
    		reg = <0x51>;
    	};
    };
    

    I booted the board but the output is still 0xff:

    root@tda4vm-sk:/opt/vision_apps# dmesg | grep i2c
    [    0.762738] i2c_dev: i2c /dev entries driver
    [    0.921875] omap_i2c 42120000.i2c: bus 0 rev0.12 at 400 kHz
    [    0.949839] i2c i2c-1: Added multiplexed i2c bus 2
    [    0.954819] i2c i2c-1: Added multiplexed i2c bus 3
    [    0.967572] omap_i2c 2000000.i2c: bus 1 rev0.12 at 400 kHz
    [    0.973610] omap_i2c 2010000.i2c: bus 4 rev0.12 at 100 kHz
    [    1.001840] i2c i2c-5: Added multiplexed i2c bus 6
    [    1.006817] i2c i2c-5: Added multiplexed i2c bus 7
    [    1.019471] omap_i2c 2030000.i2c: bus 5 rev0.12 at 400 kHz
    [    1.025431] omap_i2c 2050000.i2c: bus 8 rev0.12 at 400 kHz
    root@tda4vm-sk:/opt/vision_apps# i2cdump -y 0 0x51
    No size specified (using byte-data access)
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
    00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    10: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    20: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    30: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    40: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    50: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    60: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    70: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    90: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    b0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    c0: ff ff ff ff ff ff ff ff 01 ff ff ff ff ff ff ff    ........?.......
    d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff    ................
    root@tda4vm-sk:/opt/vision_apps# 
    

    Regards,
    Tamas

  • Tamas,

    There is a different way to read from eeprom using some of the sysfs nodes. As mentioned in the above link that i shared. 

    Have you tried that? 

    Best regards,

    Keerthy