From abb5d53bd1c8b4a76a162a31c95ef9dc0a002202 Mon Sep 17 00:00:00 2001 From: zhaoxingyu1 Date: Wed, 4 Jun 2025 14:53:31 +0800 Subject: [PATCH 1/3] mtd/nvs: modify config name to MTD_CONFIG_NVS part1 Because the MTD_CONFIG configuration item in drivers/mtd/Kconfig has changed Signed-off-by: zhaoxingyu1 --- system/cfgdata/Kconfig | 2 +- testing/fs/mtd_config_fs/Kconfig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system/cfgdata/Kconfig b/system/cfgdata/Kconfig index 23eb9ebced4..64f51d40e8f 100644 --- a/system/cfgdata/Kconfig +++ b/system/cfgdata/Kconfig @@ -6,7 +6,7 @@ config SYSTEM_CFGDATA tristate "Cfgdata Command" default n - depends on MTD_CONFIG + depends on !MTD_CONFIG_NONE ---help--- Enable support for the CFGDATA tool. diff --git a/testing/fs/mtd_config_fs/Kconfig b/testing/fs/mtd_config_fs/Kconfig index 02f8b752a86..d2c9c2e8c33 100644 --- a/testing/fs/mtd_config_fs/Kconfig +++ b/testing/fs/mtd_config_fs/Kconfig @@ -6,7 +6,7 @@ config TESTING_MTD_CONFIG_FAIL_SAFE tristate "MTD Config fail-safe storage test" default n - depends on MTD_CONFIG_FAIL_SAFE + depends on MTD_CONFIG_NVS select MTD_CONFIG_NAMED ---help--- Enable the fail-safe storage test From 84441789be9afbe492da6511685aadb48eb27c59 Mon Sep 17 00:00:00 2001 From: guohao15 Date: Tue, 17 Dec 2024 11:08:19 +0800 Subject: [PATCH 2/3] mtdconfig: support ram_mtdconfig device && lomtdconfig device For nvs test in qemu Signed-off-by: guohao15 --- nshlib/nsh_command.c | 6 ++++ nshlib/nsh_fscmds.c | 74 +++++++++++++++++++++----------------------- 2 files changed, 42 insertions(+), 38 deletions(-) diff --git a/nshlib/nsh_command.c b/nshlib/nsh_command.c index af0084218c4..cace8eeac7f 100644 --- a/nshlib/nsh_command.c +++ b/nshlib/nsh_command.c @@ -322,9 +322,15 @@ static const struct cmdmap_s g_cmdmap[] = #ifndef CONFIG_DISABLE_MOUNTPOINT # if defined(CONFIG_MTD_LOOP) && !defined(CONFIG_NSH_DISABLE_LOMTD) +# ifdef CONFIG_MTD_CONFIG + CMD_MAP("lomtd", cmd_lomtd, 3, 10, + "[-d ] | [[-o ] [-e ] " + "[-b ] [-c ] ]]"), +# else CMD_MAP("lomtd", cmd_lomtd, 3, 9, "[-d ] | [[-o ] [-e ] " "[-b ] ]]"), +# endif # endif #endif diff --git a/nshlib/nsh_fscmds.c b/nshlib/nsh_fscmds.c index c1abcd357f2..447d45e7222 100644 --- a/nshlib/nsh_fscmds.c +++ b/nshlib/nsh_fscmds.c @@ -965,8 +965,8 @@ int cmd_cp(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) * Name: cmd_losetup ****************************************************************************/ -#ifndef CONFIG_DISABLE_MOUNTPOINT -# if defined(CONFIG_DEV_LOOP) && !defined(CONFIG_NSH_DISABLE_LOSETUP) +#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_DEV_LOOP) && \ + !defined(CONFIG_NSH_DISABLE_LOSETUP) int cmd_losetup(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) { FAR char *loopdev = NULL; @@ -1120,14 +1120,13 @@ int cmd_losetup(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) return ret; } #endif -#endif /**************************************************************************** * Name: cmd_losmart ****************************************************************************/ -#ifndef CONFIG_DISABLE_MOUNTPOINT -# if defined(CONFIG_SMART_DEV_LOOP) && !defined(CONFIG_NSH_DISABLE_LOSMART) +#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_SMART_DEV_LOOP) && \ + !defined(CONFIG_NSH_DISABLE_LOSMART) int cmd_losmart(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) { FAR char *loopdev = NULL; @@ -1292,14 +1291,13 @@ int cmd_losmart(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) return ret; } #endif -#endif /**************************************************************************** * Name: cmd_lomtd ****************************************************************************/ -#ifndef CONFIG_DISABLE_MOUNTPOINT -# if defined(CONFIG_MTD_LOOP) && !defined(CONFIG_NSH_DISABLE_LOMTD) +#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_MTD_LOOP) && \ + !defined(CONFIG_NSH_DISABLE_LOMTD) int cmd_lomtd(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) { FAR char *loopdev = NULL; @@ -1310,6 +1308,9 @@ int cmd_lomtd(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) int sectsize = -1; off_t offset = 0; bool badarg = false; +# ifdef CONFIG_MTD_CONFIG + int configdata = 0; +# endif int ret = ERROR; int option; int fd; @@ -1317,14 +1318,17 @@ int cmd_lomtd(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) /* Get the lomtd options: Two forms are supported: * * lomtd -d - * lomtd [-o ] [-e erasesize] [-b sectsize] + * lomtd [-o ] [-e erasesize] [-b sectsize] [-c configdata] * * * NOTE that the -o and -r options are accepted with the -d option, but * will be ignored. */ - +# ifdef CONFIG_MTD_CONFIG + while ((option = getopt(argc, argv, "d:o:e:b:c:")) != ERROR) +# else while ((option = getopt(argc, argv, "d:o:e:b:")) != ERROR) +# endif { switch (option) { @@ -1345,6 +1349,12 @@ int cmd_lomtd(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) sectsize = atoi(optarg); break; +# ifdef CONFIG_MTD_CONFIG + case 'c': + configdata = atoi(optarg); + break; +# endif + case '?': default: nsh_error(vtbl, g_fmtarginvalid, argv[0]); @@ -1420,11 +1430,14 @@ int cmd_lomtd(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) { /* Set up the loop device */ - setup.devname = loopdev; /* The loop block device to be created */ - setup.filename = filepath; /* The file or character device to use */ - setup.sectsize = sectsize; /* The sector size to use with the block device */ - setup.erasesize = erasesize; /* The sector size to use with the block device */ - setup.offset = offset; /* An offset that may be applied to the device */ + setup.devname = loopdev; /* The loop block device to be created */ + setup.filename = filepath; /* The file or character device to use */ + setup.sectsize = sectsize; /* The sector size to use with the block device */ + setup.erasesize = erasesize; /* The sector size to use with the block device */ + setup.offset = offset; /* An offset that may be applied to the device */ +# ifdef CONFIG_MTD_CONFIG + setup.configdata = configdata; /* Is a loop mtdconfig device */ +# endif ret = ioctl(fd, MTD_LOOPIOC_SETUP, (unsigned long)((uintptr_t)&setup)); @@ -1455,7 +1468,6 @@ int cmd_lomtd(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) return ret; } -# endif #endif /**************************************************************************** @@ -1661,8 +1673,7 @@ int cmd_ls(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) * Name: cmd_mkdir ****************************************************************************/ -#ifdef NSH_HAVE_DIROPTS -#ifndef CONFIG_NSH_DISABLE_MKDIR +#if defined(NSH_HAVE_DIROPTS) && !defined(CONFIG_NSH_DISABLE_MKDIR) int cmd_mkdir(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) { FAR char *fullpath = NULL; @@ -1722,14 +1733,13 @@ int cmd_mkdir(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) return ret; } #endif -#endif /**************************************************************************** * Name: cmd_mkfatfs ****************************************************************************/ -#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FSUTILS_MKFATFS) -#ifndef CONFIG_NSH_DISABLE_MKFATFS +#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FSUTILS_MKFATFS) && \ + !defined(CONFIG_NSH_DISABLE_MKFATFS) int cmd_mkfatfs(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) { struct fat_format_s fmt = FAT_FORMAT_INITIALIZER; @@ -1825,7 +1835,6 @@ int cmd_mkfatfs(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) return ret; } #endif -#endif /**************************************************************************** * Name: cmd_mkfifo @@ -1962,8 +1971,7 @@ int cmd_mkrd(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) ****************************************************************************/ #if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_SMARTFS) && \ - defined(CONFIG_FSUTILS_MKSMARTFS) -#ifndef CONFIG_NSH_DISABLE_MKSMARTFS + defined(CONFIG_FSUTILS_MKSMARTFS) && !defined(CONFIG_NSH_DISABLE_MKSMARTFS) int cmd_mksmartfs(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) { FAR char *fullpath = NULL; @@ -2048,14 +2056,12 @@ int cmd_mksmartfs(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) return ret; } #endif -#endif /**************************************************************************** * Name: cmd_mv ****************************************************************************/ -#ifdef NSH_HAVE_DIROPTS -#ifndef CONFIG_NSH_DISABLE_MV +#if defined(NSH_HAVE_DIROPTS) && !defined(CONFIG_NSH_DISABLE_MV) int cmd_mv(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) { UNUSED(argc); @@ -2098,7 +2104,6 @@ int cmd_mv(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) return ret; } #endif -#endif /**************************************************************************** * Name: cmd_readlink @@ -2141,9 +2146,7 @@ int cmd_readlink(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) * Name: cmd_rm ****************************************************************************/ -#ifdef NSH_HAVE_DIROPTS -#ifndef CONFIG_NSH_DISABLE_RM - +#if defined(NSH_HAVE_DIROPTS) && !defined(CONFIG_NSH_DISABLE_RM) static int unlink_recursive(FAR char *path, FAR struct stat *stat) { struct dirent *d; @@ -2273,14 +2276,12 @@ int cmd_rm(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) return ret; } #endif -#endif /**************************************************************************** * Name: cmd_rmdir ****************************************************************************/ -#ifdef NSH_HAVE_DIROPTS -#ifndef CONFIG_NSH_DISABLE_RMDIR +#if defined(NSH_HAVE_DIROPTS) && !defined(CONFIG_NSH_DISABLE_RMDIR) int cmd_rmdir(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) { UNUSED(argc); @@ -2302,7 +2303,6 @@ int cmd_rmdir(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) return ret; } #endif -#endif /**************************************************************************** * Name: cmd_source @@ -2431,8 +2431,7 @@ int cmd_cmp(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) * Name: cmd_truncate ****************************************************************************/ -#ifndef CONFIG_DISABLE_MOUNTPOINT -#ifndef CONFIG_NSH_DISABLE_TRUNCATE +#if !defined(CONFIG_DISABLE_MOUNTPOINT) && !defined(CONFIG_NSH_DISABLE_TRUNCATE) int cmd_truncate(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) { UNUSED(argc); @@ -2536,7 +2535,6 @@ int cmd_truncate(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) return ret; } #endif -#endif /**************************************************************************** * Name: cmd_fdinfo From 84f496d9cc9e9ee36136a6dacb4aca90a8549391 Mon Sep 17 00:00:00 2001 From: zhaoxingyu1 Date: Tue, 3 Jun 2025 17:33:16 +0800 Subject: [PATCH 3/3] mtdconfig: lomtdconfig device change to depends on !MTD_CONFIG_NONE Because MTD_CONFIG configuration item in drivers/mtd/Kconfig has changed. Signed-off-by: zhaoxingyu1 --- nshlib/nsh_command.c | 2 +- nshlib/nsh_fscmds.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/nshlib/nsh_command.c b/nshlib/nsh_command.c index cace8eeac7f..ec3f8a385f2 100644 --- a/nshlib/nsh_command.c +++ b/nshlib/nsh_command.c @@ -322,7 +322,7 @@ static const struct cmdmap_s g_cmdmap[] = #ifndef CONFIG_DISABLE_MOUNTPOINT # if defined(CONFIG_MTD_LOOP) && !defined(CONFIG_NSH_DISABLE_LOMTD) -# ifdef CONFIG_MTD_CONFIG +# ifndef CONFIG_MTD_CONFIG_NONE CMD_MAP("lomtd", cmd_lomtd, 3, 10, "[-d ] | [[-o ] [-e ] " "[-b ] [-c ] ]]"), diff --git a/nshlib/nsh_fscmds.c b/nshlib/nsh_fscmds.c index 447d45e7222..13f26f6947e 100644 --- a/nshlib/nsh_fscmds.c +++ b/nshlib/nsh_fscmds.c @@ -1308,7 +1308,7 @@ int cmd_lomtd(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) int sectsize = -1; off_t offset = 0; bool badarg = false; -# ifdef CONFIG_MTD_CONFIG +# ifndef CONFIG_MTD_CONFIG_NONE int configdata = 0; # endif int ret = ERROR; @@ -1324,7 +1324,7 @@ int cmd_lomtd(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) * NOTE that the -o and -r options are accepted with the -d option, but * will be ignored. */ -# ifdef CONFIG_MTD_CONFIG +# ifndef CONFIG_MTD_CONFIG_NONE while ((option = getopt(argc, argv, "d:o:e:b:c:")) != ERROR) # else while ((option = getopt(argc, argv, "d:o:e:b:")) != ERROR) @@ -1349,7 +1349,7 @@ int cmd_lomtd(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) sectsize = atoi(optarg); break; -# ifdef CONFIG_MTD_CONFIG +# ifndef CONFIG_MTD_CONFIG_NONE case 'c': configdata = atoi(optarg); break; @@ -1435,7 +1435,7 @@ int cmd_lomtd(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv) setup.sectsize = sectsize; /* The sector size to use with the block device */ setup.erasesize = erasesize; /* The sector size to use with the block device */ setup.offset = offset; /* An offset that may be applied to the device */ -# ifdef CONFIG_MTD_CONFIG +# ifndef CONFIG_MTD_CONFIG_NONE setup.configdata = configdata; /* Is a loop mtdconfig device */ # endif