module/sotest: Try devminor of romdisk
For case that /dev/ram${EXAMPLES_SOTEST_DEVMINOR}(e.g. /dev/ram0) already exists, and users may not care which device to use. Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
This commit is contained in:
parent
758ed55722
commit
dae4d7572f
@ -35,13 +35,14 @@ config EXAMPLES_SOTEST_BUILTINFS
|
|||||||
|
|
||||||
if EXAMPLES_SOTEST_BUILTINFS
|
if EXAMPLES_SOTEST_BUILTINFS
|
||||||
|
|
||||||
config EXAMPLES_SOTEST_DEVMINOR
|
config EXAMPLES_SOTEST_DEVMINOR_MAX
|
||||||
int "ROMFS Minor Device Number"
|
int "ROMFS Max Minor Device Number"
|
||||||
default 0
|
default 5
|
||||||
---help---
|
---help---
|
||||||
The minor device number of the ROMFS block. For example, the N in /dev/ramN.
|
The max minor device number of the ROMFS block will be tried.
|
||||||
|
For example, from /dev/ram0 to /dev/ramN.
|
||||||
Used for registering the RAM block driver that will hold the ROMFS file system
|
Used for registering the RAM block driver that will hold the ROMFS file system
|
||||||
containing the SOTEST executables to be tested. Default: 0
|
containing the SOTEST executables to be tested. Default: 5
|
||||||
|
|
||||||
endif # EXAMPLES_SOTEST_BUILTINFS
|
endif # EXAMPLES_SOTEST_BUILTINFS
|
||||||
|
|
||||||
|
@ -71,8 +71,8 @@
|
|||||||
# define NSECTORS(b) (((b)+SECTORSIZE-1)/SECTORSIZE)
|
# define NSECTORS(b) (((b)+SECTORSIZE-1)/SECTORSIZE)
|
||||||
# define BINDIR "/mnt/romfs"
|
# define BINDIR "/mnt/romfs"
|
||||||
|
|
||||||
# ifndef CONFIG_EXAMPLES_SOTEST_DEVMINOR
|
# ifndef CONFIG_EXAMPLES_SOTEST_DEVMINOR_MAX
|
||||||
# define CONFIG_EXAMPLES_SOTEST_DEVMINOR 0
|
# define CONFIG_EXAMPLES_SOTEST_DEVMINOR_MAX 5
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
# define BINDIR CONFIG_EXAMPLES_SOTEST_BINDIR
|
# define BINDIR CONFIG_EXAMPLES_SOTEST_BINDIR
|
||||||
@ -127,26 +127,33 @@ int main(int argc, FAR char *argv[])
|
|||||||
#ifdef CONFIG_EXAMPLES_SOTEST_BUILTINFS
|
#ifdef CONFIG_EXAMPLES_SOTEST_BUILTINFS
|
||||||
/* Create a ROM disk for the ROMFS filesystem */
|
/* Create a ROM disk for the ROMFS filesystem */
|
||||||
|
|
||||||
desc.minor = CONFIG_EXAMPLES_SOTEST_DEVMINOR; /* Minor device number of the ROM disk. */
|
desc.minor = 0; /* Minor device number of the ROM disk. */
|
||||||
desc.nsectors = NSECTORS(romfs_img_len); /* The number of sectors in the ROM disk */
|
desc.nsectors = NSECTORS(romfs_img_len); /* The number of sectors in the ROM disk */
|
||||||
desc.sectsize = SECTORSIZE; /* The size of one sector in bytes */
|
desc.sectsize = SECTORSIZE; /* The size of one sector in bytes */
|
||||||
desc.image = (FAR uint8_t *)romfs_img; /* File system image */
|
desc.image = (FAR uint8_t *)romfs_img; /* File system image */
|
||||||
|
|
||||||
printf("main: Registering romdisk at /dev/ram%d\n",
|
for (; desc.minor <= CONFIG_EXAMPLES_SOTEST_DEVMINOR_MAX; desc.minor++)
|
||||||
CONFIG_EXAMPLES_SOTEST_DEVMINOR);
|
|
||||||
|
|
||||||
ret = boardctl(BOARDIOC_ROMDISK, (uintptr_t)&desc);
|
|
||||||
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
{
|
||||||
fprintf(stderr, "ERROR: romdisk_register failed: %s\n",
|
printf("main: Registering romdisk at /dev/ram%d\n", desc.minor);
|
||||||
strerror(errno));
|
|
||||||
exit(EXIT_FAILURE);
|
ret = boardctl(BOARDIOC_ROMDISK, (uintptr_t)&desc);
|
||||||
|
if (ret >= 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errno != EEXIST ||
|
||||||
|
desc.minor == CONFIG_EXAMPLES_SOTEST_DEVMINOR_MAX)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "ERROR: romdisk_register failed: %s\n",
|
||||||
|
strerror(errno));
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mount the file system */
|
/* Mount the file system */
|
||||||
|
|
||||||
sprintf(devname, SOTEST_DEVPATH_FMT, CONFIG_EXAMPLES_SOTEST_DEVMINOR);
|
sprintf(devname, SOTEST_DEVPATH_FMT, desc.minor);
|
||||||
printf("main: Mounting ROMFS filesystem at target=%s with source=%s\n",
|
printf("main: Mounting ROMFS filesystem at target=%s with source=%s\n",
|
||||||
BINDIR, devname);
|
BINDIR, devname);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user