blob: b03d6018cc0fdc8cdbbbed9e84a62fd2de471dac [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Creating Your First Mynewt Project &mdash; Apache Mynewt latest documentation</title>
<link rel="shortcut icon" href="../_static/mynewt-logo-only-newt32x32.png"/>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/sphinx_theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/bootstrap-3.0.3.min.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/v2.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/custom.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/restructuredtext.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/overrides.css" type="text/css" />
<link rel="index" title="Index"
href="../genindex.html"/>
<link rel="search" title="Search" href="../search.html"/>
<link rel="top" title="Apache Mynewt latest documentation" href="../index.html"/>
<link rel="up" title="Setup &amp; Get Started" href="index.html"/>
<link rel="next" title="Using the Serial Port with Mynewt OS" href="serial_access.html"/>
<link rel="prev" title="Everything You Need in a Docker Container" href="docker.html"/>
<script src="../_static/js/modernizr.min.js"></script>
<script>
(function(i, s, o, g, r, a, m) {
i["GoogleAnalyticsObject"] = r;
(i[r] =
i[r] ||
function() {
(i[r].q = i[r].q || []).push(arguments);
}),
(i[r].l = 1 * new Date());
(a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]);
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m);
})(window, document, "script", "//www.google-analytics.com/analytics.js", "ga");
ga("create", "UA-72162311-1", "auto");
ga("send", "pageview");
</script>
</head>
<body class="not-front page-documentation" role="document" >
<div id="wrapper">
<div class="container">
<div id="banner" class="row v2-main-banner">
<a class="logo-cell" href="/">
<img class="logo" src="../_static/img/logo.png">
</a>
<div class="tagline-cell">
<h4 class="tagline">An OS to build, deploy and securely manage billions of devices</h4>
</div>
<div class="news-cell">
<div class="well">
<h4>Latest News:</h4> <a href="/download">Apache Mynewt 1.11.0, Apache NimBLE 1.6.0 </a> released September 7, 2023)
</div>
</div>
</div>
</div>
<header>
<nav id="navbar" class="navbar navbar-inverse" role="navigation">
<div class="container">
<!-- Collapsed navigation -->
<div class="navbar-header">
<!-- Expander button -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- Expanded navigation -->
<div class="navbar-collapse collapse">
<!-- Main navigation -->
<ul class="nav navbar-nav navbar-right">
<li>
<a href="/"><i class="fa fa-home" style="font-size: larger;"></i></a>
</li>
<li class="important">
<a href="/quick-start/">Quick Start</a>
</li>
<li>
<a href="/about/">About</a>
</li>
<li>
<a href="/talks/">Talks</a>
</li>
<li class="active">
<a href="/documentation/">Documentation</a>
</li>
<li>
<a href="/download/">Download</a>
</li>
<li>
<a href="/community/">Community</a>
</li>
<li>
<a href="/events/">Events</a>
</li>
</ul>
<!-- Search, Navigation and Repo links -->
<ul class="nav navbar-nav navbar-right">
</ul>
</div>
</div>
</nav>
</header>
<!-- STARTS MAIN CONTENT -->
<div id="main-content">
<div id="breadcrumb">
<div class="container">
<a href="/documentation/">Docs</a> /
<a href="index.html">Setup &amp; Get Started</a> /
Creating Your First Mynewt Project
<div class="sourcelink">
<a href="https://github.com/apache/mynewt-documentation/edit/master/docs/get_started/project_create.rst" class="icon icon-github"
rel="nofollow"> Edit on GitHub</a>
</div>
</div>
</div>
<!-- STARTS CONTAINER -->
<div class="container">
<!-- STARTS .content -->
<div id="content" class="row">
<!-- STARTS .container-sidebar -->
<div class="container-sidebar col-xs-12 col-sm-3">
<div id="docSidebar" class="sticky-container">
<div role="search" class="sphinx-search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search documentation" class="search-documentation" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<!-- Note: only works when deployed -->
<select class="form-control" onchange="if (this.value) window.location.href=this.value">
<option value="/latest" selected>
Version: latest
</option>
<option value="/v1_11_0" >
Version: 1.11.0
</option>
<option value="/v1_10_0" >
Version: 1.10.0
</option>
<option value="/v1_9_0" >
Version: 1.9.0
</option>
<option value="/v1_8_0" selected="selected" >
Version: 1.8.0
</option>
<option value="/v1_7_0" >
Version: 1.7.0
</option>
<option value="/v1_6_0" >
Version: 1.6.0
</option>
<option value="/v1_5_0" >
Version: 1.5.0
</option>
<option value="/v1_4_0" >
Version: 1.4.0
</option>
<option value="/v1_3_0/os/introduction" >
Version: 1.3.0
</option>
<option value="/v1_2_0/os/introduction" >
Version: 1.2.0
</option>
<option value="/v1_1_0/os/introduction" >
Version: 1.1.0
</option>
<option value="/v1_0_0/os/introduction" >
Version: 1.0.0
</option>
<option value="/v0_9_0/os/introduction" >
Version: 0.9.0
</option>
</select>
<div class="region region-sidebar">
<div class="docs-menu">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index.html">Introduction</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Setup &amp; Get Started</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="native_install/index.html">Native Installation</a></li>
<li class="toctree-l2"><a class="reference internal" href="docker.html">Docker Container</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Create Your First Project</a></li>
<li class="toctree-l2"><a class="reference internal" href="serial_access.html">Serial Port Setup</a></li>
<li class="toctree-l2"><a class="reference internal" href="debug.html">Debugging Mynewt</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../concepts.html">Concepts</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorials/tutorials.html">Tutorials</a></li>
<li class="toctree-l1"><a class="reference internal" href="../external_links.html">Third-party Resources</a></li>
<li class="toctree-l1"><a class="reference internal" href="../os/os_user_guide.html">OS User Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../network/index.html">BLE User Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../newt/index.html">Newt Tool Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../newtmgr/index.html">Newt Manager Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../mynewt_faq/index.html">Mynewt FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="../misc/index.html">Appendix</a></li>
</ul>
</div>
</div>
</div>
<!-- ENDS STICKY CONTAINER -->
</div>
<!-- ENDS .container-sidebar -->
<div class="col-xs-12 col-sm-9">
<div class="alert alert-warning">
<p>
Version 1.8.0 is not the most recent version of the
Apache Mynewt documentation. Click <a href="/latest">here</a> to
read the latest version.
</p>
</div>
<div class="">
<div class="rst-content">
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="creating-your-first-mynewt-project">
<h1>Creating Your First Mynewt Project<a class="headerlink" href="#creating-your-first-mynewt-project" title="Permalink to this headline"></a></h1>
<p>This page shows you how to create a Mynewt project using the <code class="docutils literal notranslate"><span class="pre">newt</span></code>
command-line tool. The project is a blinky application that toggles a
pin. The application uses the Mynewt’s simulated hardware and runs as a
native application on Linux, FreeBSD and older versions of Mac OS.</p>
<p><strong>Note:</strong> The Mynewt simulator is not yet supported natively on Windows or
newer Mac OS versions.</p>
<p>If you are using the native install option (not the Docker option), you will
need to create the blinky application for a target board. We recommend that
you read the section on creating a new project and fetching the source
repository to understand the Mynewt repository structure, create a new
project, and fetch the source dependencies before proceeding to
one of the <a class="reference internal" href="../tutorials/blinky/blinky.html#blinky-tutorials"><span class="std std-ref">Project Blinky</span></a>.</p>
<p>This guide shows you how to:</p>
<ol class="arabic simple">
<li><p>Create a new project and fetch the source repository and
dependencies.</p></li>
<li><p>Test the project packages. (Using Docker image for Windows and MacOS.)</p></li>
<li><p>Build and run the simulated blinky application.</p></li>
</ol>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#prerequisites" id="id1">Prerequisites</a></p></li>
<li><p><a class="reference internal" href="#creating-a-new-project-and-fetching-the-source-repository" id="id2">Creating a New Project and Fetching the Source Repository</a></p>
<ul>
<li><p><a class="reference internal" href="#creating-a-new-project" id="id3">Creating a New Project</a></p></li>
<li><p><a class="reference internal" href="#fetching-the-mynewt-source-repository-and-dependencies" id="id4">Fetching the Mynewt Source Repository and Dependencies</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#testing-the-project-packages" id="id5">Testing the Project Packages</a></p></li>
<li><p><a class="reference internal" href="#building-and-running-the-simulated-blinky-application" id="id6">Building and Running the Simulated Blinky Application</a></p>
<ul>
<li><p><a class="reference internal" href="#building-the-application" id="id7">Building the Application</a></p></li>
<li><p><a class="reference internal" href="#running-the-blinky-application" id="id8">Running the Blinky Application</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#exploring-other-mynewt-os-features" id="id9">Exploring other Mynewt OS Features</a></p></li>
</ul>
</div>
<div class="section" id="prerequisites">
<h2><a class="toc-backref" href="#id1">Prerequisites</a><a class="headerlink" href="#prerequisites" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li><p>Have Internet connectivity to fetch remote Mynewt components.</p></li>
<li><p>Install the newt tool:</p>
<ul>
<li><p>If you have taken the native install option, see the installation
instructions for <a class="reference internal" href="../newt/install/newt_mac.html"><span class="doc">Mac OS</span></a>,
<a class="reference internal" href="../newt/install/newt_linux.html"><span class="doc">Linux</span></a>, or
<a class="reference internal" href="../newt/install/newt_windows.html"><span class="doc">Windows</span></a>.</p></li>
<li><p>If you have taken the Docker option, you have already installed
Newt.</p></li>
</ul>
</li>
<li><p>Install the <a class="reference internal" href="native_install/native_tools.html"><span class="doc">native toolchain</span></a> to compile and
build a Mynewt native application.</p></li>
</ul>
</div>
<div class="section" id="creating-a-new-project-and-fetching-the-source-repository">
<h2><a class="toc-backref" href="#id2">Creating a New Project and Fetching the Source Repository</a><a class="headerlink" href="#creating-a-new-project-and-fetching-the-source-repository" title="Permalink to this headline"></a></h2>
<p>This section describes how to use the newt tool to create a new project
and fetch the core mynewt source repository.</p>
<div class="section" id="creating-a-new-project">
<h3><a class="toc-backref" href="#id3">Creating a New Project</a><a class="headerlink" href="#creating-a-new-project" title="Permalink to this headline"></a></h3>
<p>Choose a name for your project. We name the project <code class="docutils literal notranslate"><span class="pre">myproj</span></code>.</p>
<p>Run the <code class="docutils literal notranslate"><span class="pre">newt</span> <span class="pre">new</span> <span class="pre">myproj</span></code> command, from your <strong>dev</strong> directory, to
create a new project:</p>
<p><strong>Note:</strong> This tutorial assumes you created a <strong>dev</strong> directory under
your home directory.</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span><span class="nb">cd</span><span class="w"> </span>~/dev
<span class="gp">$ </span>newt<span class="w"> </span>new<span class="w"> </span>myproj
<span class="go">Downloading project skeleton from apache/mynewt-blinky...</span>
<span class="go">Downloading repository mynewt-blinky (commit: master) ...</span>
<span class="go">Installing skeleton in myproj...</span>
<span class="go">Project myproj successfully created.</span>
</pre></div>
</div>
<p>The newt tool creates a project base directory name <strong>myproj</strong>. All newt
tool commands are run from the project base directory. The newt tool
populates this new project with a base skeleton of a new Apache Mynewt
project in the project base directory. It has the following structure:</p>
<p><strong>Note</strong>: If you do not have <code class="docutils literal notranslate"><span class="pre">tree</span></code>, run <code class="docutils literal notranslate"><span class="pre">brew</span> <span class="pre">install</span> <span class="pre">tree</span></code> to
install on Mac OS, <code class="docutils literal notranslate"><span class="pre">sudo</span> <span class="pre">apt-get</span> <span class="pre">install</span> <span class="pre">tree</span></code> to install on Linux,
<code class="docutils literal notranslate"><span class="pre">pacman</span> <span class="pre">-Su</span> <span class="pre">tree</span></code> from a MinGW terminal to install on Windows, and
<code class="docutils literal notranslate"><span class="pre">pkg</span> <span class="pre">install</span> <span class="pre">tree</span></code> on FreeBSD.</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span><span class="nb">cd</span><span class="w"> </span>myproj
<span class="gp">$ </span>tree
<span class="go">.</span>
<span class="go">├── DISCLAIMER</span>
<span class="go">├── LICENSE</span>
<span class="go">├── NOTICE</span>
<span class="go">├── README.md</span>
<span class="go">├── apps</span>
<span class="go">│   └── blinky</span>
<span class="go">│   ├── pkg.yml</span>
<span class="go">│   └── src</span>
<span class="go">│   └── main.c</span>
<span class="go">├── project.yml</span>
<span class="go">└── targets</span>
<span class="go"> ├── my_blinky_sim</span>
<span class="go"> │   ├── pkg.yml</span>
<span class="go"> │   └── target.yml</span>
<span class="go"> └── unittest</span>
<span class="go"> ├── pkg.yml</span>
<span class="go"> └── target.yml</span>
<span class="go">6 directories, 11 files</span>
</pre></div>
</div>
<p>The newt tool installs the following files for a project in the project
base directory:</p>
<ol class="arabic simple">
<li><p>The file <code class="docutils literal notranslate"><span class="pre">project.yml</span></code> contains the repository list that the
project uses to fetch its packages. Your project is a collection of
repositories. In this case, the project only comprises the core
mynewt repository. Later, you will add more repositories to include
other mynewt components.</p></li>
<li><p>The file <code class="docutils literal notranslate"><span class="pre">apps/blinky/pkg.yml</span></code> contains the description of your
application and its package dependencies.</p></li>
<li><p>A <code class="docutils literal notranslate"><span class="pre">target</span></code> directory that contains the <code class="docutils literal notranslate"><span class="pre">my_blinky_sim</span></code> directory.
The <code class="docutils literal notranslate"><span class="pre">my_blinky_sim</span></code> directory a target information to build a
version of myproj. Use <code class="docutils literal notranslate"><span class="pre">newt</span> <span class="pre">target</span> <span class="pre">show</span></code> to see available build
targets.</p></li>
<li><p>A non-buildable target called <code class="docutils literal notranslate"><span class="pre">unittest</span></code>. This is used internally
by <code class="docutils literal notranslate"><span class="pre">newt</span></code> and is not a formal build target.</p></li>
</ol>
<p><strong>Note:</strong> The actual code and package files are not installed (except
the template for <code class="docutils literal notranslate"><span class="pre">main.c</span></code>). See the next step to install the packages.</p>
</div>
<div class="section" id="fetching-the-mynewt-source-repository-and-dependencies">
<h3><a class="toc-backref" href="#id4">Fetching the Mynewt Source Repository and Dependencies</a><a class="headerlink" href="#fetching-the-mynewt-source-repository-and-dependencies" title="Permalink to this headline"></a></h3>
<p>By default, Mynewt projects rely on a single repository:
<strong>apache-mynewt-core</strong> and uses the source in the master branch. If you
need to use a different branch, you need to change the <code class="docutils literal notranslate"><span class="pre">vers</span></code> value in
the project.yml file:</p>
<div class="highlight-yaml notranslate"><div class="highlight"><pre><span></span><span class="nt">repository.apache-mynewt-core</span><span class="p">:</span>
<span class="w"> </span><span class="nt">type</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">github</span>
<span class="hll"><span class="w"> </span><span class="nt">vers</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">1-latest</span>
</span><span class="w"> </span><span class="nt">user</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">apache</span>
<span class="w"> </span><span class="nt">repo</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">mynewt-core</span>
</pre></div>
</div>
<p>Changing vers to 0-dev will put you on the latest master branch. <strong>This
branch may not be stable and you may encounter bugs or other problems.</strong></p>
<p>Run the <code class="docutils literal notranslate"><span class="pre">newt</span> <span class="pre">upgrade</span></code> command, from your project base directory
(myproj), to fetch the source repository and dependencies.</p>
<p><strong>Note:</strong> It may take a while to download the apache-mynewt-core
repository. Use the <em>-v</em> (verbose) option to see the installation
progress.</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>newt<span class="w"> </span>upgrade
<span class="go">Downloading repository mynewt-core (commit: master) ...</span>
<span class="go">Downloading repository mynewt-mcumgr (commit: master) ...</span>
<span class="go">Downloading repository mynewt-nimble (commit: master) ...</span>
<span class="go">Downloading repository mcuboot (commit: master) from ...</span>
<span class="go">Making the following changes to the project:</span>
<span class="go">apache-mynewt-core successfully upgraded to version 1.7.0</span>
<span class="go">apache-mynewt-nimble successfully upgraded to version 1.2.0</span>
<span class="go">mcuboot successfully upgraded to version 1.3.1</span>
</pre></div>
</div>
<p>View the core of the Apache Mynewt OS that is downloaded into your local
directory.</p>
<p>(The actual output will depend on what is in the latest ‘master’ branch)</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>repos/apache-mynewt-core/
<span class="go">├── apps</span>
<span class="go">│   ├── bleprph_oic</span>
<span class="go">│   ├── blesplit</span>
<span class="go">│   ├── bleuart</span>
<span class="go">│   ├── bsncent</span>
<span class="go">│   ├── bsnprph</span>
<span class="go">│   ├── bus_test</span>
<span class="go">│   ├── coremark</span>
<span class="go">│   ├── crypto_test</span>
<span class="go">│   ├── ffs2native</span>
<span class="go">│   ├── flash_loader</span>
<span class="go">│   ├── iptest</span>
<span class="go">│   ├── lora_app_shell</span>
<span class="go">│   ├── loraping</span>
<span class="go">│   ├── lorashell</span>
<span class="go">│   ├── metrics</span>
<span class="go">│   ├── ocf_sample</span>
<span class="go">│   ├── pwm_test</span>
<span class="go">│   ├── sensors_test</span>
<span class="go">│   ├── slinky</span>
<span class="go">│   ├── slinky_oic</span>
<span class="go">│   ├── spitest</span>
<span class="go">│   ├── splitty</span>
<span class="go">│   ├── testbench</span>
<span class="go">│   ├── timtest</span>
<span class="go">│   └── trng_test</span>
<span class="go">├── boot</span>
<span class="go">│   ├── split</span>
<span class="go">│   └── split_app</span>
<span class="go">├── CODING_STANDARDS.md</span>
<span class="go">├── compiler</span>
<span class="go">│   ├── arc</span>
<span class="go">│   ├── arm-none-eabi-m0</span>
<span class="go">│   ├── arm-none-eabi-m3</span>
<span class="go">│   ├── arm-none-eabi-m33</span>
<span class="go">│   ├── arm-none-eabi-m4</span>
<span class="go">│   ├── arm-none-eabi-m7</span>
<span class="go">│   ├── gdbmacros</span>
<span class="go">│   ├── mips</span>
<span class="go">│   ├── riscv64</span>
<span class="go">│   ├── sim</span>
<span class="go">│   ├── sim-armv7</span>
<span class="go">│   ├── sim-mips</span>
<span class="go">│   └── xc32</span>
<span class="go">├── crypto</span>
<span class="go">│   ├── mbedtls</span>
<span class="go">│   └── tinycrypt</span>
<span class="go">├── docs</span>
<span class="go">│   ├── conf.py</span>
<span class="go">│   ├── doxygen.xml</span>
<span class="go">│   ├── index.rst</span>
<span class="go">│   ├── Makefile</span>
<span class="go">│   ├── os</span>
<span class="go">│   └── README.rst</span>
<span class="go">├── encoding</span>
<span class="go">│   ├── base64</span>
<span class="go">│   ├── cborattr</span>
<span class="go">│   ├── json</span>
<span class="go">│   └── tinycbor</span>
<span class="go">├── fs</span>
<span class="go">│   ├── disk</span>
<span class="go">│   ├── fatfs</span>
<span class="go">│   ├── fcb</span>
<span class="go">│   ├── fcb2</span>
<span class="go">│   ├── fs</span>
<span class="go">│   └── nffs</span>
<span class="go">├── hw</span>
<span class="go">│   ├── battery</span>
<span class="go">│   ├── bsp</span>
<span class="go">│   ├── bus</span>
<span class="go">│   ├── charge-control</span>
<span class="go">│   ├── cmsis-core</span>
<span class="go">│   ├── drivers</span>
<span class="go">│   ├── hal</span>
<span class="go">│   ├── mcu</span>
<span class="go">│   ├── mips-hal</span>
<span class="go">│   ├── scripts</span>
<span class="go">│   ├── sensor</span>
<span class="go">│   └── util</span>
<span class="go">├── kernel</span>
<span class="go">│   ├── os</span>
<span class="go">│   └── sim</span>
<span class="go">├── libc</span>
<span class="go">│   └── baselibc</span>
<span class="go">├── LICENSE</span>
<span class="go">├── mgmt</span>
<span class="go">│   ├── imgmgr</span>
<span class="go">│   ├── mgmt</span>
<span class="go">│   ├── newtmgr</span>
<span class="go">│   └── oicmgr</span>
<span class="go">├── net</span>
<span class="go">│   ├── ip</span>
<span class="go">│   ├── lora</span>
<span class="go">│   ├── mqtt</span>
<span class="go">│   ├── oic</span>
<span class="go">│   └── wifi</span>
<span class="go">├── NOTICE</span>
<span class="go">├── project.yml</span>
<span class="go">├── README.md</span>
<span class="go">├── RELEASE_NOTES.md</span>
<span class="go">├── repository.yml</span>
<span class="go">├── sys</span>
<span class="go">│   ├── config</span>
<span class="go">│   ├── console</span>
<span class="go">│   ├── coredump</span>
<span class="go">│   ├── defs</span>
<span class="go">│   ├── fault</span>
<span class="go">│   ├── flash_map</span>
<span class="go">│   ├── id</span>
<span class="go">│   ├── log</span>
<span class="go">│   ├── metrics</span>
<span class="go">│   ├── mfg</span>
<span class="go">│   ├── reboot</span>
<span class="go">│   ├── shell</span>
<span class="go">│   ├── stats</span>
<span class="go">│   ├── sys</span>
<span class="go">│   ├── sysdown</span>
<span class="go">│   ├── sysinit</span>
<span class="go">│   └── sysview</span>
<span class="go">├── targets</span>
<span class="go">│   └── unittest</span>
<span class="go">├── test</span>
<span class="go">│   ├── crash_test</span>
<span class="go">│   ├── flash_test</span>
<span class="go">│   ├── i2c_scan</span>
<span class="go">│   ├── runtest</span>
<span class="go">│   ├── spiflash_stress_test</span>
<span class="go">│   └── testutil</span>
<span class="go">├── time</span>
<span class="go">│   ├── datetime</span>
<span class="go">│   ├── timepersist</span>
<span class="go">│   └── timesched</span>
<span class="go">├── uncrustify.cfg</span>
<span class="go">├── util</span>
<span class="go">│   ├── cbmem</span>
<span class="go">│   ├── cmdarg</span>
<span class="go">│   ├── crc</span>
<span class="go">│   ├── debounce</span>
<span class="go">│   ├── easing</span>
<span class="go">│   ├── mem</span>
<span class="go">│   ├── parse</span>
<span class="go">│   ├── rwlock</span>
<span class="go">│   ├── streamer</span>
<span class="go">│   └── taskpool</span>
<span class="go">└── version.yml</span>
<span class="go">131 directories, 14 files</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="testing-the-project-packages">
<h2><a class="toc-backref" href="#id5">Testing the Project Packages</a><a class="headerlink" href="#testing-the-project-packages" title="Permalink to this headline"></a></h2>
<p><strong>Note:</strong> If you’re running this with Docker, use <code class="docutils literal notranslate"><span class="pre">newt</span></code> wrapper
script as described in <a class="reference internal" href="docker.html"><span class="doc">Docker Container</span></a>. Unit tests
depend on Mynewt simulator.</p>
<p>You can use the newt tool to execute the unit tests in a package. For
example, run the following command to test the <code class="docutils literal notranslate"><span class="pre">sys/config</span></code> package in
the <code class="docutils literal notranslate"><span class="pre">apache-mynewt-core</span></code> repo:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>newt<span class="w"> </span><span class="nb">test</span><span class="w"> </span>@apache-mynewt-core/sys/config
<span class="go">Testing package @apache-mynewt-core/sys/config/selftest-fcb</span>
<span class="go">Compiling repos/apache-mynewt-core/crypto/tinycrypt/src/aes_decrypt.c</span>
<span class="go">Compiling repos/apache-mynewt-core/crypto/tinycrypt/src/aes_encrypt.c</span>
<span class="go">Compiling repos/apache-mynewt-core/crypto/tinycrypt/src/cbc_mode.c</span>
<span class="go">Compiling repos/apache-mynewt-core/crypto/tinycrypt/src/ccm_mode.c</span>
<span class="go">Compiling repos/apache-mynewt-core/crypto/tinycrypt/src/cmac_mode.c</span>
<span class="go">...</span>
<span class="go">Linking ~/dev/myproj/bin/targets/unittest/sys_config_selftest-fcb/app/sys/config/selftest-fcb/sys_config_selftest-fcb.elf</span>
<span class="go">Executing test: ~/dev/myproj/bin/targets/unittest/sys_config_selftest-fcb/app/sys/config/selftest-fcb/sys_config_selftest-fcb.elf</span>
<span class="go">Testing package @apache-mynewt-core/sys/config/selftest-nffs</span>
<span class="go">Compiling repos/apache-mynewt-core/encoding/base64/src/hex.c</span>
<span class="go">Compiling repos/apache-mynewt-core/fs/fs/src/fs_cli.c</span>
<span class="go">Compiling repos/apache-mynewt-core/fs/fs/src/fs_dirent.c</span>
<span class="go">Compiling repos/apache-mynewt-core/fs/fs/src/fs_mkdir.c</span>
<span class="go">Compiling repos/apache-mynewt-core/fs/fs/src/fs_mount.c</span>
<span class="go">Compiling repos/apache-mynewt-core/encoding/base64/src/base64.c</span>
<span class="go">Compiling repos/apache-mynewt-core/fs/fs/src/fs_file.c</span>
<span class="go">Compiling repos/apache-mynewt-core/fs/disk/src/disk.c</span>
<span class="go">Compiling repos/apache-mynewt-core/fs/fs/src/fs_nmgr.c</span>
<span class="go">Compiling repos/apache-mynewt-core/fs/fs/src/fsutil.c</span>
<span class="go">Compiling repos/apache-mynewt-core/fs/nffs/src/nffs.c</span>
<span class="go">...</span>
<span class="go">Linking ~/dev/myproj/bin/targets/unittest/sys_config_selftest-nffs/app/sys/config/selftest-nffs/sys_config_selftest-nffs.elf</span>
<span class="go">Executing test: ~/dev/myproj/bin/targets/unittest/sys_config_selftest-nffs/app/sys/config/selftest-nffs/sys_config_selftest-nffs.elf</span>
<span class="go">Passed tests: [sys/config/selftest-fcb sys/config/selftest-nffs]</span>
<span class="go">All tests passed</span>
</pre></div>
</div>
<p><strong>Note:</strong> If you installed the latest gcc using homebrew on your Mac,
you are probably running gcc-6. Make sure you change the compiler.yml
configuration to specify that you are using gcc-6 (See <a class="reference internal" href="native_install/native_tools.html"><span class="doc">Installing Native Toolchain</span></a>). You can also
downgrade your installation to gcc-5 and use the default gcc compiler configuration for MyNewt:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>brew<span class="w"> </span>uninstall<span class="w"> </span>gcc-6
<span class="gp">$ </span>brew<span class="w"> </span>link<span class="w"> </span>gcc-5
</pre></div>
</div>
<p><strong>Note:</strong> If you are running the standard gcc for 64-bit machines, it
does not support 32-bit. In that case you will see compilation errors.
You need to install multilib gcc (e.g. gcc-multilib if you running on a
64-bit Ubuntu).
<strong>Note:</strong> Running <code class="docutils literal notranslate"><span class="pre">newt</span> <span class="pre">test</span> <span class="pre">all</span></code> within Docker Container can take
a long time.</p>
<p>To test all the packages in a project, specify <code class="docutils literal notranslate"><span class="pre">all</span></code> instead of the
package name.</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>newt<span class="w"> </span><span class="nb">test</span><span class="w"> </span>all
<span class="go">Testing package @apache-mynewt-core/crypto/mbedtls/selftest</span>
<span class="go">Compiling repos/apache-mynewt-core/crypto/mbedtls/src/aesni.c</span>
<span class="go">Compiling repos/apache-mynewt-core/crypto/mbedtls/src/aria.c</span>
<span class="go">Compiling repos/apache-mynewt-core/crypto/mbedtls/src/arc4.c</span>
<span class="go">Compiling repos/apache-mynewt-core/crypto/mbedtls/src/aes.c</span>
<span class="go">...</span>
<span class="go">Linking ~/dev/myproj/bin/targets/unittest/crypto_mbedtls_selftest/app/@apache-mynewt-core/crypto/mbedtls/selftest/@apache-mynewt-core_crypto_mbedtls_selftest.elf</span>
<span class="go">Executing test: ~/dev/myproj/bin/targets/unittest/crypto_mbedtls_selftest/app/@apache-mynewt-core/crypto/mbedtls/selftest/@apache-mynewt-core_crypto_mbedtls_selftest.elf</span>
<span class="go">...lots of compiling and testing...</span>
<span class="go">Linking ~/dev/myproj/bin/targets/unittest/boot_boot_serial_test/app/@mcuboot/boot/boot_serial/test/@mcuboot_boot_boot_serial_test.elf</span>
<span class="go">Executing test: ~/dev/myproj/bin/targets/unittest/boot_boot_serial_test/app/@mcuboot/boot/boot_serial/test/@mcuboot_boot_boot_serial_test.elf</span>
<span class="go">Passed tests: [crypto/mbedtls/selftest encoding/base64/selftest encoding/cborattr/selftest encoding/json/selftest fs/fcb/selftest fs/fcb2/selftest fs/nffs/selftest hw/drivers/flash/enc_flash/selftest hw/drivers/trng/trng_sw/selftest hw/sensor/selftest kernel/os/selftest net/ip/mn_socket/selftest net/oic/selftest sys/config/selftest-fcb sys/config/selftest-nffs sys/flash_map/selftest sys/log/full/selftest/align1 sys/log/full/selftest/align2 sys/log/full/selftest/align4 sys/log/full/selftest/align8 sys/log/full/selftest/fcb_bookmarks sys/log/modlog/selftest util/cbmem/selftest util/debounce/selftest util/rwlock/selftest cborattr/test nimble/controller/test nimble/host/test boot/boot_serial/test]</span>
<span class="go">All tests passed</span>
</pre></div>
</div>
</div>
<div class="section" id="building-and-running-the-simulated-blinky-application">
<h2><a class="toc-backref" href="#id6">Building and Running the Simulated Blinky Application</a><a class="headerlink" href="#building-and-running-the-simulated-blinky-application" title="Permalink to this headline"></a></h2>
<p>The section shows you how to build and run the blinky application to run
on Mynewt’s simulated hardware.</p>
<p><strong>Note</strong>: This is not yet supported on Windows or newer versions of MacOS. Refer to the <a class="reference internal" href="../tutorials/blinky/blinky.html#blinky-tutorials"><span class="std std-ref">Project Blinky</span></a> to create a blinky application for a target board, or run the the application within Docker Container.</p>
<div class="section" id="building-the-application">
<h3><a class="toc-backref" href="#id7">Building the Application</a><a class="headerlink" href="#building-the-application" title="Permalink to this headline"></a></h3>
<p>To build the simulated blinky application, run <code class="docutils literal notranslate"><span class="pre">newt</span> <span class="pre">build</span> <span class="pre">my_blinky_sim</span></code>:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>newt<span class="w"> </span>build<span class="w"> </span>my_blinky_sim
<span class="go">Building target targets/my_blinky_sim</span>
<span class="go">Compiling repos/apache-mynewt-core/hw/hal/src/hal_common.c</span>
<span class="go">Compiling repos/apache-mynewt-core/hw/drivers/uart/src/uart.c</span>
<span class="go">Compiling repos/apache-mynewt-core/hw/hal/src/hal_flash.c</span>
<span class="go">Compiling repos/apache-mynewt-core/hw/bsp/native/src/hal_bsp.c</span>
<span class="go">Compiling repos/apache-mynewt-core/hw/drivers/uart/uart_hal/src/uart_hal.c</span>
<span class="go">Compiling apps/blinky/src/main.c</span>
<span class="go">...</span>
<span class="go">Archiving sys_mfg.a</span>
<span class="go">Archiving sys_sysinit.a</span>
<span class="go">Archiving util_mem.a</span>
<span class="go">Linking ~/dev/myproj/bin/targets/my_blinky_sim/app/apps/blinky/blinky.elf</span>
<span class="go">Target successfully built: targets/my_blinky_sim</span>
</pre></div>
</div>
</div>
<div class="section" id="running-the-blinky-application">
<h3><a class="toc-backref" href="#id8">Running the Blinky Application</a><a class="headerlink" href="#running-the-blinky-application" title="Permalink to this headline"></a></h3>
<p>You can run the simulated version of your project and see the simulated
LED blink.</p>
<p>If you natively install the toolchain execute the binary directly:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>./bin/targets/my_blinky_sim/app/apps/blinky/blinky.elf
<span class="go">hal_gpio set pin 1 to 0</span>
</pre></div>
</div>
<p>If you are using newt docker, use <code class="docutils literal notranslate"><span class="pre">newt</span> <span class="pre">run</span></code> to run the simulated binary.
Remember to use the <code class="docutils literal notranslate"><span class="pre">newt</span></code> wrapper script when doing that.</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>newt<span class="w"> </span>run<span class="w"> </span>my_blinky_sim
<span class="go">Loading app image into slot 1</span>
<span class="go"> ...</span>
<span class="go">Debugging ~/dev/myproj/bin/targets/my_blinky_sim/app/apps/blinky/blinky.elf</span>
<span class="go"> ...</span>
<span class="go">Reading symbols from /bin/targets/my_blinky_sim/app/apps/blinky/blinky.elf...done.</span>
<span class="gp gp-VirtualEnv">(gdb)</span>
</pre></div>
</div>
<p>Type <code class="docutils literal notranslate"><span class="pre">r</span></code> at the <code class="docutils literal notranslate"><span class="pre">(gdb)</span></code> prompt to run the project. You will see an
output indicating that the <code class="docutils literal notranslate"><span class="pre">hal_gpio</span></code> pin is toggling between 1 and 0
in a simulated blink.</p>
</div>
</div>
<div class="section" id="exploring-other-mynewt-os-features">
<h2><a class="toc-backref" href="#id9">Exploring other Mynewt OS Features</a><a class="headerlink" href="#exploring-other-mynewt-os-features" title="Permalink to this headline"></a></h2>
<p>Congratulations, you have created your first project! The blinky
application is not terribly exciting when it is run in the simulator, as
there is no LED to blink. Apache Mynewt has a lot more functionality
than just running simulated applications. It provides all the features
you’ll need to cross-compile your application, run it on real hardware
and develop a full featured application.</p>
<p>If you’re interested in learning more, a good next step is to dig in to
one of the <a class="reference internal" href="../tutorials/tutorials.html#tutorials"><span class="std std-ref">Tutorials</span></a> and get a Mynewt
project running on real hardware.</p>
<p>Happy Hacking!</p>
</div>
</div>
</div>
</div>
<div class="rst-footer-buttons row" role="navigation" aria-label="footer navigation">
<a href="serial_access.html" class="btn btn-neutral float-right" title="Using the Serial Port with Mynewt OS" accesskey="n">Next: Using the Serial Port with Mynewt OS <span class="fa fa-arrow-circle-right"></span></a>
<a href="docker.html" class="btn btn-neutral" title="Everything You Need in a Docker Container" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous: Everything You Need in a Docker Container</a>
</div>
</div>
</div>
</div>
<!-- ENDS CONTENT SECTION -->
</div>
<!-- ENDS .content -->
</div>
</div>
<footer>
<div class="container">
<div class="row">
<div class="col-xs-12">
<p class="copyright">Apache Mynewt is available under Apache License, version 2.0.</p>
</div>
<div class="col-xs-12">
<div class="logos">
<img src="../_static/img/asf_logo_wide_small.png" alt="Apache" title="Apache">
<small class="footnote">
Apache Mynewt, Mynewt, Apache, the Apache feather logo, and the Apache Mynewt project logo are either
registered trademarks or trademarks of the Apache Software Foundation in the United States and other countries.
</small>
<a href="">
<img src="../_static/img/add_to_slack.png" alt="Slack Icon" title="Join our Slack Community" />
</a>
</div>
</div>
</div>
</div>
</footer>
</div>
<!-- ENDS #wrapper -->
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../',
VERSION:'latest',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt',
LINK_SUFFIX: '.html'
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="../_static/js/bootstrap-3.0.3.min.js"></script>
<script type="text/javascript" src="../_static/js/affix.js"></script>
<script type="text/javascript" src="../_static/js/main.js"></script>
</body>
</html>