Ubiquitous/RT-Thread_Fusion_XiUOS/: add romfs function

This commit is contained in:
chunyexixiaoyu 2022-04-29 15:33:55 +08:00
parent c271cd16ea
commit f3d7e7e3d4
6 changed files with 48 additions and 3 deletions

View File

@ -149,7 +149,7 @@ CONFIG_RT_DFS_ELM_MAX_SECTOR_SIZE=512
CONFIG_RT_DFS_ELM_REENTRANT=y
CONFIG_RT_DFS_ELM_MUTEX_TIMEOUT=3000
CONFIG_RT_USING_DFS_DEVFS=y
# CONFIG_RT_USING_DFS_ROMFS is not set
CONFIG_RT_USING_DFS_ROMFS=y
# CONFIG_RT_USING_DFS_RAMFS is not set
# CONFIG_RT_USING_DFS_NFS is not set

View File

@ -15,6 +15,9 @@ if GetDepend('BSP_USING_PHY') and GetDepend('PHY_USING_8720A'):
src += ['./ports/LAN8720A.c']
if GetDepend('BSP_USING_SDCARD'):
src += ['./ports/sdcard_port.c']
if GetDepend(['RT_USING_DFS_ROMFS']):
src += ['ports/romfs.c']
src += ['ports/mnt_romfs.c']
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES=CPPDEFINES)
Return('group')

View File

@ -0,0 +1,20 @@
#include <rtthread.h>
#if defined RT_USING_DFS && defined RT_USING_DFS_ROMFS
#include <dfs_fs.h>
#include "dfs_romfs.h"
int mnt_init(void)
{
if (dfs_mount(RT_NULL, "/", "rom", 0, &(romfs_root)) == 0)
{
rt_kprintf("ROM file system initializated!\n");
}
else
{
rt_kprintf("ROM file system initializate failed!\n");
}
return 0;
}
INIT_ENV_EXPORT(mnt_init);
#endif

View File

@ -0,0 +1,18 @@
/* Generated by mkromfs. Edit with caution. */
#include <rtthread.h>
#include <dfs_romfs.h>
static const rt_uint8_t _romfs_root_romfstest_txt[] = {
0x68,0x65,0x6c,0x6c,0x6f,0x20,0x78,0x69,0x64,0x61,0x74,0x6f,0x6e,0x67,0x0d,0x0a
};
static const struct romfs_dirent _romfs_root[] = {
{ROMFS_DIRENT_DIR, "SD", RT_NULL, 0},
{ROMFS_DIRENT_FILE, "romfstest.txt", (rt_uint8_t *)_romfs_root_romfstest_txt, sizeof(_romfs_root_romfstest_txt)/sizeof(_romfs_root_romfstest_txt[0])}
};
const struct romfs_dirent romfs_root = {
ROMFS_DIRENT_DIR, "/", (rt_uint8_t *)_romfs_root, sizeof(_romfs_root)/sizeof(_romfs_root[0])
};

View File

@ -1,4 +1,3 @@
#include <rtdevice.h>
#include <rtthread.h>
#include "drv_gpio.h"
@ -15,7 +14,11 @@ int sd_mount()
if (result == MMCSD_HOST_PLUGED)
{
/* mount sd card fat partition 1 as root directory */
if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
#ifdef RT_USING_DFS_ROMFS
if(dfs_mount("sd0", "/SD", "elm", 0, 0) == 0)
#else
if(dfs_mount("sd0", "/", "elm", 0, 0) == 0)
#endif
{
LOG_I("File System initialized!\n");
return RT_EOK;

View File

@ -101,6 +101,7 @@
#define RT_DFS_ELM_REENTRANT
#define RT_DFS_ELM_MUTEX_TIMEOUT 3000
#define RT_USING_DFS_DEVFS
#define RT_USING_DFS_ROMFS
/* Device Drivers */