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.

I2C EEPROM early access via sysfs

Hello,

I am trying to run my application as init via the kernel command line (I use Linux 3.20 from AM335x Processor SDK v1). My program must read data from I2C EEPROM, make some action and then call /bin/init. But despite the fact that at24 driver already loaded, I cannot access the EEPROM via sysfs (cannot open /sys/bus/i2c/devices/1-0050/eeprom). I think there is because of udev has not been started. After startup completion EEPROM becomes accessible via sysfs.

What can I do to get access to EEPROM in my init application?

  • Dear Lev,
    Actually, to get SYSFS entries, you have to mount the SYSFS.
    So , you have to add the mount stuff in your init file.

    Could you please share that why you are trying like this (init binary), so that we can provide or see any other method available instead.
  • Hi Lev Urusov,

    I have created the start-up script which will mount SYSFS and accessing the EEPROM then calling the init.

    Here is the script below (manual_init) used and tested.

    vi /manual_init

    #!/bin/sh

    echo "Hi I'm the startup script instead of init"

    mount -t sysfs sys /sys/

    echo "SYSFS mount done!"

    cat /sys/bus/i2c/devices/0-0050/eeprom | od -x >> /eeprom_data.txt

    exec /sbin/init 5

    chmod 777 /manual_init

     

    Boot command used :

    setenv bootargs 'console=ttyS0,115200n8 ip=dhcp rootwait=1 init=/manual_init root=/dev/nfs nfsroot=10.100.1.3:/usr/local/k2hk_fs_3_01_04_07,v3,tcp rw'

     

    ------------------------