[stm32l4-pandora] 整理文件系统
增加ROMFS,FATFS和未来的LittleFS将挂载在ROMFS上 初步增加littlefs文件系统,尚未完全实现一键化配置
This commit is contained in:
parent
5f474ed26c
commit
4fa40bcee5
|
@ -103,15 +103,35 @@ menu "Onboard Peripheral Drivers"
|
|||
default y
|
||||
endif
|
||||
|
||||
config BSP_USING_SDCARD
|
||||
bool "Enable SDCARD (spi1)"
|
||||
select BSP_USING_SPI
|
||||
select BSP_USING_SPI1
|
||||
select RT_USING_SPI_MSD
|
||||
|
||||
|
||||
menuconfig BSP_USING_FS
|
||||
bool "Enable File System"
|
||||
select RT_USING_DFS
|
||||
select RT_USING_DFS_ELMFAT
|
||||
select RT_USING_DFS_ROMFS
|
||||
default n
|
||||
|
||||
if BSP_USING_FS
|
||||
config BSP_USING_SDCARD_FATFS
|
||||
bool "Enable SDCARD (FATFS)"
|
||||
select BSP_USING_SPI
|
||||
select BSP_USING_SPI1
|
||||
select RT_USING_SPI_MSD
|
||||
select RT_USING_DFS_ELMFAT
|
||||
default n
|
||||
|
||||
config BSP_USING_SPI_FLASH_LITTLEFS
|
||||
bool "Enable SPI-FLASH (LittleFS)"
|
||||
select RT_USING_MTD_NOR
|
||||
select BSP_USING_QSPI_FLASH
|
||||
select RT_USING_FAL
|
||||
select FAL_USING_AUTO_INIT
|
||||
select FAL_PART_HAS_TABLE_CFG
|
||||
select PKG_USING_LITTLEFS
|
||||
default n
|
||||
endif
|
||||
|
||||
|
||||
config BSP_USING_ICM20608
|
||||
bool "Enable ICM20608 (i2c3)"
|
||||
select BSP_USING_I2C
|
||||
|
|
|
@ -12,14 +12,20 @@ board.c
|
|||
CubeMX_Config/Src/stm32l4xx_hal_msp.c
|
||||
''')
|
||||
|
||||
path = [cwd]
|
||||
path += [cwd + '/CubeMX_Config/Inc']
|
||||
|
||||
if GetDepend(['BSP_USING_KEY']):
|
||||
src += Glob('ports/drv_key.c')
|
||||
|
||||
if GetDepend(['BSP_USING_QSPI_FLASH']):
|
||||
src += Glob('ports/drv_qspi_flash.c')
|
||||
|
||||
if GetDepend(['BSP_USING_SDCARD']):
|
||||
src += Glob('ports/drv_sdcard.c')
|
||||
if GetDepend(['BSP_USING_FS']):
|
||||
src += Glob('ports/drv_filesystem.c')
|
||||
if GetDepend(['BSP_USING_SPI_FLASH_LITTLEFS']):
|
||||
src += Glob('ports/fal/fal_spi_flash_sfud_port.c')
|
||||
path += [cwd + '/ports/fal']
|
||||
|
||||
if GetDepend(['BSP_USING_ICM20608']) or GetDepend(['BSP_USING_AHT10']):
|
||||
src += Glob('ports/sensor_port.c')
|
||||
|
@ -34,8 +40,7 @@ if GetDepend(['BSP_USING_AUDIO_RECORD']):
|
|||
if GetDepend(['BSP_USING_STM32_SDIO']):
|
||||
src += Glob('ports/drv_sdio_adapter.c')
|
||||
|
||||
path = [cwd]
|
||||
path += [cwd + '/CubeMX_Config/Inc']
|
||||
|
||||
|
||||
if GetDepend(['BSP_USING_AUDIO']):
|
||||
path += [cwd + '/ports/audio']
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* 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", GPIOC, GPIO_PIN_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
|
||||
};
|
||||
|
||||
static 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);
|
|
@ -74,7 +74,7 @@ static int rt_hw_qspi_flash_with_sfud_init(void)
|
|||
}
|
||||
INIT_COMPONENT_EXPORT(rt_hw_qspi_flash_with_sfud_init);
|
||||
|
||||
#if defined(RT_USING_DFS_ELMFAT) && !defined(BSP_USING_SDCARD)
|
||||
#if defined(RT_USING_DFS_ELMFAT) && !defined(BSP_USING_SDCARD_FATFS)
|
||||
#include <dfs_fs.h>
|
||||
|
||||
#define BLK_DEV_NAME "W25Q128"
|
||||
|
@ -106,5 +106,5 @@ int mnt_init(void)
|
|||
}
|
||||
INIT_ENV_EXPORT(mnt_init);
|
||||
|
||||
#endif /* defined(RT_USING_DFS_ELMFAT) && !defined(BSP_USING_SDCARD) */
|
||||
#endif /* defined(RT_USING_DFS_ELMFAT) && !defined(BSP_USING_SDCARD_FATFS) */
|
||||
#endif /* BSP_USING_QSPI_FLASH */
|
||||
|
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
* 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>
|
||||
|
||||
#ifdef BSP_USING_SDCARD
|
||||
|
||||
#include <dfs_elm.h>
|
||||
#include <dfs_fs.h>
|
||||
#include <dfs_file.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/statfs.h>
|
||||
#include "drv_spi.h"
|
||||
#include "spi_msd.h"
|
||||
|
||||
#define DBG_TAG "app.card"
|
||||
#define DBG_LVL DBG_INFO
|
||||
#include <rtdbg.h>
|
||||
|
||||
static void sd_mount(void *parameter)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
rt_thread_mdelay(500);
|
||||
if(rt_device_find("sd0") != RT_NULL)
|
||||
{
|
||||
if (dfs_mount("sd0", "/", "elm", 0, 0) == RT_EOK)
|
||||
{
|
||||
LOG_I("sd card mount to '/'");
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_W("sd card mount to '/' failed!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int onboard_sdcard_mount(void)
|
||||
{
|
||||
rt_thread_t tid;
|
||||
|
||||
if (dfs_mount("sd0", "/", "elm", 0, 0) == RT_EOK)
|
||||
{
|
||||
LOG_I("sd card mount to '/'");
|
||||
}
|
||||
else
|
||||
{
|
||||
tid = rt_thread_create("sd_mount", sd_mount, RT_NULL,
|
||||
1024, RT_THREAD_PRIORITY_MAX - 2, 20);
|
||||
if (tid != RT_NULL)
|
||||
{
|
||||
rt_thread_startup(tid);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_E("create sd_mount thread err!");
|
||||
}
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
INIT_APP_EXPORT(onboard_sdcard_mount);
|
||||
|
||||
static int rt_hw_spi1_tfcard(void)
|
||||
{
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
rt_hw_spi_device_attach("spi1", "spi10", GPIOC, GPIO_PIN_3);
|
||||
return msd_init("sd0", "spi10");
|
||||
}
|
||||
INIT_DEVICE_EXPORT(rt_hw_spi1_tfcard);
|
||||
|
||||
#endif /* BSP_USING_SDCARD */
|
||||
|
Loading…
Reference in New Issue