|
16 | 16 | #include <dfs_romfs.h> |
17 | 17 | #include <dfs_fs.h> |
18 | 18 | #include <dfs_posix.h> |
19 | | -#include <fal.h> |
20 | 19 |
|
21 | 20 | #if DFS_FILESYSTEMS_MAX < 4 |
22 | 21 | #error "Please define DFS_FILESYSTEMS_MAX more than 4" |
@@ -77,71 +76,49 @@ static int onboard_sdcard_mount(void) |
77 | 76 | #endif |
78 | 77 |
|
79 | 78 | #ifdef BSP_USING_SPI_FLASH_LITTLEFS |
| 79 | +#include <fal.h> |
| 80 | +#define FS_PARTITION_NAME "spiflash0" |
80 | 81 |
|
81 | | -#define FS_PARTITION_NAME "filesystem" |
82 | | - |
83 | | -static void spiflash_mount(void *parameter) |
| 82 | +static int onboard_spiflash_mount(void) |
84 | 83 | { |
85 | 84 | struct rt_device *mtd_dev = RT_NULL; |
| 85 | + |
86 | 86 | fal_init(); |
87 | 87 | mtd_dev = fal_mtd_nor_device_create(FS_PARTITION_NAME); |
88 | 88 | if (!mtd_dev) |
89 | 89 | { |
90 | 90 | LOG_E("Can't create a mtd device on '%s' partition.", FS_PARTITION_NAME); |
91 | 91 | } |
92 | | - while (1) |
93 | | - { |
94 | | - rt_thread_mdelay(500); |
95 | | - if(rt_device_find(FS_PARTITION_NAME) != RT_NULL) |
96 | | - { |
97 | | - if (dfs_mount(FS_PARTITION_NAME, "/flash", "lfs", 0, 0) == RT_EOK) |
98 | | - { |
99 | | - LOG_I("spi flash mount to '/flash'"); |
100 | | - break; |
101 | | - } |
102 | | - else |
103 | | - { |
104 | | - LOG_W("spi flash mount to '/flash' failed!"); |
105 | | - } |
106 | | - } |
107 | | - } |
108 | | -} |
109 | | - |
110 | | -static int onboard_spiflash_mount(void) |
111 | | -{ |
112 | | - rt_thread_t tid; |
113 | 92 |
|
114 | | - if (dfs_mount(FS_PARTITION_NAME, "/flash", "lfs", 0, 0) == RT_EOK) |
| 93 | + if (dfs_mount(FS_PARTITION_NAME, "/spiflash", "lfs", 0, 0) == RT_EOK) |
115 | 94 | { |
116 | | - LOG_I("spi flash mount to '/flash'"); |
| 95 | + LOG_I("spi flash mount to '/spiflash'"); |
117 | 96 | } |
118 | 97 | else |
119 | 98 | { |
120 | | - tid = rt_thread_create("spiflash_mount", spiflash_mount, RT_NULL, |
121 | | - 1024, RT_THREAD_PRIORITY_MAX - 3, 20); |
122 | | - if (tid != RT_NULL) |
| 99 | + dfs_mkfs("lfs", FS_PARTITION_NAME); |
| 100 | + if (dfs_mount(FS_PARTITION_NAME, "/spiflash", "lfs", 0, 0) == RT_EOK) |
123 | 101 | { |
124 | | - rt_thread_startup(tid); |
| 102 | + LOG_I("spi flash mount to '/spiflash'"); |
125 | 103 | } |
126 | 104 | else |
127 | 105 | { |
128 | | - LOG_E("create spiflash_mount thread err!"); |
| 106 | + LOG_E("spi flash failed to mount to '/spiflash'"); |
129 | 107 | } |
130 | 108 | } |
131 | 109 |
|
132 | 110 | return RT_EOK; |
133 | 111 | } |
134 | 112 | #endif |
135 | 113 |
|
136 | | - |
137 | 114 | static const struct romfs_dirent _romfs_root[] = |
138 | 115 | { |
139 | 116 | #ifdef BSP_USING_SDCARD |
140 | 117 | {ROMFS_DIRENT_DIR, "sdcard", RT_NULL, 0}, |
141 | 118 | #endif |
142 | 119 |
|
143 | 120 | #ifdef BSP_USING_SPI_FLASH_LITTLEFS |
144 | | - {ROMFS_DIRENT_DIR, "flash", RT_NULL, 0}, |
| 121 | + {ROMFS_DIRENT_DIR, "spiflash", RT_NULL, 0}, |
145 | 122 | #endif |
146 | 123 | }; |
147 | 124 |
|
|
0 commit comments