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

Upmerge 01.03.2024 #301

Merged
merged 71 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
cd82f8b
boot: zephyr: add support for lpcxpresso55s28
butok Nov 20, 2023
47b3436
zephyr: kconfig: Prevent MBEDTLS selection when tinycrypt is used
nordicjm Nov 21, 2023
3f0b89d
boot: zephyr: add support for mimxrt101x_evk
butok Nov 27, 2023
5e6cffb
boot: boot_serial: Fix single slot encrypted image list
nordicjm Nov 24, 2023
433b848
zephyr: Move IO functions out of main to separate file
nordicjm Aug 16, 2023
215345f
zephyr: Add firmware loader MCUboot operation style
nordicjm Aug 16, 2023
05d1194
docs: release: Add note on firmware loader mode
nordicjm Aug 16, 2023
ab99fe2
scripts: add missing pyyaml dependency
samueltardieu Nov 19, 2023
c43a20f
boot: zephyr: add support for mimxrt1040_evk
butok Dec 5, 2023
d99154f
zephyr: rename 'led_init()' to 'io_led_init()'
pepe2k Dec 5, 2023
8c6c670
zephyr: io: include 'bootutil_log.h' and declare log module membership
pepe2k Dec 5, 2023
2a74a2b
zephyr: io: add 'io_led_set()'
pepe2k Dec 5, 2023
a88e229
zephyr: sysflash: Fix if condition for zephyr applications
nordicjm Dec 7, 2023
2129973
zephyr: firmware/single_loader: Fix compile warning
nordicjm Dec 7, 2023
26d6423
boot: zephyr: esp32: zephyr port
feilongfl Sep 23, 2023
4c7942e
zephyr: Add estimated image footer size to cache in sysbuild
nordicjm Oct 30, 2023
e9131ee
zephyr: kconfig: Make saving encrypt TLVs depending on encryption
nordicjm Oct 31, 2023
12e2b63
docs: release: Add release notes
nordicjm Dec 12, 2023
8cee355
zephyr: kconfig: make MBEDTLS_PROMPTLESS depend on MBEDTLS
xudongzheng Dec 27, 2023
db9a7f5
boot: zephyr: cmake: Fix issue with missing dts entries
nordicjm Dec 18, 2023
35e9931
bootutil: Add debug logging for boot status write
nordicjm Jan 3, 2024
4d75fc8
bootutil: Fix compatible sector checking
nordicjm Jan 3, 2024
b994ba2
docs: release: Add release notes on changes
nordicjm Jan 3, 2024
c3a72e9
boot: zephyr: moonlight watchdogs
michalek-no Jan 9, 2024
ad5f0ac
zcbor: Copy source and header files
oyvindronningstad Jan 10, 2024
a899390
zcbor: Add copy notice to all copied files
oyvindronningstad Jan 10, 2024
63ddb71
boot_serial: Adapt to API changes in zcbor 0.8.0
oyvindronningstad Jan 10, 2024
f09e205
zcbor: Make changes to zcbor code to satisfy mynewt compile options
oyvindronningstad Jan 10, 2024
c8d213a
zcbor: Copy source and header files
oyvindronningstad Jan 26, 2024
cf882ef
zcbor: Make changes to zcbor code to satisfy mynewt compile options
oyvindronningstad Jan 10, 2024
205d7e5
boot_serial: Adapt to zcbor 0.8.x
oyvindronningstad Jan 29, 2024
a4eda30
zephyr: Add estimated size of update trailer to sysbuild
nordicjm Jan 29, 2024
f44f042
Revert "[nrf noup] boards: thingy53: disable GPIO ISR support"
rlubos Mar 11, 2024
c56303f
Revert "[nrf noup] loader: introduced cleanup of unusable secondary s…
rlubos Mar 11, 2024
5f9c2d5
Revert "[nrf noup] loader: Add firmware version check downgrade preve…
rlubos Mar 11, 2024
50962cb
Revert "[nrf noup] zephyr: Boot even if EXT_ABI is not provided"
rlubos Mar 11, 2024
ba7dd6f
Revert "[nrf noup] zephyr: Add RAM flash configuration to cache for s…
rlubos Mar 11, 2024
fa880e6
Revert "[nrf noup] loader: Do not check reset vector for XIP image"
rlubos Mar 11, 2024
08439d8
Revert "[nrf noup] sysflash: Add support for three images"
rlubos Mar 11, 2024
761738c
Revert "[nrf noup] sysflash: Move partition manager definitions to pm…
rlubos Mar 11, 2024
97e049b
Revert "[nrf noup] boot: Add support for NSIB and multi-image"
rlubos Mar 11, 2024
3aafd78
Revert "[nrf noup] loader: Fix missing PCD define check"
rlubos Mar 11, 2024
69006ec
Revert "[nrf noup] zephyr: Fix path variables"
rlubos Mar 11, 2024
4fa8d28
Revert "[nrf noup] loader: Fix reading reset addr to support ext flash"
rlubos Mar 11, 2024
959ddb9
Revert "[nrf noup] zephyr: Clean up non-secure RAM if enabled"
rlubos Mar 11, 2024
666eaed
Revert "[nrf noup] zephyr: clean peripherals state before boot"
rlubos Mar 11, 2024
ed6a957
Revert "[nrf noup] boot: nrf53-specific customizations"
rlubos Mar 11, 2024
710ca46
Revert "[nrf noup] treewide: add NCS partition manager support"
rlubos Mar 11, 2024
57e0fc7
Revert "[nrf fromtree] boot: zephyr: moonlight watchdogs"
rlubos Mar 11, 2024
b2e6ef5
Revert "[nrf fromtree] boot_serial: Adapt to zcbor 0.8.x"
rlubos Mar 11, 2024
4e40746
Revert "[nrf fromtree] zcbor: Copy source and header files"
rlubos Mar 11, 2024
3885aab
Revert "[nrf fromtree] boot_serial: Adapt to API changes in zcbor 0.8.0"
rlubos Mar 11, 2024
d490bed
Revert "[nrf fromtree] zcbor: Add copy notice to all copied files"
rlubos Mar 11, 2024
a8c9844
Revert "[nrf fromtree] zcbor: Copy source and header files"
rlubos Mar 11, 2024
4b6c0dd
[nrf mergeup] Merge upstream up to commit a4eda30f5b0cfd0cf15512be9dc…
rlubos Mar 11, 2024
518617a
[nrf noup] treewide: add NCS partition manager support
SebastianBoe Dec 12, 2018
42e43d0
[nrf noup] boot: nrf53-specific customizations
sigvartmh Aug 27, 2020
3b2a5ba
[nrf noup] zephyr: clean peripherals state before boot
nvlsianpu Feb 27, 2020
047d463
[nrf noup] zephyr: Clean up non-secure RAM if enabled
sigvartmh Jan 6, 2023
2dac63a
[nrf noup] loader: Fix reading reset addr to support ext flash
chrta Feb 10, 2022
c28fa1d
[nrf noup] zephyr: Fix path variables
nordicjm Jul 11, 2023
f577000
[nrf noup] loader: Fix missing PCD define check
nordicjm Aug 31, 2023
22ed9fb
[nrf noup] boot: Add support for NSIB and multi-image
sigvartmh May 31, 2023
f013888
[nrf noup] sysflash: Move partition manager definitions to pm_sysflash.h
de-nordic Aug 10, 2023
d3f55fe
[nrf noup] sysflash: Add support for three images
de-nordic Aug 11, 2023
d798de3
[nrf noup] loader: Do not check reset vector for XIP image
de-nordic Sep 22, 2023
af27205
[nrf noup] zephyr: Add RAM flash configuration to cache for sysbuild
nordicjm Sep 18, 2023
41cc274
[nrf noup] zephyr: Boot even if EXT_ABI is not provided
sigvartmh Oct 17, 2023
8e91ec1
[nrf noup] loader: Add firmware version check downgrade prevention
sigvartmh Sep 27, 2023
3b0eac8
[nrf noup] loader: introduced cleanup of unusable secondary slot
nvlsianpu Feb 15, 2024
86af2de
[nrf noup] boards: thingy53: disable GPIO ISR support
nika-nordic Oct 9, 2023
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
4 changes: 3 additions & 1 deletion boot/boot_serial/src/boot_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,12 @@ bs_list(char *buf, int len)
if (FIH_EQ(fih_rc, FIH_BOOT_HOOK_REGULAR))
{
#if defined(MCUBOOT_ENC_IMAGES)
#if !defined(MCUBOOT_SINGLE_APPLICATION_SLOT)
if (IS_ENCRYPTED(&hdr) && MUST_DECRYPT(fap, image_index, &hdr)) {
FIH_CALL(boot_image_validate_encrypted, fih_rc, fap,
&hdr, tmpbuf, sizeof(tmpbuf));
} else {
#endif
if (IS_ENCRYPTED(&hdr)) {
/*
* There is an image present which has an encrypted flag set but is
Expand All @@ -310,7 +312,7 @@ bs_list(char *buf, int len)

FIH_CALL(bootutil_img_validate, fih_rc, NULL, 0, &hdr,
fap, tmpbuf, sizeof(tmpbuf), NULL, 0, NULL);
#if defined(MCUBOOT_ENC_IMAGES)
#if defined(MCUBOOT_ENC_IMAGES) && !defined(MCUBOOT_SINGLE_APPLICATION_SLOT)
}
#endif
}
Expand Down
3 changes: 2 additions & 1 deletion boot/bootutil/include/bootutil/boot_status.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ enum mcuboot_mode {
MCUBOOT_MODE_SWAP_USING_MOVE,
MCUBOOT_MODE_DIRECT_XIP,
MCUBOOT_MODE_DIRECT_XIP_WITH_REVERT,
MCUBOOT_MODE_RAM_LOAD
MCUBOOT_MODE_RAM_LOAD,
MCUBOOT_MODE_FIRMWARE_LOADER
};

enum mcuboot_signature_type {
Expand Down
2 changes: 2 additions & 0 deletions boot/bootutil/src/boot_record.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ int boot_save_shared_data(const struct image_header *hdr, const struct flash_are
#endif
#elif defined(MCUBOOT_RAM_LOAD)
uint8_t mode = MCUBOOT_MODE_RAM_LOAD;
#elif defined(MCUBOOT_FIRMWARE_LOADER)
uint8_t mode = MCUBOOT_MODE_FIRMWARE_LOADER;
#else
#error "Unknown mcuboot operating mode"
#endif
Expand Down
3 changes: 2 additions & 1 deletion boot/bootutil/src/bootutil_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ boot_write_enc_key(const struct flash_area *fap, uint8_t slot,

uint32_t bootutil_max_image_size(const struct flash_area *fap)
{
#if defined(MCUBOOT_SWAP_USING_SCRATCH) || defined(MCUBOOT_SINGLE_APPLICATION_SLOT)
#if defined(MCUBOOT_SWAP_USING_SCRATCH) || defined(MCUBOOT_SINGLE_APPLICATION_SLOT) || \
defined(MCUBOOT_FIRMWARE_LOADER)
return boot_status_off(fap);
#elif defined(MCUBOOT_SWAP_USING_MOVE)
struct flash_sector sector;
Expand Down
8 changes: 5 additions & 3 deletions boot/bootutil/src/bootutil_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,17 @@ struct flash_area;
#if (defined(MCUBOOT_OVERWRITE_ONLY) + \
defined(MCUBOOT_SWAP_USING_MOVE) + \
defined(MCUBOOT_DIRECT_XIP) + \
defined(MCUBOOT_RAM_LOAD)) > 1
#error "Please enable only one of MCUBOOT_OVERWRITE_ONLY, MCUBOOT_SWAP_USING_MOVE, MCUBOOT_DIRECT_XIP or MCUBOOT_RAM_LOAD"
defined(MCUBOOT_RAM_LOAD) + \
defined(MCUBOOT_FIRMWARE_LOADER)) > 1
#error "Please enable only one of MCUBOOT_OVERWRITE_ONLY, MCUBOOT_SWAP_USING_MOVE, MCUBOOT_DIRECT_XIP, MCUBOOT_RAM_LOAD or MCUBOOT_FIRMWARE_LOADER"
#endif

#if !defined(MCUBOOT_OVERWRITE_ONLY) && \
!defined(MCUBOOT_SWAP_USING_MOVE) && \
!defined(MCUBOOT_DIRECT_XIP) && \
!defined(MCUBOOT_RAM_LOAD) && \
!defined(MCUBOOT_SINGLE_APPLICATION_SLOT)
!defined(MCUBOOT_SINGLE_APPLICATION_SLOT) && \
!defined(MCUBOOT_FIRMWARE_LOADER)
#define MCUBOOT_SWAP_USING_SCRATCH 1
#endif

Expand Down
4 changes: 4 additions & 0 deletions boot/bootutil/src/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,10 @@ boot_write_status(const struct boot_loader_state *state, struct boot_status *bs)
memset(buf, erased_val, BOOT_MAX_ALIGN);
buf[0] = bs->state;

BOOT_LOG_DBG("writing swap status; fa_id=%d off=0x%lx (0x%lx)",
flash_area_get_id(fap), (unsigned long)off,
(unsigned long)flash_area_get_off(fap) + off);

rc = flash_area_write(fap, off, buf, align);
if (rc != 0) {
rc = BOOT_EFLASH;
Expand Down
56 changes: 38 additions & 18 deletions boot/bootutil/src/swap_move.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,28 @@ boot_status_internal_off(const struct boot_status *bs, int elem_sz)
return off;
}

static int app_max_sectors(struct boot_loader_state *state)
{
uint32_t sz = 0;
uint32_t sector_sz;
uint32_t trailer_sz;
uint32_t first_trailer_idx;

sector_sz = boot_img_sector_size(state, BOOT_PRIMARY_SLOT, 0);
trailer_sz = boot_trailer_sz(BOOT_WRITE_SZ(state));
first_trailer_idx = boot_img_num_sectors(state, BOOT_PRIMARY_SLOT) - 1;

while (1) {
sz += sector_sz;
if (sz >= trailer_sz) {
break;
}
first_trailer_idx--;
}

return first_trailer_idx;
}

int
boot_slots_compatible(struct boot_loader_state *state)
{
Expand All @@ -254,20 +276,31 @@ boot_slots_compatible(struct boot_loader_state *state)
size_t sector_sz_pri = 0;
size_t sector_sz_sec = 0;
size_t i;
size_t num_usable_sectors_pri;

num_sectors_pri = boot_img_num_sectors(state, BOOT_PRIMARY_SLOT);
num_sectors_sec = boot_img_num_sectors(state, BOOT_SECONDARY_SLOT);
num_usable_sectors_pri = app_max_sectors(state);

if ((num_sectors_pri != num_sectors_sec) &&
(num_sectors_pri != (num_sectors_sec + 1))) {
(num_sectors_pri != (num_sectors_sec + 1)) &&
(num_usable_sectors_pri != (num_sectors_sec + 1))) {
BOOT_LOG_WRN("Cannot upgrade: not a compatible amount of sectors");
BOOT_LOG_DBG("slot0 sectors: %d, slot1 sectors: %d, usable slot0 sectors: %d",
(int)num_sectors_pri, (int)num_sectors_sec,
(int)(num_usable_sectors_pri - 1));
return 0;
}

if (num_sectors_pri > BOOT_MAX_IMG_SECTORS) {
} else if (num_sectors_pri > BOOT_MAX_IMG_SECTORS) {
BOOT_LOG_WRN("Cannot upgrade: more sectors than allowed");
return 0;
}

if (num_usable_sectors_pri != (num_sectors_sec + 1)) {
BOOT_LOG_DBG("Non-optimal sector distribution, slot0 has %d usable sectors (%d assigned) "
"but slot1 has %d assigned", (int)(num_usable_sectors_pri - 1),
(int)num_sectors_pri, (int)num_sectors_sec);
}

for (i = 0; i < num_sectors_sec; i++) {
sector_sz_pri = boot_img_sector_size(state, BOOT_PRIMARY_SLOT, i);
sector_sz_sec = boot_img_sector_size(state, BOOT_SECONDARY_SLOT, i);
Expand Down Expand Up @@ -557,24 +590,11 @@ swap_run(struct boot_loader_state *state, struct boot_status *bs,

int app_max_size(struct boot_loader_state *state)
{
uint32_t sz = 0;
uint32_t sector_sz;
uint32_t trailer_sz;
uint32_t first_trailer_idx;

sector_sz = boot_img_sector_size(state, BOOT_PRIMARY_SLOT, 0);
trailer_sz = boot_trailer_sz(BOOT_WRITE_SZ(state));
first_trailer_idx = boot_img_num_sectors(state, BOOT_PRIMARY_SLOT) - 1;

while (1) {
sz += sector_sz;
if (sz >= trailer_sz) {
break;
}
first_trailer_idx--;
}

return (first_trailer_idx * sector_sz);
return (app_max_sectors(state) * sector_sz);
}

#endif
12 changes: 6 additions & 6 deletions boot/zcbor/include/zcbor_print.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,25 @@ do { \
#endif

__attribute__((used))
static void zcbor_print_compare_lines(const uint8_t *str1, const uint8_t *str2, uint32_t size)
static void zcbor_print_compare_lines(const uint8_t *str1, const uint8_t *str2, size_t size)
{
for (uint32_t j = 0; j < size; j++) {
for (size_t j = 0; j < size; j++) {
zcbor_do_print("%x ", str1[j]);
}
zcbor_do_print("\r\n");
for (uint32_t j = 0; j < size; j++) {
for (size_t j = 0; j < size; j++) {
zcbor_do_print("%x ", str2[j]);
}
zcbor_do_print("\r\n");
for (uint32_t j = 0; j < size; j++) {
for (size_t j = 0; j < size; j++) {
zcbor_do_print("%x ", str1[j] != str2[j]);
}
zcbor_do_print("\r\n");
zcbor_do_print("\r\n");
}

__attribute__((used))
static void zcbor_print_compare_strings(const uint8_t *str1, const uint8_t *str2, uint32_t size)
static void zcbor_print_compare_strings(const uint8_t *str1, const uint8_t *str2, size_t size)
{
const size_t col_width = 16;

Expand All @@ -104,7 +104,7 @@ static void zcbor_print_compare_strings(const uint8_t *str1, const uint8_t *str2
}

__attribute__((used))
static void zcbor_print_compare_strings_diff(const uint8_t *str1, const uint8_t *str2, uint32_t size)
static void zcbor_print_compare_strings_diff(const uint8_t *str1, const uint8_t *str2, size_t size)
{
const size_t col_width = 16;
bool printed = false;
Expand Down
13 changes: 10 additions & 3 deletions boot/zcbor/src/zcbor_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,23 +355,30 @@ float zcbor_float16_to_32(uint16_t input)
: (expo + (F32_BIAS - F16_BIAS));
uint32_t value32 = (sign << F32_SIGN_OFFS) | (new_expo << F32_EXPO_OFFS)
| (mantissa << (F32_EXPO_OFFS - F16_EXPO_OFFS));
return *(float *)&value32;
float result;

memcpy(&result, &value32, sizeof(result));
return result;
}
}


uint16_t zcbor_float32_to_16(float input)
{
uint32_t value32 = *(uint32_t *)&input;
uint32_t value32;

memcpy(&value32, &input, sizeof(value32));

uint32_t sign = value32 >> F32_SIGN_OFFS;
uint32_t expo = (value32 >> F32_EXPO_OFFS) & F32_EXPO_MSK;
uint32_t mantissa = value32 & F32_MANTISSA_MSK;

uint16_t value16 = (uint16_t)(sign << F16_SIGN_OFFS);

uint32_t abs_value32 = value32 & ~(1 << F32_SIGN_OFFS);
float abs_input;
*(uint32_t *)&abs_input = value32 & ~(1 << F32_SIGN_OFFS);

memcpy(&abs_input, &abs_value32, sizeof(abs_input));

if (abs_input <= (F16_MIN / 2)) {
/* 0 or too small for float16. Round down to 0. value16 is already correct. */
Expand Down
Loading
Loading