summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-06-16 13:26:07 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-06-16 13:26:07 +0000
commit3fe80d8f04e88a7972131dad5babc5c1429fddfd (patch)
tree5711385e037e1113f541db35a8e775a5a2f6ac68
parent7ab326bbb406504d0ae528af8a06b8456201b6a6 (diff)
downloadnuttx-3fe80d8f04e88a7972131dad5babc5c1429fddfd.tar.gz
nuttx-3fe80d8f04e88a7972131dad5babc5c1429fddfd.tar.bz2
nuttx-3fe80d8f04e88a7972131dad5babc5c1429fddfd.zip
Adding basic framework for NXFLAT
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1887 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/include/nuttx/sched.h8
-rw-r--r--nuttx/include/nxflat.h209
-rw-r--r--nuttx/include/unistd.h24
-rw-r--r--nuttx/lib/Makefile2
-rw-r--r--nuttx/lib/lib_getopt.c10
-rw-r--r--nuttx/lib/lib_getoptargp.c73
-rw-r--r--nuttx/lib/lib_getoptindp.c73
-rw-r--r--nuttx/lib/lib_getoptoptp.c73
-rw-r--r--nuttx/tools/mkconfig.c6
9 files changed, 470 insertions, 8 deletions
diff --git a/nuttx/include/nuttx/sched.h b/nuttx/include/nuttx/sched.h
index 74b420bfc..21feb7db0 100644
--- a/nuttx/include/nuttx/sched.h
+++ b/nuttx/include/nuttx/sched.h
@@ -214,7 +214,13 @@ struct _TCB
/* The initial stack pointer value */
#endif
- /* POSIX thread Specific Data *************************************************/
+ /* External Module Support ****************************************************/
+
+#ifdef CONFIG_NXFLAT
+ FAR void *picbase; /* Allocated area for .bss and .data */
+#endif
+
+ /* POSIX Thread Specific Data *************************************************/
#if !defined(CONFIG_DISABLE_PTHREAD) && CONFIG_NPTHREAD_KEYS > 0
FAR void *pthread_data[CONFIG_NPTHREAD_KEYS];
diff --git a/nuttx/include/nxflat.h b/nuttx/include/nxflat.h
new file mode 100644
index 000000000..59f158dd4
--- /dev/null
+++ b/nuttx/include/nxflat.h
@@ -0,0 +1,209 @@
+/****************************************************************************
+ * include/nxflat.h
+ *
+ * Copyright (C) 2009 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+#ifndef __INCLUDE_NXFLAT_H
+#define __INCLUDE_NXFLAT_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <sys/types.h>
+
+/****************************************************************************
+ * Maximum Sizes
+ ****************************************************************************/
+
+#define NXFLAT_MAX_STRING_SIZE 64 /* Largest size of string (w/zterminator) */
+
+/****************************************************************************
+ * The NXFLAT file header
+ *
+ * The elements within this structure are stored in network order (i.e.,
+ * ntohs() and ntohl() should be used to access fields within the
+ * header.
+ ****************************************************************************/
+
+struct nxflat_hdr_s
+{
+ /* The "magic number identifying the file type. This field should contain
+ * "NxFT"
+ */
+
+ char h_magic[4];
+
+ /* NXFLAT revision number number. */
+
+ uint16 h_rev;
+ uint16 h_pad;
+
+ /* The following fields provide the memory map for the nxflat binary.
+ *
+ * h_entry - Offset to the the first executable insruction from
+ * the beginning of the file.
+ * h_datastart - Offset to the beginning of the data segment from
+ * the beginning of the file. This field can also
+ * interpreted as the size of the ISpace segment.
+ * h_dataend - Offset to the end of the data segment from the
+ * beginning of the file.
+ * h_bssend - Offset to the end of bss segment from the beginning
+ * of the file.
+ *
+ * The text segment can be considered to be the contiguous (unrelocated)
+ * address space range from address zero through (but not including)
+ * h_datastart.
+ *
+ * The size of the data/bss segment includes (as a minimum) the data
+ * and bss regions (bss_end - data_start) as well as the size of the
+ * stack. At run time, this region will also include program arguments
+ * and environement variables.
+ *
+ * The bss segment is data_end through bss_end.
+ */
+
+ uint32 h_entry;
+ uint32 h_datastart;
+ uint32 h_dataend;
+ uint32 h_bssend;
+
+ /* Size of stack, in bytes */
+
+ uint32 h_stacksize;
+
+ /* Relocation entries
+ * h_relocstart - Offset to the beginning of an array of relocation
+ * records (struct nxflat_reloc). The offset is
+ * relative to the start of the file
+ * h_reloccount - The number of relocation records in the arry
+ */
+
+ uint32 h_relocstart; /* Offset of relocation records */
+ uint32 h_reloccount; /* Number of relocation records */
+
+ /* Imported and exported symbol tables
+ *
+ * h_importsymbols - Offset to the beginning of an array of imported
+ * symbol structures (struct nxflat_import). The
+ * h_importsymbols offset is relative to the
+ * beginning of the file. Each entry of the
+ * array contains an uint32 offset (again from
+ * the beginning of the file) to the name of
+ * a symbol string. This string is null-terminated.
+ * h_importcount - The number of records in the h_exportsymbols array.
+ * h_exportsymbols - Offset to the beginning of an array of export
+ * symbol structures (struct nxflat_export). The
+ * h_importsymbols offset is relative to the
+ * beginning of the file. Each entry of the
+ * array contains an uint32 offset (again from
+ * the beginning of the file) to the name of
+ * a symbol string. This string is null-terminated.
+ * h_exportcount - The number of records in the h_exportsymbols array.
+ *
+ * NOTE: All of the arrays referenced in the header reside in the
+ * the .text section. This is possible because these arrays are
+ * read-only and are only referenced by the load. Residing in text
+ * also guarantees that only one copy of the array is required.
+ *
+ * An exception is the h_importsymbols array with will lie
+ * in .data. This array contains write-able data and must have
+ * a single instance per process. NOTE: The string offset contained
+ * within nxflat_import still refers to strings residing in the text
+ * section.
+ */
+
+ uint32 h_importsymbols; /* Offset to list of imported symbols */
+ uint32 h_exportsymbols; /* Offset to list of exported symbols */
+ uint16 h_importcount; /* Number of imported symbols */
+ uint16 h_exportcount; /* Number of imported symbols */
+};
+
+/* Legal values for the version field. */
+
+#define NXFLAT_VERSION_NONE 0 /* Invalid NXFLAT version */
+#define NXFLAT_VERSION_CURRENT 1 /* Current version */
+#define NXFLAT_VERSION_NUM 2
+
+/****************************************************************************
+ * NXFLAT Relocation types.
+ *
+ * The relocation records are an array of the following type. The fields
+ * in each element are stored in native machine order.
+ ****************************************************************************/
+
+#define NXFLAT_RELOC_TYPE_NONE 0 /* Invalid relocation type */
+#define NXFLAT_RELOC_TYPE_TEXT 1 /* Symbol lies in .text region */
+#define NXFLAT_RELOC_TYPE_DATA 2 /* Symbol lies in .data region */
+#define NXFLAT_RELOC_TYPE_BSS 3 /* Symbol lies in .bss region */
+#define NXFLAT_RELOC_TYPE_NUM 4
+
+struct nxflat_reloc_s
+{
+#ifdef CONFIG_ENDIAN_BIG
+ uint32 r_type : 2;
+ sint32 r_offset : 30;
+#else
+ sint32 r_offset : 30;
+ uint32 r_type : 2;
+#endif
+};
+
+/****************************************************************************
+ * NXFLAT Imported symbol type
+ *
+ * The imported symbols are an array of the following type. The fields
+ * in each element are stored in native machine order.
+ ****************************************************************************/
+
+struct nxflat_import_s
+{
+ uint32 i_funcname; /* Offset to name of imported function */
+ uint32 i_funcaddress; /* Resolved address of imported function */
+};
+
+/****************************************************************************
+ * Exported symbol type
+ *
+ * The exported symbols are an array of the following type. The fields
+ * in each element are stored in native machine order.
+ ****************************************************************************/
+
+struct nxflat_export_s
+{
+ uint32 x_funcname; /* Offset to name of exported function */
+ uint32 x_funcaddress; /* Address of exported function */
+};
+
+#endif /* __INCLUDE_NXFLAT_H */
diff --git a/nuttx/include/unistd.h b/nuttx/include/unistd.h
index 54b9b64c0..3d05dcb99 100644
--- a/nuttx/include/unistd.h
+++ b/nuttx/include/unistd.h
@@ -1,7 +1,7 @@
/****************************************************************************
- * unistd.h
+ * include/unistd.h
*
- * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -108,11 +108,20 @@ extern "C" {
#define EXTERN extern
#endif
-/* Used by getopt (obviously NOT thread safe!) */
+/* Used by getopt (obviously NOT thread safe!). These variables cannot be
+ * accessed directly by an external NXFLAT module. In that case, accessor
+ * functions must be used.
+ */
+#ifndef __NXFLAT__
EXTERN FAR char *optarg; /* Optional argument following option */
EXTERN int optind; /* Index into argv */
EXTERN int optopt; /* unrecognized option character */
+#else
+# define optarg (*(getoptargp()))
+# define optind (*(getopindgp()))
+# define optopt (*(getoptoptp()))
+#endif
/****************************************************************************
* Global Function Prototypes
@@ -153,6 +162,15 @@ EXTERN int rmdir(FAR const char *pathname);
EXTERN int getopt(int argc, FAR char *const argv[], FAR const char *optstring);
+/* Accessor functions intended for use only by external NXFLAT
+ * modules. The global variables optarg, optind, and optopt cannot
+ * be referenced directly from external modules.
+ */
+
+EXTERN FAR char **getoptargp(void); /* Optional argument following option */
+EXTERN int *getopindgp(void); /* Index into argv */
+EXTERN int *getoptoptp(void); /* unrecognized option character */
+
#undef EXTERN
#if defined(__cplusplus)
}
diff --git a/nuttx/lib/Makefile b/nuttx/lib/Makefile
index bef36aad8..66af20704 100644
--- a/nuttx/lib/Makefile
+++ b/nuttx/lib/Makefile
@@ -76,7 +76,7 @@ STDLIB_SRCS = lib_rand.c
MATH_SRCS = lib_rint.c lib_fixedmath.c lib_b16sin.c lib_b16cos.c
-UNISTD_SRCS = lib_getopt.c
+UNISTD_SRCS = lib_getopt.c lib_getoptargp.c lib_getoptindp.c lib_getoptoptp.c
ifneq ($(CONFIG_NFILE_DESCRIPTORS),0)
ifneq ($(CONFIG_DISABLE_ENVIRON),y)
UNISTD_SRCS += lib_chdir.c lib_getcwd.c
diff --git a/nuttx/lib/lib_getopt.c b/nuttx/lib/lib_getopt.c
index b9b3c2b26..9df4efe0f 100644
--- a/nuttx/lib/lib_getopt.c
+++ b/nuttx/lib/lib_getopt.c
@@ -1,7 +1,7 @@
/****************************************************************************
- * lib_getopt.c
+ * lib/lib_getopt.c
*
- * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -43,6 +43,10 @@
#include <string.h>
/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
* Global Variables
****************************************************************************/
@@ -62,7 +66,7 @@ static boolean g_binitialized = FALSE;
****************************************************************************/
/****************************************************************************
- * Name: Name
+ * Name: getopt
*
* Description: getopt() parses command-line arguments. Its arguments argc
* and argv are the argument count and array as passed to the main()
diff --git a/nuttx/lib/lib_getoptargp.c b/nuttx/lib/lib_getoptargp.c
new file mode 100644
index 000000000..953dba3ef
--- /dev/null
+++ b/nuttx/lib/lib_getoptargp.c
@@ -0,0 +1,73 @@
+/****************************************************************************
+ * lib/lib_getoptargp.c
+ *
+ * Copyright (C) 2009 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Global Variables
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Variables
+ ****************************************************************************/
+
+/****************************************************************************
+ * Global Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: getoptargp
+ *
+ * Description:
+ * Returns a pointer to optarg. This function is only used for external
+ * modules that need to access the base, global variable, optarg.
+ *
+ ****************************************************************************/
+
+FAR char **getoptargp(void)
+{
+ return &optarg;
+}
+
diff --git a/nuttx/lib/lib_getoptindp.c b/nuttx/lib/lib_getoptindp.c
new file mode 100644
index 000000000..c77742b46
--- /dev/null
+++ b/nuttx/lib/lib_getoptindp.c
@@ -0,0 +1,73 @@
+/****************************************************************************
+ * lib/lib_getoptindp.c
+ *
+ * Copyright (C) 2009 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Global Variables
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Variables
+ ****************************************************************************/
+
+/****************************************************************************
+ * Global Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: getoptindp
+ *
+ * Description:
+ * Returns a pointer to optind. This function is only used for external
+ * modules that need to access the base, global variable, optind.
+ *
+ ****************************************************************************/
+
+int *getoptindp(void)
+{
+ return &optind;
+}
+
diff --git a/nuttx/lib/lib_getoptoptp.c b/nuttx/lib/lib_getoptoptp.c
new file mode 100644
index 000000000..316d77b04
--- /dev/null
+++ b/nuttx/lib/lib_getoptoptp.c
@@ -0,0 +1,73 @@
+/****************************************************************************
+ * lib/lib_getoptoptp.c
+ *
+ * Copyright (C) 2009 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Global Variables
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Variables
+ ****************************************************************************/
+
+/****************************************************************************
+ * Global Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: getoptoptp
+ *
+ * Description:
+ * Returns a pointer to optopt. This function is only used for external
+ * modules that need to access the base, global variable, optopt.
+ *
+ ****************************************************************************/
+
+int *getoptoptp(void)
+{
+ return &optopt;
+}
+
diff --git a/nuttx/tools/mkconfig.c b/nuttx/tools/mkconfig.c
index 6b2299e7b..1486586dd 100644
--- a/nuttx/tools/mkconfig.c
+++ b/nuttx/tools/mkconfig.c
@@ -214,6 +214,12 @@ int main(int argc, char **argv, char **envp)
printf("/* Architecture-specific options *************************/\n\n");
parse_file(stream);
printf("\n/* Sanity Checks *****************************************/\n\n");
+ printf("/* If this is an NXFLAT, external build, then make sure that\n");
+ printf(" * NXFLAT support is enabled in the base code.\n");
+ printf(" */\n\n");
+ printf("#if defined(__NXFLAT__) && !defined(CONFIG_NXFLAT)\n");
+ printf("# error \"NXFLAT support not enabled in this configuration\"\n");
+ printf("#endif\n\n");
printf("/* The correct way to disable RR scheduling is to set the\n");
printf(" * timeslice to zero.\n");
printf(" */\n\n");