Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions boot/bootutil/src/swap_nsib.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ void nsib_swap_run(struct boot_loader_state *state, struct boot_status *bs)
const struct flash_area *fap_pri;
const struct flash_area *fap_sec;
int rc;
#ifdef CONFIG_NCS_MCUBOOT_DISCARDS_HEADER_IN_SECONDARY_MCUBOOT
const struct image_header *hdr = boot_img_hdr(state, BOOT_SLOT_SECONDARY);
#endif

BOOT_LOG_INF("Starting swap using nsib algorithm.");

Expand All @@ -53,7 +56,11 @@ void nsib_swap_run(struct boot_loader_state *state, struct boot_status *bs)
rc = boot_erase_region(fap_pri, 0, fap_pri->fa_size, false);
assert(rc == 0);

#ifdef CONFIG_NCS_MCUBOOT_DISCARDS_HEADER_IN_SECONDARY_MCUBOOT
rc = boot_copy_region(state, fap_sec, fap_pri, hdr->ih_hdr_size, 0, hdr->ih_img_size);
#else
rc = boot_copy_region(state, fap_sec, fap_pri, 0, 0, fap_pri->fa_size);
#endif
assert(rc == 0);

rc = swap_scramble_trailer_sectors(state, fap_sec);
Expand Down
14 changes: 13 additions & 1 deletion boot/zephyr/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ config NCS_MCUBOOT_DISABLE_SELF_RWX_SKIP_SIZE
hex
depends on NCS_MCUBOOT_DISABLE_SELF_RWX
depends on !PARTITION_MANAGER_ENABLED
default 0x800 if SOC_SERIES_NRF54L
default ROM_START_OFFSET if SOC_SERIES_NRF54L
help
Size of region, at the beginning of the partition, that does not require
protections. This is used, for example, when MCUboot type image is protected
Expand Down Expand Up @@ -1586,6 +1586,18 @@ config NCS_MCUBOOT_MANUFACTURING_APP_KEY_IDENTIFIER
help
Manufacturing application key identifier.


config NCS_MCUBOOT_DISCARDS_HEADER_IN_SECONDARY_MCUBOOT
bool "Discard MCUboot header in second stage MCUboot bootloader image" if !PARTITION_MANAGER_ENABLED
depends on MCUBOOT_MCUBOOT_IMAGE_NUMBER != -1
help
Default n to keep compatibility with PM built MCUboot images.
When selected, the MCUboot header, attached to MCUboot image for DFU,
will be discarded while MCUboot will be copied to s0/s1 slots, leaving
more space within slot for the MCUboot image.
When unselected the MCUboot header will be kept and copied with
MCUboot image to the s0/s1 slot.

configdefault PSA_CRYPTO
default y if SOC_NRF54H20 && BOOT_SIGNATURE_TYPE_ED25519

Expand Down
27 changes: 23 additions & 4 deletions scripts/imgtool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,24 @@ def validate_security_counter(ctx, param, value):

def validate_header_size(ctx, param, value):
min_hdr_size = image.IMAGE_HEADER_SIZE
if value < min_hdr_size:
if value.lower() == 'auto':
return min_hdr_size

if isinstance(value, int):
converted = value
else:
try:
converted = int(value, 0)
except ValueError:
raise click.BadParameter(
f"{value} is not a valid integer. Please use code literals "
"prefixed with 0b/0B, 0o/0O, or 0x/0X as necessary."
)

if converted < min_hdr_size:
raise click.BadParameter(
f"Minimum value for -H/--header-size is {min_hdr_size}")
return value
return converted


def get_dependencies(ctx, param, value):
Expand Down Expand Up @@ -456,8 +470,13 @@ def convert(self, value, param, ctx):
@click.option('--pad-header', default=False, is_flag=True,
help='Add --header-size zeroed bytes at the beginning of the '
'image')
@click.option('-H', '--header-size', callback=validate_header_size,
type=BasedIntParamType(), required=True)
@click.option('-H', '--header-size', callback=validate_header_size, required=False,
default='auto',
help='Unsigned integer in hex, dec or oct format, or auto;'
' auto will use smallest possible value , rounded up to 32 bits,'
' capable of storing full header in current version. The auto'
' is preffered when no address/size requirement are needed for header,'
' and will give smallest image.')
@click.option('--pad-sig', default=False, is_flag=True,
help='Add 0-2 bytes of padding to ECDSA signature '
'(for mcuboot <1.5)')
Expand Down
Loading