From 414f61410fc40b94f293a6f4a5359564ee333892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B8e?= Date: Fri, 26 Jul 2019 11:42:14 -0600 Subject: [PATCH] [nrf fromlist] samples: Added a minimal MCUBoot integration test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From upstream #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 (cherry picked from commit 1937b41459ca722848abe88cf84067945e8cf0c2) (cherry picked from commit 026bd218e410fd679baafb2d4b4e95657539a917) (cherry picked from commit 4b3a15bd6a793dfe23117684e6fa65a82c8fe12e) Signed-off-by: Martí Bolívar --- CODEOWNERS | 1 + samples/index.rst | 1 + samples/mcuboot/CMakeLists.txt | 6 +++++ samples/mcuboot/README.rst | 40 ++++++++++++++++++++++++++++++++++ samples/mcuboot/prj.conf | 1 + samples/mcuboot/sample.yaml | 13 +++++++++++ samples/mcuboot/src/main.c | 14 ++++++++++++ 7 files changed, 76 insertions(+) create mode 100644 samples/mcuboot/CMakeLists.txt create mode 100644 samples/mcuboot/README.rst create mode 100644 samples/mcuboot/prj.conf create mode 100644 samples/mcuboot/sample.yaml create mode 100644 samples/mcuboot/src/main.c diff --git a/CODEOWNERS b/CODEOWNERS index 9f66cc25e68c..9b8f15dcc301 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -303,6 +303,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 diff --git a/samples/index.rst b/samples/index.rst index 792fe9c9b440..eb84a70920f9 100644 --- a/samples/index.rst +++ b/samples/index.rst @@ -16,6 +16,7 @@ Samples and Demos bluetooth/bluetooth.rst sensor/* boards/* + mcuboot/* mpu/* drivers/drivers.rst application_development/* diff --git a/samples/mcuboot/CMakeLists.txt b/samples/mcuboot/CMakeLists.txt new file mode 100644 index 000000000000..0300bdd0b02e --- /dev/null +++ b/samples/mcuboot/CMakeLists.txt @@ -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) diff --git a/samples/mcuboot/README.rst b/samples/mcuboot/README.rst new file mode 100644 index 000000000000..f329b8384e11 --- /dev/null +++ b/samples/mcuboot/README.rst @@ -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] mcuboot: Starting bootloader + [00:00:00.011,505] mcuboot: Image 0: magic=unset, copy_done=0x3, image_ok=0x3 + [00:00:00.020,690] mcuboot: Scratch: magic=unset, copy_done=0xe0, image_ok=0x3 + [00:00:00.029,998] mcuboot: Boot source: slot 0 + [00:00:00.039,062] mcuboot: Swap type: none + [00:00:00.132,904] mcuboot: Bootloader chainload address offset: 0xc000 + [00:00:00.141,479] mcuboot: Jumping to the first image slot + ***** Booting Zephyr OS v1.14.0-rc1-447-gb30b83a6eb ***** + Hello World! nrf52_pca10040 diff --git a/samples/mcuboot/prj.conf b/samples/mcuboot/prj.conf new file mode 100644 index 000000000000..0608e7a866c0 --- /dev/null +++ b/samples/mcuboot/prj.conf @@ -0,0 +1 @@ +CONFIG_BOOTLOADER_MCUBOOT=y diff --git a/samples/mcuboot/sample.yaml b/samples/mcuboot/sample.yaml new file mode 100644 index 000000000000..b916c050b624 --- /dev/null +++ b/samples/mcuboot/sample.yaml @@ -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! (.*)" diff --git a/samples/mcuboot/src/main.c b/samples/mcuboot/src/main.c new file mode 100644 index 000000000000..74fc4389febe --- /dev/null +++ b/samples/mcuboot/src/main.c @@ -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 +#include + +void main(void) +{ + printk("Hello World! %s\n", CONFIG_BOARD); +}