Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dfu/boot: rework using newly introduced MCUBOOT_BOOTUTIL library #30370

Merged
merged 2 commits into from
Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions include/dfu/mcuboot.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,58 @@
extern "C" {
#endif

#ifdef BOOT_SWAP_TYPE_NONE
#if BOOT_SWAP_TYPE_NONE != 1 /*ensure the same definition in MCUboot */
mniestroj marked this conversation as resolved.
Show resolved Hide resolved
#error "definition incompatible"
#endif
#else
/** Attempt to boot the contents of slot 0. */
#define BOOT_SWAP_TYPE_NONE 1
#endif

#ifdef BOOT_SWAP_TYPE_TEST
#if BOOT_SWAP_TYPE_TEST != 2 /*ensure the same definition in MCUboot */
#error "definition incompatible"
#endif
#else
/** Swap to slot 1. Absent a confirm command, revert back on next boot. */
#define BOOT_SWAP_TYPE_TEST 2
#endif

#ifdef BOOT_SWAP_TYPE_PERM
#if BOOT_SWAP_TYPE_PERM != 3 /*ensure the same definition in MCUboot */
#error "definition incompatible"
#endif
#else
/** Swap to slot 1, and permanently switch to booting its contents. */
#define BOOT_SWAP_TYPE_PERM 3
#endif

#ifdef BOOT_SWAP_TYPE_REVERT
#if BOOT_SWAP_TYPE_REVERT != 4 /*ensure the same definition in MCUboot */
#error "definition incompatible"
#endif
#else
/** Swap back to alternate slot. A confirm changes this state to NONE. */
#define BOOT_SWAP_TYPE_REVERT 4
#endif

#ifdef BOOT_SWAP_TYPE_FAIL
#if BOOT_SWAP_TYPE_FAIL != 5 /*ensure the same definition in MCUboot */
#error "definition incompatible"
#endif
nvlsianpu marked this conversation as resolved.
Show resolved Hide resolved
#else
/** Swap failed because image to be run is not valid */
#define BOOT_SWAP_TYPE_FAIL 5
#endif

#define BOOT_IMG_VER_STRLEN_MAX 25 /* 255.255.65535.4294967295\0 */

/* Trailer: */
#define BOOT_MAX_ALIGN 8
#ifndef BOOT_MAGIC_SZ
#define BOOT_MAGIC_SZ 16
#endif
mniestroj marked this conversation as resolved.
Show resolved Hide resolved

#define BOOT_TRAILER_IMG_STATUS_OFFS(bank_area) ((bank_area)->fa_size -\
BOOT_MAGIC_SZ -\
Expand Down
1 change: 1 addition & 0 deletions modules/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ source "modules/Kconfig.tinycbor"
source "modules/Kconfig.tinycrypt"
source "modules/Kconfig.vega"
source "modules/Kconfig.xtensa"
source "modules/Kconfig.mcuboot_bootutil"
24 changes: 24 additions & 0 deletions modules/Kconfig.mcuboot_bootutil
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) 2020 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

menuconfig MCUBOOT_BOOTUTIL_LIB
bool "MCUboot utility library"
help
Enable MCUboot utility library which implements functions
required by the chain-loaded application and the MCUboot.

if MCUBOOT_BOOTUTIL_LIB

# hiden option for disabling module-own log configuration
# while building MCUboot bootloader
config MCUBOOT_BOOTUTIL_LIB_OWN_LOG
bool
default y

if MCUBOOT_BOOTUTIL_LIB_OWN_LOG
module = MCUBOOT_UTIL
module-str = MCUboot bootutil
source "subsys/logging/Kconfig.template.log_config"
endif

endif # MCUBOOT_BOOTUTIL_LIB
1 change: 1 addition & 0 deletions subsys/dfu/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ choice
config MCUBOOT_IMG_MANAGER
bool "Image manager for mcuboot"
select FLASH_MAP
select MCUBOOT_BOOTUTIL_LIB
help
Enable support for managing DFU image downloaded using mcuboot.

Expand Down
8 changes: 6 additions & 2 deletions subsys/dfu/boot/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# SPDX-License-Identifier: Apache-2.0

zephyr_sources_ifdef(CONFIG_MCUBOOT_IMG_MANAGER mcuboot.c)
zephyr_sources_ifdef(CONFIG_MCUBOOT_SHELL mcuboot_shell.c)
if(CONFIG_MCUBOOT_IMG_MANAGER)
zephyr_library()
zephyr_library_sources(mcuboot.c)
zephyr_library_sources_ifdef(CONFIG_MCUBOOT_SHELL mcuboot_shell.c)
zephyr_library_link_libraries(MCUBOOT_BOOTUTIL)
endif()
Loading