Skip to content
README.txt 74.6 KiB
Newer Older
patacongo's avatar
patacongo committed
README
^^^^^^

Gregory Nutt's avatar
Gregory Nutt committed
  o Environments
Gregory Nutt's avatar
Gregory Nutt committed
    - Ubuntu Bash under Windows 10
Gregory Nutt's avatar
Gregory Nutt committed
  o Installation
    - Download and Unpack
    - Semi-Optional apps/ Package
    - Installation Directories with Spaces in the Path
    - Downloading from Repositories
Gregory Nutt's avatar
Gregory Nutt committed
    - Related Repositories
    - Notes about Header Files
patacongo's avatar
patacongo committed
  o Configuring NuttX
    - Instantiating "Canned" Configurations
    - Refreshing Configurations
    - NuttX Configuration Tool
    - Finding Selections in the Configuration Menus
    - Reveal Hidden Configuration Options
    - Make Sure that You on on the Right Platform
    - Comparing Two Configurations
    - Incompatibilities with Older Configurations
patacongo's avatar
patacongo committed
    - NuttX Configuration Tool under DOS
patacongo's avatar
patacongo committed
  o Toolchains
    - Cross-Development Toolchains
    - NuttX Buildroot Toolchain
  o Shells
patacongo's avatar
patacongo committed
  o Building NuttX
Gregory Nutt's avatar
Gregory Nutt committed
    - Re-building
  o Cygwin Build Problems
    - Strange Path Problems
    - Window Native Toolchain Issues
patacongo's avatar
patacongo committed
  o Documentation

Gregory Nutt's avatar
Gregory Nutt committed
ENVIRONMENTS
patacongo's avatar
patacongo committed
^^^^^^^^^^^^

  NuttX requires a POSIX development environment such as you would find under
Bill Morgan's avatar
Bill Morgan committed
  Linux or OSX.  NuttX may also be installed and built on Windows system
  if you also provide such a POSIX development environment.  Options for a
Gregory Nutt's avatar
Gregory Nutt committed
  POSIX development environment under Windows include:
Gregory Nutt's avatar
Gregory Nutt committed

    - An installation of Linux on a virtual machine (VM) in Windows.  I have
      not been happy using a VM myself.  I have had stability problems with
      open source VMs and commercial VMs cost more than I want to spend.
      Sharing files with Linux running in a VM is awkward;  sharing devices
      connected to the Windows box with Linux in a VM is, at the very least,
      confusing;  Using Windows tools (such as Segger J-Link) with files
      built under the Linux VM is not a possibility.
Gregory Nutt's avatar
Gregory Nutt committed
    - The Cygwin environment.  Instructions for installation of Cygwin on a
      Windows system are provided in the following paragraph, "Installing
      Cygwin".  Cygwin is a mature, well-tested, and very convenient
Bill Morgan's avatar
Bill Morgan committed
      environment.  It is especially convenient if you  need to
      integrate with Windows tools and files.  Downsides are that the
      installation time is very long and the compile times are slow.
Gregory Nutt's avatar
Gregory Nutt committed

    - Ubuntu/Bash shell under Windows 10.  This is a new option under
Gregory Nutt's avatar
Gregory Nutt committed
      Windows 10.  See the section "Ubuntu Bash under Windows 10" below.
Gregory Nutt's avatar
Gregory Nutt committed
      This is an improvement over Cygwin if your concern is compile time;
Gregory Nutt's avatar
Gregory Nutt committed
      its build performance is comparable to native Linux, certainly better
      than the Cygwin build time.  It also installs in a tiny fraction of
      the time as Cygwin, perhaps 20 minutes for the basic Ubuntu install
      (vs. more than a day for the complete Cygwin install).

    - The MSYS environment.  I have no experience using the MSYS environment
      and that configuration will not be discussed in this README file.
      See http://www.mingw.org/wiki/MSYS if you are interested in
      using MSYS.  People report to me that they have used MSYS
      successfully.  I suppose that the advantages of the MSYS environment
      is that it is closer to a native Windows environment and uses only a
      minimal of add-on POSIX-land tools.
Gregory Nutt's avatar
Gregory Nutt committed

Gregory Nutt's avatar
Gregory Nutt committed
    - NuttX can also be installed and built on a native Windows system, but
      with some potential tool-related issues (see the discussion "Native
      Windows Build" under "Building NuttX" below).  GNUWin32 is used to
      provide compatible native windows tools.
Gregory Nutt's avatar
Gregory Nutt committed

patacongo's avatar
patacongo committed
Installing Cygwin
patacongo's avatar
patacongo committed

Gregory Nutt's avatar
Gregory Nutt committed
  Installing Cygwin on your Windows PC is simple, but time consuming.  See
  http://www.cygwin.com/ for installation instructions. Basically you just
  need to download a tiny setup.exe program and it does the real, network
  installation for you.
patacongo's avatar
patacongo committed
  Some Cygwin installation tips:
patacongo's avatar
patacongo committed
  1. Install at C:\cygwin

  2. Install EVERYTHING:  "Only the minimal base packages from the
     Cygwin distribution are installed by default. Clicking on categories
     and packages in the setup.exe package installation screen will
     provide you with the ability to control what is installed or updated.
     Clicking on the "Default" field next to the "All" category will
     provide you with the opportunity to install every Cygwin package.
     Be advised that this will download and install hundreds of megabytes
     to your computer."
patacongo's avatar
patacongo committed
     If you use the "default" installation, you will be missing many
     of the Cygwin utilities that you will need to build NuttX.  The
     build will fail in numerous places because of missing packages.

Gregory Nutt's avatar
Gregory Nutt committed
     NOTE: You don't really have to install EVERYTHING but I cannot
     answer the question "Then what should I install?"  I don't know
     the answer to that and so will continue to recommend installing
     EVERYTHING.

     You should certainly be able to omit "Science", "Math", and
Paul A. Patience's avatar
Paul A. Patience committed
     "Publishing".  You can try omitting KDE, Gnome, GTK, and other
     graphics packages if you don't plan to use them.

     Perhaps a minimum set would be those packages listed below for the
     "Ubuntu Bash under Windows 10" installation?

patacongo's avatar
patacongo committed
  After installing Cygwin, you will get lots of links for installed
  tools and shells.  I use the RXVT native shell.  It is fast and reliable
  and does not require you to run the Cygwin X server (which is neither
patacongo's avatar
patacongo committed
  fast nor reliable).  Unless otherwise noted, the rest of these
  instructions assume that you are at a bash command line prompt in
  either Linux or in Cygwin shell.
patacongo's avatar
patacongo committed

  UPDATE: The last time I installed EVERYTHING, the download was
Gregory Nutt's avatar
Gregory Nutt committed
  about 5GiB.  The server I selected was also very slow so it took
  over a day to do the whole install!

Gregory Nutt's avatar
Gregory Nutt committed
Ubuntu Bash under Windows 10
----------------------------

  A better version of a command-line only Ubuntu under Windows 10 (beta)
Gregory Nutt's avatar
Gregory Nutt committed
  has recently been made available from Microsoft.
Gregory Nutt's avatar
Gregory Nutt committed

  Installation
  ------------
  Installation instructions abound on the Internet complete with screen
  shots.  I will attempt to duplicate those instructions in full here.
  Here are the simplified installation steps:

    - Open "Settings".
    - Click on "Update & security".
    - Click on "For Developers".
    - Under "Use developer features", select the "Developer mode" option to
      setup the environment to install Bash.
    - A message box should pop up.  Click "Yes" to turn on developer mode.
    - After the necessary components install, you'll need to restart your
      computer.

  Once your computer reboots:

    - Open "Control Panel".
    - Click on "Programs".
    - Click on "Turn Windows features on or off".
    - A list of features will pop up, check the "Windows Subsystem for Linux
      (beta)" option.
    - Click OK.
    - Once the components installed on your computer, click the "Restart
      now" button to complete the task.

  After your computer restarts, you will notice that Bash will not appear in
  the "Recently added" list of apps, this is because Bash isn't actually
  installed yet. Now that you have setup the necessary components, use the
  following steps to complete the installation of Bash:

    - Open "Start", do a search for bash.exe, and press "Enter".
    - On the command prompt, type y and press Enter to download and install
      Bash from the Windows Store.  This will take awhile.
    - Then you'll need to create a default UNIX user account. This account
      doesn't have to be the same as your Windows account. Enter the
      username in the required field and press Enter (you can't use the
      username "admin").
    - Close the "bash.exe" command prompt.

  Now that you completed the installation and setup, you can open the Bash
  tool from the Start menu like you would with any other app.

  Accessing Windows Files from Ubuntu
  -----------------------------------
  File systems will be mounted under "/mnt" so for example "C:\Program Files"
Bill Morgan's avatar
Bill Morgan committed
  appears at "/mnt/c/Program Files".  This is as opposed to Cygwin where
Gregory Nutt's avatar
Gregory Nutt committed
  the same directory would appear at "/cygdrive/c/Program Files".

  With these differences (perhaps a few other Windows quirks) the Ubuntu
  install works just like Ubuntu running natively on your PC.
Gregory Nutt's avatar
Gregory Nutt committed

Gregory Nutt's avatar
Gregory Nutt committed
  A good tip for file sharing is to use symbolic links within your Ubuntu
  home directory.  For example, suppose you have your "projects" directory
  at C:\Documents\projects.  Then you can set up a link to the projects/
  directory in your Ubuntu directory like:

Gregory Nutt's avatar
Gregory Nutt committed
    ln -s /mnt/c/Documents/projects projects
Gregory Nutt's avatar
Gregory Nutt committed

  Accessing Ubuntu Files From Windows
  -----------------------------------
  In Ubuntu Userspace for Windows, the Ubuntu file system root directory is
  at:

    %localappdata%\lxss\rootfs

  Or

    C:\Users\Username\AppData\Local\lxss\rootfs

  However, I am unable to see my files under the rootfs\home directory.
  After some looking around, I find the home directory
  %localappdata%\lxss\home.

  With that trick access to the /home directory, you should actually be
  able to use Windows tools outside of the Ubuntu sandbox with versions of
  NuttX built within the sandbox using that path.

Gregory Nutt's avatar
Gregory Nutt committed
  Executing Windows Tools from Ubuntu
  -----------------------------------
  You can also execute Windows tools from within the Ubuntu sandbox:

Gregory Nutt's avatar
Gregory Nutt committed
    /mnt/c/Program\ Files\ \(x86\)/Microchip/xc32/v1.43/bin/xc32-gcc.exe --version
    Unable to translate current working directory. Using C:\WINDOWS\System32
    xc32-gcc.exe (Microchip Technology) 4.8.3 MPLAB XC32 Compiler v1.43 Build date: Mar  1 2017
    ...

  The error message indicates that there are more issues:  You cannot mix
  Windows tools that use Windows style paths in an environment that uses
  POSIX paths.  I think you would have to use Linux tools only from within
  the Ubuntu sandbox.
Gregory Nutt's avatar
Gregory Nutt committed
  Install Ubuntu Software
Gregory Nutt's avatar
Gregory Nutt committed
  -----------------------
Gregory Nutt's avatar
Gregory Nutt committed
  Use "sudo apt-get install <package name>".  As examples, this is how
  you would get GIT:

Gregory Nutt's avatar
Gregory Nutt committed
    sudo apt-get install git
Gregory Nutt's avatar
Gregory Nutt committed
  This will get you a compiler for your host PC:

Gregory Nutt's avatar
Gregory Nutt committed
    sudo apt-get install gcc
Gregory Nutt's avatar
Gregory Nutt committed

  This will get you an ARM compiler for your target:
Gregory Nutt's avatar
Gregory Nutt committed
    sudo apt-get install gcc-arm-none-eabi
Gregory Nutt's avatar
Gregory Nutt committed

  NOTE: That is just an example.  I am not sure if apt-get will give you a
  current or usable compiler.  You should carefully select your toolchain
Bill Morgan's avatar
Bill Morgan committed
  for the needs of your project.
Gregory Nutt's avatar
Gregory Nutt committed

Bill Morgan's avatar
Bill Morgan committed
  You will also need to get the kconfig-frontends configuration as
  described below under "NuttX Configuration tool".  In order to build the
Gregory Nutt's avatar
Gregory Nutt committed
  kconfig-frontends configuration tool you will also need:  make, gperf,
  flex, bison, and libncurses-dev.

  That is enough to do a basic NuttX build.

Gregory Nutt's avatar
Gregory Nutt committed
  Integrating with Windows Tools
  ------------------------------
  If you want to integrate with Windows native tools, then you would need
Gregory Nutt's avatar
Gregory Nutt committed
  deal with the same kind of craziness as with integrating Cygwin with
  native toolchains, see the section "Cygwin Build Problems" below.

  However, there is currently no build support for using Windows native
  tools with Ubuntu under Windows.  This tool combination is made to work
  with Cygwin through the use of the 'cygpath -w' tool that converts paths
  from say '/cydrive/c/Program Files' to 'C:\Program Files'.  There is,
  however, no corresponding tool to convert '/mnt/c/Program Files' in the
  Ubuntu environment.
  Graphics Support
  ----------------
  The Ubuntu version support by Microsoft is a command-line only version.
  There is no support for Linux graphics utilities.

  This limitation is not a limitation of Ubuntu, however, only in what
  Microsoft is willing to support.  If you install a X-Server, then you
  can also use basic graphics utilities.  See for example:

    http://www.howtogeek.com/261575/how-to-run-graphical-linux-desktop-applications-from-windows-10s-bash-shell/

  Many Linux graphics programs would, however, also require a graphics
  framework like GTK or Qt.  So this might be a trip down the rabbit hole.

Gregory Nutt's avatar
Gregory Nutt committed
INSTALLATION
^^^^^^^^^^^^
Gregory Nutt's avatar
Gregory Nutt committed

Gregory Nutt's avatar
Gregory Nutt committed
  There are two ways to get NuttX:  You may download released, stable
  tarballs from wither the Bitbucket or Sourceforge download locations.
  Or you may get NuttX by cloning the Bitbucket GIT repositories.  Let's
  consider the released tarballs first:

Download and Unpack
-------------------

  Download and unpack the NuttX tarball.  If you are reading this, then
  you have probably already done that.  After unpacking, you will end
  up with a directory called nuttx-version (where version is the NuttX
  version number). You might want to rename that directory nuttx to
  match the various instructions in the documentation and some scripts
  in the source tree.

Gregory Nutt's avatar
Gregory Nutt committed
  Download locations:

    https://bitbucket.org/nuttx/nuttx/downloads
    https://sourceforge.net/projects/nuttx/files/nuttx/

Semi-Optional apps/ Package
---------------------------
patacongo's avatar
patacongo committed

  All NuttX libraries and example code used to be in included within
  the NuttX source tree.  As of NuttX-6.0, this application code was
  moved into a separate tarball, the apps tarball.  If you are just
  beginning with NuttX, then you will want to download the versioned
  apps tarball along with the NuttX tarball.  If you already have your
  own product application directory, then you may not need the apps
  tarball.

Bill Morgan's avatar
Bill Morgan committed
  It is called "Semi-optional" because if you don't have some apps/
Gregory Nutt's avatar
Gregory Nutt committed
  directory, NuttX will *fail* to build! You do not necessarily need
  to use the NuttX apps tarball but may, instead, provide your own
  custom application directory.  Such a custom directory would need
  to include a valid Makefile to support the build and a valid Kconfig
Bill Morgan's avatar
Bill Morgan committed
  file to support the configuration.  More about these files later.
patacongo's avatar
patacongo committed

Gregory Nutt's avatar
Gregory Nutt committed
  Download then unpack the apps tarball in the same directory where you
patacongo's avatar
patacongo committed
  unpacked the NuttX tarball.  After you unpack the apps tarball, you
  will have a new directory called apps-version (where the version
patacongo's avatar
patacongo committed
  should exactly match the version of the NuttX tarball).  Again, you
  might want to rename the directory to simply apps/ to match what
  you read in the documentation
Gregory Nutt's avatar
Gregory Nutt committed
  After unpacking (and renaming) the apps tarball, you will have two
  directories side by side like this:
patacongo's avatar
patacongo committed
             |
        +----+----+
        |         |
      nuttx/     apps/

  This is important because the NuttX build will expect to find the
Gregory Nutt's avatar
Gregory Nutt committed
  apps directory in that (default) location.  That default location
Gregory Nutt's avatar
Gregory Nutt committed
  can be changed by modifying your NuttX configuration file, but that
  is another story.
patacongo's avatar
patacongo committed

Installation Directories with Spaces in the Path
------------------------------------------------
patacongo's avatar
patacongo committed

  The nuttx build directory should reside in a path that contains no
  spaces in any higher level directory name.  For example, under
  Cygwin, your home directory might be formed from your first and last
  names like: "/home/First Last". That will cause strange errors when
  the make system tries to build.

Bill Morgan's avatar
Bill Morgan committed
  [Actually, that problem is probably not too difficult to fix.  Some
patacongo's avatar
patacongo committed
   Makefiles probably just need some paths within double quotes]
patacongo's avatar
patacongo committed

  I work around spaces in the home directory name, by creating a
  new directory that does not contain any spaces, such as /home/nuttx.
Gregory Nutt's avatar
Gregory Nutt committed
  Then I install NuttX in /home/nuttx and always build from
  /home/nuttx/nuttx-code.
Downloading from Repositories
-----------------------------

Gregory Nutt's avatar
Gregory Nutt committed

Gregory Nutt's avatar
Gregory Nutt committed
    The current NuttX du jour is available in from a GIT repository.  Here are
    instructions for cloning the core NuttX RTOS (corresponding to the nuttx
    tarball discussed above)::

      git clone https://bitbucket.org/nuttx/nuttx.git nuttx
Gregory Nutt's avatar
Gregory Nutt committed

Gregory Nutt's avatar
Gregory Nutt committed
    And the semi-optional apps/ application directory and be cloned like:
Gregory Nutt's avatar
Gregory Nutt committed

      git clone https://bitbucket.org/nuttx/apps.git apps

Gregory Nutt's avatar
Gregory Nutt committed
    That will give you the same directory structure like this:
Gregory Nutt's avatar
Gregory Nutt committed

             |
        +----+----+
        |         |
      nuttx/     apps/
Gregory Nutt's avatar
Gregory Nutt committed
  Configuring the Clones
Gregory Nutt's avatar
Gregory Nutt committed

Gregory Nutt's avatar
Gregory Nutt committed
    The following steps need to be performed for each of the repositories.
    After changing to the clone directory:
Gregory Nutt's avatar
Gregory Nutt committed

Gregory Nutt's avatar
Gregory Nutt committed
    Set your identity:

      git config --global user.name "My Name"
      git config --global user.email my.name@example.com

    Colorized diffs are much easier to read:

      git config --global color.branch auto
      git config --global color.diff auto
      git config --global color.interactive auto
      git config --global color.status auto

    Checkout other settings

      git config --list

Gregory Nutt's avatar
Gregory Nutt committed

    If you are cloning the NuttX repository, it is recommended to avoid
    automatic end of lines conversions by git. These conversions may break
    some scripts like configure.sh. Before cloning, do the following:
Gregory Nutt's avatar
Gregory Nutt committed

Gregory Nutt's avatar
Gregory Nutt committed
Related Repositories
--------------------

Gregory Nutt's avatar
Gregory Nutt committed
  These are standalone repositories:

Gregory Nutt's avatar
Gregory Nutt committed
  * https://bitbucket.org/nuttx/apps

    This directory holds an optional package of applications and libraries
    can be used with the NuttX RTOS.  There is a README.txt file there that
Bill Morgan's avatar
Bill Morgan committed
    will provide more information about that package.
Gregory Nutt's avatar
Gregory Nutt committed

  * https://bitbucket.org/nuttx/nxwidgets

    This is the NuttX C++ graphics support.  This includes NxWM, the tiny
    NuttX Window Manager.

  * https://bitbucket.org/nuttx/uclibc

    This repository contains a version of the uClibc++ C++ library.  This code
    originates from http://cxx.uclibc.org/ and has been adapted for NuttX by the
    RGMP team (http://rgmp.sourceforge.net/wiki/index.php/Main_Page).

  * https://bitbucket.org/nuttx/buildroot

    A environment that you can to use to build a custom, NuttX GNU toolchain.

  * https://bitbucket.org/nuttx/tools

    There are snapshots of some tools here that you will need to work with
    NuttX:  kconfig-frontends, genromfs, and others.

  * https://bitbucket.org/nuttx/drivers

    A few drivers that are not integrated into the main NuttX source tree due
    to licensing issues.

  * https://bitbucket.org/nuttx/pascal

    Yes, this really is a Pascal compiler.  The Pascal p-code run-time and
    pcode debugger can be built as a part of NuttX.

Notes about Header Files
------------------------
  Other C-Library Header Files.
Gregory Nutt's avatar
Gregory Nutt committed
    When a GCC toolchain is built, it must be built against a C library.
    The compiler together with the contents of the C library completes the
    C language definition and provides the complete C development
    environment.  NuttX provides its own, built-in C library.  So the
    complete, consistent C language definition for use with NuttX comes from
    the combination of the compiler and the header files provided by the
    NuttX C library.

    When a GCC toolchain is built, it incorporates the C library header
    files into the compiler internal directories and, in this way, the C
    library really becomes a part of the toolchain.  If you use the NuttX
    buildroot toolchain as described below under under "NuttX Buildroot
    Toolchain", your GCC toolchain will build against the NuttX C library
    and will incorporate the NuttX C library header files as part of the
    toolchain.

    If you use some other, third-party tool chain, this will not be the
    case, however.  Those toolchains were probably built against some
    other, incompatible C library distribution (such as newlib).  Those
    tools will have incorporated the incompatible C library header files
    as part of the toolchain.  These incompatible header files must *not*
Bill Morgan's avatar
Bill Morgan committed
    be used with NuttX because they will conflict with definitions in the
Gregory Nutt's avatar
Gregory Nutt committed
    NuttX built-in C-Library.  For such toolchains that include header
    files from a foreign C-Library, NuttX must be compiled without using
    the standard header files that are distributed with your toolchain.
    This prevents including conflicting, incompatible header files such
    as stdio.h.

    The math.h and stdarg.h are probably the two most trouble some header
    files to deal with.  These troublesome header files are discussed in
    more detail below.
  Header Files Provided by Your Toolchain.

    Certain header files, such as setjmp.h, stdarg.h, and math.h, may still
    be needed from your toolchain and your compiler may not, however, be able
    to find these if you compile NuttX without using standard header files
    (i.e., with -nostdinc).  If that is the case, one solution is to copy
    those header file from your toolchain into the NuttX include directory.

  Duplicated Header Files.

    There are also a few header files that can be found in the nuttx/include
    directory which are duplicated by the header files from your toolchain.
    stdint.h and stdbool.h are examples.  If you prefer to use the stdint.h
    and stdbool.h header files from your toolchain, those could be copied
    into the nuttx/include/ directory. Using most other header files from
    your toolchain would probably cause errors.

  math.h

    Even though you should not use a foreign C-Library, you may still need
    to use other, external libraries with NuttX.  In particular, you may
    need to use the math library, libm.a.  NuttX supports a generic, built-in
    math library that can be enabled using CONFIG_LIBM=y.  However, you may
    still want to use a higher performance external math library that has
Bill Morgan's avatar
Bill Morgan committed
    been tuned for your CPU.  Sometimes such tuned math libraries are
    bundled with your toolchain.

    The math library header file, math.h, is a then special case.  If you do
    nothing, the standard math.h header file that is provided with your
    toolchain will be used.

    If you have a custom, architecture specific math.h header file, then
    that header file should be placed at arch/<cpu>/include/math.h.  There
    is a stub math.h header file located at include/nuttx/lib/math.h.  This stub
    header file can be used to "redirect" the inclusion to an architecture-
    specific math.h header file.  If you add an architecture specific math.h
    header file then you should also define CONFIG_ARCH_MATH_H=y in your
    NuttX Configuration file.  If CONFIG_ARCH_MATH_H is selected, then the
    top-level Makefile will copy the stub math.h header file from
    include/nuttx/lib/math.h to include/math.h where it will become the system
    math.h header file.  The stub math.h header file does nothing other
    than to include that architecture-specific math.h header file as the
    system math.h header file.
  float.h

    If you enable the generic, built-in math library, then that math library
    will expect your toolchain to provide the standard float.h header file.
    The float.h header file defines the properties of your floating point
    implementation.  It would always be best to use your toolchain's float.h
    header file but if none is available, a default float.h header file will
Bill Morgan's avatar
Bill Morgan committed
    be provided if this option is selected.  However, there is no assurance
    that the settings in this float.h are actually correct for your platform!
    In most cases, the correct version of stdarg.h is the version provided
Bill Morgan's avatar
Bill Morgan committed
    with your toolchain.  However, sometimes there are issues with
    using your toolchains stdarg.h.  For example, it may attempt to draw in
    header files that do not exist in NuttX or perhaps the header files that
Bill Morgan's avatar
Bill Morgan committed
    it uses are not compatible with the NuttX header files.  In those cases,
    you can use an architecture-specific stdarg.h header file by defining
    CONFIG_ARCH_STDARG_H=y.

    See the discussion above for the math.h header.  This setting works
    exactly the same for the stdarg.h header file.
patacongo's avatar
patacongo committed
CONFIGURING NUTTX
^^^^^^^^^^^^^^^^^

Instantiating "Canned" Configurations
-------------------------------------

Gregory Nutt's avatar
Gregory Nutt committed
  configure.sh and configure.bat:
patacongo's avatar
patacongo committed

Gregory Nutt's avatar
Gregory Nutt committed
    "Canned" NuttX configuration files are retained in:
patacongo's avatar
patacongo committed

Gregory Nutt's avatar
Gregory Nutt committed
      configs/<board-name>/<config-dir>
patacongo's avatar
patacongo committed

Gregory Nutt's avatar
Gregory Nutt committed
    Where <board-name> is the name of your development board and <config-dir>
    is the name of the sub-directory containing a specific configuration for
Bill Morgan's avatar
Bill Morgan committed
    that board.  Only a few steps are required to instantiate a NuttX
Gregory Nutt's avatar
Gregory Nutt committed
    configuration, but to make the configuration even easier there are
Bill Morgan's avatar
Bill Morgan committed
    scripts available in the tools/ sub-directory combines those simple steps
Gregory Nutt's avatar
Gregory Nutt committed
    into one command.
Bill Morgan's avatar
Bill Morgan committed

    There is one tool for use with any Bash-like shell that does configuration
Gregory Nutt's avatar
Gregory Nutt committed
    steps.  It is used as follows:

      tools/configure.sh <board-name>/<config-dir>

    There is an alternative Windows batch file that can be used in the windows
    native environment like:

      tools\configure.bat <board-name>\<config-dir>

Bill Morgan's avatar
Bill Morgan committed
    And, to make sure that other platforms are supported, there is also a
Gregory Nutt's avatar
Gregory Nutt committed
    C program at tools/configure.c that can be compiled to establish the
    board configuration.

    See tools/README.txt for more information about these scripts.

    General information about configuring NuttX can be found in:

     {TOPDIR}/configs/README.txt
     {TOPDIR}/configs/<board-name>/README.txt

  The Hidden Configuration Scripts:

    As mentioned above, there are only a few simple steps to instantiating a
    NuttX configuration.  Those steps are hidden by the configuration scripts
    but are summarized below:

    1. Copy Files

      Configuring NuttX requires only copying two files from the
      <config-dir> to the directory where you installed NuttX (TOPDIR):

        Copy configs/<board-name>/<config-dir>/Make.def to{TOPDIR}/Make.defs
        OR
        Copy configs/<board-name>/scripts/Make.def to{TOPDIR}/Make.defs
Bill Morgan's avatar
Bill Morgan committed
      Make.defs describes the rules needed by your tool chain to compile
      and link code.  You may need to modify this file to match the
      specific needs of your toolchain.  NOTE that a configuration may
      have its own unique Make.defs file in its configuration directory or
      it may use a common Make.defs file for the board in the scripts/
      directory.  The first takes precedence.
patacongo's avatar
patacongo committed

Gregory Nutt's avatar
Gregory Nutt committed
        Copy configs/<board-name>/<config-dir>/defconfig to{TOPDIR}/.config
      The defconfig file holds the actual build configuration.  This
      file is included by all other make files to determine what is
      included in the build and what is not.  This file is also used
      to generate a C configuration header at include/nuttx/config.h.
patacongo's avatar
patacongo committed

Bill Morgan's avatar
Bill Morgan committed
        Copy other, environment-specific files to{TOPDIR}

      This might include files like .gdbinit or IDE configuration files
      like .project or .cproject.

Gregory Nutt's avatar
Gregory Nutt committed
    2. Refresh the Configuration
patacongo's avatar
patacongo committed

Gregory Nutt's avatar
Gregory Nutt committed
      New configuration setting may be added or removed.  Existing settings
      may also change there values or options.  This must be handled by
      refreshing the configuration as described below.
patacongo's avatar
patacongo committed

Gregory Nutt's avatar
Gregory Nutt committed
      NOTE:  NuttX uses only compressed defconfig files.  For the NuttX
      defconfig files, this refrshing step is *NOT* optional; it is also
      necessary to uncompress and regenerate the full making file.  This is
Bill Morgan's avatar
Bill Morgan committed
      discussed further below.

Refreshing Configurations
-------------------------

Gregory Nutt's avatar
Gregory Nutt committed
  Configurations can get out of date.  As new configuration settings are
  added or removed or as dependencies between configuration settings
  change, the contents of a default configuration can become out of synch
Gregory Nutt's avatar
Gregory Nutt committed
  with the build systems.  Hence, it is a good practice to "refresh" each
Gregory Nutt's avatar
Gregory Nutt committed
  configuration after configuring and before making.  To refresh the
  configuration, use the NuttX Configuration Tool like this:
Gregory Nutt's avatar
Gregory Nutt committed
  AFTER you have instantiated the NuttX configuration as described above.
  The configuration step copied the .config file into place in the top-level
  NuttX directory; 'make oldconfig' step will then operate on that .config
  file to bring it up-to-date.

Bill Morgan's avatar
Bill Morgan committed
  If your configuration is out of date, you will be prompted by 'make oldconfig'
Gregory Nutt's avatar
Gregory Nutt committed
  to resolve the issues detected by the configuration tool, that is, to
  provide values for the new configuration options in the build system.  Doing
  this can save you a lot of problems down the road due to obsolete settings in
  the default board configuration file.  The NuttX configuration tool is
  discussed in more detail in the following paragraph.
Gregory Nutt's avatar
Gregory Nutt committed
  Confused about what the correct value for a new configuration item should
  be?  Enter ? in response to the 'make oldconfig' prompt and it will show
  you the help text that goes with the option.

  If you don't want to make any decisions are are willing to just accept the
Gregory Nutt's avatar
Gregory Nutt committed
  recommended default value for each new configuration item, an even easier
  way is:

Bill Morgan's avatar
Bill Morgan committed
    make olddefconfig
Bill Morgan's avatar
Bill Morgan committed
  The olddefconfig target will simply bring your configuration up to date with
Gregory Nutt's avatar
Gregory Nutt committed
  the current Kconfig files, setting any new options to the default value.
  No questions asked.

NuttX Configuration Tool
------------------------

  An automated tool has been incorporated to support re-configuration
Gregory Nutt's avatar
Gregory Nutt committed
  of NuttX.  This automated tool is based on the kconfig-frontends
  application available at http://ymorin.is-a-geek.org/projects/kconfig-frontends
  (A snapshot of this tool is also available from the tools repository at
Gregory Nutt's avatar
Gregory Nutt committed
  https://bitbucket.org/nuttx/tools).  This application provides a tool
  called 'kconfig-mconf' that is used by the NuttX top-level Makefile.
Gregory Nutt's avatar
Gregory Nutt committed
  The following make target is provided:
  This make target will bring up NuttX configuration menus.

  WARNING:  Never do 'make menuconfig' on a configuration that has
  not been converted to use the kconfig-frontends tools!  This will
Gregory Nutt's avatar
Gregory Nutt committed
  damage your configuration (see
  http://www.nuttx.org/doku.php?id=wiki:howtos:convertconfig).

Gregory Nutt's avatar
Gregory Nutt committed
  How do we tell a new configuration from an old one? See "Incompatibilities
  with Older Configurations" below.

  The 'menuconfig' make target depends on two things:

  1. The Kconfig configuration data files that appear in almost all
     NuttX directories.  These data files are the part that is still
     under development (patches are welcome!).  The Kconfig files
     contain configuration information for the configuration settings
     relevant to the directory in which the Kconfig file resides.

     NOTE: For a description of the syntax of this configuration file,
Gregory Nutt's avatar
Gregory Nutt committed
     see kconfig-language.txt in the tools repository at
     https://bitbucket.org/nuttx/tools
Gregory Nutt's avatar
Gregory Nutt committed
  2. The 'kconfig-mconf' tool.  'kconfig-mconf' is part of the
     kconfig-frontends package.  You can download that package from
     the website http://ymorin.is-a-geek.org/projects/kconfig-frontends
Gregory Nutt's avatar
Gregory Nutt committed
     or you can use the snapshot in the tools repository at
     https://bitbucket.org/nuttx/tools.
Gregory Nutt's avatar
Gregory Nutt committed
     Building kconfig-frontends under Linux may be as simple as
     'configure; make; make install' but there may be some build
     complexities, especially if you are building under Cygwin.  See
Gregory Nutt's avatar
Gregory Nutt committed
     the more detailed build instructions in the top-level README.txt
     file of the tools repository at https://bitbucket.org/nuttx/tools.
Gregory Nutt's avatar
Gregory Nutt committed
     The 'make install' step will, by default, install the 'kconfig-mconf'
     tool at /usr/local/bin/mconf.  Where ever you choose to
Gregory Nutt's avatar
Gregory Nutt committed
     install 'kconfig-mconf', make certain that your PATH variable includes
     a path to that installation directory.

Gregory Nutt's avatar
Gregory Nutt committed
     The kconfig-frontends tools will not build in a native Windows
     environment directly "out-of-the-box".  For the Windows native
Bill Morgan's avatar
Bill Morgan committed
     case, you should use the modified version of kconfig-frontends
Gregory Nutt's avatar
Gregory Nutt committed
     that can be found at
     http://uvc.de/posts/linux-kernel-configuration-tool-mconf-under-windows.html

  The basic configuration order is "bottom-up":

    - Select the build environment,
    - Select the processor,
    - Select the board,
    - Select the supported peripherals
    - Configure the device drivers,
    - Configure the application options on top of this.

  This is pretty straight forward for creating new configurations
  but may be less intuitive for modifying existing configurations.

  If you have an environment that supports the Qt or GTK graphical systems
Gregory Nutt's avatar
Gregory Nutt committed
  (probably KDE or gnome, respectively, or Cygwin under Windows with Qt or
  GTK installed), then you can also build the graphical kconfig-frontends,
  kconfig-qconf and kconfig-gconf.  In these case, you can start the
  graphical configurator with either:
Gregory Nutt's avatar
Gregory Nutt committed

    make qconfig

  or

    make gconfig

  Some keyboard shortcuts supported by kconfig-mconf, the tool that runs
  when you do 'make menuconfig':

    - '?' will bring up the mconfig help display.

    - '/' can be used find configuration selections.

    - 'Z' can be used to reveal hidden configuration options

Bill Morgan's avatar
Bill Morgan committed
  These last two shortcuts are described further in the following
Finding Selections in the Configuration Menus
---------------------------------------------

  The NuttX configuration options have gotten complex and it can be very
  difficult to find options in the menu trees if you are not sure where
  to look.  The "basic configuration order" describe above can help to
  narrow things down.

  But if you know exactly what configuration setting you want to select,
  say CONFIG_XYZ, but not where to find it, then the 'make menuconfig'
  version of the tool offers some help:  By pressing the '/' key, the
  tool will bring up a menu that will allow you to search for a
  configuration item.  Just enter the string CONFIG_XYZ and press 'ENTER'.
  It will show you not only where to find the configuration item, but
  also all of the dependencies related to the configuration item.

Reveal Hidden Configuration Options
-----------------------------------

  If you type 'Z', then kconfig-mconf will change what is displayed.
  Normally, only enabled features that have all of their dependencies met
  are displayed.  That is, of course, not very useful if you would like to
  discover new options or if you are looking for an option and do not
  realize that the dependencies have not yet been selected and, hence, it
  is not displayed.

  But if you enter 'Z', then every option will be shown, whether or not its
Bill Morgan's avatar
Bill Morgan committed
  dependencies have been met.  You can then see everything that could be
  selected with the right dependency selections.  These additional options
  will be shown the '-' for the selection and for the value (since it
  cannot be selected and has no value).  About all you do is to select
  the <Help> option to see what the dependencies are.

Bill Morgan's avatar
Bill Morgan committed
Make Sure that You are on the Right Platform
--------------------------------------------

  Saved configurations may run on Linux, Cygwin (32- or 64-bit), or other
  platforms.  The platform characteristics can be changed use 'make
  menuconfig'.  Sometimes this can be confusing due to the differences
  between the platforms.  Enter sethost.sh

  sethost.sh is a simple script that changes a configuration to your
  host platform.  This can greatly simplify life if you use many different
  configurations.  For example, if you are running on Linux and you
  configure like this:

Gregory Nutt's avatar
Gregory Nutt committed
    tools/configure.sh board/configuration

  The you can use the following command to both (1) make sure that the
  configuration is up to date, AND (2) the configuration is set up
  correctly for Linux:

Gregory Nutt's avatar
Gregory Nutt committed
    tools/sethost.sh -l

  Or, if you are on a Windows/Cygwin 64-bit platform:

Gregory Nutt's avatar
Gregory Nutt committed
    tools/sethost.sh -c

  Other options are available from the help option built into the
  script.  You can see all options with:

    tools/sethost.sh -h

Bill Morgan's avatar
Bill Morgan committed
  Recently, the options to the configure.sh (and configure.bat) scripts have
  been extended so that you both setup the configuration, select for the host
  platform that you use, and uncompress and refresh the defconfig file all in
  one command like:
Gregory Nutt's avatar
Gregory Nutt committed

    tools/configure.sh -l board/configuration

  For a Linux host or for a Windows/Cygwin host:

    tools/configure.sh -h board/configuration

  Other options are available from the help option built into the
  script.  You can see all options with:

Gregory Nutt's avatar
Gregory Nutt committed
    tools/configure.sh -h
Comparing Two Configurations
----------------------------

Bill Morgan's avatar
Bill Morgan committed
  If you try to compare two configurations using 'diff', you will probably
  not be happy with the result.  There are superfluous things added to
Bill Morgan's avatar
Bill Morgan committed
  the configuration files that make comparisons with the human eye
Bill Morgan's avatar
Bill Morgan committed
  There is a tool at nuttx/tools/cmpconfig.c that can be built to simplify
  these comparisons.  The output from this difference tool will show only
  the meaningful differences between two configuration files.  This tool is
  built as follows:

    cd nuttx/tools
    make -f Makefile.host

Bill Morgan's avatar
Bill Morgan committed
  This will create a program called 'cmpconfig' or 'comconfig.exe' on Windows.
Gregory Nutt's avatar
Gregory Nutt committed
  Why would you want to compare two configuration files?  Here are a few
Bill Morgan's avatar
Bill Morgan committed
  of the reasons why I do this

  1. When I create a new configuration I usually base it on an older
     configuration and I want to know, "What are the options that I need to
     change to add the new feature to the older configurations?"  For example,
Gregory Nutt's avatar
Gregory Nutt committed
     suppose that I have a boardA/nsh configuration and I want to create a
     boardA/nxwm configuration.  Suppose I already have boardB/nsh and
     boardB/nxwm configurations.  Then by comparing the boardB/nsh with the
     boardB/nxwm I can see the modifications that I would need to make to my
     boardA/nsh to create a new  boardA/nxwm.

Bill Morgan's avatar
Bill Morgan committed
  2. But the most common reason that I use the 'cmpconfig' program is to
     check the results of "refreshing" a configuration with 'make oldconfig'
Gregory Nutt's avatar
Gregory Nutt committed
     (see the paragraph "Refreshing Configurations" above).  The 'make
     oldconfig' command will make changes to my configuration and using
     'cmpconfig', I can see precisely what those changes were and if any
     should be of concern to me.
Gregory Nutt's avatar
Gregory Nutt committed
  3. The 'cmpconfig' tool can also be useful when converting older, legacy
     manual configurations to the current configurations based on the
     kconfig-frontends tools.  See the following paragraph.
Gregory Nutt's avatar
Gregory Nutt committed
  .config Files as defconfig Files:
Gregory Nutt's avatar
Gregory Nutt committed
    The minimum defconfig file is simply the generated .config file with
    CONFIG_APPS_DIR setting removed or commented out.  That setting provides
    the name and location of the apps/ directory relative to the nuttx build
    directory.  The default is ../apps/, however, the apps directory may be
    any other location and may have a different name.  For example, the name
    of versioned NuttX releases are always in the form apps-xx.yy where xx.yy
    is the version number.
Gregory Nutt's avatar
Gregory Nutt committed
  Finding the apps/ Directory Path:
Gregory Nutt's avatar
Gregory Nutt committed
    When the default configuration is installed using one of the scripts or
    programs in the NuttX tools directory, there will be an option to provide
    the path to the apps/ directory.  If not provided, then the configure tool
    will look around and try to make a reasonable decision about where the
    apps/ directory is located.

  Compressed defconfig Files:

    The Makefile also supports an option to generate very small defconfig
    files.  The .config files are quite large and complex.  But most of the
    settings in the .config file simply have the default settings from the
    Kconfig files.  These .config files can be converted into small defconfig
    file:

      make savedefconfig

    That make target will generate a defconfig file in the top-level
    directory.  The size reduction is really quite remarkable:
Gregory Nutt's avatar
Gregory Nutt committed
      wc -l .config defconfig
       1085 .config
         82 defconfig
       1167 total
Gregory Nutt's avatar
Gregory Nutt committed
     In order to be usable, the .config file installed from the compressed
     defconfig file must be reconstituted using:

       make olddefconfig

Gregory Nutt's avatar
Gregory Nutt committed
     NOTE 1:  Only compressed defconfig files are retained in the NuttX repository.
Gregory Nutt's avatar
Gregory Nutt committed
     All patches and PRs that attempt to add or modify a defconfig file MUST
     use the compressed defconfig format as created by 'make savdefconfig.'

Gregory Nutt's avatar
Gregory Nutt committed
     NOTE 2:  When 'make savedefconfig' runs it will try several things some of
     which are expected to fail.  In these cases you will see an error message
     from make followed by "(ignored)."  You should also ignore these messages

Gregory Nutt's avatar
Gregory Nutt committed
     CAUTION:  This size reduction was accomplished by removing all setting
     from the .config file that were at the default value.  'make olddefconfig'
     can regenerate the original .config file by simply restoring those default
     settings.  The underlying assumption here is, of course, that the default
     settings do not change.  If the default settings change, and they often
     do, then the original .config may not be reproducible.

     So if your project requires 100% reproducibility over a long period of
     time, you make want to save the complete .config files vs. the standard,
     compressed defconfig file.

  Configuring with "Compressed" defconfig Files:

    As described above defconfig, all NuttX defconfig files are compressed
    using 'make savedeconfig'.  These compressed defconfig files are
    generally not fully usable as they are and may not build the target
    binaries that you want because the compression process removed all of
    the default settings from the defconfig file.  To restore the default
    settings, you should run the following after configuring:

      make olddefconfig

    That will restore the the missing defaulted values.

    Using this command after configuring is generally a good practice anyway:
    Even if the defconfig files are not "compressed" in this fashion, the
    defconfig file may be old and the only way to assure that the installed
Bill Morgan's avatar
Bill Morgan committed
    .config is is up to date is via 'make oldconfig' or 'make olddefconfig'.
Gregory Nutt's avatar
Gregory Nutt committed
    See the paragraph above entitled ""Refreshing Configurations" for
    additional information.
Incompatibilities with Older Configurations
-------------------------------------------

  ***** WARNING *****

Gregory Nutt's avatar
Gregory Nutt committed
  The current NuttX build system supports *only* the new compressed,
  defconfig configuration files generated using the kconfig-frontends tools
Bill Morgan's avatar
Bill Morgan committed
  as described in the preceding section.  Support for the older, legacy,
  manual configurations was eliminated in NuttX 7.0; support for
Gregory Nutt's avatar
Gregory Nutt committed
  uncompressed .config-files-as-defconfig files was eliminated after
  NuttX-7.21.  All configurations must now be done using the
  kconfig-frontends tool.  The older manual configurations and the new
  kconfig-frontends configurations are not compatible.  Old legacy
  configurations can *not* be used with the kconfig-frontends tool and,
  hence, cannot be used with releases of NuttX 7.0 and beyond:

  If you run 'make menuconfig' with a legacy configuration the resulting
  configuration will probably not be functional.

  Q: How can I tell if a configuration is a new kconfig-frontends
     configuration or an older, manual configuration?

  A: Only old, manual configurations will have an appconfig file