DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
Custom Application Directories
Most people use the generic apps/ directory with NuttX. That is convenient and well-documented. However, it should always be remembered that NuttX is a stand-alone general purpose OS and has no dependency on that "canned" application directory.
This Wiki page will show you how to create your own, custom application directory from scratch.
Creating the Custom Application Directory
I created a directory to demonstrate the simplest possible custom application directory. It contains only the minimum three files: Makefile, Kconfig, and hello.c
Makefile
The custom application directory must include a Makefile and this makefile must all of the make targets expected by the NuttX build and must generate an archive called libapps.a in the top-level of the custom directory structure. The Makefile has just those minimum required targets:
...
| Code Block |
|---|
# files
CSRCS = hello.c
COBJS = hello.o
ROOTDEPPATH = --dep-path .
# Build targets
all: libapps.a
.PHONY: dirlinks context preconfig depend clean clean_context distclean
.PRECIOUS: libapps$(LIBEXT)
# Compile C Files
$(COBJS): %$(OBJEXT): %.c
$(call COMPILE, $<, $@)
# Add object files to the apps archive
libapps.a: $(COBJS)
$(call ARCHIVE, libapps.a, $(COBJS))
# Create directory links
dirlinks:
# Setup any special pre-build context
context:
# Setup any special pre-configuration context
preconfig:
# Make the dependency file, Make.deps
depend: Makefile $(CSRCS)
$(Q) $(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
# Clean the results of the last build
clean:
$(call CLEAN)
# Remove the build context and directory links
clean_context:
# Restore the directory to its original state
distclean: clean clean_context
$(call DELFILE, Make.dep)
# Include dependencies
|
- include Make.dep
Kconfig
A Kconfig file must be included but need not be populated with any meaningful options. This is a place where you can add settings to generate customized builds of your custom application. In the minimum case, Kconfig is only:
| Code Block |
|---|
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
|
hello.c
And, of course, you custom application must actually compile some source files in order to generate the required libapps.a archive. One of these source files must include the main() entry point to the application. The function of this main() entry point simply to bring-up the full application. It is called at the completion of OS initialization.
...
| Code Block |
|---|
#include <stdio.h>
int custom_main(int argc, char *argv[])
{
printf("Hello, World!!\n");
return 0;
}
|
Building with the Custom Application Directory
In order to build with the new custom configuration, you will need the following in your configuration.
...