Skip to content

Commit

Permalink
Merge: synchronized up to mcu-tools@9b97456
Browse files Browse the repository at this point in the history
Synch up to:
mcu-tools@9b97456eb2

- boot_serial: allow to build when CONFIG_MULTITHREADING=n
- allow to not provide scratch area definition if scratch algorithm is not used.

Merged by GH GUI

Signed-off-by: Andrzej Puzdrowski <[email protected]>
  • Loading branch information
nvlsianpu authored May 18, 2021
2 parents 3ad36f8 + 9b97456 commit 2fce976
Show file tree
Hide file tree
Showing 24 changed files with 152 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/imgtool.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
on:
push:
branches:
- master
- main
- v*-branch

name: imgtool
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mynewt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
on:
push:
branches:
- master
- main
pull_request:

name: Mynewt
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
on:
push:
branches:
- master
- main
pull_request:

name: Sim
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Build Status (Sim)](https:/mcu-tools/mcuboot/workflows/Sim/badge.svg)][sim]
[![Build Status (Mynewt)](https:/mcu-tools/mcuboot/workflows/Mynewt/badge.svg)][mynewt]
[![Publishing Status (imgtool)](https:/mcu-tools/mcuboot/workflows/imgtool/badge.svg)][imgtool]
[![Build Status (Travis CI)](https://img.shields.io/travis/mcu-tools/mcuboot/master.svg?label=travis-ci)][travis]
[![Build Status (Travis CI)](https://img.shields.io/travis/mcu-tools/mcuboot/main.svg?label=travis-ci)][travis]
[![Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)][license]

[pypi]: https://pypi.org/project/imgtool/
Expand All @@ -14,7 +14,7 @@
[mynewt]: https:/mcu-tools/mcuboot/actions?query=workflow:Mynewt
[imgtool]: https:/mcu-tools/mcuboot/actions?query=workflow:imgtool
[travis]: https://travis-ci.org/mcu-tools/mcuboot
[license]: https:/mcu-tools/mcuboot/blob/master/LICENSE
[license]: https:/mcu-tools/mcuboot/blob/main/LICENSE

This is mcuboot version 1.8.0-dev

Expand Down
4 changes: 4 additions & 0 deletions boot/boot_serial/src/boot_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,11 @@ bs_reset(char *buf, int len)
bs_empty_rsp(buf, len);

#ifdef __ZEPHYR__
#ifdef CONFIG_MULTITHREADING
k_sleep(K_MSEC(250));
#else
k_busy_wait(250000);
#endif
sys_reboot(SYS_REBOOT_COLD);
#else
os_cputime_delay_usecs(250000);
Expand Down
53 changes: 41 additions & 12 deletions boot/bootutil/include/bootutil/bootutil_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Copyright (c) 2017-2019 Linaro LTD
* Copyright (c) 2016-2019 JUUL Labs
* Copyright (c) 2019-2020 Arm Limited
* Copyright (c) 2019-2021 Arm Limited
* Copyright (c) 2020 Nordic Semiconductor ASA
*
* Original license:
Expand Down Expand Up @@ -147,25 +147,54 @@ int boot_swap_type_multi(int image_index);
int boot_swap_type(void);

/**
* Marks the image in the secondary slot as pending. On the next reboot,
* the system will perform a one-time boot of the the secondary slot image.
* Marks the image with the given index in the secondary slot as pending. On the
* next reboot, the system will perform a one-time boot of the the secondary
* slot image.
*
* @param permanent Whether the image should be used permanently or
* only tested once:
* 0=run image once, then confirm or revert.
* 1=run image forever.
* @param image_index Image pair index.
*
* @return 0 on success; nonzero on failure.
* @param permanent Whether the image should be used permanently or
* only tested once:
* 0=run image once, then confirm or revert.
* 1=run image forever.
*
* @return 0 on success; nonzero on failure.
*/
int boot_set_pending_multi(int image_index, int permanent);

/**
* Marks the image with index 0 in the secondary slot as pending. On the next
* reboot, the system will perform a one-time boot of the the secondary slot
* image. Note that this API is kept for compatibility. The
* boot_set_pending_multi() API is recommended.
*
* @param permanent Whether the image should be used permanently or
* only tested once:
* 0=run image once, then confirm or revert.
* 1=run image forever.
*
* @return 0 on success; nonzero on failure.
*/
int boot_set_pending(int permanent);

/**
* @brief Marks the image in the primary slot as confirmed.
* Marks the image with the given index in the primary slot as confirmed. The
* system will continue booting into the image in the primary slot until told to
* boot from a different slot.
*
* The system will continue booting into the image in the primary slot until
* told to boot from a different slot.
* @param image_index Image pair index.
*
* @return 0 on success; nonzero on failure.
* @return 0 on success; nonzero on failure.
*/
int boot_set_confirmed_multi(int image_index);

/**
* Marks the image with index 0 in the primary slot as confirmed. The system
* will continue booting into the image in the primary slot until told to boot
* from a different slot. Note that this API is kept for compatibility. The
* boot_set_confirmed_multi() API is recommended.
*
* @return 0 on success; nonzero on failure.
*/
int boot_set_confirmed(void);

Expand Down
70 changes: 54 additions & 16 deletions boot/bootutil/src/bootutil_public.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Copyright (c) 2017-2019 Linaro LTD
* Copyright (c) 2016-2019 JUUL Labs
* Copyright (c) 2019-2020 Arm Limited
* Copyright (c) 2019-2021 Arm Limited
* Copyright (c) 2020 Nordic Semiconductor ASA
*
* Original license:
Expand Down Expand Up @@ -471,25 +471,28 @@ boot_swap_type(void)
}

/**
* Marks the image in the secondary slot as pending. On the next reboot,
* the system will perform a one-time boot of the the secondary slot image.
* Marks the image with the given index in the secondary slot as pending. On the
* next reboot, the system will perform a one-time boot of the the secondary
* slot image.
*
* @param image_index Image pair index.
*
* @param permanent Whether the image should be used permanently or
* only tested once:
* 0=run image once, then confirm or revert.
* 1=run image forever.
* only tested once:
* 0=run image once, then confirm or revert.
* 1=run image forever.
*
* @return 0 on success; nonzero on failure.
*/
int
boot_set_pending(int permanent)
boot_set_pending_multi(int image_index, int permanent)
{
const struct flash_area *fap;
struct boot_swap_state state_secondary_slot;
uint8_t swap_type;
int rc;

rc = boot_read_swap_state_by_id(FLASH_AREA_IMAGE_SECONDARY(0),
rc = boot_read_swap_state_by_id(FLASH_AREA_IMAGE_SECONDARY(image_index),
&state_secondary_slot);
if (rc != 0) {
return rc;
Expand All @@ -501,7 +504,7 @@ boot_set_pending(int permanent)
return 0;

case BOOT_MAGIC_UNSET:
rc = flash_area_open(FLASH_AREA_IMAGE_SECONDARY(0), &fap);
rc = flash_area_open(FLASH_AREA_IMAGE_SECONDARY(image_index), &fap);
if (rc != 0) {
rc = BOOT_EFLASH;
} else {
Expand All @@ -528,7 +531,7 @@ boot_set_pending(int permanent)
/* The image slot is corrupt. There is no way to recover, so erase the
* slot to allow future upgrades.
*/
rc = flash_area_open(FLASH_AREA_IMAGE_SECONDARY(0), &fap);
rc = flash_area_open(FLASH_AREA_IMAGE_SECONDARY(image_index), &fap);
if (rc != 0) {
return BOOT_EFLASH;
}
Expand All @@ -544,20 +547,41 @@ boot_set_pending(int permanent)
}

/**
* Marks the image in the primary slot as confirmed. The system will continue
* booting into the image in the primary slot until told to boot from a
* different slot.
* Marks the image with index 0 in the secondary slot as pending. On the next
* reboot, the system will perform a one-time boot of the the secondary slot
* image. Note that this API is kept for compatibility. The
* boot_set_pending_multi() API is recommended.
*
* @param permanent Whether the image should be used permanently or
* only tested once:
* 0=run image once, then confirm or revert.
* 1=run image forever.
*
* @return 0 on success; nonzero on failure.
*/
int
boot_set_confirmed(void)
boot_set_pending(int permanent)
{
return boot_set_pending_multi(0, permanent);
}

/**
* Marks the image with the given index in the primary slot as confirmed. The
* system will continue booting into the image in the primary slot until told to
* boot from a different slot.
*
* @param image_index Image pair index.
*
* @return 0 on success; nonzero on failure.
*/
int
boot_set_confirmed_multi(int image_index)
{
const struct flash_area *fap;
struct boot_swap_state state_primary_slot;
int rc;

rc = boot_read_swap_state_by_id(FLASH_AREA_IMAGE_PRIMARY(0),
rc = boot_read_swap_state_by_id(FLASH_AREA_IMAGE_PRIMARY(image_index),
&state_primary_slot);
if (rc != 0) {
return rc;
Expand All @@ -577,7 +601,7 @@ boot_set_confirmed(void)
return BOOT_EBADVECT;
}

rc = flash_area_open(FLASH_AREA_IMAGE_PRIMARY(0), &fap);
rc = flash_area_open(FLASH_AREA_IMAGE_PRIMARY(image_index), &fap);
if (rc) {
rc = BOOT_EFLASH;
goto done;
Expand All @@ -599,3 +623,17 @@ boot_set_confirmed(void)
flash_area_close(fap);
return rc;
}

/**
* Marks the image with index 0 in the primary slot as confirmed. The system
* will continue booting into the image in the primary slot until told to boot
* from a different slot. Note that this API is kept for compatibility. The
* boot_set_confirmed_multi() API is recommended.
*
* @return 0 on success; nonzero on failure.
*/
int
boot_set_confirmed(void)
{
return boot_set_confirmed_multi(0);
}
3 changes: 3 additions & 0 deletions boot/bootutil/src/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -2365,6 +2365,9 @@ context_boot_go(struct boot_loader_state *state, struct boot_rsp *rsp)
}
}

/* Reset rc since we use it above for boot_version_cmp */
rc = 0;

#ifdef MCUBOOT_DIRECT_XIP_REVERT
rc = boot_select_or_erase(&slot_state, selected_slot);
if (rc != 0) {
Expand Down
11 changes: 9 additions & 2 deletions boot/bootutil/src/swap_scratch.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,9 @@ int
swap_status_source(struct boot_loader_state *state)
{
const struct boot_status_table *table;
#if MCUBOOT_SWAP_USING_SCRATCH
struct boot_swap_state state_scratch;
#endif
struct boot_swap_state state_primary_slot;
int rc;
size_t i;
Expand All @@ -380,25 +382,30 @@ swap_status_source(struct boot_loader_state *state)
&state_primary_slot);
assert(rc == 0);

#if MCUBOOT_SWAP_USING_SCRATCH
rc = boot_read_swap_state_by_id(FLASH_AREA_IMAGE_SCRATCH, &state_scratch);
assert(rc == 0);
#endif

BOOT_LOG_SWAP_STATE("Primary image", &state_primary_slot);
#if MCUBOOT_SWAP_USING_SCRATCH
BOOT_LOG_SWAP_STATE("Scratch", &state_scratch);

#endif
for (i = 0; i < BOOT_STATUS_TABLES_COUNT; i++) {
table = &boot_status_tables[i];

if (boot_magic_compatible_check(table->bst_magic_primary_slot,
state_primary_slot.magic) &&
#if MCUBOOT_SWAP_USING_SCRATCH
boot_magic_compatible_check(table->bst_magic_scratch,
state_scratch.magic) &&
#endif
(table->bst_copy_done_primary_slot == BOOT_FLAG_ANY ||
table->bst_copy_done_primary_slot == state_primary_slot.copy_done))
{
source = table->bst_status_source;

#if (BOOT_IMAGE_NUMBER > 1)
#if (BOOT_IMAGE_NUMBER > 1) && MCUBOOT_SWAP_USING_SCRATCH
/* In case of multi-image boot it can happen that if boot status
* info is found on scratch area then it does not belong to the
* currently examined image.
Expand Down
2 changes: 0 additions & 2 deletions boot/mbed/app_enc_keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ extern unsigned int ecdsa_pub_key_len;
#define HAVE_KEYS
extern const unsigned char ed25519_pub_key[];
extern unsigned int ed25519_pub_key_len;
#else
#error "No public key available for given signing algorithm."
#endif

/*
Expand Down
1 change: 1 addition & 0 deletions boot/mbed/include/mcuboot_config/mcuboot_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define SIGNATURE_TYPE_RSA 0
#define SIGNATURE_TYPE_EC256 1
#define SIGNATURE_TYPE_ED25519 2
#define SIGNATURE_TYPE_NONE 3

/*
* Signature algorithm
Expand Down
8 changes: 1 addition & 7 deletions boot/mbed/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@
"help": "Size of the scratch area, in bytes. If needed, please set on a per-target basis.",
"macro_name": "MCUBOOT_SCRATCH_SIZE"
},
"header-size": {
"help": "Header size, in bytes, prepended to the bootable application image. Should be one or multiple times the sector size.",
"macro_name": "MCUBOOT_HEADER_SIZE",
"required": true,
"value": 4096
},
"validate-primary-slot": {
"help": "Always check the signature of the image in the primary slot before booting, even if no upgrade was performed. This is recommended if the boot time penalty is acceptable.",
"macro_name": "MCUBOOT_VALIDATE_PRIMARY_SLOT",
Expand All @@ -41,7 +35,7 @@
"help": "The algorithm used for digital signing.",
"macro_name": "MCUBOOT_SIGNATURE_ALGORITHM",
"required": true,
"accepted_values": ["SIGNATURE_TYPE_RSA", "SIGNATURE_TYPE_EC256", "SIGNATURE_TYPE_ED25519"],
"accepted_values": ["SIGNATURE_TYPE_RSA", "SIGNATURE_TYPE_EC256", "SIGNATURE_TYPE_ED25519", "SIGNATURE_TYPE_NONE"],
"value": "SIGNATURE_TYPE_RSA"
},
"rsa-signature-length": {
Expand Down
1 change: 1 addition & 0 deletions boot/zephyr/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ config BOOT_USB_DFU_DETECT_PIN
default 11 if BOARD_NRF52840DK_NRF52840
default 13 if BOARD_NRF52DK_NRF52832
default 23 if BOARD_NRF5340_DK_NRF5340_CPUAPP || BOARD_NRF5340_DK_NRF5340_CPUAPPNS
default 43 if BOARD_BL5340_DVK_CPUAPP || BOARD_BL5340_DVK_CPUAPPNS
help
Pin on the DFU detect port that triggers DFU mode.

Expand Down
4 changes: 2 additions & 2 deletions boot/zephyr/flash_map_extended.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ int flash_area_id_from_multi_image_slot(int image_index, int slot)
case 0: return FLASH_AREA_IMAGE_PRIMARY(image_index);
#if !defined(CONFIG_SINGLE_APPLICATION_SLOT)
case 1: return FLASH_AREA_IMAGE_SECONDARY(image_index);
#if !defined(CONFIG_BOOT_SWAP_USING_MOVE)
case 2: return FLASH_AREA_IMAGE_SCRATCH;
#endif
#if defined(CONFIG_BOOT_SWAP_USING_SCRATCH)
case 2: return FLASH_AREA_IMAGE_SCRATCH;
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion boot/zephyr/include/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
!defined(FLASH_ALIGN) || \
!(FLASH_AREA_LABEL_EXISTS(image_0)) || \
!(FLASH_AREA_LABEL_EXISTS(image_1) || CONFIG_SINGLE_APPLICATION_SLOT) || \
(!defined(CONFIG_BOOT_SWAP_USING_MOVE) && !FLASH_AREA_LABEL_EXISTS(image_scratch) && !defined(CONFIG_SINGLE_APPLICATION_SLOT))
(defined(CONFIG_BOOT_SWAP_USING_SCRATCH) && !FLASH_AREA_LABEL_EXISTS(image_scratch))
#error "Target support is incomplete; cannot build mcuboot."
#endif

Expand Down
Loading

0 comments on commit 2fce976

Please sign in to comment.