Skip to content

I2C_CommandWriteBulk data corruption due to UART FIFO overflow during large transfers #206

Description

@rahul31124

Description

In src/bus/i2c/i2c.c, the I2C_CommandWriteBulk() function reads bytes directly from UART1_Read() and immediately passes them to I2C_Transmit() inside a tight loop.

Since the host transmits UART data significantly faster than the I2C bus can transmit bytes, the PIC microcontroller's 4-byte hardware UART FIFO overflows during large transfers (for example, 128-byte OLED frame updates).

As a result:

  • UART bytes are dropped.
  • I2C payloads become corrupted.
  • The firmware enters an inconsistent communication state.
  • Mobile and desktop clients eventually encounter persistent TimeoutException errors.

Expected Behavior

The firmware should decouple UART reception from I2C transmission by buffering the incoming payload before starting the I2C transfer.

A possible implementation is:

  1. Allocate a RAM buffer (up to 255 bytes, depending on the protocol limit

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions