Skip to content

Commit d1c935e

Browse files
gmarullnashif
authored andcommitted
app: initial application skeleton
initial application skeleton demonstrating: - custom boards - custom DT bindings - Out-of-tree drivers Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent 36602d0 commit d1c935e

31 files changed

+558
-2
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# editors
2+
.vscode
3+
*.swp
4+
*~
5+
6+
# python
7+
.venv
8+
9+
# build
10+
/build*

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright (c) 2021 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# This CMake file is picked by the Zephyr build system because it is defined
5+
# as the module CMake entry point (see zephyr/module.yml).
6+
7+
add_subdirectory(drivers)

Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) 2021 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# This Kconfig file is picked by the Zephyr build system because it is defined
5+
# as the module Kconfig entry point (see zephyr/module.yml). You can browse
6+
# module options by going to Zephyr -> Modules in Kconfig.
7+
8+
rsource "drivers/Kconfig"

README.md

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,58 @@
1-
# example-application
2-
Example out-of-tree application that is also a module
1+
# Zephyr Example Application
2+
3+
This repository contains a Zephyr example application. The main purpose of this
4+
repository is to serve as a reference on how to structure Zephyr based
5+
applications. Some of the features demonstrated in this example are:
6+
7+
- Basic application skeleton
8+
- [Custom boards][board_porting]
9+
- Custom [devicetree bindings][bindings]
10+
- Out-of-tree [drivers][drivers]
11+
- Documentation using Doxygen and Sphinx
12+
- Example CI configuration (using Github Actions)
13+
14+
[board_porting]: https://docs.zephyrproject.org/latest/guides/porting/board_porting.html
15+
[bindings]: https://docs.zephyrproject.org/latest/guides/dts/bindings.html
16+
[drivers]: https://docs.zephyrproject.org/latest/reference/drivers/index.html
17+
18+
## Getting Started
19+
20+
Before getting started, make sure you have a proper Zephyr development
21+
environment. You can follow the official
22+
[Zephyr Getting Started Guide](https://docs.zephyrproject.org/latest/getting_started/index.html).
23+
24+
### Initialization
25+
26+
The first step is to initialize the workspace folder (``my-workspace``) where
27+
the ``example-application`` and all Zephyr modules will be cloned. You can do
28+
that by running:
29+
30+
```shell
31+
# initialize my-workspace for the example-application (main branch)
32+
west init -m https://github.com/zephyrproject-rtos/example-application --mr main my-workspace
33+
# update Zephyr modules
34+
cd my-workspace
35+
west update
36+
```
37+
38+
### Build & Run
39+
40+
The application can be built by running:
41+
42+
```shell
43+
west build -b $BOARD -s app
44+
```
45+
46+
where `$BOARD` is the target board. A sample debug configuration is also
47+
provided. You can apply it by running:
48+
49+
```shell
50+
west build -b $BOARD -s app -- -DOVERLAY_CONFIG=debug.conf
51+
```
52+
53+
Note that you may also use it together with `rtt.conf` if using Segger RTT. Once
54+
you have built the application you can flash it by running:
55+
56+
```shell
57+
west flash
58+
```

app/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#-------------------------------------------------------------------------------
2+
# Zephyr Example Application
3+
#
4+
# Copyright (c) 2021 Nordic Semiconductor ASA
5+
# SPDX-License-Identifier: Apache-2.0
6+
7+
cmake_minimum_required(VERSION 3.13.1)
8+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
9+
10+
project(app LANGUAGES C VERSION 1.0.0)
11+
12+
configure_file(app_version.h.in ${CMAKE_BINARY_DIR}/app/include/app_version.h)
13+
target_include_directories(app PRIVATE ${CMAKE_BINARY_DIR}/app/include src)
14+
15+
target_sources(app PRIVATE src/main.c src/foo.c)

app/Kconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (c) 2021 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# This file is the application Kconfig entry point. All application Kconfig
5+
# options can be defined here or included via other application Kconfig files.
6+
# You can browse these options using the west targets menuconfig (terminal) or
7+
# guiconfig (GUI).
8+
9+
menu "Zephyr"
10+
source "Kconfig.zephyr"
11+
endmenu
12+
13+
module = APP
14+
module-str = APP
15+
source "subsys/logging/Kconfig.template.log_config"

app/app_version.h.in

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* @file app_version.h
3+
*
4+
* Application version information.
5+
*
6+
* Copyright (c) 2021 Nordic Semiconductor ASA
7+
* SPDX-License-Identifier: Apache-2.0
8+
*/
9+
10+
#ifndef APP_VERSION_H_
11+
#define APP_VERSION_H_
12+
13+
/** Application major version. */
14+
#define APP_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}
15+
/** Application minor version. */
16+
#define APP_VERSION_MINOR ${PROJECT_VERSION_MINOR}
17+
/** Application patch version. */
18+
#define APP_VERSION_PATCH ${PROJECT_VERSION_PATCH}
19+
20+
/** Application version. */
21+
#define APP_VERSION \
22+
((APP_VERSION_MAJOR << 16) + \
23+
(APP_VERSION_MINOR << 8) + \
24+
APP_VERSION_PATCH)
25+
26+
/** Application version (string). */
27+
#define APP_VERSION_STR "${PROJECT_VERSION}"
28+
29+
#endif /* APP_VERSION_H_ */

app/debug.conf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright (c) 2021 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# This is a Kconfig fragment which can be used to enable debug-related options
5+
# in the application. See the README for more details.
6+
7+
# compiler
8+
CONFIG_DEBUG_OPTIMIZATIONS=y
9+
10+
# console
11+
CONFIG_CONSOLE=y
12+
13+
# UART console
14+
CONFIG_SERIAL=y
15+
CONFIG_UART_CONSOLE=y
16+
17+
# logging
18+
CONFIG_LOG=y
19+
CONFIG_APP_LOG_LEVEL_DBG=y

app/prj.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright (c) 2021 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# This file contains selected Kconfig options for the application.
5+
6+
CONFIG_SENSOR=y
7+
CONFIG_EXAMPLESENSOR=y

app/rtt.conf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2021 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# This is a Kconfig fragment which can be used to enable Segger RTT options.
5+
# It should be used in conjunction with debug.conf.
6+
7+
# segger RTT console
8+
CONFIG_USE_SEGGER_RTT=y
9+
CONFIG_RTT_CONSOLE=y

0 commit comments

Comments
 (0)