Read more than 256 bytes via i2c with iMX8X

Hello,

I’m currently trying to read data via i2c.
I’m successfully writing and reading data without issue except with a long read command of 457 bytes. In that case, it seems the iMX8X send a NAK after the 256th byte read.

Is there some known limitation in the iMX8X i2c?

Kind regards

Hi @ykrons,

Thanks for reaching out. From the NXP’s Reference Manual for the iMX8X chip, it seems that the I2C is able to deal with up to 256 bytes before automatically sending a NAK as stated below:

I’m checking if there could be a way to change this value or if you’d need to adapt the command in order to keep sending your data. You can find the reference manual here: https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-8-processors/i-mx-8x-family-arm-cortex-a35-3d-graphics-4k-video-dsp-error-correcting-code-on-ddr:i.MX8X

Best regards,

Hi @gclaudino.tx,

Thanks for this information. It is good to have confirmation of this annoying limitation.
I’m looking at the driver but it is not clear how is managed the case of frame bigger than 256 bytes. I would greatly appreciate your feedback on the possible fixes (in the driver) or workaround (in the way to use it).

Regards

Hi,

I think I have identified the problem in the driver. A small test has given good result and I was able to read more than 256 bytes. I will draft a cleaner patch.

Regards

Hi @ykrons,

Thanks for updating. I’m glad you could make a successful test. Please share the resulting patch so that other users in the community could also profit from your findings :slight_smile:

Best regards,

Hi @gclaudino.tx,

After some tests, the following patch seems to fix the 256 bytes read limitation:
0001-i2c-imx-lpi2c-fix-256-bytes-read-limitation.patch (1.9 KB)

Initially, the i2c read routine was waiting the 256th byte to issue a new read command, but it is too late because the i2c block has already send a NACK if there is no read command ready in the FIFO.
The fix just issue the read command at the beginning of a read and not at the end.

I’m a bit surprised to be the only one annoyed by this problem.

Kind regards

1 Like

Hi,

Use this patch carefully … it seems to be bugged with 512+ bytes frames.
I’m trying to fix it

Regards

Hi @ykrons ,

Thanks for sending the patch (and the side note to be careful with it :wink: )
If you have any update on it, feel free to post it here.

Maybe you can also try to contact NXP on their community.

Best Regards
Kevin

Hi,

Here comes a better patch working with all read sizes : 0001-i2c-imx-lpi2c-fix-256-bytes-read-limitation.patch (2.9 KB)

Hope it could help someone

Regards

1 Like