diff --git a/sched/Kconfig b/sched/Kconfig index f0f9ba876de..3a4d0eb6430 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 62213ccd782..7834aa2556a 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)