zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.7k stars 6.54k forks source link

eeprom_target with 16 bit addressing does not work properly on rpi_pico #75463

Closed Manu3l0us closed 2 months ago

Manu3l0us commented 3 months ago

I'm on a RP2040 using eeprom_target to emulate a 4KB EEPROM with 4KB addressing. When the Linux host reads my emulated EEPROM using the 24c32 driver in 128 byte chunks, it issues an 2byte address write before each chunk. The issue is, that the first, most significant address byte sometimes gets lost, so when I read the EEPROM, I see the first 256 bytes over and over again. This seems to happen because dw->state does not stay in I2C_DW_CMD_SEND after the first byte, so slave_cb->write_requested(dw->slave_cfg) is called again and the MSB of the address reset. This is highly timing dependent,

I tried building a workaround in the i2c_dw_isr but was not successful yet.

To Reproduce Steps to reproduce the behavior:

  1. build application with emulated i2c eeprom and 16 bit addressing
  2. issue reads with addressing in rapid succession
  3. check results on host for aliasing

Expected behavior 16-bit I2C EEPROM emulation works correctly in conjunction if the i2c_dw driver on RP2040

Impact Only the first 256 bytes can be read reliably

Environment

henrikbrixandersen commented 3 months ago

Please use our bug template when reporting bugs. You need to edit this issue to include the information requested in https://github.com/zephyrproject-rtos/zephyr/blob/main/.github/ISSUE_TEMPLATE/001_bug_report.md (e.g. we have no idea which revision of Zephyr, you are reporting this against).

Manu3l0us commented 3 months ago

Added info about toolchain and Zephyr commit hash. I can provide detailed traces (including logic analyzer) next week.