2015-10-20 04:25:10 +08:00
|
|
|
.. _apps_structure:
|
|
|
|
|
2016-10-29 04:06:44 +08:00
|
|
|
Create an Application Directory
|
|
|
|
###############################
|
2015-10-20 04:25:10 +08:00
|
|
|
|
|
|
|
Each application resides in a uniquely-named application
|
2016-10-29 04:06:44 +08:00
|
|
|
directory created by the developer, typically in the developer's
|
2015-10-20 04:25:10 +08:00
|
|
|
workspace directory. The application developer also creates a
|
|
|
|
:file:`src` directory for the application's source code.
|
|
|
|
|
2016-10-29 04:06:44 +08:00
|
|
|
.. contents:: Procedures
|
|
|
|
:local:
|
|
|
|
:depth: 1
|
2015-10-20 04:25:10 +08:00
|
|
|
|
2016-10-29 04:06:44 +08:00
|
|
|
Creating an Application and Source Code Directory
|
|
|
|
=================================================
|
2015-10-20 04:25:10 +08:00
|
|
|
|
2016-10-29 04:06:44 +08:00
|
|
|
Create one directory for your application and a sub-directory for the
|
|
|
|
application's source code; this makes it easier to organize directories
|
|
|
|
and files in the structure that the kernel expects.
|
2015-10-20 04:25:10 +08:00
|
|
|
|
|
|
|
Before You Begin
|
|
|
|
----------------
|
|
|
|
|
2016-10-29 04:06:44 +08:00
|
|
|
* Ensure the Zephyr environment variables are set for each console terminal;
|
|
|
|
see :ref:`apps_common_procedures`.
|
2015-10-20 04:25:10 +08:00
|
|
|
|
|
|
|
Steps
|
|
|
|
-----
|
|
|
|
|
|
|
|
1. Create an application directory structure outside of the kernel's
|
|
|
|
installation directory tree. Often this is your workspace directory.
|
|
|
|
|
2016-10-29 04:06:44 +08:00
|
|
|
a) In a console terminal, navigate to a location where you want your
|
|
|
|
application to reside.
|
2015-10-20 04:25:10 +08:00
|
|
|
|
|
|
|
b) Create the application's directory, enter:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ mkdir application_name
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
This directory and the path to it, are referred to in the documentation
|
|
|
|
as :file:`~/appDir`.
|
|
|
|
|
|
|
|
2. Create a source code directory in your :file:`~/appDir`, enter:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ mkdir src
|
|
|
|
|
|
|
|
The source code directory :file:`~/appDir/src` is created.
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
-- appDir
|
|
|
|
|-- src
|
|
|
|
|
|
|
|
Creating an Application Makefile
|
|
|
|
================================
|
|
|
|
|
2016-10-29 04:06:44 +08:00
|
|
|
Create an application Makefile to define basic information,
|
|
|
|
such as the board configuration used by the application.
|
|
|
|
The build system uses the Makefile to build a :file:`zephyr.elf` image
|
|
|
|
that contains both the application and the kernel libraries.
|
2015-10-20 04:25:10 +08:00
|
|
|
|
|
|
|
Before You Begin
|
|
|
|
----------------
|
|
|
|
|
|
|
|
* Be familiar with the standard GNU Make language.
|
|
|
|
|
2015-12-18 08:12:33 +08:00
|
|
|
* Be familiar with the board configuration used for your application
|
|
|
|
and, if it is a custom board configuration, where it is located.
|
2015-10-20 04:25:10 +08:00
|
|
|
|
2016-10-29 04:06:44 +08:00
|
|
|
* Ensure the Zephyr environment variables are set for each console terminal;
|
|
|
|
see :ref:`apps_common_procedures`.
|
2015-10-20 04:25:10 +08:00
|
|
|
|
|
|
|
Steps
|
|
|
|
-----
|
|
|
|
|
|
|
|
1. In the :file:`appDir` directory, create a Makefile. Enter:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
$ touch Makefile
|
|
|
|
|
|
|
|
2. Open the :file:`Makefile` and add the following mandatory
|
|
|
|
entries using any standard text editor.
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
Ensure that there is a space after each ``=``.
|
|
|
|
|
2016-10-29 04:06:44 +08:00
|
|
|
a) Add the name of the default board configuration for your application on a
|
2015-10-20 04:25:10 +08:00
|
|
|
new line:
|
|
|
|
|
|
|
|
.. code-block:: make
|
|
|
|
|
2015-12-18 08:12:33 +08:00
|
|
|
BOARD ?= board_configuration_name
|
2015-10-20 04:25:10 +08:00
|
|
|
|
2015-12-18 08:12:33 +08:00
|
|
|
The supported boards can be found in :ref:`board`.
|
2015-10-20 04:25:10 +08:00
|
|
|
|
2016-10-29 04:06:44 +08:00
|
|
|
b) Add the name of the default kernel configuration file for your
|
2015-10-20 04:25:10 +08:00
|
|
|
application on a new line:
|
|
|
|
|
|
|
|
.. code-block:: make
|
|
|
|
|
2016-10-29 04:06:44 +08:00
|
|
|
CONF_FILE ?= kernel_configuration_name
|
2015-10-20 04:25:10 +08:00
|
|
|
|
2016-10-29 04:06:44 +08:00
|
|
|
The default kernel configuration file entry may be omitted if the file
|
|
|
|
is called :file:`prj.conf`. It may also be omitted if the default board
|
|
|
|
configuration's kernel settings are sufficient for your application.
|
2015-10-20 04:25:10 +08:00
|
|
|
|
2016-10-29 04:06:44 +08:00
|
|
|
c) Include the mandatory :file:`Makefile` fragments on a new line:
|
2015-10-20 04:25:10 +08:00
|
|
|
|
|
|
|
.. code-block:: make
|
|
|
|
|
|
|
|
include ${ZEPHYR_BASE}/Makefile.inc
|
|
|
|
|
|
|
|
3. Save and close the :file:`Makefile`.
|
|
|
|
|
|
|
|
Example Makefile
|
|
|
|
----------------
|
|
|
|
|
|
|
|
.. code-block:: make
|
|
|
|
|
2015-12-14 04:00:31 +08:00
|
|
|
BOARD ?= qemu_x86
|
2016-10-29 04:06:44 +08:00
|
|
|
CONF_FILE ?= prj.conf
|
2015-10-20 04:25:10 +08:00
|
|
|
include ${ZEPHYR_BASE}/Makefile.inc
|