mirror of
https://github.com/apache/nuttx-apps.git
synced 2025-10-21 14:42:20 +08:00
Apps Issue #246: Replace romdisk_register() with boardctl(BOARDIOC_ROMDISK)
C file changes: examples/bastest/bastest_main.c examples/elf/elf_main.c examples/module/module_main.c examples/posix_spawn/spawn_main.c examples/romfs/romfs_main.c examples/sotest/sotest_main.c examples/unionfs/unionfs_main.c Update examples/elf/elf_main.c Co-authored-by: Xiang Xiao <xiaoxiang781216@gmail.com> Update examples/unionfs/unionfs_main.c Co-authored-by: Xiang Xiao <xiaoxiang781216@gmail.com> Update examples/unionfs/unionfs_main.c Co-authored-by: Xiang Xiao <xiaoxiang781216@gmail.com> Update examples/posix_spawn/spawn_main.c Co-authored-by: Xiang Xiao <xiaoxiang781216@gmail.com> Update examples/elf/elf_main.c Co-authored-by: Xiang Xiao <xiaoxiang781216@gmail.com> Update examples/elf/elf_main.c Co-authored-by: Xiang Xiao <xiaoxiang781216@gmail.com>
This commit is contained in:

committed by
Xiang Xiao

parent
bb1e93cb67
commit
f0c044adb1
@@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* examples/posix_spawn/spawn_main.c
|
||||
* apps/examples/posix_spawn/spawn_main.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
@@ -83,12 +83,12 @@
|
||||
#define NSECTORS(b) (((b)+SECTORSIZE-1)/SECTORSIZE)
|
||||
#define MOUNTPT "/mnt/romfs"
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_ELF_DEVMINOR
|
||||
# define CONFIG_EXAMPLES_ELF_DEVMINOR 0
|
||||
#ifndef CONFIG_EXAMPLES_POSIXSPAWN_DEVMINOR
|
||||
# define CONFIG_EXAMPLES_POSIXSPAWN_DEVMINOR 0
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_EXAMPLES_ELF_DEVPATH
|
||||
# define CONFIG_EXAMPLES_ELF_DEVPATH "/dev/ram0"
|
||||
#ifndef CONFIG_EXAMPLES_POSIXSPAWN_DEVPATH
|
||||
# define CONFIG_EXAMPLES_POSIXSPAWN_DEVPATH "/dev/ram0"
|
||||
#endif
|
||||
|
||||
/* If CONFIG_DEBUG_FEATURES is enabled, use info/err instead of printf so
|
||||
@@ -207,6 +207,7 @@ int main(int argc, FAR char *argv[])
|
||||
FAR const char *filepath;
|
||||
pid_t pid;
|
||||
int ret;
|
||||
struct boardioc_romdisk_s desc;
|
||||
|
||||
/* Initialize the memory monitor */
|
||||
|
||||
@@ -214,15 +215,19 @@ int main(int argc, FAR char *argv[])
|
||||
|
||||
/* Create a ROM disk for the ROMFS filesystem */
|
||||
|
||||
message("Registering romdisk at /dev/ram%d\n",
|
||||
CONFIG_EXAMPLES_ELF_DEVMINOR);
|
||||
desc.minor = CONFIG_EXAMPLES_POSIXSPAWN_DEVMINOR; /* Minor device number of 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.image = (FAR uint8_t *)romfs_img; /* File system image */
|
||||
|
||||
message("Registering romdisk at /dev/ram%d\n",
|
||||
CONFIG_EXAMPLES_POSIXSPAWN_DEVMINOR);
|
||||
|
||||
ret = boardctl(BOARDIOC_ROMDISK, (uintptr_t)&desc);
|
||||
|
||||
ret = romdisk_register(CONFIG_EXAMPLES_ELF_DEVMINOR,
|
||||
(FAR uint8_t *)romfs_img, NSECTORS(romfs_img_len),
|
||||
SECTORSIZE);
|
||||
if (ret < 0)
|
||||
{
|
||||
errmsg("ERROR: romdisk_register failed: %d\n", ret);
|
||||
errmsg("ERROR: romdisk_register failed: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -231,14 +236,14 @@ int main(int argc, FAR char *argv[])
|
||||
/* Mount the file system */
|
||||
|
||||
message("Mounting ROMFS filesystem at target=%s with source=%s\n",
|
||||
MOUNTPT, CONFIG_EXAMPLES_ELF_DEVPATH);
|
||||
MOUNTPT, CONFIG_EXAMPLES_POSIXSPAWN_DEVPATH);
|
||||
|
||||
ret = mount(CONFIG_EXAMPLES_ELF_DEVPATH, MOUNTPT, "romfs",
|
||||
ret = mount(CONFIG_EXAMPLES_POSIXSPAWN_DEVPATH, MOUNTPT, "romfs",
|
||||
MS_RDONLY, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
errmsg("ERROR: mount(%s,%s,romfs) failed: %d\n",
|
||||
CONFIG_EXAMPLES_ELF_DEVPATH, MOUNTPT, errno);
|
||||
errmsg("ERROR: mount(%s,%s,romfs) failed: %s\n",
|
||||
CONFIG_EXAMPLES_POSIXSPAWN_DEVPATH, MOUNTPT, strerror(errno));
|
||||
}
|
||||
|
||||
mm_update(&g_mmstep, "after mount");
|
||||
|
Reference in New Issue
Block a user