Skip to content

Commit 2fce976

Browse files
authored
Merge: synchronized up to mcu-tools/mcuboot@9b97456
Synch up to: mcu-tools/mcuboot@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]>
2 parents 3ad36f8 + 9b97456 commit 2fce976

File tree

24 files changed

+152
-66
lines changed

24 files changed

+152
-66
lines changed

.github/workflows/imgtool.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
on:
22
push:
33
branches:
4-
- master
4+
- main
55
- v*-branch
66

77
name: imgtool

.github/workflows/mynewt.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
on:
33
push:
44
branches:
5-
- master
5+
- main
66
pull_request:
77

88
name: Mynewt

.github/workflows/sim.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
on:
33
push:
44
branches:
5-
- master
5+
- main
66
pull_request:
77

88
name: Sim

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Build Status (Sim)](https://github.com/mcu-tools/mcuboot/workflows/Sim/badge.svg)][sim]
66
[![Build Status (Mynewt)](https://github.com/mcu-tools/mcuboot/workflows/Mynewt/badge.svg)][mynewt]
77
[![Publishing Status (imgtool)](https://github.com/mcu-tools/mcuboot/workflows/imgtool/badge.svg)][imgtool]
8-
[![Build Status (Travis CI)](https://img.shields.io/travis/mcu-tools/mcuboot/master.svg?label=travis-ci)][travis]
8+
[![Build Status (Travis CI)](https://img.shields.io/travis/mcu-tools/mcuboot/main.svg?label=travis-ci)][travis]
99
[![Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)][license]
1010

1111
[pypi]: https://pypi.org/project/imgtool/
@@ -14,7 +14,7 @@
1414
[mynewt]: https://github.com/mcu-tools/mcuboot/actions?query=workflow:Mynewt
1515
[imgtool]: https://github.com/mcu-tools/mcuboot/actions?query=workflow:imgtool
1616
[travis]: https://travis-ci.org/mcu-tools/mcuboot
17-
[license]: https://github.com/mcu-tools/mcuboot/blob/master/LICENSE
17+
[license]: https://github.com/mcu-tools/mcuboot/blob/main/LICENSE
1818

1919
This is mcuboot version 1.8.0-dev
2020

boot/boot_serial/src/boot_serial.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,11 @@ bs_reset(char *buf, int len)
436436
bs_empty_rsp(buf, len);
437437

438438
#ifdef __ZEPHYR__
439+
#ifdef CONFIG_MULTITHREADING
439440
k_sleep(K_MSEC(250));
441+
#else
442+
k_busy_wait(250000);
443+
#endif
440444
sys_reboot(SYS_REBOOT_COLD);
441445
#else
442446
os_cputime_delay_usecs(250000);

boot/bootutil/include/bootutil/bootutil_public.h

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2017-2019 Linaro LTD
55
* Copyright (c) 2016-2019 JUUL Labs
6-
* Copyright (c) 2019-2020 Arm Limited
6+
* Copyright (c) 2019-2021 Arm Limited
77
* Copyright (c) 2020 Nordic Semiconductor ASA
88
*
99
* Original license:
@@ -147,25 +147,54 @@ int boot_swap_type_multi(int image_index);
147147
int boot_swap_type(void);
148148

149149
/**
150-
* Marks the image in the secondary slot as pending. On the next reboot,
151-
* the system will perform a one-time boot of the the secondary slot image.
150+
* Marks the image with the given index in the secondary slot as pending. On the
151+
* next reboot, the system will perform a one-time boot of the the secondary
152+
* slot image.
152153
*
153-
* @param permanent Whether the image should be used permanently or
154-
* only tested once:
155-
* 0=run image once, then confirm or revert.
156-
* 1=run image forever.
154+
* @param image_index Image pair index.
157155
*
158-
* @return 0 on success; nonzero on failure.
156+
* @param permanent Whether the image should be used permanently or
157+
* only tested once:
158+
* 0=run image once, then confirm or revert.
159+
* 1=run image forever.
160+
*
161+
* @return 0 on success; nonzero on failure.
162+
*/
163+
int boot_set_pending_multi(int image_index, int permanent);
164+
165+
/**
166+
* Marks the image with index 0 in the secondary slot as pending. On the next
167+
* reboot, the system will perform a one-time boot of the the secondary slot
168+
* image. Note that this API is kept for compatibility. The
169+
* boot_set_pending_multi() API is recommended.
170+
*
171+
* @param permanent Whether the image should be used permanently or
172+
* only tested once:
173+
* 0=run image once, then confirm or revert.
174+
* 1=run image forever.
175+
*
176+
* @return 0 on success; nonzero on failure.
159177
*/
160178
int boot_set_pending(int permanent);
161179

162180
/**
163-
* @brief Marks the image in the primary slot as confirmed.
181+
* Marks the image with the given index in the primary slot as confirmed. The
182+
* system will continue booting into the image in the primary slot until told to
183+
* boot from a different slot.
164184
*
165-
* The system will continue booting into the image in the primary slot until
166-
* told to boot from a different slot.
185+
* @param image_index Image pair index.
167186
*
168-
* @return 0 on success; nonzero on failure.
187+
* @return 0 on success; nonzero on failure.
188+
*/
189+
int boot_set_confirmed_multi(int image_index);
190+
191+
/**
192+
* Marks the image with index 0 in the primary slot as confirmed. The system
193+
* will continue booting into the image in the primary slot until told to boot
194+
* from a different slot. Note that this API is kept for compatibility. The
195+
* boot_set_confirmed_multi() API is recommended.
196+
*
197+
* @return 0 on success; nonzero on failure.
169198
*/
170199
int boot_set_confirmed(void);
171200

boot/bootutil/src/bootutil_public.c

Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2017-2019 Linaro LTD
55
* Copyright (c) 2016-2019 JUUL Labs
6-
* Copyright (c) 2019-2020 Arm Limited
6+
* Copyright (c) 2019-2021 Arm Limited
77
* Copyright (c) 2020 Nordic Semiconductor ASA
88
*
99
* Original license:
@@ -471,25 +471,28 @@ boot_swap_type(void)
471471
}
472472

473473
/**
474-
* Marks the image in the secondary slot as pending. On the next reboot,
475-
* the system will perform a one-time boot of the the secondary slot image.
474+
* Marks the image with the given index in the secondary slot as pending. On the
475+
* next reboot, the system will perform a one-time boot of the the secondary
476+
* slot image.
477+
*
478+
* @param image_index Image pair index.
476479
*
477480
* @param permanent Whether the image should be used permanently or
478-
* only tested once:
479-
* 0=run image once, then confirm or revert.
480-
* 1=run image forever.
481+
* only tested once:
482+
* 0=run image once, then confirm or revert.
483+
* 1=run image forever.
481484
*
482485
* @return 0 on success; nonzero on failure.
483486
*/
484487
int
485-
boot_set_pending(int permanent)
488+
boot_set_pending_multi(int image_index, int permanent)
486489
{
487490
const struct flash_area *fap;
488491
struct boot_swap_state state_secondary_slot;
489492
uint8_t swap_type;
490493
int rc;
491494

492-
rc = boot_read_swap_state_by_id(FLASH_AREA_IMAGE_SECONDARY(0),
495+
rc = boot_read_swap_state_by_id(FLASH_AREA_IMAGE_SECONDARY(image_index),
493496
&state_secondary_slot);
494497
if (rc != 0) {
495498
return rc;
@@ -501,7 +504,7 @@ boot_set_pending(int permanent)
501504
return 0;
502505

503506
case BOOT_MAGIC_UNSET:
504-
rc = flash_area_open(FLASH_AREA_IMAGE_SECONDARY(0), &fap);
507+
rc = flash_area_open(FLASH_AREA_IMAGE_SECONDARY(image_index), &fap);
505508
if (rc != 0) {
506509
rc = BOOT_EFLASH;
507510
} else {
@@ -528,7 +531,7 @@ boot_set_pending(int permanent)
528531
/* The image slot is corrupt. There is no way to recover, so erase the
529532
* slot to allow future upgrades.
530533
*/
531-
rc = flash_area_open(FLASH_AREA_IMAGE_SECONDARY(0), &fap);
534+
rc = flash_area_open(FLASH_AREA_IMAGE_SECONDARY(image_index), &fap);
532535
if (rc != 0) {
533536
return BOOT_EFLASH;
534537
}
@@ -544,20 +547,41 @@ boot_set_pending(int permanent)
544547
}
545548

546549
/**
547-
* Marks the image in the primary slot as confirmed. The system will continue
548-
* booting into the image in the primary slot until told to boot from a
549-
* different slot.
550+
* Marks the image with index 0 in the secondary slot as pending. On the next
551+
* reboot, the system will perform a one-time boot of the the secondary slot
552+
* image. Note that this API is kept for compatibility. The
553+
* boot_set_pending_multi() API is recommended.
554+
*
555+
* @param permanent Whether the image should be used permanently or
556+
* only tested once:
557+
* 0=run image once, then confirm or revert.
558+
* 1=run image forever.
550559
*
551560
* @return 0 on success; nonzero on failure.
552561
*/
553562
int
554-
boot_set_confirmed(void)
563+
boot_set_pending(int permanent)
564+
{
565+
return boot_set_pending_multi(0, permanent);
566+
}
567+
568+
/**
569+
* Marks the image with the given index in the primary slot as confirmed. The
570+
* system will continue booting into the image in the primary slot until told to
571+
* boot from a different slot.
572+
*
573+
* @param image_index Image pair index.
574+
*
575+
* @return 0 on success; nonzero on failure.
576+
*/
577+
int
578+
boot_set_confirmed_multi(int image_index)
555579
{
556580
const struct flash_area *fap;
557581
struct boot_swap_state state_primary_slot;
558582
int rc;
559583

560-
rc = boot_read_swap_state_by_id(FLASH_AREA_IMAGE_PRIMARY(0),
584+
rc = boot_read_swap_state_by_id(FLASH_AREA_IMAGE_PRIMARY(image_index),
561585
&state_primary_slot);
562586
if (rc != 0) {
563587
return rc;
@@ -577,7 +601,7 @@ boot_set_confirmed(void)
577601
return BOOT_EBADVECT;
578602
}
579603

580-
rc = flash_area_open(FLASH_AREA_IMAGE_PRIMARY(0), &fap);
604+
rc = flash_area_open(FLASH_AREA_IMAGE_PRIMARY(image_index), &fap);
581605
if (rc) {
582606
rc = BOOT_EFLASH;
583607
goto done;
@@ -599,3 +623,17 @@ boot_set_confirmed(void)
599623
flash_area_close(fap);
600624
return rc;
601625
}
626+
627+
/**
628+
* Marks the image with index 0 in the primary slot as confirmed. The system
629+
* will continue booting into the image in the primary slot until told to boot
630+
* from a different slot. Note that this API is kept for compatibility. The
631+
* boot_set_confirmed_multi() API is recommended.
632+
*
633+
* @return 0 on success; nonzero on failure.
634+
*/
635+
int
636+
boot_set_confirmed(void)
637+
{
638+
return boot_set_confirmed_multi(0);
639+
}

boot/bootutil/src/loader.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2365,6 +2365,9 @@ context_boot_go(struct boot_loader_state *state, struct boot_rsp *rsp)
23652365
}
23662366
}
23672367

2368+
/* Reset rc since we use it above for boot_version_cmp */
2369+
rc = 0;
2370+
23682371
#ifdef MCUBOOT_DIRECT_XIP_REVERT
23692372
rc = boot_select_or_erase(&slot_state, selected_slot);
23702373
if (rc != 0) {

boot/bootutil/src/swap_scratch.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,9 @@ int
364364
swap_status_source(struct boot_loader_state *state)
365365
{
366366
const struct boot_status_table *table;
367+
#if MCUBOOT_SWAP_USING_SCRATCH
367368
struct boot_swap_state state_scratch;
369+
#endif
368370
struct boot_swap_state state_primary_slot;
369371
int rc;
370372
size_t i;
@@ -380,25 +382,30 @@ swap_status_source(struct boot_loader_state *state)
380382
&state_primary_slot);
381383
assert(rc == 0);
382384

385+
#if MCUBOOT_SWAP_USING_SCRATCH
383386
rc = boot_read_swap_state_by_id(FLASH_AREA_IMAGE_SCRATCH, &state_scratch);
384387
assert(rc == 0);
388+
#endif
385389

386390
BOOT_LOG_SWAP_STATE("Primary image", &state_primary_slot);
391+
#if MCUBOOT_SWAP_USING_SCRATCH
387392
BOOT_LOG_SWAP_STATE("Scratch", &state_scratch);
388-
393+
#endif
389394
for (i = 0; i < BOOT_STATUS_TABLES_COUNT; i++) {
390395
table = &boot_status_tables[i];
391396

392397
if (boot_magic_compatible_check(table->bst_magic_primary_slot,
393398
state_primary_slot.magic) &&
399+
#if MCUBOOT_SWAP_USING_SCRATCH
394400
boot_magic_compatible_check(table->bst_magic_scratch,
395401
state_scratch.magic) &&
402+
#endif
396403
(table->bst_copy_done_primary_slot == BOOT_FLAG_ANY ||
397404
table->bst_copy_done_primary_slot == state_primary_slot.copy_done))
398405
{
399406
source = table->bst_status_source;
400407

401-
#if (BOOT_IMAGE_NUMBER > 1)
408+
#if (BOOT_IMAGE_NUMBER > 1) && MCUBOOT_SWAP_USING_SCRATCH
402409
/* In case of multi-image boot it can happen that if boot status
403410
* info is found on scratch area then it does not belong to the
404411
* currently examined image.

boot/mbed/app_enc_keys.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ extern unsigned int ecdsa_pub_key_len;
3030
#define HAVE_KEYS
3131
extern const unsigned char ed25519_pub_key[];
3232
extern unsigned int ed25519_pub_key_len;
33-
#else
34-
#error "No public key available for given signing algorithm."
3533
#endif
3634

3735
/*

0 commit comments

Comments
 (0)