blob: 17dd4c58992460b47fcb1d4ed9218e33bb08ab14 [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>Theory of Operations &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="Newt Tool Guide" href="index.html"/>
<link rel="next" title="Command Structure" href="newt_ops.html"/>
<link rel="prev" title="Newt Tool Guide" href="index.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">Newt Tool Guide</a> /
Theory of Operations
<div class="sourcelink">
<a href="https://github.com/apache/mynewt-newt/edit/master/docs/newt_operation.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" >
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"><a class="reference internal" href="../get_started/index.html">Setup &amp; Get Started</a></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 current"><a class="reference internal" href="index.html">Newt Tool Guide</a><ul class="current">
<li class="toctree-l2 current"><a class="current reference internal" href="#">Theory of Operations</a></li>
<li class="toctree-l2"><a class="reference internal" href="newt_ops.html">Command Structure</a></li>
<li class="toctree-l2"><a class="reference internal" href="install/index.html">Install</a></li>
</ul>
</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="">
<div class="rst-content">
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="theory-of-operations">
<h1>Theory of Operations<a class="headerlink" href="#theory-of-operations" title="Permalink to this headline"></a></h1>
<p>Newt has a fairly smart package manager that can read a directory tree,
build a dependency tree, and emit the right build artifacts.</p>
<div class="section" id="building-dependencies">
<h2>Building dependencies<a class="headerlink" href="#building-dependencies" title="Permalink to this headline"></a></h2>
<p>Newt can read a directory tree, build a dependency tree, and emit the
right build artifacts. An example newt source tree is in
mynewt-blinky/develop:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>tree<span class="w"> </span>-L<span class="w"> </span><span class="m">3</span>
<span class="go">.</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">├── 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, 9 files</span>
</pre></div>
</div>
<p>When newt sees a directory tree that contains a “project.yml” file it knows that it is in the base directory of a project,
and automatically builds a package tree. You can see that there are two essential package directories, “apps” and “targets.”</p>
<div class="section" id="apps-package-directory">
<h3>“apps” Package Directory<a class="headerlink" href="#apps-package-directory" title="Permalink to this headline"></a></h3>
<p><code class="docutils literal notranslate"><span class="pre">apps</span></code> is where applications are stored, and applications are where the main() function is contained. The base project
directory comes with one simple app called <code class="docutils literal notranslate"><span class="pre">blinky</span></code> in the <code class="docutils literal notranslate"><span class="pre">apps</span></code> directory. The core repository <code class="docutils literal notranslate"><span class="pre">&#64;apache-mynewt-core</span></code>
comes with many additional sample apps in its <code class="docutils literal notranslate"><span class="pre">apps</span></code> directory. At the time of this writing, there are several example BLE
apps, the boot app, slinky app for using newt manager protocol, and more in that directory.</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>ls<span class="w"> </span>repos/apache-mynewt-core/apps
<span class="go">blecent blehr blemesh_shell blesplit boot btshell lora_app_shell ocf_sample slinky splitty trng_test</span>
<span class="go">blecsc blemesh bleprph bletest bsncent ffs2native loraping pwm_test slinky_oic testbench</span>
<span class="go">blehci blemesh_light bleprph_oic bleuart bsnprph iptest lorashell sensors_test spitest timtest</span>
</pre></div>
</div>
<p>Along with the <code class="docutils literal notranslate"><span class="pre">targets</span></code> directory, <code class="docutils literal notranslate"><span class="pre">apps</span></code> represents the top-level of the build tree for the particular project, and
define the dependencies for the rest of the system. Mynewt users and developers can add their own apps to the project’s <code class="docutils literal notranslate"><span class="pre">apps</span></code> directory.</p>
<p>The app definition is contained in a <code class="docutils literal notranslate"><span class="pre">pkg.yml</span></code> file. For example, blinky’s <code class="docutils literal notranslate"><span class="pre">pkg.yml</span></code> file is:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>more<span class="w"> </span>apps/blinky/pkg.yml
<span class="go">pkg.name: apps/blinky</span>
<span class="go">pkg.type: app</span>
<span class="go">pkg.description: Basic example application which blinks an LED.</span>
<span class="go">pkg.author: &quot;Apache Mynewt &lt;dev@mynewt.apache.org&gt;&quot;</span>
<span class="go">pkg.homepage: &quot;http://mynewt.apache.org/&quot;</span>
<span class="go">pkg.keywords:</span>
<span class="go">pkg.deps:</span>
<span class="go"> - &quot;@apache-mynewt-core/kernel/os&quot;</span>
<span class="go"> - &quot;@apache-mynewt-core/hw/hal&quot;</span>
<span class="go"> - &quot;@apache-mynewt-core/sys/console/stub&quot;</span>
</pre></div>
</div>
<p>This file says that the name of the package is apps/blinky, and it depends on the <code class="docutils literal notranslate"><span class="pre">kernel/os</span></code>, <code class="docutils literal notranslate"><span class="pre">hw/hal</span></code> and <code class="docutils literal notranslate"><span class="pre">sys/console/stub</span></code> packages.</p>
<p><strong>NOTE:</strong> &#64;apache-mynewt-core is a repository descriptor, and this will be
covered in the “repository” section.</p>
</div>
<div class="section" id="targets-package-directory">
<h3>“targets” Package Directory<a class="headerlink" href="#targets-package-directory" title="Permalink to this headline"></a></h3>
<p><code class="docutils literal notranslate"><span class="pre">targets</span></code> is where targets are stored, and each target is a collection of parameters that must be passed to newt in
order to generate a reproducible build. Along with the <code class="docutils literal notranslate"><span class="pre">apps</span></code> directory, <code class="docutils literal notranslate"><span class="pre">targets</span></code> represents the top of the build
tree. Any packages or parameters specified at the target level cascades down to all dependencies.</p>
<p>Most targets consist of:</p>
<ul class="simple">
<li><p>app: The application to build</p></li>
<li><p>bsp: The board support package to combine with that application</p></li>
<li><p>build_profile: Either debug or optimized.</p></li>
</ul>
<p>The <code class="docutils literal notranslate"><span class="pre">my_blinky_sim</span></code> target that is included by default has the following settings:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>newt<span class="w"> </span>target<span class="w"> </span>show
<span class="go">targets/my_blinky_sim</span>
<span class="go"> app=apps/blinky</span>
<span class="go"> bsp=@apache-mynewt-core/hw/bsp/native</span>
<span class="go"> build_profile=debug</span>
<span class="gp">$ </span>ls<span class="w"> </span>targets/my_blinky_sim/
<span class="go">pkg.yml target.yml</span>
</pre></div>
</div>
<p>There are helper functions to aid the developer specify parameters for a target.</p>
<ul class="simple">
<li><p><strong>vals</strong>: Displays all valid values for the specified parameter type (e.g. bsp for a target)</p></li>
<li><p><strong>target show</strong>: Displays the variable values for either a specific target or all targets defined for the project</p></li>
<li><p><strong>target set</strong>: Sets values for target variables</p></li>
</ul>
<p>In general, the three basic parameters of a target (<code class="docutils literal notranslate"><span class="pre">app</span></code>, <code class="docutils literal notranslate"><span class="pre">bsp</span></code>, and <code class="docutils literal notranslate"><span class="pre">build_profile</span></code>) are stored in the
target’s <code class="docutils literal notranslate"><span class="pre">target.yml</span></code> file in the targets/&lt;target-name&gt; directory, where <code class="docutils literal notranslate"><span class="pre">target-name</span></code> is the name of the target. You
will also see a <code class="docutils literal notranslate"><span class="pre">pkg.yml</span></code> file in the same directory. Since targets are packages, a <code class="docutils literal notranslate"><span class="pre">pkg.yml</span></code> is expected. It contains
typical package descriptors, dependencies, and additional parameters such as the following:</p>
<ul class="simple">
<li><p>Cflags: Any additional compiler flags you might want to specify to the build</p></li>
<li><p>Aflags: Any additional assembler flags you might want to specify to the build</p></li>
<li><p>Lflags: Any additional linker flags you might want to specify to the build</p></li>
</ul>
<p>You can also override the values of the system configuration settings that are defined by the packages that your target
includes. You override the values in your target’s <code class="docutils literal notranslate"><span class="pre">syscfg.yml</span></code> file (stored in the targets/&lt;target-name&gt; directory).
You can use the <code class="docutils literal notranslate"><span class="pre">newt</span> <span class="pre">target</span> <span class="pre">config</span> <span class="pre">show</span></code> command to see the configuration settings and values for your target, and use
the <code class="docutils literal notranslate"><span class="pre">newt</span> <span class="pre">target</span> <span class="pre">set</span></code> command to set the <code class="docutils literal notranslate"><span class="pre">syscfg</span></code> variable and override the configuration setting values. You can
also use an editor to create your target’s <code class="docutils literal notranslate"><span class="pre">syscfg.yml</span></code> file and add the setting values to the file.
See <a class="reference internal" href="../os/modules/sysinitconfig/sysinitconfig.html"><span class="doc">Compile-Time Configuration</span></a> for more information on system configuration settings.</p>
</div>
</div>
<div class="section" id="resolving-dependencies">
<h2>Resolving dependencies<a class="headerlink" href="#resolving-dependencies" title="Permalink to this headline"></a></h2>
<p>When newt builds a project, it will:</p>
<ul class="simple">
<li><p>find the top-level project.yml file</p></li>
<li><p>recurse the packages in the package tree, and build a list of all source packages</p></li>
</ul>
<p>Newt then looks at the target that the user set, for example, blinky_sim:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>more<span class="w"> </span>targets/my_blinky_sim/target.yml
<span class="gp">#</span><span class="c1">## Target: targets/my_blinky_sim</span>
<span class="go">target.app: &quot;apps/blinky&quot;</span>
<span class="go">target.bsp: &quot;@apache-mynewt-core/hw/bsp/native&quot;</span>
<span class="go">target.build_profile: &quot;debug&quot;</span>
</pre></div>
</div>
<p>The target specifies two major things:</p>
<ul class="simple">
<li><p>Application (target.app): The application to build</p></li>
<li><p>Board Support Package (target.bsp): The board support package to build along with that application.</p></li>
</ul>
<p>Newt builds the dependency tree specified by all the packages. While building this tree, it does a few other things:</p>
<ul class="simple">
<li><p>Sets up the include paths for each package. Any package that depends on another package, automatically gets the include
directories from the package it includes. Include directories in the
newt structure must always be prefixed by the package name. For example, kernel/os has the following include tree and its
include directory files contains the package name “os” before any header files. This is so in order to avoid any header file conflicts.</p></li>
</ul>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>tree<span class="w"> </span>repos/apache-mynewt-core/kernel/os/include/
<span class="go">repos/apache-mynewt-core/kernel/os/include/</span>
<span class="go">└── os</span>
<span class="go"> ├── arch</span>
<span class="go"> │   ├── cortex_m0</span>
<span class="go"> │   │   └── os</span>
<span class="go"> │   │   └── os_arch.h</span>
<span class="go"> │   ├── cortex_m4</span>
<span class="go"> │   │   └── os</span>
<span class="go"> │   │   └── os_arch.h</span>
<span class="go"> │   ├── mips</span>
<span class="go"> │   │   └── os</span>
<span class="go"> │   │   └── os_arch.h</span>
<span class="go"> │   ├── sim</span>
<span class="go"> │   │   └── os</span>
<span class="go"> │   │   └── os_arch.h</span>
<span class="go"> │   └── sim-mips</span>
<span class="go"> │   └── os</span>
<span class="go"> │   └── os_arch.h</span>
<span class="go"> ├── endian.h</span>
<span class="go"> ├── os.h</span>
<span class="go"> ├── os_callout.h</span>
<span class="go"> ├── os_cfg.h</span>
<span class="go"> ├── os_cputime.h</span>
<span class="go"> ├── os_dev.h</span>
<span class="go"> ├── os_eventq.h</span>
<span class="go"> ├── os_fault.h</span>
<span class="go"> ├── os_heap.h</span>
<span class="go"> ├── os_malloc.h</span>
<span class="go"> ├── os_mbuf.h</span>
<span class="go"> ├── os_mempool.h</span>
<span class="go"> ├── os_mutex.h</span>
<span class="go"> ├── os_sanity.h</span>
<span class="go"> ├── os_sched.h</span>
<span class="go"> ├── os_sem.h</span>
<span class="go"> ├── os_task.h</span>
<span class="go"> ├── os_test.h</span>
<span class="go"> ├── os_time.h</span>
<span class="go"> └── queue.h</span>
<span class="go">12 directories, 25 files</span>
</pre></div>
</div>
<ul class="simple">
<li><p>Validates API requirements. Packages can export APIs they
implement, (i.e. pkg.api: hw-hal-impl), and other packages can require
those APIs (i.e. pkg.req_api: hw-hal-impl).</p></li>
<li><p>Reads and validates the configuration setting definitions and values from the package <code class="docutils literal notranslate"><span class="pre">syscfg.yml</span></code> files.
It generates a <code class="docutils literal notranslate"><span class="pre">syscfg.h</span></code> header file that packages include in the source files in order to access the settings.
It also generates a system initialization function to initialize the packages.
See <a class="reference internal" href="../os/modules/sysinitconfig/sysinitconfig.html"><span class="doc">Compile-Time Configuration</span></a> for more information.</p></li>
</ul>
<p>In order to properly resolve all dependencies in the build system, newt recursively processes the package dependencies
until there are no new dependencies. And it builds a big list of all the packages that need to be build.</p>
<p>Newt then goes through this package list, and builds every package into
an archive file.</p>
<p><strong>NOTE:</strong> The newt tool generates compiler dependencies for all of these packages, and only rebuilds the packages whose
dependencies have changed. Changes in package &amp; project dependencies are also taken into account. It is smart, after all!</p>
</div>
<div class="section" id="producing-artifacts">
<h2>Producing artifacts<a class="headerlink" href="#producing-artifacts" title="Permalink to this headline"></a></h2>
<p>Once newt has built all the archive files, it then links the archive files together. The linkerscript to use is specified
by the board support package (BSP.)</p>
<p>The newt tool creates a bin directory under the base project directory, and places a target’s build artifacts into the
bin/targets/&lt;target-name&gt;/app/apps/&lt;app-name&gt; directory, where <code class="docutils literal notranslate"><span class="pre">target-name</span></code> is the name of the target and <code class="docutils literal notranslate"><span class="pre">app-name</span></code>
is the name of the application. As an example, the <code class="docutils literal notranslate"><span class="pre">blinky.elf</span></code> executable for the <code class="docutils literal notranslate"><span class="pre">blinky</span></code> application defined by
the <code class="docutils literal notranslate"><span class="pre">my_blinky_sim</span></code> target is stored in the bin/targets/my_blinky_sim/app/apps/blinky directory as shown in the following source tree:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$</span>tree<span class="w"> </span>-L<span class="w"> </span><span class="m">9</span><span class="w"> </span>bin/
<span class="go">bin/</span>
<span class="go">└── targets</span>
<span class="go"> ├── my_blinky_sim</span>
<span class="go"> │ ├── app</span>
<span class="go"> │ │ ├── apps</span>
<span class="go"> │ │ │ └── blinky</span>
<span class="go"> │ │ │ ├── apps</span>
<span class="go"> │ │ │ │ └── blinky</span>
<span class="go"> │ │ │ │ └── src</span>
<span class="go"> │ │ │ │ ├── main.d</span>
<span class="go"> │ │ │ │ ├── main.o</span>
<span class="go"> │ │ │ │ └── main.o.cmd</span>
<span class="go"> │ │ │ ├── apps_blinky.a</span>
<span class="go"> │ │ │ ├── apps_blinky.a.cmd</span>
<span class="go"> │ │ │ ├── blinky.elf</span>
<span class="go"> │ │ │ ├── blinky.elf.cmd</span>
<span class="go"> │ │ │ ├── blinky.elf.dSYM</span>
<span class="go"> │ │ │ │ └── Contents</span>
<span class="go"> │ │ │ │ ├── Info.plist</span>
<span class="go"> │ │ │ │ └── Resources</span>
<span class="go"> │ │ │ │ └── DWARF</span>
<span class="go"> │ │ │ ├── blinky.elf.lst</span>
<span class="go"> │ │ │ └── manifest.json</span>
<span class="go"> │ │ ├── hw</span>
<span class="go"> │ │ │ ├── bsp</span>
<span class="go"> │ │ │ │ └── native</span>
<span class="go"> │ │ │ │ ├── hw_bsp_native.a</span>
<span class="go"> │ │ │ │ ├── hw_bsp_native.a.cmd</span>
<span class="go"> │ │ │ │ └── repos</span>
<span class="go"> │ │ │ │ └── apache-mynewt-core</span>
<span class="go"> │ │ │ │ └── hw</span>
<span class="go">&lt;snip&gt;</span>
</pre></div>
</div>
<p>As you can see, a number of files are generated:</p>
<ul class="simple">
<li><p>Archive File</p></li>
<li><p>*.cmd: The command use to generate the object or archive file</p></li>
<li><p>*.lst: The list file where symbols are located</p></li>
</ul>
<p>Note: The *.o object files that get put into the archive file are stored in the bin/targets/my_blinky_sim/app/apps/blinky/apps/blinky/src directory.</p>
</div>
<div class="section" id="download-debug-support">
<h2>Download/Debug Support<a class="headerlink" href="#download-debug-support" title="Permalink to this headline"></a></h2>
<p>Once a target has been built, there are a number of helper functions
that work on the target. These are:</p>
<ul class="simple">
<li><p><strong>load</strong> Download built target to board</p></li>
<li><p><strong>debug</strong> Open debugger session to target</p></li>
<li><p><strong>size</strong> Size of target components</p></li>
<li><p><strong>create-image</strong> Add image header to target binary</p></li>
<li><p><strong>run</strong> The equivalent of build, create-image, load, and debug on specified target</p></li>
<li><p><strong>target</strong> Create, delete, configure, and query a target</p></li>
</ul>
<p><code class="docutils literal notranslate"><span class="pre">load</span></code> and <code class="docutils literal notranslate"><span class="pre">debug</span></code> handles driving GDB and the system debugger. These
commands call out to scripts that are defined by the BSP.</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>more<span class="w"> </span>repos/apache-mynewt-core/hw/bsp/nrf52dk/nrf52dk_debug.sh
<span class="go">&lt;snip&gt;</span>
<span class="go">. $CORE_PATH/hw/scripts/jlink.sh</span>
<span class="go">FILE_NAME=$BIN_BASENAME.elf</span>
<span class="go">if [ $# -gt 2 ]; then</span>
<span class="go"> SPLIT_ELF_NAME=$3.elf</span>
<span class="gp"> # </span>TODO<span class="w"> </span>--<span class="w"> </span>this<span class="w"> </span>magic<span class="w"> </span>number<span class="w"> </span>0x42000<span class="w"> </span>is<span class="w"> </span>the<span class="w"> </span>location<span class="w"> </span>of<span class="w"> </span>the<span class="w"> </span>second<span class="w"> </span>image
<span class="gp"> # </span>slot.<span class="w"> </span>we<span class="w"> </span>should<span class="w"> </span>either<span class="w"> </span>get<span class="w"> </span>this<span class="w"> </span>from<span class="w"> </span>a<span class="w"> </span>flash<span class="w"> </span>map<span class="w"> </span>file<span class="w"> </span>or<span class="w"> </span>somehow<span class="w"> </span>learn
<span class="gp"> # </span>this<span class="w"> </span>from<span class="w"> </span>the<span class="w"> </span>image<span class="w"> </span>itself
<span class="go"> EXTRA_GDB_CMDS=&quot;add-symbol-file $SPLIT_ELF_NAME 0x8000 -readnow&quot;</span>
<span class="go">fi</span>
<span class="go">JLINK_DEV=&quot;nRF52&quot;</span>
<span class="go">jlink_debug</span>
</pre></div>
</div>
<p>The idea is that every BSP will add support for the debugger environment
for that board. That way common tools can be used across various
development boards and kits.</p>
</div>
</div>
</div>
</div>
<div class="rst-footer-buttons row" role="navigation" aria-label="footer navigation">
<a href="newt_ops.html" class="btn btn-neutral float-right" title="Command Structure" accesskey="n">Next: Command Structure <span class="fa fa-arrow-circle-right"></span></a>
<a href="index.html" class="btn btn-neutral" title="Newt Tool Guide" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous: Newt Tool Guide</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>