From e7a1e9675754991beb08a01e16154311ec4ffb96 Mon Sep 17 00:00:00 2001 From: Carl John Kugler III Date: Mon, 21 Jun 2021 17:36:47 -0600 Subject: [PATCH] Pull request https://github.com/carlk3/no-OS-FatFS-SD-SPI-RPi-Pico/pull/5#issue-674957974 Bug in ff_getcwd when FF_VOLUMES < 2 --- .gitmodules | 0 FatFs_SPI/sd_driver/sd_card.c | 3 ++- FatFs_SPI/src/ff_stdio.c | 2 ++ example/CMakeLists.txt | 3 ++- 4 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e69de29 diff --git a/FatFs_SPI/sd_driver/sd_card.c b/FatFs_SPI/sd_driver/sd_card.c index f47d645..39c5df1 100644 --- a/FatFs_SPI/sd_driver/sd_card.c +++ b/FatFs_SPI/sd_driver/sd_card.c @@ -466,7 +466,8 @@ static int sd_cmd(sd_card_t *this, const cmdSupported cmd, uint32_t arg, return SD_BLOCK_DEVICE_ERROR_NO_DEVICE; // No device } if (response & R1_COM_CRC_ERROR) { - DBG_PRINTF("CRC error CMD:%d response 0x%" PRIx32 "\n", cmd, response); + if (ACMD23_SET_WR_BLK_ERASE_COUNT != cmd) + DBG_PRINTF("CRC error CMD:%d response 0x%" PRIx32 "\n", cmd, response); return SD_BLOCK_DEVICE_ERROR_CRC; // CRC error } if (response & R1_ILLEGAL_COMMAND) { diff --git a/FatFs_SPI/src/ff_stdio.c b/FatFs_SPI/src/ff_stdio.c index 9b22b16..5bf06ca 100644 --- a/FatFs_SPI/src/ff_stdio.c +++ b/FatFs_SPI/src/ff_stdio.c @@ -198,6 +198,8 @@ char *ff_getcwd(char *pcBuffer, size_t xBufferLength) { else p = buf; strncpy(pcBuffer, p, xBufferLength); + } else { + strncpy(pcBuffer, buf, xBufferLength); } return pcBuffer; } else { diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index c99d70e..0b1d8b4 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.13) -# Pull in Pico SDK (must be before project) +# initialize the SDK based on PICO_SDK_PATH +# note: this must happen before project() include(pico_sdk_import.cmake) project(FatFS_SPI_example C CXX ASM)