Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions bsp/stm32/stm32f407-atk-explorer/board/ports/drv_filesystem.c
Original file line number Diff line number Diff line change
@@ -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
*
* 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 <dfs_romfs.h>
#include <dfs_fs.h>
#include <dfs_file.h>
#include "drv_sdmmc.h"

#if DFS_FILESYSTEMS_MAX < 4
#error "Please define DFS_FILESYSTEMS_MAX more than 4"
Expand All @@ -29,15 +31,28 @@
#ifdef BSP_USING_SDCARD_FATFS
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;
}
#endif /* BSP_USING_SDCARD_FATFS */
Expand Down Expand Up @@ -112,3 +127,4 @@ static int filesystem_mount(void)
return RT_EOK;
}
INIT_APP_EXPORT(filesystem_mount);

Loading