bsp: cvitek/c906B: feat: add config of bootfs
To support more choice on bootfs. romfs, cromfs are now supported on risc_v_big platform. Changes: - added mount operations under port - added prototypes for cromfs init APIs Signed-off-by: Shell <smokewood@qq.com> Reviewed-on: https://github.com/RT-Thread/rt-thread/pull/9229 Reviewed-by: Chen Wang <unicorn_wang@outlook.com>
This commit is contained in:
parent
20c04e51f8
commit
cfa3ecfa9e
|
@ -75,3 +75,18 @@ choice
|
||||||
bool "milkv-duo256m-spinor"
|
bool "milkv-duo256m-spinor"
|
||||||
|
|
||||||
endchoice
|
endchoice
|
||||||
|
|
||||||
|
choice BSP_ROOTFS_TYPE
|
||||||
|
prompt "rootfs type"
|
||||||
|
default BSP_ROOTFS_TYPE_ROMFS
|
||||||
|
|
||||||
|
config BSP_ROOTFS_TYPE_ROMFS
|
||||||
|
bool "ROMFS"
|
||||||
|
select RT_USING_DFS_ROMFS
|
||||||
|
|
||||||
|
config BSP_ROOTFS_TYPE_CROMFS
|
||||||
|
bool "CROMFS"
|
||||||
|
select RT_USING_DFS_CROMFS
|
||||||
|
select PKG_USING_ZLIB
|
||||||
|
select PKG_USING_ZLIB_LATEST_VERSION
|
||||||
|
endchoice
|
||||||
|
|
|
@ -38,10 +38,14 @@ if GetDepend('BSP_USING_PWM'):
|
||||||
src += ['drv_pwm.c']
|
src += ['drv_pwm.c']
|
||||||
CPPPATH += [cwd + r'/libraries/cv180x/pwm']
|
CPPPATH += [cwd + r'/libraries/cv180x/pwm']
|
||||||
|
|
||||||
if GetDepend('BSP_USING_SDH'):
|
if GetDepend('BSP_ROOTFS_TYPE_CROMFS'):
|
||||||
src += ['drv_sdhci.c', 'port/mnt.c']
|
src += ['port/mnt_cromfs.c']
|
||||||
CPPPATH += [cwd + r'/libraries/sdif']
|
elif GetDepend('BSP_ROOTFS_TYPE_ROMFS'):
|
||||||
|
src += ['port/mnt_romfs.c']
|
||||||
|
|
||||||
|
if GetDepend('BSP_USING_SDH'):
|
||||||
|
src += ['drv_sdhci.c']
|
||||||
|
CPPPATH += [cwd + r'/libraries/sdif']
|
||||||
|
|
||||||
if GetDepend('BSP_USING_ETH'):
|
if GetDepend('BSP_USING_ETH'):
|
||||||
src += Split('''
|
src += Split('''
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2006-2023, RT-Thread Development Team
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2024-06-18 Shell add cromfs support
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define DBG_TAG "app.filesystem"
|
||||||
|
#define DBG_LVL DBG_LOG
|
||||||
|
#include <rtdbg.h>
|
||||||
|
|
||||||
|
#include <dfs_cromfs.h>
|
||||||
|
#include <dfs_posix.h>
|
||||||
|
#include <dfs_fs.h>
|
||||||
|
#include <ioremap.h>
|
||||||
|
#include <mmu.h>
|
||||||
|
#include <rtthread.h>
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
struct _mount_table
|
||||||
|
{
|
||||||
|
char *dev_name;
|
||||||
|
char *mount_point;
|
||||||
|
char *fs_name;
|
||||||
|
long rwflag;
|
||||||
|
void *data;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _mount_table _mount_table[] = {
|
||||||
|
[0] = {NULL, "/", "crom", 0, 0},
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
static int _wait_device_ready(const char* devname)
|
||||||
|
{
|
||||||
|
int k;
|
||||||
|
|
||||||
|
for(k = 0; k < 10; k++)
|
||||||
|
{
|
||||||
|
if (rt_device_find(devname) != RT_NULL)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
rt_thread_mdelay(50);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mnt_init(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
uint32_t crom_data_len = 0;
|
||||||
|
uint32_t length;
|
||||||
|
|
||||||
|
_mount_table[0].data = cromfs_get_partition_data(&length);
|
||||||
|
crom_data_len = length;
|
||||||
|
|
||||||
|
if (_mount_table[0].data && (crom_data_len > 0))
|
||||||
|
{
|
||||||
|
for (i = 0; i < sizeof(_mount_table) / sizeof(_mount_table[0]); i++)
|
||||||
|
{
|
||||||
|
if (_mount_table[i].dev_name && !_wait_device_ready(_mount_table[i].dev_name))
|
||||||
|
{
|
||||||
|
LOG_E("device %s find timeout", _mount_table[i].dev_name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dfs_mount(_mount_table[i].dev_name, _mount_table[i].mount_point,
|
||||||
|
_mount_table[i].fs_name, _mount_table[i].rwflag, _mount_table[i].data) != 0)
|
||||||
|
{
|
||||||
|
LOG_E("Dir %s %s mount failed!", _mount_table[i].mount_point,
|
||||||
|
_mount_table[i].dev_name ? _mount_table[i].dev_name : _mount_table[i].fs_name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG_I("Dir %s %s mount ok!", _mount_table[i].mount_point,
|
||||||
|
_mount_table[i].dev_name ? _mount_table[i].dev_name : _mount_table[i].fs_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG_E("No mount data found!");
|
||||||
|
}
|
||||||
|
|
||||||
|
mkdir("/dev/shm", 0777);
|
||||||
|
|
||||||
|
if (dfs_mount(NULL, "/dev/shm", "tmp", 0, 0) != 0)
|
||||||
|
{
|
||||||
|
LOG_E("Dir %s %s mount failed!", "/dev/shm", "tmp");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG_I("Dir %s %s mount ok!", "/dev/shm", "tmp");
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_I("file system initialization done!\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
INIT_ENV_EXPORT(mnt_init);
|
|
@ -11,6 +11,9 @@
|
||||||
#ifndef __DFS_CROMFS_H__
|
#ifndef __DFS_CROMFS_H__
|
||||||
#define __DFS_CROMFS_H__
|
#define __DFS_CROMFS_H__
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
int dfs_cromfs_init(void);
|
int dfs_cromfs_init(void);
|
||||||
|
uint8_t *cromfs_get_partition_data(uint32_t *len);
|
||||||
|
|
||||||
#endif /*__DFS_CROMFS_H__*/
|
#endif /*__DFS_CROMFS_H__*/
|
||||||
|
|
Loading…
Reference in New Issue