From 026bd218e410fd679baafb2d4b4e95657539a917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B8e?= Date: Fri, 1 Mar 2019 09:42:54 +0100 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) --- CODEOWNERS | 1 + doc/application/index.rst | 2 +- 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 ++++++++++++ 8 files changed, 77 insertions(+), 1 deletion(-) 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 3c05df50ee5989..9ce7c46847d649 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -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 diff --git a/doc/application/index.rst b/doc/application/index.rst index ef2c15a07db32e..b139ad3b27765d 100644 --- a/doc/application/index.rst +++ b/doc/application/index.rst @@ -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 diff --git a/samples/index.rst b/samples/index.rst index 792fe9c9b4401a..eb84a70920f949 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 00000000000000..0300bdd0b02e98 --- /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 00000000000000..f329b8384e1121 --- /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 00000000000000..0608e7a866c00a --- /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 00000000000000..b916c050b624e4 --- /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 00000000000000..74fc4389febe1d --- /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); +}