espressif / qemu

Fork of QEMU with Espressif patches. See Wiki for details.
https://github.com/espressif/esp-toolchain-docs/blob/main/qemu/README.md
Other
230 stars 61 forks source link

esp32_i2c: allow to read many bytes (QEMU-95) #61

Closed knw1 closed 1 year ago

knw1 commented 1 year ago

Hi There!

The pull request provides a fix that solves a problem of reading a few bytes at once (as one transaction) from an emulated i2c device

I encountered the problem during using the example "i2c_tools". Consider the following i2c-tools cmd:

i2c-tools> i2cget -c 0x48 -r 0x00 -l 0x05
0x19 0xee 0xee 0xee 0x00 
i2c-tools> 

There is an error on stdout/stderr of the qemu during performing above cmd:

qemu-system-xtensa: esp32_i2c: read I2C FIFO while it is empty
qemu-system-xtensa: esp32_i2c: read I2C FIFO while it is empty
qemu-system-xtensa: esp32_i2c: read I2C FIFO while it is empty

Response after applying my changes

i2c-tools> i2cget -c 0x48 -r 0x00 -l 0x05
0x19 0x00 0xff 0xff 0xff 
i2c-tools> 

No error on QEMU stdout/stderr. Got expected result, emulated TMP105 returns 0xff when i2c master wants to read more than two bytes

If you need more info, let me know.

Best regards, Karol

knw1 commented 1 year ago

ping

knw1 commented 1 year ago

Corrected according to your suggestion :)

knw1 commented 1 year ago

Thanks a lot for the fix, and sorry I have overlooked your PR when doing the recent rebase to v7.2.0. One small comment, which I can also apply myself when cherry-picking your commit, if you agree.

I prepared a correction and squashed the commits so there is only one commit.

igrr commented 1 year ago

Cherry-picked as https://github.com/espressif/qemu/commit/db73e5e237c1e89b6952d3d7a06f20d76a2ce237, thank you for the fix!