diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2015-03-13 07:26:16 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2015-03-13 07:26:16 -0600 |
commit | 0f2171342318f0ffb29bfb0f0fe14682ac2e54b3 (patch) | |
tree | 73a9ae5523c37b32cfff733cd08ae8f538d70dfd /nuttx/drivers/mmcsd | |
parent | 70cb75adaf3243478276cebf367c5f47c4725715 (diff) | |
download | px4-nuttx-0f2171342318f0ffb29bfb0f0fe14682ac2e54b3.tar.gz px4-nuttx-0f2171342318f0ffb29bfb0f0fe14682ac2e54b3.tar.bz2 px4-nuttx-0f2171342318f0ffb29bfb0f0fe14682ac2e54b3.zip |
Debugging and manuals (this one https://www.sdcard.org/downloads/pls/simplified_specs/part1_410.pdf
and this one https://www.sdcard.org/downloads/pls/simplified_specs/part1_410.pdf) shows that ACMD23
must be preceeded with CMD55 command as any other ACMD commands.
Also, after the block reading wait loop must be inserted before writing the next block of data to
the sd card
From Dmitry Nikolaev via Jussi Kivilinna
Diffstat (limited to 'nuttx/drivers/mmcsd')
-rw-r--r-- | nuttx/drivers/mmcsd/mmcsd_spi.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/nuttx/drivers/mmcsd/mmcsd_spi.c b/nuttx/drivers/mmcsd/mmcsd_spi.c index 3990e517a..19f0552cd 100644 --- a/nuttx/drivers/mmcsd/mmcsd_spi.c +++ b/nuttx/drivers/mmcsd/mmcsd_spi.c @@ -1243,7 +1243,7 @@ static ssize_t mmcsd_read(FAR struct inode *inode, unsigned char *buffer, response = mmcsd_sendcmd(slot, &g_cmd18, offset); if (response != MMCSD_SPIR1_OK) { - fdbg("CMD118 failed: R1=%02x\n", response); + fdbg("CMD18 failed: R1=%02x\n", response); goto errout_with_eio; } @@ -1402,6 +1402,13 @@ static ssize_t mmcsd_write(FAR struct inode *inode, const unsigned char *buffer, if (IS_SD(slot->type)) { + response = mmcsd_sendcmd(slot, &g_cmd55, 0); + if (response != MMCSD_SPIR1_OK) + { + fdbg("CMD55 failed: R1=%02x\n", response); + goto errout_with_sem; + } + response = mmcsd_sendcmd(slot, &g_acmd23, nsectors); if (response != MMCSD_SPIR1_OK) { @@ -1431,6 +1438,12 @@ static ssize_t mmcsd_write(FAR struct inode *inode, const unsigned char *buffer, goto errout_with_sem; } buffer += SECTORSIZE(slot); + + if (mmcsd_waitready(slot) != OK) + { + fdbg("Failed: card is busy\n"); + goto errout_with_sem; + } } /* Send the stop transmission token */ |