Discussion:
Auto-start applications
m***@public.gmane.org
2014-03-06 20:17:29 UTC
Permalink
I just tried to reproduce this and I was struggeling a bit with the documentation. Am I correct that the rcS.template needs to reside in the same location as mkromfsimg.sh? This at least how I got it working. The resulting needs then to be placed in app/nshlib (or configs/<board>/include when CONFIG_NSH_ARCHROMFS is enabled). I might help to make this a bit more clear in the documentation.
Thanks,
Max
s***@public.gmane.org
2014-03-06 20:49:33 UTC
Permalink
Post by m***@public.gmane.org
I just tried to reproduce this and I was struggeling a bit with the documentation. Am I correct that the rcS.template needs to reside in the same location as mkromfsimg.sh? This at least how I got it working. The resulting needs then to be placed in app/nshlib (or configs/<board>/include when CONFIG_NSH_ARCHROMFS is enabled). I might help to make this a bit more clear in the documentation.
Please send changes to the documentation to remove the confusion and I will be happy to update the documentation with your changes.

Greg
m***@public.gmane.org
2014-03-06 23:11:07 UTC
Permalink
At http://www.nuttx.org/Documentation/NuttShell.html#custonshlib http://www.nuttx.org/Documentation/NuttShell.html#custonshlib under "Modifying the ROMFS Image" I think it should say
OR, if CONFIG_NSH_ARCHROMFS is defined include/arch/board/nsh_romfsimg.hThen under point 3 I would like something like:
"To generate a custom rcS file a copy of rcS.template needs to be place at tools/ and changed according to the desired start-up behaviour. Running tools/mkromfsimg.h creates nsh_romfsimg.h which needs to be copied to apps/nhslib OR if CONFIG_NSH_ARCHROMFS is defined to configs/<board>/include"

Max
s***@public.gmane.org
2014-03-06 23:50:11 UTC
Permalink
Thanks Max,
At http://www.nuttx.org/Documentation/NuttShell.html#custonshlib under "Modifying the ROMFS Image" I think it should say
"To generate a custom rcS file a copy of rcS.template needs to be place at tools/ and changed according to the desired start-up behaviour. Running tools/mkromfsimg.h creates nsh_romfsimg.h which needs to be copied to apps/nhslib OR if CONFIG_NSH_ARCHROMFS is defined to configs/<board>/include"
I have incorporated your changes as recommended.

Greg
max.kriegleder@yahoo.com [nuttx]
2017-01-20 22:29:31 UTC
Permalink
Hi Greg,

Could it be that the mkromfsimg.sh script changed? I am trying to follow my procedure (that I documented in the Documentation) but now the script fails because it is looking for a bin folder in the apps directory.

Thanks,
max
spudarnia@yahoo.com [nuttx]
2017-01-20 22:39:17 UTC
Permalink
spudarnia@yahoo.com [nuttx]
2017-01-20 22:41:48 UTC
Permalink
I don't see any recent, significant changes in nuttx/mkromfsimg.sh. Nor do I see any reference to bin/ in that file. I would need more information about the nature of the problem to have any opinion.


Maybe


$ sh -x tools/mkromfsimg.sh


That should show you everything that the script is doing.


Greg
spudarnia@yahoo.com [nuttx]
2017-01-20 22:52:13 UTC
Permalink
or are you talking about apps/tools/mkromfsimg.sh? That file has never been modified, but I see this line:

mkromfsimg.sh:fsdir=${topdir}/bin

where topdir is defined to be:

mkromfsimg.sh:topdir=$PWD
mkromfsimg.sh:fsdir=${topdir}/bin

The apps/bin/directory is created by apps/Makefile:

BIN_DIR = $(APPDIR)$(DELIM)bin

$(BIN_DIR):
mkdir -p $(BIN_DIR)

Which is a part of the target that is used to install the export ZIP file.

install: $(BIN_DIR) .install

.import: $(BIN) install

The version of mkromfsimg.sh is intended only to support the KERNEL build mode and should never be used for any other purpose.

I suspect that you are confused and are using the wrong version. You probably want the script of the same name in nuttx/tools.
spudarnia@yahoo.com [nuttx]
2017-01-20 23:21:16 UTC
Permalink
I will babble on because I am feeling chatty today.

Let me explain more about the role of apps/tools/mkromfsimg.sh in the KERNEL build.

In the kernel build, there are not tasks. There are only processes and all code lives in its own, private address space.

One consequence of that is that task_create() and friends cannot be used in the KERNEL build mode. Instead, all processes are loaded into a virtual address space from an ELF or NxFLAT file in the file system.

You have probably seen logic like this and wonder what was going on:

#ifdef CONFIG_BUILD_KERNEL
int main(int argc, FAR char *argv[])
#else
int hello_main(int argc, char *argv[])
#endif

In the FLAT and PROTECTED build mode all applications are built into a single BLOB, every symbol must have a unique name to avoid collitions.

In the KERNEL build mode, all applications are built at separated linked programs in the file system. The entry point to ALL programs is the function main().

There is also some strange magic in all of the Makefiles to build each application differently in the KERNEL build.

When you build the apps/ programs in FLAT or PROTECTED modes, all of the object files are put into an archive apps/libapps.a which is, eventually, copied to nuttx/libs and the BLOB is created by linking with lib/libapps.a.

But when you build the apps/ programs in the KERNEL mode, the directory apps/bin is created. Each source file is compiled, but the object files are not added to an archive. Instead, the object files are linked into a separate compiled and linked program. The program is then installed at apps/bin.

When the apps/ kernel build is complete, all of the programs have been installed in apps/bin. That is where apps/tools/mkromfsimg.sh file comes into to play. It takes all of the programs in apps/bin and creates a ROMFS file system image containing all of the applications. That ROMFS file system image is built into the kernel.

At run time, when the kernel boots, it will mount that ROMFS file system at /bin. In the FLAT build mode, the OS boot logic calls task_create() to start the task you have configured with CONFIG_USER_ENTRYPOINT. But in the KERNEL build, something different happens. CONFIG_USER_ENTRYPOINT is not used. Instead, CONFIG_INIT_FILEPATH is used. This will be the name of the program to stared in /bin to bring up the system.

Look at the logic in nuttx/sched/init/os_bringup.c:

#elif defined(CONFIG_INIT_FILEPATH)
static inline void os_do_appstart(void)
{
int ret;

#ifdef CONFIG_BOARD_INITIALIZE
/* Perform any last-minute, board-specific initialization, if so
* configured.
*/

board_initialize();
#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.
*/

sinfo("Starting init task: %s\n", CONFIG_USER_INITPATH);

ret = exec(CONFIG_USER_INITPATH, NULL, CONFIG_INIT_SYMTAB,
CONFIG_INIT_NEXPORTS);
ASSERT(ret >= 0);
}

Where exec() is an internal, more primitive function that is the base for the POSIX standard functions execv() and friends.

This is probably worth turning into a Wiki page.
spudarnia@yahoo.com [nuttx]
2017-01-20 23:42:32 UTC
Permalink
Post by ***@yahoo.com [nuttx]
This is probably worth turning into a Wiki page.
Here is the Wiki page: http://www.nuttx.org/doku.php?id=wiki:nshhowtos:app-mkromfsimg
max.kriegleder@yahoo.com [nuttx]
2017-01-22 15:12:35 UTC
Permalink
Uups, yes I confused nuttx/tools and apps/tools. Sorry about that and thank you for the clarification.
Loading...