diff --git a/Kconfig b/Kconfig index c2db1e8682..415774c0b3 100644 --- a/Kconfig +++ b/Kconfig @@ -161,6 +161,16 @@ config APPS_DIR example, to include makefile fragments (e.g., .config or Make.defs) or to set up include file paths. +config BUILD_LOADABLE + bool "NuttX application loadable build" + default n if !BUILD_KERNEL + default y if BUILD_KERNEL + ---help--- + Automatically selected if KERNEL build is selected. + This selection only effects the behavior of the 'make export' + target and currently has no effect unless you wish to build + loadable applications in a FLAT build. + choice prompt "Memory organization" default BUILD_FLAT diff --git a/configs/lc823450-xgevk/krndis/defconfig b/configs/lc823450-xgevk/krndis/defconfig index fc263aced5..78af095ba9 100644 --- a/configs/lc823450-xgevk/krndis/defconfig +++ b/configs/lc823450-xgevk/krndis/defconfig @@ -22,6 +22,7 @@ CONFIG_BINFMT_EXEPATH=y CONFIG_BOARDCTL_RESET=y CONFIG_BOARDCTL_USBDEVCTRL=y CONFIG_BOARD_LOOPSPERMSEC=12061 +CONFIG_BUILD_LOADABLE=y CONFIG_BUILD_PROTECTED=y CONFIG_C99_BOOL8=y CONFIG_CODECS_HASH_MD5=y diff --git a/configs/lc823450-xgevk/rndis/defconfig b/configs/lc823450-xgevk/rndis/defconfig index e7ed4b493b..5a7e41716a 100644 --- a/configs/lc823450-xgevk/rndis/defconfig +++ b/configs/lc823450-xgevk/rndis/defconfig @@ -21,6 +21,7 @@ CONFIG_BINFMT_EXEPATH=y CONFIG_BOARDCTL_RESET=y CONFIG_BOARDCTL_USBDEVCTRL=y CONFIG_BOARD_LOOPSPERMSEC=12061 +CONFIG_BUILD_LOADABLE=y CONFIG_BUILTIN=y CONFIG_C99_BOOL8=y CONFIG_CODECS_HASH_MD5=y diff --git a/configs/sim/README.txt b/configs/sim/README.txt index 88fbe85e8c..1aa9db6cea 100644 --- a/configs/sim/README.txt +++ b/configs/sim/README.txt @@ -561,6 +561,12 @@ ipforward Additional required settings will also be selected when you manually select the above via 'make menuconfig'. +loadable + + This configuration provides an example of loadable apps. It cannot used + with any Windows configuration, however, because Windows does not use + the ELF format. + minibasic This configuration was used to test the Mini Basic port at diff --git a/configs/sim/loadable/defconfig b/configs/sim/loadable/defconfig index 4baa2aeffa..5cb0291b62 100644 --- a/configs/sim/loadable/defconfig +++ b/configs/sim/loadable/defconfig @@ -1,4 +1,3 @@ -CONFIG_APPS_LOADABLE=y CONFIG_ARCH="sim" CONFIG_ARCH_BOARD="sim" CONFIG_ARCH_BOARD_SIM=y @@ -6,26 +5,31 @@ CONFIG_ARCH_SIM=y CONFIG_BINFMT_EXEPATH=y CONFIG_BOARDCTL_APP_SYMTAB=y CONFIG_BOARDCTL_POWEROFF=y +CONFIG_BOARD_INITIALIZE=y +CONFIG_BUILD_LOADABLE=y CONFIG_BUILTIN=y CONFIG_CLOCK_MONOTONIC=y CONFIG_DEBUG_FEATURES=y CONFIG_DEBUG_SYMBOLS=y CONFIG_ELF=y -CONFIG_EXAMPLES_HELLO=y +CONFIG_EXAMPLES_HELLO=m CONFIG_EXAMPLES_HELLO_STACKSIZE=8192 CONFIG_EXECFUNCS_HAVE_SYMTAB=y CONFIG_FS_HOSTFS=y CONFIG_FS_PROCFS=y CONFIG_IDLETHREAD_STACKSIZE=4096 CONFIG_INIT_FILEPATH=y +CONFIG_INIT_MOUNT=y CONFIG_INIT_MOUNT_DATA="fs=../apps/exe/system" CONFIG_INIT_MOUNT_FLAGS=0x1 CONFIG_INIT_MOUNT_FSTYPE="hostfs" +CONFIG_INIT_MOUNT_SOURCE="" CONFIG_INIT_MOUNT_TARGET="/system" CONFIG_LIBC_EXECFUNCS=y CONFIG_MEMSET_OPTSPEED=y CONFIG_NSH_ARCHINIT=y CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILE_APPS=y CONFIG_NSH_LINELEN=128 CONFIG_NSH_READLINE=y CONFIG_PATH_INITIAL="/system/bin" @@ -40,7 +44,7 @@ CONFIG_SIM_M32=y CONFIG_SIM_WALLTIME=y CONFIG_START_MONTH=6 CONFIG_START_YEAR=2008 -CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_NSH=m CONFIG_TIME_EXTENDED=y CONFIG_USERMAIN_STACKSIZE=4096 CONFIG_USER_INITPATH="/system/bin/nsh" diff --git a/configs/sim/src/sim_bringup.c b/configs/sim/src/sim_bringup.c index af5ef61420..ee613ae4d4 100644 --- a/configs/sim/src/sim_bringup.c +++ b/configs/sim/src/sim_bringup.c @@ -44,6 +44,7 @@ #include #include +#include #include #include #include diff --git a/configs/stm3240g-eval/knxwm/Make.defs b/configs/stm3240g-eval/knxwm/Make.defs index fafde0fd28..f469c20934 100644 --- a/configs/stm3240g-eval/knxwm/Make.defs +++ b/configs/stm3240g-eval/knxwm/Make.defs @@ -77,7 +77,7 @@ ifneq ($(CONFIG_DEBUG_NOOPT),y) endif ARCHCFLAGS = -fno-builtin -ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new -fno-rtti +ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new -fno-rtti -fpermissive ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef ARCHDEFINES = diff --git a/sched/Kconfig b/sched/Kconfig index f0f9ba876d..3a4d0eb643 100644 --- a/sched/Kconfig +++ b/sched/Kconfig @@ -363,6 +363,40 @@ config INIT_NEXPORTS Any kernel mode symbols tables would not be usable for resolving symbols in user mode executables. +menuconfig INIT_MOUNT + bool "Auto-mount init file system" + default n + depends on !DISABLE_MOUNTPOINT + ---help--- + In order to use the the initial startup program when CONFIG_INIT_FILEPATH + is provided, it is necessary to mount the initial file system that + provides init program. Normally this mount is done in the board-specific + initialization logic. However, if the mount is very simple, it can be + performed by the OS bring-up logic itself by selecting this option. + +if INIT_MOUNT + +config INIT_MOUNT_SOURCE + string "The block device to mount" + default "/dev/ram0" + +config INIT_MOUNT_TARGET + string "Path to the mounted file system" + default "/bin" + +config INIT_MOUNT_FSTYPE + string "The file system type to mount" + default "romfs" + +config INIT_MOUNT_FLAGS + hex "Flags passed to mount" + default 0 + +config INIT_MOUNT_DATA + string "Additional data passed to mount" + default "" + +endif # INIT_MOUNT endif # INIT_FILEPATH config RR_INTERVAL diff --git a/sched/init/os_bringup.c b/sched/init/os_bringup.c index 62213ccd78..7834aa2556 100644 --- a/sched/init/os_bringup.c +++ b/sched/init/os_bringup.c @@ -45,7 +45,9 @@ #include #include +#include #include +#include #include #include @@ -98,10 +100,6 @@ * program. */ -# ifndef CONFIG_BOARD_INITIALIZE -# warning You probably need CONFIG_BOARD_INITIALIZE to mount the file system -# endif - # ifndef CONFIG_USER_INITPATH /* Path to the initialization program must have been provided */ @@ -287,6 +285,16 @@ static inline void os_do_appstart(void) board_initialize(); #endif +#ifdef CONFIG_INIT_MOUNT + /* Mount the file system containing the init program. */ + + ret = mount(CONFIG_INIT_MOUNT_SOURCE, CONFIG_INIT_MOUNT_TARGET, + CONFIG_INIT_MOUNT_FSTYPE, CONFIG_INIT_MOUNT_FLAGS, + CONFIG_INIT_MOUNT_DATA); + DEBUGASSERT(ret >= 0); + UNUSED(ret); +#endif + /* Start the application initialization program from a program in a * mounted file system. Presumably the file system was mounted as part * of the board_initialize() operation. @@ -297,6 +305,7 @@ static inline void os_do_appstart(void) ret = exec(CONFIG_USER_INITPATH, NULL, CONFIG_INIT_SYMTAB, CONFIG_INIT_NEXPORTS); ASSERT(ret >= 0); + UNUSED(ret); } #elif defined(CONFIG_INIT_NONE) diff --git a/syscall/syscall_funclookup.c b/syscall/syscall_funclookup.c index 4b99ac6efb..aeef6df668 100644 --- a/syscall/syscall_funclookup.c +++ b/syscall/syscall_funclookup.c @@ -86,7 +86,7 @@ #undef get_errno #undef set_errno -#include +#include #include /**************************************************************************** diff --git a/tools/Makefile.unix b/tools/Makefile.unix index dc5466fed9..5eb7fd8772 100644 --- a/tools/Makefile.unix +++ b/tools/Makefile.unix @@ -166,10 +166,10 @@ MKEXPORT_ARGS = -w$(WINTOOL) -t "$(TOPDIR)" ifeq ($(CONFIG_BUILD_PROTECTED),y) MKEXPORT_ARGS += -u -else -ifeq ($(CONFIG_BUILD_KERNEL),y) +else ifeq ($(CONFIG_BUILD_KERNEL),y) +MKEXPORT_ARGS += -u +else ifeq ($(CONFIG_BUILD_LOADABLE),y) MKEXPORT_ARGS += -u -endif endif ifeq ($(V),2) diff --git a/tools/Makefile.win b/tools/Makefile.win index fadb6e796d..d995c9def2 100644 --- a/tools/Makefile.win +++ b/tools/Makefile.win @@ -158,11 +158,11 @@ MKEXPORT = tools\mkexport.bat MKEXPORT_ARGS = -w$(WINTOOL) -t "$(TOPDIR)" ifeq ($(CONFIG_BUILD_PROTECTED),y) -MKEXPORT_ARGS = -u -else -ifeq ($(CONFIG_BUILD_KERNEL),y) -MKEXPORT_ARGS = -u -endif +MKEXPORT_ARGS += -u +else ifeq ($(CONFIG_BUILD_KERNEL),y) +MKEXPORT_ARGS += -u +else ifeq ($(CONFIG_BUILD_LOADABLE),y) +MKEXPORT_ARGS += -u endif ifeq ($(V),2)