diff --git a/configs/eagle100/nxflat/defconfig b/configs/eagle100/nxflat/defconfig index f66eaa82fdc..14b4c795eba 100644 --- a/configs/eagle100/nxflat/defconfig +++ b/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/examples/nxflat/nxflat_main.c b/examples/nxflat/nxflat_main.c index e792fa1b75e..4c4de43135b 100644 --- a/examples/nxflat/nxflat_main.c +++ b/examples/nxflat/nxflat_main.c @@ -39,6 +39,7 @@ #include #include +#include #include #include @@ -48,7 +49,9 @@ #include #include +#include #include + #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/examples/nxflat/tests/Makefile b/examples/nxflat/tests/Makefile index c327e71b4aa..77fd01fb73f 100644 --- a/examples/nxflat/tests/Makefile +++ b/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