diff --git a/raiden_debug_spi.c b/raiden_debug_spi.c index 65ce32bb8..521539f16 100644 --- a/raiden_debug_spi.c +++ b/raiden_debug_spi.c @@ -343,6 +343,7 @@ #include "usb_device.h" #include +#include #include #include #include @@ -983,6 +984,22 @@ static int get_spi_config_v2(struct raiden_debug_spi_data *ctx_data) 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"