BusPirate / Bus_Pirate

Community driven firmware and hardware for Bus Pirate version 3 and 4
625 stars 131 forks source link

Binary SPI write-then-read doesn't confirm when there's nothing to read #158

Open mpasternacki opened 3 years ago

mpasternacki commented 3 years ago

In binary SPI mode, the write-then-read command is supposed to send a confirmation byte (0x01) when the operation is complete. This happens in spi_read_to_uart, which is called only when read > 0.

When there is 0 bytes to read, BusPirate doesn't send any confirmation (and application needs to guess how long it needs to sleep to use SPI again without interfering).

Flashrom uses write-then-read without read to send commands (e.g. erase, program page). It waits for confirmation byte, which never arrives, so flashrom hangs.

This patch fixes the problem. I tested that the confirmation byte is sent and that flashrom no longer hangs.