MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / flash_init

Function flash_init

bsp/mm32f526x/drivers/drv_flash.c:102–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100#endif
101
102int flash_init(void)
103{
104#ifdef OCFLASH_USE_FAL
105 fal_init();
106#endif
107#ifdef OCFLASH_USE_LFS
108 struct rt_device *flash_dev = fal_mtd_nor_device_create(FS_PARTITION_NAME);
109
110 if (flash_dev == NULL)
111 {
112 rt_kprintf("Can't create a mtd device on '%s' partition.\n", FS_PARTITION_NAME);
113 }
114 else
115 {
116 rt_kprintf("Create a mtd device on the %s partition of flash successful.\n", FS_PARTITION_NAME);
117 }
118
119 if (rt_device_find(FS_PARTITION_NAME) != RT_NULL)
120 {
121 if (dfs_mount(FS_PARTITION_NAME, "/", "lfs", 0, 0) == RT_EOK)
122 {
123 rt_kprintf("onchip lfs filesystem mount to '/'\n");
124 }
125 else
126 {
127 dfs_mkfs("lfs", FS_PARTITION_NAME);
128 if (dfs_mount(FS_PARTITION_NAME, "/", "lfs", 0, 0) == RT_EOK)
129 {
130 rt_kprintf("onchip lfs filesystem mount to '/' with mkfs\n");
131 }
132 else
133 {
134 rt_kprintf("onchip lfs filesystem mount to '/' failed!\n");
135 }
136 }
137 }
138 else
139 {
140 rt_kprintf("find filesystem portion failed\r\n");
141 }
142#endif
143 return 0;
144}
145INIT_APP_EXPORT(flash_init);

Callers

nothing calls this directly

Calls 6

fal_initFunction · 0.85
rt_kprintfFunction · 0.85
rt_device_findFunction · 0.85
dfs_mountFunction · 0.50
dfs_mkfsFunction · 0.50

Tested by

no test coverage detected