From ca8aa64b5a803cb6b592ac5f3de788ca8078237a Mon Sep 17 00:00:00 2001 From: Rob Meades Date: Tue, 22 May 2018 16:13:29 +0100 Subject: [PATCH 1/2] Make the test for success when programming single blocks the same as that for programming multiple blocks (i.e. the response must be SPI_DATA_ACCEPTED). Otherwise a response of zero (e.g. from a slow SD card) was being treated as success. --- SDBlockDevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDBlockDevice.cpp b/SDBlockDevice.cpp index 06728268b5..1601449890 100644 --- a/SDBlockDevice.cpp +++ b/SDBlockDevice.cpp @@ -444,7 +444,7 @@ int SDBlockDevice::program(const void *b, bd_addr_t addr, bd_size_t size) response = _write(buffer, SPI_START_BLOCK, _block_size); // Only CRC and general write error are communicated via response token - if ((response == SPI_DATA_CRC_ERROR) || (response == SPI_DATA_WRITE_ERROR)) { + if (response != SPI_DATA_ACCEPTED) { debug_if(SD_DBG, "Single Block Write failed: 0x%x \n", response); status = SD_BLOCK_DEVICE_ERROR_WRITE; } From 3e23227be6696a4ec44fe1390a4bc95b347c7761 Mon Sep 17 00:00:00 2001 From: Rob Meades Date: Tue, 22 May 2018 16:31:57 +0100 Subject: [PATCH 2/2] Increase the default command timeout to 10 seconds in order to accommodate more SD cards; the very boring Kingston brand 8GB Micro SD HC cards available from Amazon (https://www.amazon.co.uk/gp/product/B001CQT0X4) don't work with the default command timeout of 5 seconds. --- config/mbed_lib.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/mbed_lib.json b/config/mbed_lib.json index 50407ccae6..8af1ef188e 100644 --- a/config/mbed_lib.json +++ b/config/mbed_lib.json @@ -7,7 +7,7 @@ "SPI_CLK": "NC", "DEVICE_SPI": 1, "FSFAT_SDCARD_INSTALLED": 1, - "CMD_TIMEOUT": 5000, + "CMD_TIMEOUT": 10000, "CMD0_IDLE_STATE_RETRIES": 5, "SD_INIT_FREQUENCY": 100000 },