Skip to content

Commit a716126

Browse files
authored
Merge pull request #4389 from mysterywolf/sdcard
[bug][bsp][stm32][pandora] cannot use fatfs in the main thread at starting up
2 parents 53b3089 + 9da70b7 commit a716126

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

bsp/stm32/stm32l475-atk-pandora/board/ports/sdcard_port.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Change Logs:
77
* Date Author Notes
88
* 2018-12-14 balanceTWK add sdcard port file
9+
* 2021-02-26 Meco Man fix a bug that cannot use fatfs in the main thread at starting up
910
*/
1011

1112
#include <rtthread.h>
@@ -46,16 +47,24 @@ int stm32_sdcard_mount(void)
4647
{
4748
rt_thread_t tid;
4849

49-
tid = rt_thread_create("sd_mount", sd_mount, RT_NULL,
50-
1024, RT_THREAD_PRIORITY_MAX - 2, 20);
51-
if (tid != RT_NULL)
50+
if (dfs_mount("sd0", "/", "elm", 0, 0) == RT_EOK)
5251
{
53-
rt_thread_startup(tid);
52+
LOG_I("sd card mount to '/'");
5453
}
5554
else
5655
{
57-
LOG_E("create sd_mount thread err!");
56+
tid = rt_thread_create("sd_mount", sd_mount, RT_NULL,
57+
1024, RT_THREAD_PRIORITY_MAX - 2, 20);
58+
if (tid != RT_NULL)
59+
{
60+
rt_thread_startup(tid);
61+
}
62+
else
63+
{
64+
LOG_E("create sd_mount thread err!");
65+
}
5866
}
67+
5968
return RT_EOK;
6069
}
6170
INIT_APP_EXPORT(stm32_sdcard_mount);

0 commit comments

Comments
 (0)