From a56fc1dcdcefb00a2a53394c7ffbad1d1f0cd280 Mon Sep 17 00:00:00 2001 From: Fancy code <258828110.@qq.com> Date: Mon, 22 Jul 2024 10:49:44 +0800 Subject: [PATCH] Fixed:sd card format bug. --- hal/src/SdCardHal.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hal/src/SdCardHal.cpp b/hal/src/SdCardHal.cpp index 42411ae..000edd4 100644 --- a/hal/src/SdCardHal.cpp +++ b/hal/src/SdCardHal.cpp @@ -65,6 +65,12 @@ StatusCode SdCardHal::GetCapacity(unsigned long long &totalSizeMB, unsigned long LogInfo("Used size: %llu MB\n", usedSizeMB); return CreateStatusCode(STATUS_CODE_OK); } +/** + * @brief To format an SD card, you normally need to unmount the SD card before formatting it. However, when the SD card + * is abnormal (usually it cannot be mounted or unmounted), you still need to execute the format command operation, + * because some cards can be restored to normal by formatting when they are abnormal. + * @return StatusCode + */ StatusCode SdCardHal::FormatSDCard(void) { UnInit(); @@ -221,7 +227,7 @@ void SdCardHal::UnmountSdCard(void) * card node to be occupied and cannot be loaded. To find problems and optimize them, it is especially important to * check whether there are any omissions. */ - sprintf(command, "umount -fl %s", SD_CARD_MOUNT_PATH); + sprintf(command, "umount -fl %s", SD_CARD_DEVICE); int ret = fx_system(command); if (ret != 0) { LogError("Format sd card failed [%s].\n", SD_CARD_DEVICE);