3e4797c63c
#### 为什么提交这份PR (why to submit this PR) 原版编译报错:Static declaration of 'romfs_root' follows non-static declaration in dfs_romfs.h 原因为:在`board/ports/drv_filesystem.c`71行用`static`定义了常量`romfs_root`,而在`rt-thread/components/dfs/dfs_v1/filesystems/romfs/dfs_romfs.h`29行,有它的外部引用: ``` extern const struct romfs_dirent romfs_root; ``` Original compilation error: Static declaration of 'romfs_ root' follows non-static declaration in dfs_romfs. h The reason is: in 'board/ports/drv_filesystem.c' line 71 use `static` define `romfs_root`, while in `rt-thread/components/dfs/dfs_v1/filesystems/romfs/dfs_romfs.h` line 29, with its external reference: ``` extern const struct romfs_dirent romfs_root; ``` #### 你的解决方案是什么 (what is your solution) 在`drv_filesystem.c`中,不可以用static修饰这个常量,故去掉`static`关键字。 In `board/ports/drv_filesystem.c`, it is not allowed to define this constant with static, so the `static` keyword must be removed. #### 在什么测试环境下测试通过 (what is the test environment) 正点原子潘多拉开发板 stm32l475-atk-pandora
93 lines
2.0 KiB
C
93 lines
2.0 KiB
C
/*
|
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*
|
|
* Change Logs:
|
|
* Date Author Notes
|
|
* 2018-12-14 balanceTWK add sdcard port file
|
|
* 2021-02-26 Meco Man fix a bug that cannot use fatfs in the main thread at starting up
|
|
*/
|
|
|
|
#include <rtthread.h>
|
|
#include <dfs_elm.h>
|
|
#include <dfs_fs.h>
|
|
#include <dfs_file.h>
|
|
#include <dfs_romfs.h>
|
|
|
|
#if DFS_FILESYSTEMS_MAX < 4
|
|
#error "Please define DFS_FILESYSTEMS_MAX more than 4"
|
|
#endif
|
|
#if DFS_FILESYSTEM_TYPES_MAX < 4
|
|
#error "Please define DFS_FILESYSTEM_TYPES_MAX more than 4"
|
|
#endif
|
|
|
|
#define DBG_TAG "app.filesystem"
|
|
#define DBG_LVL DBG_INFO
|
|
#include <rtdbg.h>
|
|
|
|
#ifdef BSP_USING_SDCARD_FATFS
|
|
#include <drv_spi.h>
|
|
#include <spi_msd.h>
|
|
static int rt_hw_spi1_tfcard(void)
|
|
{
|
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
|
rt_hw_spi_device_attach("spi1", "spi10", GET_PIN(C, 3));
|
|
return msd_init("sd0", "spi10");
|
|
}
|
|
INIT_DEVICE_EXPORT(rt_hw_spi1_tfcard);
|
|
|
|
static int onboard_sdcard_mount(void)
|
|
{
|
|
if (dfs_mount("sd0", "/sdcard", "elm", 0, 0) == RT_EOK)
|
|
{
|
|
LOG_I("SD card mount to '/sdcard'");
|
|
}
|
|
else
|
|
{
|
|
LOG_E("SD card mount to '/sdcard' failed!");
|
|
}
|
|
|
|
return RT_EOK;
|
|
}
|
|
#endif /* BSP_USING_SDCARD_FATFS */
|
|
|
|
|
|
#ifdef BSP_USING_SPI_FLASH_LITTLEFS
|
|
|
|
#endif /* BSP_USING_SPI_FLASH_LITTLEFS */
|
|
|
|
static const struct romfs_dirent _romfs_root[] =
|
|
{
|
|
#ifdef BSP_USING_SDCARD_FATFS
|
|
{ROMFS_DIRENT_DIR, "sdcard", RT_NULL, 0},
|
|
#endif
|
|
|
|
#ifdef BSP_USING_SPI_FLASH_LITTLEFS
|
|
{ROMFS_DIRENT_DIR, "spiflash", RT_NULL, 0},
|
|
#endif
|
|
};
|
|
|
|
const struct romfs_dirent romfs_root =
|
|
{
|
|
ROMFS_DIRENT_DIR, "/", (rt_uint8_t *)_romfs_root, sizeof(_romfs_root) / sizeof(_romfs_root[0])
|
|
};
|
|
|
|
static int filesystem_mount(void)
|
|
{
|
|
if (dfs_mount(RT_NULL, "/", "rom", 0, &(romfs_root)) != 0)
|
|
{
|
|
LOG_E("rom mount to '/' failed!");
|
|
}
|
|
#ifdef BSP_USING_SDCARD_FATFS
|
|
onboard_sdcard_mount();
|
|
#endif
|
|
|
|
#ifdef BSP_USING_SPI_FLASH_LITTLEFS
|
|
onboard_spiflash_mount();
|
|
#endif
|
|
|
|
return RT_EOK;
|
|
}
|
|
INIT_APP_EXPORT(filesystem_mount);
|