Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry on SDIO Write errors. #211

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions lib/BlueSCSI_platform_RP2040/rp2040_sdio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ static struct {
uint32_t end_token_buf[3]; // CRC and end token for write block
sdio_status_t wr_status;
uint32_t card_response;
uint8_t retries;

// Variables for block reads
// This is used to perform DMA into data buffers and checksum buffers separately.
Expand Down Expand Up @@ -706,19 +707,15 @@ sdio_status_t __not_in_flash_func(rp2040_sdio_tx_start)(const uint8_t *buffer, u
g_sdio.total_blocks = num_blocks;
g_sdio.blocks_checksumed = 0;
g_sdio.checksum_errors = 0;
g_sdio.retries = 0;
g_sdio.wr_status = SDIO_OK;

// Compute first block checksum
sdio_compute_next_tx_checksum();

// Start first DMA transfer and PIO
sdio_start_next_block_tx();

if (g_sdio.blocks_checksumed < g_sdio.total_blocks)
{
// Precompute second block checksum
sdio_compute_next_tx_checksum();
}

return SDIO_OK;
}

Expand Down Expand Up @@ -788,23 +785,32 @@ static void __not_in_flash_func(rp2040_sdio_tx_irq)()
g_sdio.wr_status = check_sdio_write_response(g_sdio.card_response);

if (g_sdio.wr_status != SDIO_OK)
{
rp2040_sdio_stop();
return;
}
{
g_sdio.retries++;
if (g_sdio.retries > 3)
{
rp2040_sdio_stop();
return;
}
else if (g_sdio.blocks_done < g_sdio.total_blocks)
{
g_sdio.wr_status = SDIO_OK;
sdio_start_next_block_tx();
g_sdio.transfer_state = SDIO_TX;
return;
}
}

g_sdio.retries = 0;
if (g_sdio.blocks_checksumed < g_sdio.total_blocks)
sdio_compute_next_tx_checksum();

g_sdio.blocks_done++;
if (g_sdio.blocks_done < g_sdio.total_blocks)
{
sdio_start_next_block_tx();
g_sdio.transfer_state = SDIO_TX;

if (g_sdio.blocks_checksumed < g_sdio.total_blocks)
{
// Precompute the CRC for next block so that it is ready when
// we want to send it.
sdio_compute_next_tx_checksum();
}
}
else
{
Expand Down