Skip to content

Commit

Permalink
[nrf fromlist] samples: Added a minimal MCUBoot integration test
Browse files Browse the repository at this point in the history
From upstream zephyrproject-rtos#13672

Added a minimal integration test for MCUBoot. It has just enough
coverage to catch build issues. Which is better than before (no
coverage in the Zephyr CI).

Signed-off-by: Sebastian Bøe <[email protected]>
(cherry picked from commit 1937b41)
  • Loading branch information
SebastianBoe authored and mbolivar-nordic committed Jul 12, 2019
1 parent b4d8e6d commit 026bd21
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 1 deletion.
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@
/samples/drivers/CAN/ @alexanderwachter
/samples/drivers/ht16k33/ @henrikbrixandersen
/samples/gui/ @vanwinkeljan
/samples/mcuboot/ @SebastianBoe
/samples/net/ @jukkar @tbursztyka @pfalcon
/samples/net/dns_resolve/ @jukkar @tbursztyka @pfalcon
/samples/net/lwm2m_client/ @mike-scott
Expand Down
2 changes: 1 addition & 1 deletion doc/application/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,7 @@ changes to the build scripts are necessary.
As mentioned earlier, each target needs a prefix to disambiguate. This
includes the library target 'app', so any references to 'app' would
need to be changed to '${IMAGE}app'. Or, even better, one would use
the zephyr_library_ API instead of the target_* API to indirectly
the zephyr_library_* API instead of the target_* API to indirectly
modify '${IMAGE}app'.

After the application build scripts have been ported we can write some
Expand Down
1 change: 1 addition & 0 deletions samples/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Samples and Demos
bluetooth/bluetooth.rst
sensor/*
boards/*
mcuboot/*
mpu/*
drivers/drivers.rst
application_development/*
Expand Down
6 changes: 6 additions & 0 deletions samples/mcuboot/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 3.13.1)

include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
project(mcuboot)

target_sources(app PRIVATE src/main.c)
40 changes: 40 additions & 0 deletions samples/mcuboot/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.. _mcuboot_sample:

MCUBoot Sample
##############

Overview
********
A simple hello world sample that is booted by the bootloader
MCUBoot. This sample can be used with any platform that supports
MCUBoot.

Building and Running
********************

This project outputs output from the bootloader and then 'Hello World'
from the application. It can be built and executed on nRF52_pca10040
as follows:

.. zephyr-app-commands::
:zephyr-app: samples/mcuboot
:host-os: unix
:board: nrf52_pca10040
:goals: run
:compact:

Sample Output
=============

.. code-block:: console
***** Booting Zephyr OS v1.14.0-rc1-447-gb30b83a6eb *****
[00:00:00.004,638] <inf> mcuboot: Starting bootloader
[00:00:00.011,505] <inf> mcuboot: Image 0: magic=unset, copy_done=0x3, image_ok=0x3
[00:00:00.020,690] <inf> mcuboot: Scratch: magic=unset, copy_done=0xe0, image_ok=0x3
[00:00:00.029,998] <inf> mcuboot: Boot source: slot 0
[00:00:00.039,062] <inf> mcuboot: Swap type: none
[00:00:00.132,904] <inf> mcuboot: Bootloader chainload address offset: 0xc000
[00:00:00.141,479] <inf> mcuboot: Jumping to the first image slot
***** Booting Zephyr OS v1.14.0-rc1-447-gb30b83a6eb *****
Hello World! nrf52_pca10040
1 change: 1 addition & 0 deletions samples/mcuboot/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_BOOTLOADER_MCUBOOT=y
13 changes: 13 additions & 0 deletions samples/mcuboot/sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
sample:
name: mcuboot
tests:
boards.mcuboot:
tags: mcuboot
# All platforms supported by MCUBoot out-of-the-box are
# supported. nRF52 is known to be supported.
platform_whitelist: nrf52840_pca10056 nrf52_pca10040
harness: console
harness_config:
type: one_line
regex:
- "Hello World! (.*)"
14 changes: 14 additions & 0 deletions samples/mcuboot/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright (c) 2012-2014 Wind River Systems, Inc.
* Copyright (c) 2019 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr.h>
#include <misc/printk.h>

void main(void)
{
printk("Hello World! %s\n", CONFIG_BOARD);
}

0 comments on commit 026bd21

Please sign in to comment.