Ubiquitous/RT_Thread/: add RomFS and RamFS support to stm32h743_openmv_h7plus

This commit is contained in:
WentaoWong 2022-04-18 16:42:50 +08:00
parent 09d7d3cd6b
commit 5a6e853712
4 changed files with 72 additions and 1 deletions

View File

@ -18,7 +18,11 @@ if GetDepend(['BSP_USING_QSPI_FLASH']):
src += ['ports/drv_qspi_flash.c']
if GetDepend(['BSP_USING_SDMMC']):
src += ['ports/drv_sdio.c']
if GetDepend(['RT_USING_DFS_ROMFS']):
src += ['ports/romfs.c']
src += ['ports/mnt_romfs.c']
if GetDepend(['RT_USING_DFS_RAMFS']):
src += ['ports/mnt_ramfs.c']
path = [cwd]
path += [cwd + '/CubeMX_Config/Core/Inc']

View File

@ -0,0 +1,22 @@
#include <rtthread.h>
#if defined RT_USING_DFS && defined RT_USING_DFS_RAMFS
#include <dfs_fs.h>
#include "dfs_ramfs.h"
int mnt_ramfs_init(void)
{
if (dfs_mount(RT_NULL, "/", "ram", 0, dfs_ramfs_create(rt_malloc(1024),1024)) == 0)
{
rt_kprintf("RAM file system initializated!\n");
}
else
{
rt_kprintf("RAM file system initializate failed!\n");
}
return 0;
}
INIT_ENV_EXPORT(mnt_ramfs_init);
#endif

View File

@ -0,0 +1,22 @@
#include <rtthread.h>
#if defined RT_USING_DFS && defined RT_USING_DFS_ROMFS
#include <dfs_fs.h>
#include "dfs_romfs.h"
int mnt_romfs_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_romfs_init);
#endif

View File

@ -0,0 +1,23 @@
/* Generated by mkromfs. Edit with caution. */
#include <rtthread.h>
#include <dfs_romfs.h>
#ifdef RT_USING_DFS_ROMFS
static const rt_uint8_t _romfs_root_hello_txt[] = {
0x58,0x49,0x55,0x4f,0x53,0x20,0x73,0x74,0x6d,0x33,0x32,0x68,0x37,0x20,0x52,0x6f,0x6d,0x46,0x53,0x20,0x73,0x75,0x63,0x63,0x65,0x73,0x73,0x21
};
static const struct romfs_dirent _romfs_root[] = {
#ifdef BSP_USING_QSPI_FLASH
{ROMFS_DIRENT_DIR, "FLASH", RT_NULL, 0},
#endif
#ifdef BSP_USING_SDMMC
{ROMFS_DIRENT_DIR, "SD", RT_NULL, 0},
#endif
{ROMFS_DIRENT_FILE, "hello.txt", (rt_uint8_t *)_romfs_root_hello_txt, sizeof(_romfs_root_hello_txt)/sizeof(_romfs_root_hello_txt[0])}
};
const struct romfs_dirent romfs_root = {
ROMFS_DIRENT_DIR, "/", (rt_uint8_t *)_romfs_root, sizeof(_romfs_root)/sizeof(_romfs_root[0])
};
#endif