Hi,
I am reading an I2C device on a verdin-imx8mm in user space with:
$ time i2cget -y 1 0x20 0x00
real 0m0.022s
user 0m0.005s
sys 0m0.000s
So it takes about 22ms to read out one I2C register? Is this normal?
Thanks in advance
Chris
Hi,
I am reading an I2C device on a verdin-imx8mm in user space with:
$ time i2cget -y 1 0x20 0x00
real 0m0.022s
user 0m0.005s
sys 0m0.000s
So it takes about 22ms to read out one I2C register? Is this normal?
Thanks in advance
Chris
Hi, I’m the Toradex AI Assistant.
I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.
Hello Chris,
Thank you for your question!
The Verdin iMX8M Mini implements the I2C V2.1 specification, and while I2C transactions are typically quick, seeing approximately 22ms for a single i2cget read from user space can indeed seem higher than expected for a standard I2C operation. Several factors can influence this timing:
1. Userspace Overhead
The i2cget command operates from user space, adding system-call and context-switching overhead compared to direct kernel access or hardware-level control.
2. I2C Bus Speed
Check what speed your I2C bus is configured for (standard mode 100kHz, fast mode 400kHz, or higher). Slower bus speeds will increase transaction time.
You can verify or set the bus speed in the device tree or by checking the kernel messages during boot.
3. Bus Conflicts
Multiple devices on the same bus or heavy traffic can slow down transactions.
4. System Load
Running many high-priority processes can also delay userspace executions like i2cget.
To further investigate:
If you like, I can provide more general guidance about optimizing I2C performance on the Verdin iMX8M Mini.
Reference:
Best regards,
Toradex AI Assistant.
Hello @chriz,
i2cget
is a command-line tool that introduces significant overhead unrelated to actual I2C bus performance. The measured time includes process startup, system call overhead, and shell interaction—not just I2C communication.
For accurate timing, use a persistent userspace program (e.g., C using /dev/i2c-*
)
The actual speed to read a register will be slightly higher than the time it takes to send the number of bits transacted in a single register read at the used I2C bus frequency (usually 100 kHz or 400 kHz).
For more information, please check the I2C specification: https://www.nxp.com/docs/en/user-guide/UM10204.pdf
Best Regards,
Bruno
Hi Bruno,
Thanks for the reply. I understand. The time without the overhead is about 2ms to read a register which is okish.
Cheers,
Chris
Hello @chriz,
Thanks for the update.
If you end up needing the I2C transactions to be faster at some point in the future, you could consider checking the I2C frequency on the device tree.
Most I2C devices support an I2C frequency of 400 kHz (fast mode).
Best Regards,
Bruno