blob: 133c6fb7cfb57df11022816184d9cb5b4c4aa57f [file] [log] [blame]
<!--
Documentation/_templates/layout.html
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership. The
ASF licenses this file to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
-->
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Custom Apps How-to &mdash; NuttX latest documentation</title>
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/copybutton.css" type="text/css" />
<link rel="stylesheet" href="../_static/tabs.css" type="text/css" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
<link rel="shortcut icon" href="../_static/favicon.ico"/>
<!--[if lt IE 9]>
<script src="../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script src="../_static/jquery.js"></script>
<script src="../_static/_sphinx_javascript_frameworks_compat.js"></script>
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/sphinx_highlight.js"></script>
<script src="../_static/clipboard.min.js"></script>
<script src="../_static/copybutton.js"></script>
<script src="../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Running CI Test Locally" href="citests.html" />
<link rel="prev" title="Custom Boards How-To" href="customboards.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../index.html" class="icon icon-home"> NuttX
</a>
<!-- this version selector is quite ugly, should be probably replaced by something
more modern -->
<div class="version-selector">
<select onchange="javascript:location.href = this.value;">
<option value="../../latest" selected="selected">latest</option>
<option value="../../10.0.0" >10.0.0</option>
<option value="../../10.0.1" >10.0.1</option>
<option value="../../10.1.0" >10.1.0</option>
<option value="../../10.2.0" >10.2.0</option>
<option value="../../10.3.0" >10.3.0</option>
<option value="../../11.0.0" >11.0.0</option>
<option value="../../12.0.0" >12.0.0</option>
<option value="../../12.1.0" >12.1.0</option>
<option value="../../12.2.0" >12.2.0</option>
<option value="../../12.2.1" >12.2.1</option>
<option value="../../12.3.0" >12.3.0</option>
<option value="../../12.4.0" >12.4.0</option>
<option value="../../12.5.0" >12.5.0</option>
<option value="../../12.5.1" >12.5.1</option>
</select>
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Table of Contents</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index.html">Home</a></li>
<li class="toctree-l1"><a class="reference internal" href="../introduction/index.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../quickstart/index.html">Getting Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../introduction/inviolables.html">The Inviolable Principles of NuttX</a></li>
<li class="toctree-l1"><a class="reference internal" href="../platforms/index.html">Supported Platforms</a></li>
<li class="toctree-l1"><a class="reference internal" href="../components/index.html">OS Components</a></li>
<li class="toctree-l1"><a class="reference internal" href="../applications/index.html">Applications</a></li>
<li class="toctree-l1"><a class="reference internal" href="../implementation/index.html">Implementation Details</a></li>
<li class="toctree-l1"><a class="reference internal" href="../reference/index.html">API Reference</a></li>
<li class="toctree-l1"><a class="reference internal" href="../faq/index.html">FAQ</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Guides</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="nfs.html">NFS Client How-To</a></li>
<li class="toctree-l2"><a class="reference internal" href="usbtrace.html">USB Device Trace</a></li>
<li class="toctree-l2"><a class="reference internal" href="simulator.html">Simulator</a></li>
<li class="toctree-l2"><a class="reference internal" href="qemugdb.html">How to debug NuttX using QEMU and GDB</a></li>
<li class="toctree-l2"><a class="reference internal" href="rndis.html">How to use RNDIS</a></li>
<li class="toctree-l2"><a class="reference internal" href="drivers.html">Drivers</a></li>
<li class="toctree-l2"><a class="reference internal" href="tasktrace.html">Task Trace</a></li>
<li class="toctree-l2"><a class="reference internal" href="cpp_cmake.html">C++ Example using CMake</a></li>
<li class="toctree-l2"><a class="reference internal" href="pysimcoder.html">pysimCoder integration with NuttX</a></li>
<li class="toctree-l2"><a class="reference internal" href="customboards.html">Custom Boards How-To</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Custom Apps How-to</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#replace-the-apps-directory-completely">1. Replace The Apps/ Directory Completely</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#makefile">1.1 Makefile</a></li>
<li class="toctree-l4"><a class="reference internal" href="#kconfig">1.2 Kconfig</a></li>
<li class="toctree-l4"><a class="reference internal" href="#customhello-c">1.3 CustomHello.c</a></li>
<li class="toctree-l4"><a class="reference internal" href="#building-with-the-customapps-directory">1.4 Building with the CustomApps Directory</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#extend-the-apps-directory-to-include-a-new-custom-directory">2. Extend the apps/ directory to include a new custom directory</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#custom-apps-directory">2.1 Custom Apps Directory</a></li>
<li class="toctree-l4"><a class="reference internal" href="#make-defs">2.2 Make.defs</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id1">2.3 Makefile</a></li>
<li class="toctree-l4"><a class="reference internal" href="#customhello-app">2.4 CustomHello App</a></li>
<li class="toctree-l4"><a class="reference internal" href="#customhello-makefile">2.5 CustomHello Makefile</a></li>
<li class="toctree-l4"><a class="reference internal" href="#customhello-kconfig">2.6 CustomHello Kconfig</a></li>
<li class="toctree-l4"><a class="reference internal" href="#build-and-run">2.7 Build and Run</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#include-an-additional-custom-directory-outside-of-the-main-source-trees">3. Include an Additional Custom directory Outside of the Main Source Trees</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#create-custom-apps-directory-and-a-symbolic-link">3.1 Create Custom Apps directory and a Symbolic Link</a></li>
<li class="toctree-l4"><a class="reference internal" href="#make-defs-etc">3.2 Make.defs etc.</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="citests.html">Running CI Test Locally</a></li>
<li class="toctree-l2"><a class="reference internal" href="zerolatencyinterrupts.html">High Performance, Zero Latency Interrupts</a></li>
<li class="toctree-l2"><a class="reference internal" href="nestedinterrupts.html">Nested Interrupts</a></li>
<li class="toctree-l2"><a class="reference internal" href="cortexmhardfaults.html">Analyzing Cortex-M Hardfaults</a></li>
<li class="toctree-l2"><a class="reference internal" href="coredump.html">Core Dump</a></li>
<li class="toctree-l2"><a class="reference internal" href="minidumpserver.html">minidumpserver</a></li>
<li class="toctree-l2"><a class="reference internal" href="gdbwithpython.html">GDB with Python</a></li>
<li class="toctree-l2"><a class="reference internal" href="ofloader.html">Open Flash Loader</a></li>
<li class="toctree-l2"><a class="reference internal" href="testingtcpip.html">Testing TCP/IP Network Stacks</a></li>
<li class="toctree-l2"><a class="reference internal" href="automounter.html">Auto-Mounter</a></li>
<li class="toctree-l2"><a class="reference internal" href="stm32nullpointer.html">STM32 Null Pointer Detection</a></li>
<li class="toctree-l2"><a class="reference internal" href="stm32ccm.html">STM32 CCM Allocator</a></li>
<li class="toctree-l2"><a class="reference internal" href="stackrecord.html">Run time stack statistics</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../glossary.html">Glossary</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">NuttX</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item"><a href="index.html">Guides</a></li>
<li class="breadcrumb-item active">Custom Apps How-to</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/guides/customapps.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="custom-apps-how-to">
<h1>Custom Apps How-to<a class="headerlink" href="#custom-apps-how-to" title="Permalink to this heading"></a></h1>
<p>NuttX comes with a large number of Apps but, most likely, you will want to add your own.</p>
<p>There are various different options for this depending on your requirements.</p>
<blockquote>
<div><ol class="arabic simple">
<li><p>Replace the apps/ directory completely</p></li>
<li><p>Extend the apps/ directory to include a new custom directory</p></li>
<li><p>Include an additional custom directory outside of the main source trees</p></li>
</ol>
</div></blockquote>
<p>The following sections explain these 3 methods using a <code class="docutils literal notranslate"><span class="pre">CustomHello.c</span></code> app and
the directory <code class="docutils literal notranslate"><span class="pre">CustomApps</span></code> as an example.</p>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p>If you make errors while setting this up and the build fails, it is most likely you’ll
need to run <code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">clean</span></code> and possibly even <code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">distclean</span></code> before rebuilding to
ensure it works correctly.</p>
</div>
<section id="replace-the-apps-directory-completely">
<h2>1. Replace The Apps/ Directory Completely<a class="headerlink" href="#replace-the-apps-directory-completely" title="Permalink to this heading"></a></h2>
<p>The CustomApps directory need only to contain the minimum three files:</p>
<blockquote>
<div><ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">Makefile</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">Kconfig</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">CustomHello.c</span></code></p></li>
</ul>
</div></blockquote>
<section id="makefile">
<h3>1.1 Makefile<a class="headerlink" href="#makefile" title="Permalink to this heading"></a></h3>
<p>The custom application directory must include a Makefile to make all of the targets
expected by the NuttX build and must generate an archive called libapps.a in the
top-level of the custom directory structure.</p>
<p>The Makefile has just those minimum required targets:</p>
<blockquote>
<div><div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">APPDIR = ${shell pwd}</span>
<span class="go">-include $(TOPDIR)/Make.defs</span>
<span class="gp"># </span>files
<span class="go">CSRCS = CustomHello.c</span>
<span class="go">COBJS = CustomHello.o</span>
<span class="go">ROOTDEPPATH = --dep-path .</span>
<span class="gp"># </span>Build<span class="w"> </span>targets
<span class="go">all: libapps.a</span>
<span class="go">.PHONY: dirlinks context preconfig depend clean clean_context distclean</span>
<span class="go">.PRECIOUS: libapps$(LIBEXT)</span>
<span class="gp"># </span>Compile<span class="w"> </span>C<span class="w"> </span>Files
<span class="gp">$</span><span class="o">(</span>COBJS<span class="o">)</span>:<span class="w"> </span>%<span class="k">$(</span>OBJEXT<span class="k">)</span>:<span class="w"> </span>%.c
<span class="gp">$</span><span class="o">(</span>call<span class="w"> </span>COMPILE,<span class="w"> </span>$&lt;,<span class="w"> </span><span class="nv">$@</span><span class="o">)</span>
<span class="gp"># </span>Add<span class="w"> </span>object<span class="w"> </span>files<span class="w"> </span>to<span class="w"> </span>the<span class="w"> </span>apps<span class="w"> </span>archive
<span class="go">libapps.a: $(COBJS)</span>
<span class="gp"> $</span><span class="o">(</span>call<span class="w"> </span>ARCHIVE,<span class="w"> </span>libapps.a,<span class="w"> </span><span class="k">$(</span>COBJS<span class="k">)</span><span class="o">)</span>
<span class="gp"># </span>Create<span class="w"> </span>directory<span class="w"> </span>links
<span class="go">dirlinks:</span>
<span class="gp"># </span>Setup<span class="w"> </span>any<span class="w"> </span>special<span class="w"> </span>pre-build<span class="w"> </span>context
<span class="go">context:</span>
<span class="gp"># </span>Setup<span class="w"> </span>any<span class="w"> </span>special<span class="w"> </span>pre-configuration<span class="w"> </span>context
<span class="go">preconfig:</span>
<span class="gp"># </span>Make<span class="w"> </span>the<span class="w"> </span>dependency<span class="w"> </span>file,<span class="w"> </span>Make.deps
<span class="go">depend: Makefile $(CSRCS)</span>
<span class="gp"> $</span><span class="o">(</span>Q<span class="o">)</span><span class="w"> </span><span class="k">$(</span>MKDEP<span class="k">)</span><span class="w"> </span><span class="k">$(</span>ROOTDEPPATH<span class="k">)</span><span class="w"> </span><span class="s2">&quot;</span><span class="k">$(</span>CC<span class="k">)</span><span class="s2">&quot;</span><span class="w"> </span>--<span class="w"> </span><span class="k">$(</span>CFLAGS<span class="k">)</span><span class="w"> </span>--<span class="w"> </span><span class="k">$(</span>SRCS<span class="k">)</span><span class="w"> </span>&gt;<span class="w"> </span>Make.dep
<span class="gp"># </span>Clean<span class="w"> </span>the<span class="w"> </span>results<span class="w"> </span>of<span class="w"> </span>the<span class="w"> </span>last<span class="w"> </span>build
<span class="go">clean:</span>
<span class="gp"> $</span><span class="o">(</span>call<span class="w"> </span>CLEAN<span class="o">)</span>
<span class="gp"># </span>Remove<span class="w"> </span>the<span class="w"> </span>build<span class="w"> </span>context<span class="w"> </span>and<span class="w"> </span>directory<span class="w"> </span>links
<span class="go">clean_context:</span>
<span class="gp"># </span>Restore<span class="w"> </span>the<span class="w"> </span>directory<span class="w"> </span>to<span class="w"> </span>its<span class="w"> </span>original<span class="w"> </span>state
<span class="go">distclean: clean clean_context</span>
<span class="gp"> $</span><span class="o">(</span>call<span class="w"> </span>DELFILE,<span class="w"> </span>Make.dep<span class="o">)</span>
<span class="gp"># </span>Include<span class="w"> </span>dependencies
<span class="go">-include Make.dep</span>
</pre></div>
</div>
</div></blockquote>
</section>
<section id="kconfig">
<h3>1.2 Kconfig<a class="headerlink" href="#kconfig" title="Permalink to this heading"></a></h3>
<p>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 and/or choose which of your apps to include.</p>
<p>In the minimum case, Kconfig is only:</p>
<blockquote>
<div><div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp"># </span>For<span class="w"> </span>a<span class="w"> </span>description<span class="w"> </span>of<span class="w"> </span>the<span class="w"> </span>syntax<span class="w"> </span>of<span class="w"> </span>this<span class="w"> </span>configuration<span class="w"> </span>file,
<span class="gp"># </span>see<span class="w"> </span>the<span class="w"> </span>file<span class="w"> </span>kconfig-language.txt<span class="w"> </span><span class="k">in</span><span class="w"> </span>the<span class="w"> </span>NuttX<span class="w"> </span>tools<span class="w"> </span>repository.
<span class="gp">#</span>
</pre></div>
</div>
</div></blockquote>
<p>or</p>
<blockquote>
<div><div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp"># </span>For<span class="w"> </span>a<span class="w"> </span>description<span class="w"> </span>of<span class="w"> </span>the<span class="w"> </span>syntax<span class="w"> </span>of<span class="w"> </span>this<span class="w"> </span>configuration<span class="w"> </span>file,
<span class="gp"># </span>see<span class="w"> </span>the<span class="w"> </span>file<span class="w"> </span>kconfig-language.txt<span class="w"> </span><span class="k">in</span><span class="w"> </span>the<span class="w"> </span>NuttX<span class="w"> </span>tools<span class="w"> </span>repository.
<span class="gp">#</span>
</pre></div>
</div>
</div></blockquote>
</section>
<section id="customhello-c">
<h3>1.3 CustomHello.c<a class="headerlink" href="#customhello-c" title="Permalink to this heading"></a></h3>
<p>The 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 <code class="docutils literal notranslate"><span class="pre">main()</span></code> entry point to the
application.</p>
<p>The function of this main() entry point simply to bring-up the full application. It is called
at the completion of OS initialization.</p>
<p>What this application initialization entry point does, how it interacts with the rest of your
application, and where the rest of you application code is located is of no concern to the OS.</p>
<p>Only this one entry point is needed.</p>
<p>For this “Hello, Custom World!” application <code class="docutils literal notranslate"><span class="pre">custom_hello()</span></code> is the application entry point:</p>
<blockquote>
<div><div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">#</span>include<span class="w"> </span>&lt;stdio.h&gt;
<span class="go">int custom_hello(int argc, char *argv[])</span>
<span class="go">{</span>
<span class="go"> printf(&quot;Hello, Custom World!!\n&quot;);</span>
<span class="go"> return 0;</span>
<span class="go">}</span>
</pre></div>
</div>
</div></blockquote>
</section>
<section id="building-with-the-customapps-directory">
<h3>1.4 Building with the CustomApps Directory<a class="headerlink" href="#building-with-the-customapps-directory" title="Permalink to this heading"></a></h3>
<p>In order to build with the new custom configuration, you will need the following in your configuration:</p>
<p><span class="menuselection">CONFIG_APPS_DIR=”../CustomApps”</span></p>
<p><span class="menuselection">CONFIG_INIT_ENTRYPOINT=”custom_hello”</span></p>
<p>Note that you can only access the <code class="docutils literal notranslate"><span class="pre">../CustomApps/Kconfig</span></code> configuration file if <code class="docutils literal notranslate"><span class="pre">CONFIG_APPS_DIR</span></code> is set
to <code class="docutils literal notranslate"><span class="pre">../CustomApps</span></code> BEFORE <code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">menuconfig</span></code> is executed</p>
<p>This can be done by</p>
<ul>
<li><p>hand-editing the .config file before running make menuconfig, which is rarely a good idea</p></li>
<li><p>Using <code class="docutils literal notranslate"><span class="pre">kconfig-tweak</span> <span class="pre">--set-str</span> <span class="pre">CONFIG_APPS_DIR</span> <span class="pre">../CustomApps</span></code></p></li>
<li><p>select the CustomApps directory as a command line option at the time the board is configured:</p>
<blockquote>
<div><div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">./tools/configure.sh -a ../CustomApps &lt;board&gt;:&lt;config&gt;</span>
</pre></div>
</div>
</div></blockquote>
<p>or</p>
<blockquote>
<div><div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">.tools/configure.sh -l ../CustomBoards/MyCustomBoardName/MyCustomConfig</span>
</pre></div>
</div>
</div></blockquote>
</li>
</ul>
<p>Then build as you normally would. When you execute the custom_hello app you should see:</p>
<blockquote>
<div><div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">Hello, Custom World!!</span>
</pre></div>
</div>
</div></blockquote>
</section>
</section>
<section id="extend-the-apps-directory-to-include-a-new-custom-directory">
<h2>2. Extend the apps/ directory to include a new custom directory<a class="headerlink" href="#extend-the-apps-directory-to-include-a-new-custom-directory" title="Permalink to this heading"></a></h2>
<p>The collection of apps provided in nuttx-apps can be useful, and this method simply
extends the directory structure to include your own directory structure.</p>
<p>The existing /apps makefile automatically checks for the existence of sub-directories
that contain a <code class="docutils literal notranslate"><span class="pre">Makefile</span></code> and <code class="docutils literal notranslate"><span class="pre">Make.defs</span></code> file. This example assumes there is likely
to be more than one custom app, and includes a <code class="docutils literal notranslate"><span class="pre">Kconfig</span></code> for the app itself. Inclusion
of a <code class="docutils literal notranslate"><span class="pre">Kconfig</span></code> allows custom App options to be included in the NuttX configuration
system, but is optional.</p>
<section id="custom-apps-directory">
<h3>2.1 Custom Apps Directory<a class="headerlink" href="#custom-apps-directory" title="Permalink to this heading"></a></h3>
<p>Simply create a new directory under the existing apps directory with a name of your choice.
This example uses the directory name <code class="docutils literal notranslate"><span class="pre">CustomApps</span></code>.</p>
</section>
<section id="make-defs">
<h3>2.2 Make.defs<a class="headerlink" href="#make-defs" title="Permalink to this heading"></a></h3>
<p>Create this file in the <code class="docutils literal notranslate"><span class="pre">CustomApps</span></code> directory, with the following line added:</p>
<blockquote>
<div><div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">include $(wildcard $(APPDIR)/CustomApps/*/Make.defs)</span>
</pre></div>
</div>
</div></blockquote>
</section>
<section id="id1">
<h3>2.3 Makefile<a class="headerlink" href="#id1" title="Permalink to this heading"></a></h3>
<p>Create a Makefile in the <code class="docutils literal notranslate"><span class="pre">CustomApps</span></code> directory, with the following lines added:</p>
<blockquote>
<div><div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">MENUDESC = &quot;Custom Apps&quot;</span>
<span class="go">include $(APPDIR)/Directory.mk</span>
</pre></div>
</div>
</div></blockquote>
</section>
<section id="customhello-app">
<h3>2.4 CustomHello App<a class="headerlink" href="#customhello-app" title="Permalink to this heading"></a></h3>
<p>Create a sub-directory under the <code class="docutils literal notranslate"><span class="pre">CustomApps</span></code> directory called <code class="docutils literal notranslate"><span class="pre">CustomHello</span></code>.</p>
<p>The same <code class="docutils literal notranslate"><span class="pre">CustomHello.c</span></code> file as described above should be created here.</p>
</section>
<section id="customhello-makefile">
<h3>2.5 CustomHello Makefile<a class="headerlink" href="#customhello-makefile" title="Permalink to this heading"></a></h3>
<p>Create a Makefile in the <code class="docutils literal notranslate"><span class="pre">CustomApps/CustomHello</span></code> directory with the following lines:</p>
<blockquote>
<div><div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">include $(APPDIR)/Make.defs</span>
<span class="gp"># </span>Custom<span class="w"> </span>Hello<span class="w"> </span>built-in<span class="w"> </span>application<span class="w"> </span>info
<span class="go">PROGNAME = $(CONFIG_CUSTOM_APPS_CUSTOM_HELLO_PROGNAME)</span>
<span class="go">PRIORITY = $(CONFIG_CUSTOM_APPS_CUSTOM_HELLO_PRIORITY)</span>
<span class="go">STACKSIZE = $(CONFIG_CUSTOM_APPS_CUSTOM_HELLO_STACKSIZE)</span>
<span class="go">MODULE = $(CONFIG_CUSTOM_APPS_CUSTOM_HELLO)</span>
<span class="gp"># </span>Custom<span class="w"> </span>Hello
<span class="go">MAINSRC = CustomHello.c</span>
<span class="go">include $(APPDIR)/Application.mk</span>
</pre></div>
</div>
</div></blockquote>
</section>
<section id="customhello-kconfig">
<h3>2.6 CustomHello Kconfig<a class="headerlink" href="#customhello-kconfig" title="Permalink to this heading"></a></h3>
<p>Create a Kconfig file in the <code class="docutils literal notranslate"><span class="pre">CustomApps/CustomHello</span></code> directory, with the following lines. For
the purposes of this example, the Kconfig will only cover our single application):</p>
<blockquote>
<div><div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">#</span>
<span class="gp"># </span>For<span class="w"> </span>a<span class="w"> </span>description<span class="w"> </span>of<span class="w"> </span>the<span class="w"> </span>syntax<span class="w"> </span>of<span class="w"> </span>this<span class="w"> </span>configuration<span class="w"> </span>file,
<span class="gp"># </span>see<span class="w"> </span>the<span class="w"> </span>file<span class="w"> </span>kconfig-language.txt<span class="w"> </span><span class="k">in</span><span class="w"> </span>the<span class="w"> </span>NuttX<span class="w"> </span>tools<span class="w"> </span>repository.
<span class="gp">#</span>
<span class="go">config CUSTOM_APPS_CUSTOM_HELLO</span>
<span class="go"> tristate &quot;Custom Hello App&quot;</span>
<span class="go"> default n</span>
<span class="go"> ---help---</span>
<span class="go"> Enable the Custom Hello App</span>
<span class="go">if CUSTOM_APPS_CUSTOM_HELLO</span>
<span class="go">config CUSTOM_APPS_CUSTOM_HELLO_PROGNAME</span>
<span class="go"> string &quot;Program name&quot;</span>
<span class="go"> default &quot;custom_hello&quot;</span>
<span class="go"> ---help---</span>
<span class="go"> This is the name of the program that will be used when the NSH ELF</span>
<span class="go"> program is installed.</span>
<span class="go">config CUSTOM_APPS_CUSTOM_HELLO_PRIORITY</span>
<span class="go"> int &quot;Custom Hello task priority&quot;</span>
<span class="go"> default 100</span>
<span class="go">config CUSTOM_APPS_CUSTOM_HELLO_STACKSIZE</span>
<span class="go"> int &quot;Custom Hello stack size&quot;</span>
<span class="go"> default DEFAULT_TASK_STACKSIZE</span>
<span class="go">endif</span>
</pre></div>
</div>
</div></blockquote>
</section>
<section id="build-and-run">
<h3>2.7 Build and Run<a class="headerlink" href="#build-and-run" title="Permalink to this heading"></a></h3>
<p>Once these files have been created, run a <code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">clean</span></code> (you may need to run <code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">distclean</span></code>
followed by <code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">menuconfig</span></code>. If successful there will be new Kconfig entries.</p>
<p><span class="menuselection">Application Configuraration ‣ Custom Apps ‣ Custom Hello App</span></p>
<p>Select the <code class="docutils literal notranslate"><span class="pre">Custom</span> <span class="pre">Hello</span> <span class="pre">App</span></code> and run the usual build process. If successful
you can run the newly included <code class="docutils literal notranslate"><span class="pre">custom_hello</span></code> app.</p>
</section>
</section>
<section id="include-an-additional-custom-directory-outside-of-the-main-source-trees">
<h2>3. Include an Additional Custom directory Outside of the Main Source Trees<a class="headerlink" href="#include-an-additional-custom-directory-outside-of-the-main-source-trees" title="Permalink to this heading"></a></h2>
<p>Thia is similar to the previous approach, but places the <code class="docutils literal notranslate"><span class="pre">CustomApps</span></code> directory
outside of the default trees.</p>
<section id="create-custom-apps-directory-and-a-symbolic-link">
<h3>3.1 Create Custom Apps directory and a Symbolic Link<a class="headerlink" href="#create-custom-apps-directory-and-a-symbolic-link" title="Permalink to this heading"></a></h3>
<p>Create a directory for the custom apps in a location of your choosing. Then create A
symbolic link in the main nuttx/apps directory.</p>
<p>This example assumes this has been placed below the top NuttX folder, alongside the
default <code class="docutils literal notranslate"><span class="pre">apps</span></code> directory, i.e. <code class="docutils literal notranslate"><span class="pre">nuttx/CustomApps</span></code></p>
<blockquote>
<div><div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span><span class="nb">pwd</span>
<span class="go">/home/nuttx</span>
<span class="gp">$ </span>ls<span class="w"> </span>-1
<span class="go">apps</span>
<span class="go">CustomBoards</span>
<span class="go">nuttx</span>
<span class="gp">$ </span>mkdir<span class="w"> </span>CustomApps
<span class="gp">$ </span>ls<span class="w"> </span>-1
<span class="go">apps</span>
<span class="go">CustomApps</span>
<span class="go">CustomBoards</span>
<span class="go">nuttx</span>
<span class="gp">$ </span><span class="nb">cd</span><span class="w"> </span>apps
<span class="gp">$ </span>ln<span class="w"> </span>-s<span class="w"> </span>../CustomApps<span class="w"> </span>CustomApps
</pre></div>
</div>
</div></blockquote>
</section>
<section id="make-defs-etc">
<h3>3.2 Make.defs etc.<a class="headerlink" href="#make-defs-etc" title="Permalink to this heading"></a></h3>
<p>Follow all the steps as in sections 2.2 to 2.7 above, creating the exact same files but
placing then in the new <code class="docutils literal notranslate"><span class="pre">CustomApps</span></code> directory location created as described here.</p>
</section>
</section>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="customboards.html" class="btn btn-neutral float-left" title="Custom Boards How-To" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="citests.html" class="btn btn-neutral float-right" title="Running CI Test Locally" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>&#169; Copyright 2023, The Apache Software Foundation.</p>
</div>
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>