Edward O'Callaghan submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Edward O'Callaghan: Looks good to me, approved Anastasia Klimchuk: Looks good to me, approved
raiden_debug_spi: Add more informative error message when WP is enabled

Current error messages are not very helpful when attempting to flash a
target that has WP enabled. This change checks for the USB_SPI_DISABLED
error that occurs in this case and gives a more informative error
message.

BUG=b:210645611
TEST=Tested with WP enabled and disable to verify that error message is
displayed properly

Signed-off-by: Robert Zieba <robertzieba@google.com>
Change-Id: Ib1e8383baa9c3ea41ab1079af12e3dc8cdff90ae
Reviewed-on: https://review.coreboot.org/c/flashrom/+/62909
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
---
M raiden_debug_spi.c
1 file changed, 17 insertions(+), 0 deletions(-)

diff --git a/raiden_debug_spi.c b/raiden_debug_spi.c
index 65ce32b..521539f 100644
--- a/raiden_debug_spi.c
+++ b/raiden_debug_spi.c
@@ -343,6 +343,7 @@
#include "usb_device.h"

#include <libusb.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -983,6 +984,22 @@
return status;
}

+ /*
+ * Check if we received an error from the device. An error will have no
+ * response data, just the packet_id and status_code.
+ */
+ const size_t err_packet_size = sizeof(struct usb_spi_response_v2) -
+ USB_SPI_PAYLOAD_SIZE_V2_RESPONSE;
+ if (rsp_config.packet_size == err_packet_size &&
+ rsp_config.packet_v2.rsp_start.status_code !=
+ USB_SPI_SUCCESS) {
+ status = rsp_config.packet_v2.rsp_start.status_code;
+ if (status == USB_SPI_DISABLED) {
+ msg_perr("Raiden: Target SPI bridge is disabled (is WP enabled?)\n");
+ return status;
+ }
+ }
+
msg_perr("Raiden: Packet is not a valid config\n"
" config attempt = %d\n"
" packet id = %u\n"

To view, visit change 62909. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ib1e8383baa9c3ea41ab1079af12e3dc8cdff90ae
Gerrit-Change-Number: 62909
Gerrit-PatchSet: 6
Gerrit-Owner: Robert Zieba <robertzieba@google.com>
Gerrit-Reviewer: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-Reviewer: Diana Zigterman <dzigterman@google.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-Reviewer: Jon Murphy <jpmurphy@google.com>
Gerrit-Reviewer: Karthik Ramasubramanian <kramasub@google.com>
Gerrit-Reviewer: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-CC: Eric Peers <epeers@google.com>
Gerrit-CC: Paul Menzel <paulepanter@mailbox.org>
Gerrit-CC: Rob Barnes <robbarnes@google.com>
Gerrit-MessageType: merged