Unverified Commit 399720d1 authored by Andrzej Puzdrowski's avatar Andrzej Puzdrowski Committed by GitHub
Browse files

Merge: synchronized up to 1eedec3e

Synch up to upstream:
https://github.com/mcu-tools/mcuboot/commit/1eedec3e7936f74872aca43f3962246e7abe6439

- fixed the build issue caused by removal of CONFIG_SYSTEM_CLOCK_DISABLE property (within https://github.com/zephyrproject-rtos/zephyr/pull/37435

)
- always call sys_clock_disable() in main since the empty sys_clock_disable() callback is provided if the platform doesn't support system clock disable capability.
- bootutil: Close flash_area after failure to read swap status information
- fixed status offset calculation in case of scratch area
- fixed include path for reboot.h header.

Merged using GitHub web gui

Signed-off-by: default avatarAndrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
parents 33906b47 1eedec3e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@
#include "cbor_encode.h"

#ifdef __ZEPHYR__
#include <power/reboot.h>
#include <sys/reboot.h>
#include <sys/byteorder.h>
#include <sys/__assert.h>
#include <drivers/flash.h>
+55 −13
Original line number Diff line number Diff line
@@ -94,18 +94,15 @@ out:
}
#endif

uint32_t
boot_status_sz(uint32_t min_write_sz)
{
    return /* state for all sectors */
           BOOT_STATUS_MAX_ENTRIES * BOOT_STATUS_STATE_COUNT * min_write_sz;
}

uint32_t
boot_trailer_sz(uint32_t min_write_sz)
/*
 * Amount of space used to save information required when doing a swap,
 * or while a swap is under progress, but not the status of sector swap
 * progress itself.
 */
static inline uint32_t
boot_trailer_info_sz(void)
{
    return /* state for all sectors */
           boot_status_sz(min_write_sz)           +
    return (
#ifdef MCUBOOT_ENC_IMAGES
           /* encryption keys */
#  if MCUBOOT_SWAP_SAVE_ENCTLV
@@ -116,9 +113,46 @@ boot_trailer_sz(uint32_t min_write_sz)
#endif
           /* swap_type + copy_done + image_ok + swap_size */
           BOOT_MAX_ALIGN * 4                     +
           BOOT_MAGIC_SZ;
           BOOT_MAGIC_SZ
           );
}

/*
 * Amount of space used to maintain progress information for a single swap
 * operation.
 */
static inline uint32_t
boot_status_entry_sz(uint32_t min_write_sz)
{
    return BOOT_STATUS_STATE_COUNT * min_write_sz;
}

uint32_t
boot_status_sz(uint32_t min_write_sz)
{
    return BOOT_STATUS_MAX_ENTRIES * boot_status_entry_sz(min_write_sz);
}

uint32_t
boot_trailer_sz(uint32_t min_write_sz)
{
    return boot_status_sz(min_write_sz) + boot_trailer_info_sz();
}

#if MCUBOOT_SWAP_USING_SCRATCH
/*
 * Similar to `boot_trailer_sz` but this function returns the space used to
 * store status in the scratch partition. The scratch partition only stores
 * status during the swap of the last sector from primary/secondary (which
 * is the first swap operation) and thus only requires space for one swap.
 */
static uint32_t
boot_scratch_trailer_sz(uint32_t min_write_sz)
{
    return boot_status_entry_sz(min_write_sz) + boot_trailer_info_sz();
}
#endif

int
boot_status_entries(int image_index, const struct flash_area *fap)
{
@@ -142,7 +176,15 @@ boot_status_off(const struct flash_area *fap)

    elem_sz = flash_area_align(fap);

#if MCUBOOT_SWAP_USING_SCRATCH
    if (fap->fa_id == FLASH_AREA_IMAGE_SCRATCH) {
        off_from_end = boot_scratch_trailer_sz(elem_sz);
    } else {
#endif
        off_from_end = boot_trailer_sz(elem_sz);
#if MCUBOOT_SWAP_USING_SCRATCH
    }
#endif

    assert(off_from_end <= flash_area_get_size(fap));
    return flash_area_get_size(fap) - off_from_end;
+3 −1
Original line number Diff line number Diff line
@@ -166,7 +166,8 @@ swap_read_status(struct boot_loader_state *state, struct boot_status *bs)
        off = boot_swap_info_off(fap);
        rc = flash_area_read(fap, off, &swap_info, sizeof swap_info);
        if (rc != 0) {
            return BOOT_EFLASH;
            rc = BOOT_EFLASH;
            goto done;
        }

        if (bootutil_buffer_is_erased(fap, &swap_info, sizeof swap_info)) {
@@ -178,6 +179,7 @@ swap_read_status(struct boot_loader_state *state, struct boot_status *bs)
        bs->swap_type = BOOT_GET_SWAP_TYPE(swap_info);
    }

done:
    flash_area_close(fap);

    return rc;
+1 −11
Original line number Diff line number Diff line
# Copyright (c) 2021 Espressif Systems (Shanghai) Co., Ltd.
# SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
#
# SPDX-License-Identifier: Apache-2.0

@@ -37,16 +37,6 @@ execute_process(
    )
add_definitions(-DMCUBOOT_VER=\"${MCUBOOT_VER}\")

execute_process(
    COMMAND git describe --tags
    WORKING_DIRECTORY ${IDF_PATH}
    OUTPUT_VARIABLE IDF_VER
    OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (NOT "${IDF_VER}" MATCHES "v4.3")
    message(FATAL_ERROR "Unsupported ESP-IDF version found in IDF_PATH, please checkout to v4.3")
endif()

if (DEFINED MCUBOOT_CONFIG_FILE)
    set(mcuboot_config_file ${MCUBOOT_CONFIG_FILE})
else()
+12 −1
Original line number Diff line number Diff line
# Copyright (c) 2021 Espressif Systems (Shanghai) Co., Ltd.
# SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
#
# SPDX-License-Identifier: Apache-2.0

@@ -23,3 +23,14 @@ CONFIG_ESP_SCRATCH_SIZE=0x40000
# It is strongly recommended to generate a new signing key
# using imgtool instead of use the existent sample
# CONFIG_ESP_SIGN_KEY_FILE=root-ec-p256.pem

# Hardware Secure Boot related options
# CONFIG_SECURE_SIGNED_ON_BOOT=1
# CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME=1
# CONFIG_SECURE_BOOT=1
# CONFIG_SECURE_BOOT_V2_ENABLED=1
# CONFIG_SECURE_BOOT_SUPPORTS_RSA=1

# Options for enabling eFuse emulation in Flash
# CONFIG_EFUSE_VIRTUAL=1
# CONFIG_EFUSE_VIRTUAL_KEEP_IN_FLASH=1
Loading