diff --git a/samples/zephyr/hello-world/Makefile b/samples/zephyr/hello-world/Makefile new file mode 100644 index 00000000..15176e00 --- /dev/null +++ b/samples/zephyr/hello-world/Makefile @@ -0,0 +1,46 @@ +# Top-level Makefile for the skeleton application. +# +# This provides a basic application structure suitable for loading by +# mcuboot, which is easy to customize on a per-board basis. It can be +# used as a starting point for new applications. + +# The default board is FRDM-K64F. This can be overridden at +# the command line for other boards supported by Zephyr. +BOARD ?= frdm_k64f +# The top-level application configuration is prj.conf. This can also +# be overridden at the command line if you add another one. +CONF_FILE ?= prj.conf + +# This will merge any board-specific extras from boards/$(BOARD).conf +# into the configuration. +CONF_FILE += $(wildcard boards/$(BOARD).conf) +# These additional "local" files, if present, will be merged in as +# well, but they are ignored by Git. +CONF_FILE += $(wildcard local.conf) $(wildcard boards/$(BOARD)-local.conf) + +# Zephyr uses Device Tree (DT) to describe some board hardware +# configuration. +# +# For this simple example, all we need to tell DT is where on the chip +# flash to link this application image so mcuboot can find it. We do +# this with a device tree overlay file. +# +# See the Zephyr documentation for more information on DT: +# https://www.zephyrproject.org/doc/dts/device_tree.html +DTC_OVERLAY_FILE := $(CURDIR)/dts.overlay +export DTC_OVERLAY_FILE +# If you want to do your DT overlay on a per-board basis (say, if you +# need to support multiple different boards, each of which needs +# slightly different DT overlays), then comment the above lines and +# uncomment the following ones. You can then add board-specific +# overlay files named boards/$(BOARD).overlay. +# +# DTC_OVERLAY_DIR := $(CURDIR)/boards +# export DTC_OVERLAY_DIR + +# This string ends up getting printed in the device console +FROM_WHO ?= "Zephyr" +CFLAGS += -DMCUBOOT_HELLO_WORLD_FROM=\"$(FROM_WHO)\" + +# The Zephyr Makefiles do the rest. +include $(ZEPHYR_BASE)/Makefile.inc diff --git a/samples/zephyr/hello-world/README.rst b/samples/zephyr/hello-world/README.rst new file mode 100644 index 00000000..2c89008d --- /dev/null +++ b/samples/zephyr/hello-world/README.rst @@ -0,0 +1,6 @@ +This is a "Hello world" skeleton application which can be used as a +starting point for Zephyr application development using mcuboot. + +It includes the configuration "glue" needed to make the application +loadable by mcuboot in addition to a basic Zephyr hello world +application's code. diff --git a/samples/zephyr/hello-world/boards/.gitignore b/samples/zephyr/hello-world/boards/.gitignore new file mode 100644 index 00000000..27e8bd87 --- /dev/null +++ b/samples/zephyr/hello-world/boards/.gitignore @@ -0,0 +1 @@ +*-local.conf diff --git a/samples/zephyr/hello-world/boards/README.rst b/samples/zephyr/hello-world/boards/README.rst new file mode 100644 index 00000000..1715f427 --- /dev/null +++ b/samples/zephyr/hello-world/boards/README.rst @@ -0,0 +1,2 @@ +You can place per-board configuration and device tree overlays +here. See the comments in the Makefile for more information. diff --git a/samples/zephyr/hello-world/dts.overlay b/samples/zephyr/hello-world/dts.overlay new file mode 100644 index 00000000..dc3e1dca --- /dev/null +++ b/samples/zephyr/hello-world/dts.overlay @@ -0,0 +1,10 @@ +/* + * Basic Device Tree overlay file for chain-loading by mcuboot. + * See the Makefile for more information. + */ + +/ { + chosen { + zephyr,code-partition = &slot0_partition; + }; +}; diff --git a/samples/zephyr/hello-world/prj.conf b/samples/zephyr/hello-world/prj.conf new file mode 100644 index 00000000..193c6115 --- /dev/null +++ b/samples/zephyr/hello-world/prj.conf @@ -0,0 +1,11 @@ +# Print a banner on the UART on startup. +CONFIG_BOOT_BANNER=y +CONFIG_BUILD_TIMESTAMP=y + +# TEXT_SECTION_OFFSET is used to leave space in the binary for the +# mcuboot header. +# +# This is a conservative value which should work for most boards, at +# the cost of unnecessarily reducing the amount of usable flash a bit +# on some boards. +CONFIG_TEXT_SECTION_OFFSET=0x200 diff --git a/samples/zephyr/hello-world/sample.yaml b/samples/zephyr/hello-world/sample.yaml new file mode 100644 index 00000000..42417789 --- /dev/null +++ b/samples/zephyr/hello-world/sample.yaml @@ -0,0 +1,9 @@ +sample: + name: Application Skeleton + description: Basic "hello world" application, but loadable by mcuboot + platforms: all +tests: + - test: + build_only: true + tags: samples tests + min_ram: 16 diff --git a/samples/zephyr/hello-world/src/Makefile b/samples/zephyr/hello-world/src/Makefile new file mode 100644 index 00000000..00066e15 --- /dev/null +++ b/samples/zephyr/hello-world/src/Makefile @@ -0,0 +1 @@ +obj-y = main.o diff --git a/samples/zephyr/hello-world/src/main.c b/samples/zephyr/hello-world/src/main.c new file mode 100644 index 00000000..189b1fb4 --- /dev/null +++ b/samples/zephyr/hello-world/src/main.c @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2017 Linaro, Ltd. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +void main(void) +{ + printk("Hello World from %s on %s!\n", + MCUBOOT_HELLO_WORLD_FROM, CONFIG_BOARD); +}