Skip to content

Commit b265df8

Browse files
committed
drivers: mspi: fix hard fault when receiving data
Fix hard fault that occurs when receiving data caused by memory access violation. Signed-off-by: Magdalena Pastula <[email protected]>
1 parent 6e4a44d commit b265df8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

drivers/mspi/mspi_nrfe.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <zephyr/sys/atomic.h>
1616
#endif
1717
#include <zephyr/logging/log.h>
18-
LOG_MODULE_REGISTER(mspi_nrfe, CONFIG_MSPI_LOG_LEVEL);
18+
LOG_MODULE_REGISTER(mspi_nrfe, LOG_LEVEL_DBG);
1919

2020
#include <hal/nrf_gpio.h>
2121
#include <drivers/mspi/nrfe_mspi.h>
@@ -183,7 +183,8 @@ static void ipc_recv_clbk(const void *data, size_t len)
183183
}
184184
}
185185

186-
LOG_DBG("Received msg with opcode: %d", response->opcode);
186+
// LOG_DBG("Received msg with opcode: %d", response->opcode);
187+
LOG_HEXDUMP_DBG((uint8_t *)data, len, "RX IPC data:");
187188
}
188189

189190
/**
@@ -519,8 +520,10 @@ static int xfer_packet(struct mspi_xfer_packet *packet, uint32_t timeout)
519520

520521
/* Wait for the transfer to complete and receive data. */
521522
if ((packet->dir == MSPI_RX) && (ipc_receive_buffer != NULL) && (ipc_received > 0)) {
522-
memcpy((void *)packet->data_buf, (void *)ipc_receive_buffer, ipc_received);
523-
packet->num_bytes = ipc_received;
523+
/* Writing to packet->num_bytes causes memory access errors, so for now
524+
number of received data is stored in the first byte in data buffer. */
525+
packet->data_buf[0] = ipc_received;
526+
memcpy((void *)(packet->data_buf + 1), (void *)ipc_receive_buffer, ipc_received);
524527

525528
/* Clear the receive buffer pointer and size */
526529
ipc_receive_buffer = NULL;

0 commit comments

Comments
 (0)