New apps/examples/module and sotest configuration options
This commit is contained in:
parent
b2210c3a25
commit
3ab2aec4e8
@ -6,20 +6,65 @@
|
||||
config EXAMPLES_MODULE
|
||||
bool "Module Example"
|
||||
default n
|
||||
depends on MODULE && LIB_BOARDCTL && BUILD_FLAT
|
||||
depends on MODULE && LIB_BOARDCTL
|
||||
select BOARDCTL_OS_SYMTAB
|
||||
---help---
|
||||
Enable the module example
|
||||
|
||||
NOTE: This example can only be used in the FLAT build mode because
|
||||
it makes illegal OS calls to ramdisk_register(), register_device(),
|
||||
and unregister_device(). A proper solution would include the ROMFS
|
||||
file system containing the test module file in the kernel address
|
||||
space and would register it with logic in the configs/ board directory
|
||||
at start-up.
|
||||
|
||||
if EXAMPLES_MODULE
|
||||
|
||||
config EXAMPLES_MODULE_BUILTINFS
|
||||
bool "Built-in File System"
|
||||
default y
|
||||
depends on FS_ROMFS && BUILD_FLAT
|
||||
---help---
|
||||
This example supports a very, non-standard but also very convenient
|
||||
way of testing with example using CONFIG_EXAMPLES_MODULE_BUILTINFS.
|
||||
If this option is selected, the test modules will be built,
|
||||
installed in the module/lib/fsroot, then converted to a built-in
|
||||
ROMFS file system.
|
||||
|
||||
When the test runs, it will automatically create the ROMFS block
|
||||
device and mount the test modules for testing.
|
||||
|
||||
If this option is not selected, then the modules will be left in
|
||||
the fsroot/ directory. You can then copy them to, say an SD card,
|
||||
for testing on the target.
|
||||
|
||||
NOTE: This option can only be used in the FLAT build mode because
|
||||
it makes an illegal OS call to ramdisk_register().
|
||||
|
||||
if EXAMPLES_MODULE_BUILTINFS
|
||||
|
||||
config EXAMPLES_MODULE_DEVMINOR
|
||||
int "ROMFS Minor Device Number"
|
||||
default 0
|
||||
---help---
|
||||
The minor device number of the ROMFS block. For example, the N in /dev/ramN.
|
||||
Used for registering the RAM block driver that will hold the ROMFS file system
|
||||
containing the MODULE executables to be tested. Default: 0
|
||||
|
||||
config EXAMPLES_MODULE_DEVPATH
|
||||
string "ROMFS Device Path"
|
||||
default "/dev/ram0"
|
||||
---help---
|
||||
The path to the ROMFS block driver device. This must match EXAMPLES_MODULE_DEVMINOR.
|
||||
Used for registering the RAM block driver that will hold the ROMFS file system
|
||||
containing the MODULE executables to be tested. Default: "/dev/ram0"
|
||||
|
||||
endif # EXAMPLES_MODULE_BUILTINFS
|
||||
|
||||
if !EXAMPLES_MODULE_BUILTINFS
|
||||
|
||||
config EXAMPLES_MODULE_BINDIR
|
||||
string "Path to Test Modules"
|
||||
default "/mnt/sdcard"
|
||||
---help---
|
||||
The path to the directory on the mounted volume where the test
|
||||
modules can found at runtime.
|
||||
|
||||
endif # !EXAMPLES_MODULE_BUILTINFS
|
||||
|
||||
config EXAMPLES_MODULE_LIBC
|
||||
bool "Link with LIBC"
|
||||
default n
|
||||
@ -44,20 +89,4 @@ config EXAMPLES_MODULE_LIBGCC
|
||||
default n
|
||||
depends on !BUILD_KERNEL && EXPERIMENTAL
|
||||
|
||||
config EXAMPLES_MODULE_DEVMINOR
|
||||
int "ROMFS Minor Device Number"
|
||||
default 0
|
||||
---help---
|
||||
The minor device number of the ROMFS block. For example, the N in /dev/ramN.
|
||||
Used for registering the RAM block driver that will hold the ROMFS file system
|
||||
containing the MODULE executables to be tested. Default: 0
|
||||
|
||||
config EXAMPLES_MODULE_DEVPATH
|
||||
string "ROMFS Device Path"
|
||||
default "/dev/ram0"
|
||||
---help---
|
||||
The path to the ROMFS block driver device. This must match EXAMPLES_MODULE_DEVMINOR.
|
||||
Used for registering the RAM block driver that will hold the ROMFS file system
|
||||
containing the MODULE executables to be tested. Default: "/dev/ram0"
|
||||
|
||||
endif
|
||||
|
2
examples/module/drivers/.gitignore
vendored
2
examples/module/drivers/.gitignore
vendored
@ -1,4 +1,4 @@
|
||||
/romfs
|
||||
/fsroot
|
||||
/romfs.h
|
||||
/romfs.img
|
||||
/mod_symtab.c
|
||||
|
@ -1,7 +1,7 @@
|
||||
############################################################################
|
||||
# apps/examples/module/drivers/Makefile
|
||||
#
|
||||
# Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@ -42,14 +42,14 @@ BUILD_SUBDIRS = chardev
|
||||
|
||||
MODULE_DIR = $(APPDIR)/examples/module
|
||||
DRIVER_DIR = $(MODULE_DIR)/drivers
|
||||
ROMFS_DIR = $(DRIVER_DIR)/romfs
|
||||
FSROOT_DIR = $(DRIVER_DIR)/fsroot
|
||||
ROMFS_IMG = $(DRIVER_DIR)/romfs.img
|
||||
ROMFS_HDR = $(DRIVER_DIR)/romfs.h
|
||||
SYMTAB_SRC = $(DRIVER_DIR)/mod_symtab.c
|
||||
|
||||
define DIR_template
|
||||
$(1)_$(2):
|
||||
$(Q) $(MAKE) -C $(1) $(3) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" CROSSDEV=$(CROSSDEV)
|
||||
$(Q) $(MAKE) -C $(1) $(3) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" FSROOT_DIR="$(FSROOT_DIR)" CROSSDEV=$(CROSSDEV)
|
||||
endef
|
||||
|
||||
all: $(ROMFS_HDR) $(DIRLIST_HDR) $(SYMTAB_SRC)
|
||||
@ -63,36 +63,40 @@ $(foreach DIR, $(BUILD_SUBDIRS), $(eval $(call DIR_template,$(DIR),install,insta
|
||||
|
||||
build: $(foreach DIR, $(BUILD_SUBDIRS), $(DIR)_build)
|
||||
|
||||
# Install each program in the romfs directory
|
||||
# Install each program in the fsroot directory
|
||||
|
||||
install: $(foreach DIR, $(BUILD_SUBDIRS), $(DIR)_install)
|
||||
|
||||
# Create the romfs directory
|
||||
# Create the fsroot directory
|
||||
|
||||
$(ROMFS_DIR):
|
||||
$(Q) mkdir $(ROMFS_DIR)
|
||||
$(FSROOT_DIR):
|
||||
$(Q) mkdir $(FSROOT_DIR)
|
||||
|
||||
# Populate the romfs directory
|
||||
# Populate the fsroot directory
|
||||
|
||||
populate: $(ROMFS_DIR) build install
|
||||
populate: $(FSROOT_DIR) build install
|
||||
|
||||
# Create the romfs.img file from the populated romfs directory
|
||||
# Create the romfs.img file from the populated fsroot directory
|
||||
|
||||
$(ROMFS_IMG): populate
|
||||
$(Q) genromfs -f $@ -d $(ROMFS_DIR) -V "MODULETEST"
|
||||
ifeq ($(CONFIG_EXAMPLES_MODULE_BUILTINFS),y)
|
||||
$(Q) genromfs -f $@ -d $(FSROOT_DIR) -V "MODULETEST"
|
||||
endif
|
||||
|
||||
# Create the romfs.h header file from the romfs.img file
|
||||
|
||||
$(ROMFS_HDR) : $(ROMFS_IMG)
|
||||
ifeq ($(CONFIG_EXAMPLES_MODULE_BUILTINFS),y)
|
||||
$(Q) (cd $(DRIVER_DIR); xxd -i romfs.img | sed -e "s/^unsigned/static const unsigned/g" >$@)
|
||||
endif
|
||||
|
||||
# Create the exported symbol table
|
||||
|
||||
$(SYMTAB_SRC): build
|
||||
$(Q) $(DRIVER_DIR)/mksymtab.sh $(ROMFS_DIR) >$@
|
||||
$(Q) $(DRIVER_DIR)/mksymtab.sh $(FSROOT_DIR) >$@
|
||||
|
||||
# Clean each subdirectory
|
||||
|
||||
clean: $(foreach DIR, $(ALL_SUBDIRS), $(DIR)_clean)
|
||||
$(Q) rm -f $(ROMFS_HDR) $(DIRLIST_HDR) $(ROMFS_IMG) $(SYMTAB_SRC)
|
||||
$(Q) rm -rf $(ROMFS_DIR)
|
||||
$(Q) rm -rf $(FSROOT_DIR)
|
||||
|
@ -90,5 +90,5 @@ clean:
|
||||
$(call CLEAN)
|
||||
|
||||
install:
|
||||
$(Q) mkdir -p $(ROMFS_DIR)
|
||||
$(Q) install $(BIN) $(ROMFS_DIR)/$(BIN)
|
||||
$(Q) mkdir -p $(FSROOT_DIR)
|
||||
$(Q) install $(BIN) $(FSROOT_DIR)/$(BIN)
|
||||
|
@ -40,9 +40,11 @@
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/compiler.h>
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_MODULE_BUILTINFS
|
||||
# include <sys/mount.h>
|
||||
#include <sys/boardctl.h>
|
||||
#endif
|
||||
|
||||
#include <sys/boardctl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
@ -52,11 +54,13 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/drivers/ramdisk.h>
|
||||
#include <nuttx/module.h>
|
||||
#include <nuttx/binfmt/symtab.h>
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_MODULE_BUILTINFS
|
||||
# include <nuttx/drivers/ramdisk.h>
|
||||
# include "drivers/romfs.h"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
@ -74,6 +78,7 @@
|
||||
# error "You must select CONFIG_MODULE in your configuration file"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_MODULE_BUILTINFS
|
||||
# ifndef CONFIG_FS_ROMFS
|
||||
# error "You must select CONFIG_FS_ROMFS in your configuration file"
|
||||
# endif
|
||||
@ -86,7 +91,7 @@
|
||||
|
||||
# define SECTORSIZE 64
|
||||
# define NSECTORS(b) (((b)+SECTORSIZE-1)/SECTORSIZE)
|
||||
#define MOUNTPT "/mnt/romfs"
|
||||
# define BINDIR "/mnt/romfs"
|
||||
|
||||
# ifndef CONFIG_EXAMPLES_MODULE_DEVMINOR
|
||||
# define CONFIG_EXAMPLES_MODULE_DEVMINOR 0
|
||||
@ -95,6 +100,9 @@
|
||||
# ifndef CONFIG_EXAMPLES_MODULE_DEVPATH
|
||||
# define CONFIG_EXAMPLES_MODULE_DEVPATH "/dev/ram0"
|
||||
# endif
|
||||
#else
|
||||
# define BINDIR CONFIG_EXAMPLES_MODULE_BINDIR
|
||||
#endif /* CONFIG_EXAMPLES_MODULE_BUILTINFS */
|
||||
|
||||
/****************************************************************************
|
||||
* Private data
|
||||
@ -141,6 +149,7 @@ int module_main(int argc, char *argv[])
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_MODULE_BUILTINFS
|
||||
/* Create a ROM disk for the ROMFS filesystem */
|
||||
|
||||
printf("main: Registering romdisk at /dev/ram%d\n",
|
||||
@ -164,19 +173,20 @@ int module_main(int argc, char *argv[])
|
||||
/* Mount the file system */
|
||||
|
||||
printf("main: Mounting ROMFS filesystem at target=%s with source=%s\n",
|
||||
MOUNTPT, CONFIG_EXAMPLES_MODULE_DEVPATH);
|
||||
BINDIR, CONFIG_EXAMPLES_MODULE_DEVPATH);
|
||||
|
||||
ret = mount(CONFIG_EXAMPLES_MODULE_DEVPATH, MOUNTPT, "romfs", MS_RDONLY, NULL);
|
||||
ret = mount(CONFIG_EXAMPLES_MODULE_DEVPATH, BINDIR, "romfs", MS_RDONLY, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: mount(%s,%s,romfs) failed: %s\n",
|
||||
CONFIG_EXAMPLES_MODULE_DEVPATH, MOUNTPT, errno);
|
||||
CONFIG_EXAMPLES_MODULE_DEVPATH, BINDIR, errno);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#endif /* CONFIG_EXAMPLES_MODULE_BUILTINFS */
|
||||
|
||||
/* Install the character driver */
|
||||
|
||||
handle = insmod(MOUNTPT "/chardev", "chardev");
|
||||
handle = insmod(BINDIR "/chardev", "chardev");
|
||||
if (handle == NULL)
|
||||
{
|
||||
int errcode = errno;
|
||||
|
@ -6,18 +6,64 @@
|
||||
config EXAMPLES_SOTEST
|
||||
bool "Shared Library Example"
|
||||
default n
|
||||
depends on LIBC_DLLFCN && BUILD_FLAT
|
||||
depends on LIBC_DLLFCN
|
||||
---help---
|
||||
Enable the shared library example
|
||||
|
||||
NOTE: This example can only be used in the FLAT build mode because
|
||||
it makes an illegal OS call to ramdisk_register(). A proper solution
|
||||
would include the ROMFS file system containing the test shared
|
||||
library in the kernel address space and would register it with logic
|
||||
in the configs/ board directory at start-up.
|
||||
|
||||
if EXAMPLES_SOTEST
|
||||
|
||||
config EXAMPLES_SOTEST_BUILTINFS
|
||||
bool "Built-in File System"
|
||||
default y
|
||||
depends on FS_ROMFS && BUILD_FLAT
|
||||
---help---
|
||||
This example supports a very, non-standard but also very convenient
|
||||
way of testing with example using CONFIG_EXAMPLES_SOTEST_BUILTINFS.
|
||||
If this option is selected, the test shared libraries will be built,
|
||||
installed in the sotest/lib/fsroot, then converted to a built-in
|
||||
ROMFS file system.
|
||||
|
||||
When the test runs, it will automatically create the ROMFS block
|
||||
device and mount the test shared libraries for testing.
|
||||
|
||||
If this option is not selected, then the shared libraries will be
|
||||
left in the fsroot/ directory. You can then copy them to, say an SD
|
||||
card, for testing on the target.
|
||||
|
||||
NOTE: This option can only be used in the FLAT build mode because
|
||||
it makes an illegal OS call to ramdisk_register().
|
||||
|
||||
if EXAMPLES_SOTEST_BUILTINFS
|
||||
|
||||
config EXAMPLES_SOTEST_DEVMINOR
|
||||
int "ROMFS Minor Device Number"
|
||||
default 0
|
||||
---help---
|
||||
The minor device number of the ROMFS block. For example, the N in /dev/ramN.
|
||||
Used for registering the RAM block driver that will hold the ROMFS file system
|
||||
containing the SOTEST executables to be tested. Default: 0
|
||||
|
||||
config EXAMPLES_SOTEST_DEVPATH
|
||||
string "ROMFS Device Path"
|
||||
default "/dev/ram0"
|
||||
---help---
|
||||
The path to the ROMFS block driver device. This must match EXAMPLES_SOTEST_DEVMINOR.
|
||||
Used for registering the RAM block driver that will hold the ROMFS file system
|
||||
containing the SOTEST executables to be tested. Default: "/dev/ram0"
|
||||
|
||||
endif # EXAMPLES_SOTEST_BUILTINFS
|
||||
|
||||
if !EXAMPLES_SOTEST_BUILTINFS
|
||||
|
||||
config EXAMPLES_SOTEST_BINDIR
|
||||
string "Path to Test Shared Libraries"
|
||||
default "/mnt/sdcard"
|
||||
---help---
|
||||
The path to the directoy on the mounted volume where the test shared
|
||||
libraries can found at runtime.
|
||||
|
||||
endif # !EXAMPLES_SOTEST_BUILTINFS
|
||||
|
||||
config EXAMPLES_SOTEST_LIBC
|
||||
bool "Link with LIBC"
|
||||
default n
|
||||
@ -42,20 +88,4 @@ config EXAMPLES_SOTEST_LIBGCC
|
||||
default n
|
||||
depends on !BUILD_KERNEL && EXPERIMENTAL
|
||||
|
||||
config EXAMPLES_SOTEST_DEVMINOR
|
||||
int "ROMFS Minor Device Number"
|
||||
default 0
|
||||
---help---
|
||||
The minor device number of the ROMFS block. For example, the N in /dev/ramN.
|
||||
Used for registering the RAM block driver that will hold the ROMFS file system
|
||||
containing the SOTEST executables to be tested. Default: 0
|
||||
|
||||
config EXAMPLES_SOTEST_DEVPATH
|
||||
string "ROMFS Device Path"
|
||||
default "/dev/ram0"
|
||||
---help---
|
||||
The path to the ROMFS block driver device. This must match EXAMPLES_SOTEST_DEVMINOR.
|
||||
Used for registering the RAM block driver that will hold the ROMFS file system
|
||||
containing the SOTEST executables to be tested. Default: "/dev/ram0"
|
||||
|
||||
endif
|
||||
|
@ -1,7 +1,7 @@
|
||||
############################################################################
|
||||
# apps/examples/sotest/Makefile
|
||||
#
|
||||
# Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
|
2
examples/sotest/lib/.gitignore
vendored
2
examples/sotest/lib/.gitignore
vendored
@ -1,4 +1,4 @@
|
||||
/romfs
|
||||
/fsroot
|
||||
/romfs.h
|
||||
/romfs.img
|
||||
/sot_symtab.c
|
||||
|
@ -1,7 +1,7 @@
|
||||
############################################################################
|
||||
# apps/examples/sotest/lib/Makefile
|
||||
#
|
||||
# Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@ -47,14 +47,14 @@ endif
|
||||
|
||||
SOTEST_DIR = $(APPDIR)/examples/sotest
|
||||
LIB_DIR = $(SOTEST_DIR)/lib
|
||||
ROMFS_DIR = $(LIB_DIR)/romfs
|
||||
FSROOT_DIR = $(LIB_DIR)/fsroot
|
||||
ROMFS_IMG = $(LIB_DIR)/romfs.img
|
||||
ROMFS_HDR = $(LIB_DIR)/romfs.h
|
||||
SYMTAB_SRC = $(LIB_DIR)/sot_symtab.c
|
||||
|
||||
define DIR_template
|
||||
$(1)_$(2):
|
||||
$(Q) $(MAKE) -C $(1) $(3) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" CROSSDEV=$(CROSSDEV)
|
||||
$(Q) $(MAKE) -C $(1) $(3) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" FSROOT_DIR="$(FSROOT_DIR)" CROSSDEV=$(CROSSDEV)
|
||||
endef
|
||||
|
||||
all: $(ROMFS_HDR) $(DIRLIST_HDR) $(SYMTAB_SRC)
|
||||
@ -68,36 +68,40 @@ $(foreach DIR, $(BUILD_SUBDIRS), $(eval $(call DIR_template,$(DIR),install,insta
|
||||
|
||||
build: $(foreach DIR, $(BUILD_SUBDIRS), $(DIR)_build)
|
||||
|
||||
# Install each program in the romfs directory
|
||||
# Install each program in the fsroot directory
|
||||
|
||||
install: $(foreach DIR, $(BUILD_SUBDIRS), $(DIR)_install)
|
||||
|
||||
# Create the romfs directory
|
||||
# Create the fsroot directory
|
||||
|
||||
$(ROMFS_DIR):
|
||||
$(Q) mkdir $(ROMFS_DIR)
|
||||
$(FSROOT_DIR):
|
||||
$(Q) mkdir $(FSROOT_DIR)
|
||||
|
||||
# Populate the romfs directory
|
||||
# Populate the fsroot directory
|
||||
|
||||
populate: $(ROMFS_DIR) build install
|
||||
populate: $(FSROOT_DIR) build install
|
||||
|
||||
# Create the romfs.img file from the populated romfs directory
|
||||
# Create the romfs.img file from the populated fsroot directory
|
||||
|
||||
$(ROMFS_IMG): populate
|
||||
$(Q) genromfs -f $@ -d $(ROMFS_DIR) -V "SOTESTTEST"
|
||||
ifeq ($(CONFIG_EXAMPLES_SOTEST_BUILTINFS),y)
|
||||
$(Q) genromfs -f $@ -d $(FSROOT_DIR) -V "SOTESTTEST"
|
||||
endif
|
||||
|
||||
# Create the romfs.h header file from the romfs.img file
|
||||
|
||||
$(ROMFS_HDR) : $(ROMFS_IMG)
|
||||
ifeq ($(CONFIG_EXAMPLES_SOTEST_BUILTINFS),y)
|
||||
$(Q) (cd $(LIB_DIR); xxd -i romfs.img | sed -e "s/^unsigned/static const unsigned/g" >$@)
|
||||
endif
|
||||
|
||||
# Create the exported symbol table
|
||||
|
||||
$(SYMTAB_SRC): build
|
||||
$(Q) $(LIB_DIR)/mksymtab.sh $(ROMFS_DIR) >$@
|
||||
$(Q) $(LIB_DIR)/mksymtab.sh $(FSROOT_DIR) >$@
|
||||
|
||||
# Clean each subdirectory
|
||||
|
||||
clean: $(foreach DIR, $(ALL_SUBDIRS), $(DIR)_clean)
|
||||
$(Q) rm -f $(ROMFS_HDR) $(DIRLIST_HDR) $(ROMFS_IMG) $(SYMTAB_SRC)
|
||||
$(Q) rm -rf $(ROMFS_DIR)
|
||||
$(Q) rm -rf $(FSROOT_DIR)
|
||||
|
@ -90,5 +90,5 @@ clean:
|
||||
$(call CLEAN)
|
||||
|
||||
install:
|
||||
$(Q) mkdir -p $(ROMFS_DIR)
|
||||
$(Q) install $(BIN) $(ROMFS_DIR)/$(BIN)
|
||||
$(Q) mkdir -p $(FSROOT_DIR)
|
||||
$(Q) install $(BIN) $(FSROOT_DIR)/$(BIN)
|
||||
|
@ -90,5 +90,5 @@ clean:
|
||||
$(call CLEAN)
|
||||
|
||||
install:
|
||||
$(Q) mkdir -p $(ROMFS_DIR)
|
||||
$(Q) install $(BIN) $(ROMFS_DIR)/$(BIN)
|
||||
$(Q) mkdir -p $(FSROOT_DIR)
|
||||
$(Q) install $(BIN) $(FSROOT_DIR)/$(BIN)
|
||||
|
@ -39,7 +39,10 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_SOTEST_BUILTINFS
|
||||
# include <sys/mount.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <syslog.h>
|
||||
@ -47,10 +50,12 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/drivers/ramdisk.h>
|
||||
#include <nuttx/binfmt/symtab.h>
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_SOTEST_BUILTINFS
|
||||
# include <nuttx/drivers/ramdisk.h>
|
||||
# include "lib/romfs.h"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
@ -64,6 +69,7 @@
|
||||
# error "You must select CONFIG_LIBC_DLLFCN in your configuration file"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_SOTEST_BUILTINFS
|
||||
# ifndef CONFIG_FS_ROMFS
|
||||
# error "You must select CONFIG_FS_ROMFS in your configuration file"
|
||||
# endif
|
||||
@ -76,7 +82,7 @@
|
||||
|
||||
# define SECTORSIZE 64
|
||||
# define NSECTORS(b) (((b)+SECTORSIZE-1)/SECTORSIZE)
|
||||
#define MOUNTPT "/mnt/romfs"
|
||||
# define BINDIR "/mnt/romfs"
|
||||
|
||||
# ifndef CONFIG_EXAMPLES_SOTEST_DEVMINOR
|
||||
# define CONFIG_EXAMPLES_SOTEST_DEVMINOR 0
|
||||
@ -85,10 +91,9 @@
|
||||
# ifndef CONFIG_EXAMPLES_SOTEST_DEVPATH
|
||||
# define CONFIG_EXAMPLES_SOTEST_DEVPATH "/dev/ram0"
|
||||
# endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private data
|
||||
****************************************************************************/
|
||||
#else
|
||||
# define BINDIR CONFIG_EXAMPLES_SOTEST_BINDIR
|
||||
#endif /* CONFIG_EXAMPLES_SOTEST_BUILTINFS */
|
||||
|
||||
/****************************************************************************
|
||||
* Symbols from Auto-Generated Code
|
||||
@ -128,6 +133,7 @@ int sotest_main(int argc, char *argv[])
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_SOTEST_BUILTINFS
|
||||
/* Create a ROM disk for the ROMFS filesystem */
|
||||
|
||||
printf("main: Registering romdisk at /dev/ram%d\n",
|
||||
@ -152,15 +158,16 @@ int sotest_main(int argc, char *argv[])
|
||||
/* Mount the file system */
|
||||
|
||||
printf("main: Mounting ROMFS filesystem at target=%s with source=%s\n",
|
||||
MOUNTPT, CONFIG_EXAMPLES_SOTEST_DEVPATH);
|
||||
BINDIR, CONFIG_EXAMPLES_SOTEST_DEVPATH);
|
||||
|
||||
ret = mount(CONFIG_EXAMPLES_SOTEST_DEVPATH, MOUNTPT, "romfs", MS_RDONLY, NULL);
|
||||
ret = mount(CONFIG_EXAMPLES_SOTEST_DEVPATH, BINDIR, "romfs", MS_RDONLY, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: mount(%s,%s,romfs) failed: %s\n",
|
||||
CONFIG_EXAMPLES_SOTEST_DEVPATH, MOUNTPT, errno);
|
||||
CONFIG_EXAMPLES_SOTEST_DEVPATH, BINDIR, errno);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#endif /* CONFIG_EXAMPLES_SOTEST_BUILTINFS */
|
||||
|
||||
#if CONFIG_MODLIB_MAXDEPEND > 0
|
||||
/* Install the first test shared library. The first shared library only
|
||||
@ -170,7 +177,7 @@ int sotest_main(int argc, char *argv[])
|
||||
|
||||
/* Install the second test shared library */
|
||||
|
||||
handle1 = dlopen(MOUNTPT "/modprint", RTLD_NOW | RTLD_LOCAL);
|
||||
handle1 = dlopen(BINDIR "/modprint", RTLD_NOW | RTLD_LOCAL);
|
||||
if (handle1 == NULL)
|
||||
{
|
||||
fprintf(stderr, "ERROR: dlopen(/modprint) failed\n");
|
||||
@ -180,7 +187,7 @@ int sotest_main(int argc, char *argv[])
|
||||
|
||||
/* Install the second test shared library */
|
||||
|
||||
handle2 = dlopen(MOUNTPT "/sotest", RTLD_NOW | RTLD_LOCAL);
|
||||
handle2 = dlopen(BINDIR "/sotest", RTLD_NOW | RTLD_LOCAL);
|
||||
if (handle2 == NULL)
|
||||
{
|
||||
fprintf(stderr, "ERROR: dlopen(/sotest) failed\n");
|
||||
@ -278,13 +285,15 @@ int sotest_main(int argc, char *argv[])
|
||||
}
|
||||
#endif
|
||||
|
||||
ret = umount(MOUNTPT);
|
||||
#ifdef CONFIG_EXAMPLES_SOTEST_BUILTINFS
|
||||
ret = umount(BINDIR);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "ERROR: umount(%s) failed: %d\n",
|
||||
MOUNTPT, errno);
|
||||
BINDIR, errno);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#endif /* CONFIG_EXAMPLES_SOTEST_BUILTINFS */
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user