summaryrefslogtreecommitdiff
path: root/bsp
diff options
context:
space:
mode:
authorShell <[email protected]>2024-07-22 11:51:23 +0800
committerBernard Xiong <[email protected]>2024-07-29 20:16:54 +0800
commitcfa3ecfa9eee0b580d59e5a24cb374a72a5fc34e (patch)
tree77f2b4e22cc09f37b5fe04ca03b40fa0d1d3899e /bsp
parent20c04e51f87d4662c525b2f853d83d89e9650ee5 (diff)
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 <[email protected]> Reviewed-on: https://github.com/RT-Thread/rt-thread/pull/9229 Reviewed-by: Chen Wang <[email protected]>
Diffstat (limited to 'bsp')
-rwxr-xr-xbsp/cvitek/cv18xx_risc-v/Kconfig15
-rwxr-xr-xbsp/cvitek/drivers/SConscript8
-rw-r--r--bsp/cvitek/drivers/port/mnt_cromfs.c106
-rw-r--r--bsp/cvitek/drivers/port/mnt_romfs.c (renamed from bsp/cvitek/drivers/port/mnt.c)0
4 files changed, 127 insertions, 2 deletions
diff --git a/bsp/cvitek/cv18xx_risc-v/Kconfig b/bsp/cvitek/cv18xx_risc-v/Kconfig
index e21d6bfedc..42796ddcb2 100755
--- a/bsp/cvitek/cv18xx_risc-v/Kconfig
+++ b/bsp/cvitek/cv18xx_risc-v/Kconfig
@@ -75,3 +75,18 @@ choice
bool "milkv-duo256m-spinor"
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
diff --git a/bsp/cvitek/drivers/SConscript b/bsp/cvitek/drivers/SConscript
index 91961af61a..56bca8b136 100755
--- a/bsp/cvitek/drivers/SConscript
+++ b/bsp/cvitek/drivers/SConscript
@@ -38,11 +38,15 @@ if GetDepend('BSP_USING_PWM'):
src += ['drv_pwm.c']
CPPPATH += [cwd + r'/libraries/cv180x/pwm']
+if GetDepend('BSP_ROOTFS_TYPE_CROMFS'):
+ src += ['port/mnt_cromfs.c']
+elif GetDepend('BSP_ROOTFS_TYPE_ROMFS'):
+ src += ['port/mnt_romfs.c']
+
if GetDepend('BSP_USING_SDH'):
- src += ['drv_sdhci.c', 'port/mnt.c']
+ src += ['drv_sdhci.c']
CPPPATH += [cwd + r'/libraries/sdif']
-
if GetDepend('BSP_USING_ETH'):
src += Split('''
drv_eth.c
diff --git a/bsp/cvitek/drivers/port/mnt_cromfs.c b/bsp/cvitek/drivers/port/mnt_cromfs.c
new file mode 100644
index 0000000000..5ca7416215
--- /dev/null
+++ b/bsp/cvitek/drivers/port/mnt_cromfs.c
@@ -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);
diff --git a/bsp/cvitek/drivers/port/mnt.c b/bsp/cvitek/drivers/port/mnt_romfs.c
index 799b7c5ccf..799b7c5ccf 100644
--- a/bsp/cvitek/drivers/port/mnt.c
+++ b/bsp/cvitek/drivers/port/mnt_romfs.c