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.

Use uboot to probe an I2C bus and act differently if there is or isn't a device there

I would like to use uboot to probe the I2C bus and record the existence of a device.  If the device is there, I would like to change some boot parameters.

The command I would like to run is something like
if i2c probe = 5C; then setenv otherbootargs 'do stuff if device'; else setenv otherbootargs 'do stuff if no device'; fi

But this obviously won't work.  I don't know how to make uboot evaluate the conditional 'if' statement based on the return value of the i2c probe command.  Is this even possible? How might I make it work?

  • Hi Nick,

    It is possible to use "i2c probe" command in if statement in the u-boot. I'll offer you one working example which could be executed in the u-boot prompt:

    if i2c probe = 4A;  then setenv bootdelay '20'; else setenv bootdelay '5'; fi

    Let me know if this example solve your issue.

    BR

    Tsvetolin Shulev