Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 16 bit address byte order for i2c transactions #16

Open
wants to merge 1 commit into
base: khadas-vims-nougat
Choose a base branch
from

Conversation

chriskeeser
Copy link

@chriskeeser chriskeeser commented Jul 29, 2021

Why the change?

When setting the read/write pointer for an EEPROM that uses 16 bit addressing to access the internal memory, the bytes are sent [high byte] [low byte]. This commit fixes the byte ordering when sending the address to the device.

Problem example

I used an I2C EEPROM with 16 bit addressing and stored a string into the memory for recall within u-boot. Here is the information stored in the eeprom, and being read out again from within linux to show that is stored correctly:

image

image

but, when I read it from u-boot, the data was incorrect

image

using an i2c protocol analyzer to observe the transaction showed the problem. The code is reading 16 bytes at a time, and setting the address after each read of 16 bytes. The address is incorrect (high and low bytes are swapped)

image

image

I can further illustrate the problem by forcing the swap of the bytes manually in the command

image

The fix

As shown in the code, the fix is to properly send the address when doing a read or a write. After making the change, the data can be read correctly from the i2c device.

image

When setting the read/write pointer for an EEPROM that uses 16 bit addressing to access the internal memory, the bytes are sent [high byte] [low byte].  This commit fixes the byte ordering when sending the address to the device.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant