boot/mcuboot: Prepare to move MCUboot samples to examples dir

This adjusts code and Kconfig variables as preparation to move MCUboot
examples to examples/mcuboot folder.

This changes perfor below sed operations:

's/MCUBOOT_UPDATE_AGENT_EXAMPLE/EXAMPLES_MCUBOOT_UPDATE_AGENT/g'
's/MCUBOOT_SLOT_CONFIRM_EXAMPLE/EXAMPLES_MCUBOOT_SLOT_CONFIRM/g'

It replaces 'apps/boot/mcuboot' prefix by 'apps/examples/mcuboot' and
adjust it with respective application name on below source files:

boot/mcuboot/mcuboot_agent_main.c
boot/mcuboot/mcuboot_confirm_main.c

This commit does not other changes in the code.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
This commit is contained in:
Gerson Fernando Budke 2021-12-20 19:10:06 -03:00 committed by Petro Karashchenko
parent 29cc338dac
commit 36cb168077
5 changed files with 25 additions and 25 deletions

View File

@ -100,7 +100,7 @@ config MCUBOOT_DIRECT_XIP_REVERT
depends on MCUBOOT_DIRECT_XIP
default n
config MCUBOOT_UPDATE_AGENT_EXAMPLE
config EXAMPLES_MCUBOOT_UPDATE_AGENT
bool "MCUboot update agent example"
default n
depends on NET_TCP
@ -109,36 +109,36 @@ config MCUBOOT_UPDATE_AGENT_EXAMPLE
an application firmware image from a given URL and saves it to the
secondary slot as a pending update.
if MCUBOOT_UPDATE_AGENT_EXAMPLE
if EXAMPLES_MCUBOOT_UPDATE_AGENT
config MCUBOOT_UPDATE_AGENT_EXAMPLE_UPDATE_URL
config EXAMPLES_MCUBOOT_UPDATE_AGENT_UPDATE_URL
string "URL for update image"
default ""
config MCUBOOT_UPDATE_AGENT_EXAMPLE_DL_BUFFER_SIZE
config EXAMPLES_MCUBOOT_UPDATE_AGENT_DL_BUFFER_SIZE
int "Download buffer size in bytes"
default 512
config MCUBOOT_UPDATE_AGENT_EXAMPLE_DL_VERIFY_MD5
config EXAMPLES_MCUBOOT_UPDATE_AGENT_DL_VERIFY_MD5
bool "Calculate MD5 of update image"
default n
depends on CODECS_HASH_MD5
config MCUBOOT_UPDATE_AGENT_EXAMPLE_DL_MD5_HASH
config EXAMPLES_MCUBOOT_UPDATE_AGENT_DL_MD5_HASH
string "Expected MD5 sum of update image"
default ""
depends on MCUBOOT_UPDATE_AGENT_EXAMPLE_DL_VERIFY_MD5
depends on EXAMPLES_MCUBOOT_UPDATE_AGENT_DL_VERIFY_MD5
endif # MCUBOOT_UPDATE_AGENT_EXAMPLE
endif # EXAMPLES_MCUBOOT_UPDATE_AGENT
config MCUBOOT_SLOT_CONFIRM_EXAMPLE
config EXAMPLES_MCUBOOT_SLOT_CONFIRM
tristate "MCUboot slot confirm example"
default n
---help---
Example application for confirming a newly installed application
application firmware image using MCUboot public APIs.
This application should be used as the OTA update package of the
MCUBOOT_UPDATE_AGENT_EXAMPLE example.
EXAMPLES_MCUBOOT_UPDATE_AGENT example.
config MCUBOOT_WATCHDOG
bool "Watchdog feeding support"

View File

@ -30,7 +30,7 @@ DEPPATH += --dep-path $(MCUBOOT_SRCDIR)
VPATH += :$(MCUBOOT_UNPACK)$(DELIM)src
VPATH += :$(MCUBOOT_SRCDIR)
ifneq ($(CONFIG_MCUBOOT_UPDATE_AGENT_EXAMPLE),)
ifneq ($(CONFIG_EXAMPLES_MCUBOOT_UPDATE_AGENT),)
MAINSRC += mcuboot_agent_main.c
PROGNAME += mcuboot_agent
@ -38,7 +38,7 @@ PRIORITY += SCHED_PRIORITY_DEFAULT
STACKSIZE += $(CONFIG_DEFAULT_TASK_STACKSIZE)
endif
ifneq ($(CONFIG_MCUBOOT_SLOT_CONFIRM_EXAMPLE),)
ifneq ($(CONFIG_EXAMPLES_MCUBOOT_SLOT_CONFIRM),)
MAINSRC += mcuboot_confirm_main.c
PROGNAME += mcuboot_confirm

View File

@ -24,7 +24,7 @@ The NuttX port of MCUboot is implemented at application-level and requires minim
One common use case for MCUboot is to integrate it to a firmware update agent, which is an important component of a secure firmware update subsystem. Through MCUboot APIs an application is able to install a newly received application firmware image and, once this application firmware image is assured to be valid, the application may confirm it as a stable image. In case that application firmware image is deemed bogus, MCUboot provides an API for invalidating that update, which will induce a rollback procedure to the most recent stable application firmware image.
The `CONFIG_MCUBOOT_UPDATE_AGENT_EXAMPLE` example demonstrates this workflow by downloading an application firmware image from a webserver, installing it and triggering the firmware update process for the next boot after a system reset. There is also the `CONFIG_MCUBOOT_SLOT_CONFIRM_EXAMPLE`, which is a fairly simple example that just calls an MCUboot API for confirming the executing application firmware image as stable.
The `CONFIG_EXAMPLES_MCUBOOT_UPDATE_AGENT` example demonstrates this workflow by downloading an application firmware image from a webserver, installing it and triggering the firmware update process for the next boot after a system reset. There is also the `CONFIG_EXAMPLES_MCUBOOT_SLOT_CONFIRM`, which is a fairly simple example that just calls an MCUboot API for confirming the executing application firmware image as stable.
## Using MCUboot on NuttX as a secure boot solution

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/boot/mcuboot/mcuboot_agent_main.c
* apps/examples/mcuboot/update_agent/mcuboot_agent_main.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@ -38,7 +38,7 @@
#include <bootutil/bootutil_public.h>
#ifdef CONFIG_MCUBOOT_UPDATE_AGENT_EXAMPLE_DL_VERIFY_MD5
#ifdef CONFIG_EXAMPLES_MCUBOOT_UPDATE_AGENT_DL_VERIFY_MD5
#include "netutils/md5.h"
#endif
#include "netutils/netlib.h"
@ -51,14 +51,14 @@
* Preprocessor Definitions
****************************************************************************/
#define DL_BUFFER_SIZE CONFIG_MCUBOOT_UPDATE_AGENT_EXAMPLE_DL_BUFFER_SIZE
#define DL_BUFFER_SIZE CONFIG_EXAMPLES_MCUBOOT_UPDATE_AGENT_DL_BUFFER_SIZE
#define DL_UPDATE_URL CONFIG_MCUBOOT_UPDATE_AGENT_EXAMPLE_UPDATE_URL
#define DL_UPDATE_URL CONFIG_EXAMPLES_MCUBOOT_UPDATE_AGENT_UPDATE_URL
#ifdef CONFIG_MCUBOOT_UPDATE_AGENT_EXAMPLE_DL_VERIFY_MD5
#ifdef CONFIG_EXAMPLES_MCUBOOT_UPDATE_AGENT_DL_VERIFY_MD5
# define MD5_HASH_LENGTH 32
# define MD5_DIGEST_LENGTH 16
# define MD5_EXPECTED_HASH CONFIG_MCUBOOT_UPDATE_AGENT_EXAMPLE_DL_MD5_HASH
# define MD5_EXPECTED_HASH CONFIG_EXAMPLES_MCUBOOT_UPDATE_AGENT_DL_MD5_HASH
#endif
/****************************************************************************
@ -70,7 +70,7 @@ struct download_context_s
FAR const struct flash_area *fa;
uint32_t fa_offset;
ssize_t image_size;
#ifdef CONFIG_MCUBOOT_UPDATE_AGENT_EXAMPLE_DL_VERIFY_MD5
#ifdef CONFIG_EXAMPLES_MCUBOOT_UPDATE_AGENT_DL_VERIFY_MD5
MD5_CTX md5_ctx;
#endif
};
@ -138,7 +138,7 @@ static int sink_callback(FAR char **buffer, int offset, int datend,
ctx->fa_offset += length;
#ifdef CONFIG_MCUBOOT_UPDATE_AGENT_EXAMPLE_DL_VERIFY_MD5
#ifdef CONFIG_EXAMPLES_MCUBOOT_UPDATE_AGENT_DL_VERIFY_MD5
md5_update(&ctx->md5_ctx,
(FAR const unsigned char *)&((*buffer)[offset]),
length);
@ -162,7 +162,7 @@ static int download_firmware_image(FAR const char *url)
int ret;
struct webclient_context client_ctx;
struct download_context_s dl_ctx;
#ifdef CONFIG_MCUBOOT_UPDATE_AGENT_EXAMPLE_DL_VERIFY_MD5
#ifdef CONFIG_EXAMPLES_MCUBOOT_UPDATE_AGENT_DL_VERIFY_MD5
uint8_t digest[MD5_DIGEST_LENGTH];
char hash[MD5_HASH_LENGTH + 1];
int i;
@ -172,7 +172,7 @@ static int download_firmware_image(FAR const char *url)
dl_ctx.fa_offset = 0;
dl_ctx.image_size = -1;
#ifdef CONFIG_MCUBOOT_UPDATE_AGENT_EXAMPLE_DL_VERIFY_MD5
#ifdef CONFIG_EXAMPLES_MCUBOOT_UPDATE_AGENT_DL_VERIFY_MD5
md5_init(&dl_ctx.md5_ctx);
#endif
@ -202,7 +202,7 @@ static int download_firmware_image(FAR const char *url)
goto exit_close;
}
#ifdef CONFIG_MCUBOOT_UPDATE_AGENT_EXAMPLE_DL_VERIFY_MD5
#ifdef CONFIG_EXAMPLES_MCUBOOT_UPDATE_AGENT_DL_VERIFY_MD5
md5_final(digest, &dl_ctx.md5_ctx);
for (i = 0; i < MD5_DIGEST_LENGTH; i++)

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/boot/mcuboot/mcuboot_confirm_main.c
* apps/examples/mcuboot/slot_confirm/mcuboot_confirm_main.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with