Skip to content

Commit 006137c

Browse files
committed
drivers: mspi: prepare APP side driver for receiving data
Fixed hard fault that occurs when receiving data caused by memory access violation and changed logging so that all received data is printed, not only an opcode. Signed-off-by: Magdalena Pastula <[email protected]>
1 parent 1758d0b commit 006137c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/mspi/mspi_nrfe.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static void ep_recv(const void *data, size_t len, void *priv)
157157
}
158158
}
159159

160-
LOG_DBG("Received msg with opcode: %d", response->opcode);
160+
LOG_HEXDUMP_DBG((uint8_t *)data, len, "Received msg:");
161161
}
162162

163163
/**
@@ -473,8 +473,15 @@ static int xfer_packet(struct mspi_xfer_packet *packet, uint32_t timeout)
473473

474474
/* Wait for the transfer to complete and receive data. */
475475
if ((packet->dir == MSPI_RX) && (ipc_receive_buffer != NULL) && (ipc_received > 0)) {
476-
memcpy((void *)packet->data_buf, (void *)ipc_receive_buffer, ipc_received);
477-
packet->num_bytes = ipc_received;
476+
/*
477+
* It is not possible to check whether received data is valid, so packet->num_bytes
478+
* should always be equal to ipc_received. If it is not, then something went wrong.
479+
*/
480+
if (packet->num_bytes != ipc_received) {
481+
rc = -EIO;
482+
} else {
483+
memcpy((void *)packet->data_buf, (void *)ipc_receive_buffer, ipc_received);
484+
}
478485

479486
/* Clear the receive buffer pointer and size */
480487
ipc_receive_buffer = NULL;

0 commit comments

Comments
 (0)