diff options
-rw-r--r-- | nuttx/configs/eagle100/nxflat/defconfig | 4 | ||||
-rw-r--r-- | nuttx/examples/nxflat/nxflat_main.c | 38 | ||||
-rw-r--r-- | nuttx/examples/nxflat/tests/Makefile | 2 |
3 files changed, 40 insertions, 4 deletions
diff --git a/nuttx/configs/eagle100/nxflat/defconfig b/nuttx/configs/eagle100/nxflat/defconfig index f66eaa82f..14b4c795e 100644 --- a/nuttx/configs/eagle100/nxflat/defconfig +++ b/nuttx/configs/eagle100/nxflat/defconfig @@ -295,7 +295,7 @@ CONFIG_DISABLE_POSIX_TIMERS=n CONFIG_DISABLE_PTHREAD=n CONFIG_DISABLE_SIGNALS=n CONFIG_DISABLE_MQUEUE=n -CONFIG_DISABLE_MOUNTPOINT=y +CONFIG_DISABLE_MOUNTPOINT=n CONFIG_DISABLE_ENVIRON=y CONFIG_DISABLE_POLL=y @@ -382,7 +382,7 @@ CONFIG_PREALLOC_TIMERS=4 # CONFIG_FAT_SECTORSIZE - Max supported sector size # CONFIG_FS_ROMFS - Enable ROMFS filesystem support CONFIG_FS_FAT=n -CONFIG_FS_ROMFS=n +CONFIG_FS_ROMFS=y # # SPI-based MMC/SD driver diff --git a/nuttx/examples/nxflat/nxflat_main.c b/nuttx/examples/nxflat/nxflat_main.c index e792fa1b7..4c4de4313 100644 --- a/nuttx/examples/nxflat/nxflat_main.c +++ b/nuttx/examples/nxflat/nxflat_main.c @@ -39,6 +39,7 @@ #include <nuttx/config.h> #include <sys/types.h> +#include <sys/mount.h> #include <stdio.h> #include <stdlib.h> @@ -48,7 +49,9 @@ #include <debug.h> #include <errno.h> +#include <nuttx/ramdisk.h> #include <nuttx/binfmt.h> + #include "tests/romfs.h" #include "tests/dirlist.h" #include "tests/symtab.h" @@ -57,6 +60,11 @@ * Definitions ****************************************************************************/ +#define SECTORSIZE 512 +#define NSECTORS(b) (((b)+SECTORSIZE-1)/SECTORSIZE) +#define ROMFSDEV "/dev/ram0" +#define MOUNTPT "/mnt/romfs" + /**************************************************************************** * Private Types ****************************************************************************/ @@ -68,6 +76,8 @@ static const char delimiter[] = "****************************************************************************"; +static char path[128]; + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -103,12 +113,38 @@ int user_start(int argc, char *argv[]) int ret; int i; + /* Create a ROM disk for the ROMFS filesystem */ + + printf("Registering romdisk\n"); + ret = romdisk_register(0, romfs_img, NSECTORS(romfs_img_len), SECTORSIZE); + if (ret < 0) + { + fprintf(stderr, "ERROR: romdisk_register failed: %d\n", ret); + exit(1); + } + + /* Mount the file system */ + + printf("Mounting ROMFS filesystem at target=%s with source=%s\n", + MOUNTPT, ROMFSDEV); + + ret = mount(ROMFSDEV, MOUNTPT, "romfs", MS_RDONLY, NULL); + if (ret < 0) + { + fprintf(stderr, "ERROR: mount(%s,%s,romfs) failed: %s\n", + ROMFSDEV, MOUNTPT, errno); + } + + /* Now excercise every progrm in the ROMFS file system */ + for (i = 0; dirlist[i]; i++) { testheader(dirlist[i]); memset(&bin, 0, sizeof(struct binary_s)); - bin.filename = dirlist[i]; + snprintf(path, 128, "%s/%s", MOUNTPT, dirlist[i]); + + bin.filename = path; bin.exports = exports; bin.nexports = NEXPORTS; diff --git a/nuttx/examples/nxflat/tests/Makefile b/nuttx/examples/nxflat/tests/Makefile index c327e71b4..77fd01fb7 100644 --- a/nuttx/examples/nxflat/tests/Makefile +++ b/nuttx/examples/nxflat/tests/Makefile @@ -82,7 +82,7 @@ $(ROMFS_IMG): populate # Create the romfs.h header file from the romfs.img file $(ROMFS_HDR) : $(ROMFS_IMG) - @xxd -i $^ >$@ + @(cd $(TESTS_DIR); xxd -i romfs.img >$@) # Create the dirlist.h header file from the romfs directory |