|
@@ -1,19 +1,21 @@
|
|
|
/*
|
|
/*
|
|
|
- * Copyright (c) 2006-2021, RT-Thread Development Team
|
|
|
|
|
|
|
+ * Copyright (c) 2006-2026, RT-Thread Development Team
|
|
|
*
|
|
*
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
*
|
|
*
|
|
|
* Change Logs:
|
|
* Change Logs:
|
|
|
- * Date Author Notes
|
|
|
|
|
- * 2018-12-13 balanceTWK add sdcard port file
|
|
|
|
|
- * 2021-05-10 Meco Man fix a bug that cannot use fatfs in the main thread at starting up
|
|
|
|
|
- * 2021-07-28 Meco Man implement romfs as the root filesystem
|
|
|
|
|
|
|
+ * Date Author Notes
|
|
|
|
|
+ * 2018-12-13 balanceTWK add sdcard port file
|
|
|
|
|
+ * 2021-05-10 Meco Man fix a bug that cannot use fatfs in the main thread at starting up
|
|
|
|
|
+ * 2021-07-28 Meco Man implement romfs as the root filesystem
|
|
|
|
|
+ * 2026-01-13 LinuxMint-User add sdcard detect before mount in case auto mount failed
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
#include <rtthread.h>
|
|
#include <rtthread.h>
|
|
|
#include <dfs_romfs.h>
|
|
#include <dfs_romfs.h>
|
|
|
#include <dfs_fs.h>
|
|
#include <dfs_fs.h>
|
|
|
#include <dfs_file.h>
|
|
#include <dfs_file.h>
|
|
|
|
|
+#include "drv_sdmmc.h"
|
|
|
|
|
|
|
|
#if DFS_FILESYSTEMS_MAX < 4
|
|
#if DFS_FILESYSTEMS_MAX < 4
|
|
|
#error "Please define DFS_FILESYSTEMS_MAX more than 4"
|
|
#error "Please define DFS_FILESYSTEMS_MAX more than 4"
|
|
@@ -29,15 +31,28 @@
|
|
|
#ifdef BSP_USING_SDCARD_FATFS
|
|
#ifdef BSP_USING_SDCARD_FATFS
|
|
|
static int onboard_sdcard_mount(void)
|
|
static int onboard_sdcard_mount(void)
|
|
|
{
|
|
{
|
|
|
- if (dfs_mount("sd0", "/sdcard", "elm", 0, 0) == RT_EOK)
|
|
|
|
|
|
|
+ rt_device_t device;
|
|
|
|
|
+
|
|
|
|
|
+ device = rt_device_find("sd0");
|
|
|
|
|
+ if (device == NULL)
|
|
|
{
|
|
{
|
|
|
- LOG_I("SD card mount to '/sdcard'");
|
|
|
|
|
|
|
+ mmcsd_wait_cd_changed(0);
|
|
|
|
|
+ stm32_mmcsd_change();
|
|
|
|
|
+ mmcsd_wait_cd_changed(rt_tick_from_millisecond(500));
|
|
|
|
|
+ device = rt_device_find("sd0");
|
|
|
}
|
|
}
|
|
|
- else
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (device != RT_NULL)
|
|
|
{
|
|
{
|
|
|
- LOG_E("SD card mount to '/sdcard' failed!");
|
|
|
|
|
|
|
+ if (dfs_mount("sd0", "/sdcard", "elm", 0, 0) == RT_EOK)
|
|
|
|
|
+ {
|
|
|
|
|
+ LOG_I("SD card mount to '/sdcard'");
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ LOG_W("SD card mount to '/sdcard' failed!");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
return RT_EOK;
|
|
return RT_EOK;
|
|
|
}
|
|
}
|
|
|
#endif /* BSP_USING_SDCARD_FATFS */
|
|
#endif /* BSP_USING_SDCARD_FATFS */
|
|
@@ -112,3 +127,4 @@ static int filesystem_mount(void)
|
|
|
return RT_EOK;
|
|
return RT_EOK;
|
|
|
}
|
|
}
|
|
|
INIT_APP_EXPORT(filesystem_mount);
|
|
INIT_APP_EXPORT(filesystem_mount);
|
|
|
|
|
+
|