raid_debug_spi.c: USB SPI Protocol Retry Mechanism

Adds support for a retry mechanism in Flashrom. This overcomes a problem
with the ServoMicro where USB packets can be ack'd by the device without
triggering interrupts or loading data into the USB endpoints. The retry
mechanism attempts the USB read 3 times before reattempting the write call
to avoid performing multiple SPI transfers due to a USB problem. This
process repeats 3 times before we return the last error code. Intermediary
problems are reported in the status code.

BUG=chromium:952494
BRANCH=none
TEST=Manual testing of ServoMicro and Flashrom when performing
reads, writes, and verifications of the EC firmware on Nami.
* sudo emerge sys-apps/flashrom
* sudo flashrom --programmer raiden_debug_spi -v bios_good.bin
Tests of the retry mechanism were performed with a modified USB
cable with data lines exposed for probing and tampering.

Change-Id: I1a883661a1a1c299582da612c7f24cc6481c16da
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/flashrom/+/2038271
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Commit-Queue: Brian Nemec <bnemec@chromium.org>
Commit-Queue: Ruben Rodriguez Buchillon <coconutruben@chromium.org>
Tested-by: Brian Nemec <bnemec@chromium.org>
1 file changed