Skip to content

Commit e6dc18f

Browse files
mcuboot: Update to 1.7.0-rc1
Signed-off-by: Øyvind Rønningstad <[email protected]>
1 parent a683f73 commit e6dc18f

File tree

124 files changed

+5700
-1798
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+5700
-1798
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# For development, trigger this on any push.
2+
on: [pull_request]
3+
4+
jobs:
5+
environment:
6+
name: Mynewt build
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
with:
11+
fetch-depth: 0
12+
- name: Print the environment
13+
run: |
14+
uname -a
15+
lscpu
16+
free
17+
pwd
18+
- name: Signed commit check
19+
run: |
20+
./ci/check-signed-off-by.sh
21+
- name: Mynewt install
22+
run: |
23+
./ci/mynewt_install.sh
24+
- name: Mynewt run
25+
run: |
26+
./ci/mynewt_run.sh

mcuboot/.github/workflows/sim.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# For development, trigger this on any push.
2+
on: [pull_request]
3+
4+
jobs:
5+
environment:
6+
strategy:
7+
matrix:
8+
features:
9+
- "sig-ecdsa,sig-ed25519,enc-kw,bootstrap"
10+
- "sig-rsa,sig-rsa3072,overwrite-only,validate-primary-slot,swap-move"
11+
- "enc-rsa"
12+
- "enc-ec256"
13+
- "enc-x25519"
14+
- "sig-rsa overwrite-only large-write,sig-ecdsa overwrite-only large-write,multiimage overwrite-only large-write"
15+
- "sig-rsa validate-primary-slot,sig-ecdsa validate-primary-slot,sig-rsa multiimage validate-primary-slot"
16+
- "enc-kw overwrite-only large-write,enc-rsa overwrite-only large-write"
17+
- "sig-rsa enc-rsa validate-primary-slot,swap-move enc-rsa sig-rsa validate-primary-slot bootstrap"
18+
- "sig-rsa enc-kw validate-primary-slot bootstrap,sig-ed25519 enc-x25519 validate-primary-slot"
19+
- "sig-ecdsa enc-kw validate-primary-slot"
20+
- "sig-rsa validate-primary-slot overwrite-only large-write"
21+
- "sig-ecdsa enc-ec256 validate-primary-slot"
22+
- "sig-rsa validate-primary-slot overwrite-only downgrade-prevention"
23+
name: Sim
24+
runs-on: ubuntu-latest
25+
env:
26+
MULTI_FEATURES: ${{ matrix.features }}
27+
steps:
28+
- uses: actions/checkout@v2
29+
with:
30+
fetch-depth: 0
31+
submodules: recursive
32+
- name: Print the environment
33+
run: |
34+
uname -a
35+
lscpu
36+
free
37+
pwd
38+
- name: Signed commit check
39+
run: |
40+
./ci/check-signed-off-by.sh
41+
- name: Install stable Rust
42+
uses: actions-rs/toolchain@v1
43+
with:
44+
toolchain: stable
45+
- name: Sim install
46+
run: |
47+
./ci/sim_install.sh
48+
- name: Sim run
49+
run: |
50+
./ci/sim_run.sh

mcuboot/.travis.yml

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,39 +16,39 @@ matrix:
1616
include:
1717
# Runs each value defined in $SINGLE_FEATURES by itself in the order
1818
# the were defined.
19-
- os: linux
20-
env: SINGLE_FEATURES="sig-ecdsa sig-ed25519 enc-kw bootstrap" TEST=sim
21-
- os: linux
22-
env: SINGLE_FEATURES="none sig-rsa sig-rsa3072 overwrite-only validate-primary-slot swap-move" TEST=sim
23-
- os: linux
24-
env: SINGLE_FEATURES="enc-rsa enc-ec256 enc-x25519" TEST=sim
19+
# - os: linux
20+
# env: SINGLE_FEATURES="sig-ecdsa sig-ed25519 enc-kw bootstrap" TEST=sim
21+
# - os: linux
22+
# env: SINGLE_FEATURES="none sig-rsa sig-rsa3072 overwrite-only validate-primary-slot swap-move" TEST=sim
23+
# - os: linux
24+
# env: SINGLE_FEATURES="enc-rsa enc-ec256 enc-x25519" TEST=sim
2525

2626
# Values defined in $MULTI_FEATURES consist of any number of features
2727
# to be enabled at the same time. The list of multi-values should be
2828
# separated by ',' and each list of values is run sequentially in the
2929
# defined order.
30-
- os: linux
31-
env: MULTI_FEATURES="sig-rsa overwrite-only large-write,sig-ecdsa overwrite-only large-write,multiimage overwrite-only large-write" TEST=sim
32-
- os: linux
33-
env: MULTI_FEATURES="sig-rsa validate-primary-slot,sig-ecdsa validate-primary-slot,sig-rsa multiimage validate-primary-slot" TEST=sim
34-
- os: linux
35-
env: MULTI_FEATURES="enc-kw overwrite-only large-write,enc-rsa overwrite-only large-write" TEST=sim
36-
- os: linux
37-
env: MULTI_FEATURES="sig-rsa enc-rsa validate-primary-slot,swap-move enc-rsa sig-rsa validate-primary-slot" TEST=sim
38-
- os: linux
39-
env: MULTI_FEATURES="sig-rsa enc-kw validate-primary-slot bootstrap,sig-ed25519 enc-x25519 validate-primary-slot" TEST=sim
40-
- os: linux
41-
env: MULTI_FEATURES="sig-ecdsa enc-kw validate-primary-slot" TEST=sim
42-
- os: linux
43-
env: MULTI_FEATURES="sig-rsa validate-primary-slot overwrite-only large-write,sig-ecdsa enc-ec256 validate-primary-slot" TEST=sim
44-
- os: linux
45-
env: MULTI_FEATURES="sig-rsa validate-primary-slot overwrite-only downgrade-prevention" TEST=sim
30+
# - os: linux
31+
# env: MULTI_FEATURES="sig-rsa overwrite-only large-write,sig-ecdsa overwrite-only large-write,multiimage overwrite-only large-write" TEST=sim
32+
# - os: linux
33+
# env: MULTI_FEATURES="sig-rsa validate-primary-slot,sig-ecdsa validate-primary-slot,sig-rsa multiimage validate-primary-slot" TEST=sim
34+
# - os: linux
35+
# env: MULTI_FEATURES="enc-kw overwrite-only large-write,enc-rsa overwrite-only large-write" TEST=sim
36+
# - os: linux
37+
# env: MULTI_FEATURES="sig-rsa enc-rsa validate-primary-slot,swap-move enc-rsa sig-rsa validate-primary-slot" TEST=sim
38+
# - os: linux
39+
# env: MULTI_FEATURES="sig-rsa enc-kw validate-primary-slot bootstrap,sig-ed25519 enc-x25519 validate-primary-slot" TEST=sim
40+
# - os: linux
41+
# env: MULTI_FEATURES="sig-ecdsa enc-kw validate-primary-slot" TEST=sim
42+
# - os: linux
43+
# env: MULTI_FEATURES="sig-rsa validate-primary-slot overwrite-only large-write,sig-ecdsa enc-ec256 validate-primary-slot" TEST=sim
44+
# - os: linux
45+
# env: MULTI_FEATURES="sig-rsa validate-primary-slot overwrite-only downgrade-prevention" TEST=sim
4646

47-
- os: linux
48-
language: go
49-
env: TEST=mynewt
50-
go:
51-
- "1.12"
47+
# - os: linux
48+
# language: go
49+
# env: TEST=mynewt
50+
# go:
51+
# - "1.12"
5252

5353
- os: linux
5454
language: python

mcuboot/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[coverity]: https://scan.coverity.com/projects/mcuboot
77
[travis]: https://travis-ci.org/JuulLabs-OSS/mcuboot
88

9-
This is mcuboot version 1.6.0
9+
This is mcuboot version 1.7.0-rc1
1010

1111
MCUboot is a secure bootloader for 32-bit MCUs. The goal of MCUboot is to
1212
define a common infrastructure for the bootloader, system flash layout on

mcuboot/boot/boot_serial/src/boot_serial.c

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include <os/os_malloc.h>
5252

5353
#include <bootutil/image.h>
54+
#include <bootutil/bootutil.h>
5455

5556
#include "boot_serial/boot_serial.h"
5657
#include "boot_serial_priv.h"
@@ -312,11 +313,17 @@ bs_upload(char *buf, int len)
312313
rc = 0;
313314
goto out;
314315
}
315-
if (curr_off + img_blen < img_size) {
316-
rem_bytes = img_blen % flash_area_align(fap);
317-
if (rem_bytes) {
318-
img_blen -= rem_bytes;
319-
}
316+
317+
if (curr_off + img_blen > img_size) {
318+
rc = MGMT_ERR_EINVAL;
319+
goto out;
320+
}
321+
322+
rem_bytes = img_blen % flash_area_align(fap);
323+
324+
if ((curr_off + img_blen < img_size) && rem_bytes) {
325+
img_blen -= rem_bytes;
326+
rem_bytes = 0;
320327
}
321328

322329
#ifdef CONFIG_BOOT_ERASE_PROGRESSIVELY
@@ -337,7 +344,32 @@ bs_upload(char *buf, int len)
337344
#endif
338345

339346
BOOT_LOG_INF("Writing at 0x%x until 0x%x", curr_off, curr_off + img_blen);
340-
rc = flash_area_write(fap, curr_off, img_data, img_blen);
347+
if (rem_bytes) {
348+
/* the last chunk of the image might be unaligned */
349+
uint8_t wbs_aligned[BOOT_MAX_ALIGN];
350+
size_t w_size = img_blen - rem_bytes;
351+
352+
if (w_size) {
353+
rc = flash_area_write(fap, curr_off, img_data, w_size);
354+
if (rc) {
355+
goto out_invalid_data;
356+
}
357+
curr_off += w_size;
358+
img_blen -= w_size;
359+
img_data += w_size;
360+
}
361+
362+
if (img_blen) {
363+
memcpy(wbs_aligned, img_data, rem_bytes);
364+
memset(wbs_aligned + rem_bytes, flash_area_erased_val(fap),
365+
sizeof(wbs_aligned) - rem_bytes);
366+
rc = flash_area_write(fap, curr_off, wbs_aligned, flash_area_align(fap));
367+
}
368+
369+
} else {
370+
rc = flash_area_write(fap, curr_off, img_data, img_blen);
371+
}
372+
341373
if (rc == 0) {
342374
curr_off += img_blen;
343375
#ifdef CONFIG_BOOT_ERASE_PROGRESSIVELY
@@ -485,7 +517,7 @@ boot_serial_output(void)
485517
bs_hdr->nh_group = htons(bs_hdr->nh_group);
486518

487519
#ifdef __ZEPHYR__
488-
crc = crc16((u8_t *)bs_hdr, sizeof(*bs_hdr), CRC_CITT_POLYMINAL,
520+
crc = crc16((uint8_t *)bs_hdr, sizeof(*bs_hdr), CRC_CITT_POLYMINAL,
489521
CRC16_INITIAL_CRC, false);
490522
crc = crc16(data, len, CRC_CITT_POLYMINAL, crc, true);
491523
#else

mcuboot/boot/bootutil/include/bootutil/bootutil.h

Lines changed: 6 additions & 5 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 Arm Limited
6+
* Copyright (c) 2019-2020 Arm Limited
77
*
88
* Original license:
99
*
@@ -29,6 +29,7 @@
2929
#define H_BOOTUTIL_
3030

3131
#include <inttypes.h>
32+
#include "bootutil/fault_injection_hardening.h"
3233

3334
#ifdef __cplusplus
3435
extern "C" {
@@ -91,10 +92,10 @@ struct image_trailer {
9192
};
9293

9394
/* you must have pre-allocated all the entries within this structure */
94-
int boot_go(struct boot_rsp *rsp);
95+
fih_int boot_go(struct boot_rsp *rsp);
9596

9697
struct boot_loader_state;
97-
int context_boot_go(struct boot_loader_state *state, struct boot_rsp *rsp);
98+
fih_int context_boot_go(struct boot_loader_state *state, struct boot_rsp *rsp);
9899

99100
int boot_swap_type_multi(int image_index);
100101
int boot_swap_type(void);
@@ -105,8 +106,8 @@ int boot_set_confirmed(void);
105106
#define SPLIT_GO_OK (0)
106107
#define SPLIT_GO_NON_MATCHING (-1)
107108
#define SPLIT_GO_ERR (-2)
108-
int
109-
split_go(int loader_slot, int split_slot, void **entry);
109+
110+
fih_int split_go(int loader_slot, int split_slot, void **entry);
110111

111112
#ifdef __cplusplus
112113
}

mcuboot/boot/bootutil/include/bootutil/caps.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ uint32_t bootutil_get_caps(void);
4646
#define BOOTUTIL_CAP_SWAP_USING_MOVE (1<<11)
4747
#define BOOTUTIL_CAP_DOWNGRADE_PREVENTION (1<<12)
4848
#define BOOTUTIL_CAP_ENC_X25519 (1<<13)
49+
#define BOOTUTIL_CAP_BOOTSTRAP (1<<14)
4950

5051
/*
5152
* Query the number of images this bootloader is configured for. This

0 commit comments

Comments
 (0)