U-Boot中I2C md命令语法疑问:[.0/.1/.2]含义及字节数参数确认
i2c md Command Syntax Explained Hey there! Let's clear up the confusion around the i2c md command's syntax, especially those .0, .1, .2 suffixes and the [# of objects] parameter.
First: Confirming [# of objects]
Yes, you're exactly right—[# of objects] is the number of bytes you want to read from the I2C device. For example, if you run i2c md 0x50 0x00.1 16, you'll read 16 consecutive bytes starting from register 0x00 on the I2C device at address 0x50.
Breaking Down .0, .1, .2
These suffixes define the width of the register address you're targeting (not directly the I2C device address type, though .1 is commonly paired with 7-bit device addresses). Here's what each one does:
.0: No register address required. Use this for I2C devices that don't need a register address to read data—some simple sensors or devices that return data immediately after the read command is sent, or that use an internal address pointer that auto-increments. For example:i2c md 0x48 .0 4This reads 4 bytes from the device at 0x48 without specifying a starting register address.
.1: 1-byte (8-bit) register address. This is the most common use case, typically paired with 7-bit I2C device addresses. When you use this suffix, you're telling U-Boot to send a single byte of register address before starting the read. Example:i2c md 0x50 0x10.1 8Reads 8 bytes starting from the 0x10 register (1-byte address) on device 0x50.
.2: 2-byte (16-bit) register address. This is for devices that require a 16-bit register address, like larger I2C EEPROMs (e.g., 24LC256). Important note: this has nothing to do with 10-bit I2C device addresses—10-bit addresses are handled separately in U-Boot's I2C subsystem. Example:i2c md 0x50 0x100.2 16Reads 16 bytes starting from the 0x100 register (2-byte address) on device 0x50.
A quick side note on 10-bit device addresses: if you need to use one, U-Boot uses a convention where you prefix the 10-bit address with 0x700. For example, a 10-bit address of 0x123 would be specified as 0x700 | 0x123 = 0x823 in the i2c md command.
内容的提问来源于stack exchange,提问作者md.jamal

