Commit Graph

2330 Commits

Author SHA1 Message Date
Sylvio Alves 334d2c28f6 boot: main: avoid unused build warning
In case ESP32 SoC is used, *start will get
build warning as it is not used.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2024-08-21 10:20:02 +01:00
Marek Matej c87d41efc8 boot: zephyr: Fix included header
Rename the header file after upstream change.

Signed-off-by: Marek Matej <marek.matej@espressif.com>
2024-08-19 10:47:04 -03:00
Tiago Medicci 12906fdeff espressif: Update the references for using the new Espressif HAL
The new Espressif HAL is based on ESP-IDF v5.1.4.

Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
2024-08-15 10:02:03 -03:00
Jamie McCrae 034f58cbf1 bootutil: Fix missing include
Fixes a missing include in the header

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-08-14 09:09:54 +02:00
Jamie McCrae 148c2c1662 docs: release-notes: Add note on new slot info command
Adds release notes on the addition of this feature

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-08-13 09:35:21 +01:00
Jamie McCrae e261b285a1 boot_serial: Add optional img mgmt slot info feature
Adds a minimal version of the slot info feature to serial recovery,
and enables it by default.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-08-13 09:35:21 +01:00
Jamie McCrae 2db0654bc2 docs: release-notes: Add notes on maximum app size changes
Adds release notes for these changes

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-08-13 07:49:14 +01:00
Jamie McCrae e2e1e945fa bootutil: Fix swap move max app size calculation
This calculation failed to take into consideration the additional
sector needed for the swap move part of the upgrade process

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-08-13 07:49:14 +01:00
Jamie McCrae 4f1ab9e763 bootutil: Add missing images to get maximum image size details
Adds support for getting the maximum image size of multiple images
and adding this data to the shared data area

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-08-13 07:49:14 +01:00
Jamie McCrae 4baa6d3243 docs: release-notes: Add note on zephyr auto max sectors
Adds a note about the new feature that has been added

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-08-13 07:48:59 +01:00
Jamie McCrae eaae6500a7 zephyr: Add support for automatically calculcating max sectors
Adds a feature that will calculate the maximum number of sectors
that are needed for a build. Can be disabled to revert back to
the old behaviour by disabling CONFIG_BOOT_MAX_IMG_SECTORS_AUTO

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-08-13 07:48:59 +01:00
Dominik Ermel 6fe259b1b6 boot: Simplify copy loop in boot_copy_region
Move checking of conditions, which remain the same for the whole
loop run, outside of the loop.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-08-06 19:08:08 +02:00
Andrej Butok 7e69047b7d boot: zephyr: add support for frdm-mcxn947
Add default configuration for frdm-mcxn947.

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
2024-08-02 16:38:26 -06:00
Andrej Butok 899ade2d2a boot: zephyr: boards: Add mimxrt1062_fmurt6 configuration
Add default configuration for mimxrt1062_fmurt6

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
2024-08-02 16:37:52 -06:00
Andrej Butok ae27bc77dc boot: zephyr: boards: Add common mimxrt1050_evk configuration.
- Add common mimxrt1050_evk_mimxrt1052.conf for all revisions.
- Delete the qspi revision mimxrt1050_evk_mimxrt1052_qspi.conf

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
2024-08-02 16:34:11 -06:00
Andrej Butok 6123e9161f boot: zephyr: boards: Add mimxrt11xx configurations
- Add default configurations for mimxrt1160_evk and vmu_rt1170
- Fix configuration for mimxrt1170_evk

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
2024-08-02 16:23:12 -06:00
David Vincze f763c5ffee imgtool: Add missing encodings to emitter tests
Signed-off-by: David Vincze <david.vincze@arm.com>
Change-Id: Iff37cb62514b181a30f5537d6692d55e3d9c73ed
2024-08-01 15:21:51 +02:00
Dominik Ermel 3f11286e2e boot: Remove image_index from boot_encrypt
boot_encrypt required the image_index paired with flash area pointer
to be able to figure out which slot it will operate on.
Since in most calls the slot is known in advance it can be just
passed to the function directly.
The commit replaces both parameters with slot number.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-08-01 15:21:06 +02:00
David Vincze 2a7565b338 bootutil: Move encryption key function to common file
Move the definition of boot_enc_retrieve_private_key() to a common file
to avoid code duplication and also endure seamless transition to this new
key handling approach for targets which don't use hardware keys.

Change-Id: I57e54e4332503c11d18762f8291c3cab53df3d20
Signed-off-by: David Vincze <david.vincze@arm.com>
2024-07-31 16:55:55 +02:00
David Vincze 0e5e1a9fc6 Reapply "boot: Add MCUBOOT_HW_KEY support for image encryption"
This reverts commit c06f7bb367.

Signed-off-by: David Vincze <david.vincze@arm.com>
Change-Id: Ic2ab2c4d3981dec3cd3c25a50b5a989000375372
2024-07-31 16:55:55 +02:00
Rustam Ismayilov ef598b13b5 imgtool: Fix getpub fails for ed25519 key
Fix getpub command fails to emit public pair of ed25519 key with
encoding.

Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: I3d255f576b2d8a8d0cbc8e31ff378717acb060c7
2024-07-30 10:37:52 +02:00
Jamie McCrae 078874fbf0 docs: release-notes: Add note on name clash fix
Adds a note about the name clash fix for zephyr

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-07-26 14:26:27 +01:00
Jamie McCrae 8456464c04 zephyr: Fix issue with sysbuild if something else is named mcuboot
Fixes an issue which can occur in tests whereby an application
has the name mcuboot but is not mcuboot itself

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-07-26 14:26:27 +01:00
Fabio Utzig d5e0e89568 Fix style issues
Convert tab to spaces; fix opening brace position.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2024-07-25 14:45:29 +02:00
Dominik Ermel d09112acf6 boot: Reduce repeating code in boot_decrypt_and_copy_image_to_sram
There was not really needed repetition of code in if-else
block; common code has been moved out and the block has been
reduced.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-07-25 14:44:26 +02:00
Dominik Ermel 7f9ac97951 boot: Change boot_enc_load to take slot number instead of image
In all cases where boot_enc_load is called it is known what slot
is addressed, so it is better to just pass the slot number
instead of making the boot_enc_load figure out slot number from
image index and provided flash area object.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-07-25 14:30:38 +02:00
Jamie McCrae 71120e4224 docs: release-notes: Add note on fixed zephyr RAM load address
Adds a note about this fix

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-07-25 14:14:22 +02:00
Jamie McCrae 7fc3ad3d0b boot: zephyr: Fix RAM load chain load address
Fixes showing the wrong address when booting a RAM load image

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-07-25 14:14:22 +02:00
Rustam Ismayilov 49976dc678 imgtool: Bump cryptography library version
Update requirements.txt to support PrivateKeyType and
PublicKeyType which are available in cryptography library since
version 40.0.0 and prevent failing CI jobs in upcoming changes.

Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: I94b888d64c2f33ccb829912491e3b8c44b9cc2b2
2024-07-25 14:00:14 +02:00
Dominik Ermel 335573520d boot: Move encryption context invalidation to boot_enc_drop.
The enc_key_data.valid had been set to true when key has been added
to the encryption context, but in case when boot_enc_drop was called,
on the same context, the flag remained true, even though the context
may no longer hold any valid context nor key.
The commit moves the enc_key_data invalidation to enc_key_drop.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-07-24 17:27:19 +02:00
Dominik Ermel 2371c0aa7f boot: Rename boot_enc_decrypt to boot_decrypt_key
All of boot_enc_ function follow the same pattern where
they take encryption context as the first parameter, and the
boot_enc_decrypt stands out here as it does not work around
the encryption context, but is rather single-part decryption
function only used for decrypting of the image encryption
key.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-07-24 17:26:01 +02:00
Andrej Butok 50f35144e4 doc: readme-zephyr: fix the scratch partition example
It tells about adding the 24KB scratch partition,
not about storage partition.
Updates the used path to HWMv2.

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
2024-07-24 13:51:59 +02:00
Hudson C. Dalpra 4b9d07dc4f boot: boot_serial: change logging to debug level
Update the log level for RX and TX messages from INFO to DEBUG to reduce
clutter in the serial interface logs. This change helps in keeping the
output cleaner and focuses on more critical information by default.

Signed-off-by: Hudson C. Dalpra <hudson@bduncanltd.com>
2024-07-24 13:51:23 +02:00
Dominik Ermel 7e3a1cecd7 boot: Add missing boot_enc_init
The boot_enc_set_key in boot_swap_image, when recovering from
reset, has been caled on AES context that has not been
initialized.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-07-23 10:36:43 +02:00
Dominik Ermel 4da4a72cb1 boot: Remove pointless slot identification
In the boot_image_validate_encrypted there was call to
flash_area_id_to_multi_image_slot, which tries to figure out
slot index from flash area and image index, and the result of the
call was not used for anything as slot index is hardcoded in the
next call to be 1 (secondary).

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-07-23 09:04:46 +02:00
Thomas Altenbach c4b89ba144 docs: release-notes: Add snippet on encrypted scratch area
Add release note snippet regarding the change made to the swap with
scratch algorithm to avoid having plaintext firmware data stored in the
scratch area.

Signed-off-by: Thomas Altenbach <thomas.altenbach@legrand.com>
2024-07-15 20:03:21 -03:00
Thomas Altenbach 60806bce8e sim: Fix MCUBOOT_SWAP_USING_SCRATCH defined in direct-xip and ram-load
When 'direct-xip' or 'ram-load' features were enabled,
CONFIG_BOOT_SWAP_USING_SCRATCH and MCUBOOT_SWAP_USING_SCRATCH were
defined even though swap using scratch wasn't used. This commit fixes
the issue.

Signed-off-by: Thomas Altenbach <thomas.altenbach@legrand.com>
2024-07-15 20:03:21 -03:00
Thomas Altenbach 44a935ebcc docs: Update documentation regarding encrypted scratch area
When using swap using scratch, the decryption now happens when copying
from the scratch area to the primary slot, which means the image is
stored encrypted in the scratch area. This commit updates the
documentation accordingly.

Signed-off-by: Thomas Altenbach <thomas.altenbach@legrand.com>
2024-07-15 20:03:21 -03:00
Thomas Altenbach 08d2d94c14 bootutil: Keep image encrypted in scratch area
Currently, when swap using scratch is used with encrypted images,
MCUboot is decrypting the images during the copy from the secondary slot
to the scratch area. This means the scratch area contains plaintext
image data and therefore that the scratch area must be placed in the
MCU's internal flash memory. This commit makes the necessary changes to
perform the decryption when copying from the scratch area to the primary
slot instead, making possible to place the scratch area in an external
flash memory since the scratch area is now encrypted.

Note that BOOT_SWAP_SAVE_ENCTLV must be enabled if the scratch area is
placed in external flash memory.

Signed-off-by: Thomas Altenbach <thomas.altenbach@legrand.com>
2024-07-15 20:03:21 -03:00
Thomas Altenbach f515bb1c44 bootutil: Properly retrieve image headers after interrupted swap-scratch
For swap using scratch, the boot_read_image_header routine, responsible
for reading the image headers, was always looking for the primary and
secondary image's headers at the beginning of respectively the primary
and secondary slots, regardless of the current boot status.

This means if during a swap-scratch upgrade a reset happens after the
sector containing the image header in the primary or secondary slot has
been erased, invalid image headers were read since at that time the
location of the headers has changed.

Currently, this doesn't seem to cause any issue because the swap-scratch
algorithm is implemented in such a way the content of the headers is no
more necessary when the headers are erased. However, to be able to
decrypt the secondary image when copied to the primary slot instead of
when copied to the scratch area, properly reading the secondary image's
header is required even after it has been erased from the secondary
slot.

To that end, the boot_read_image_header is modified to determine from
the boot status the current location of the image headers and to always
read the actual header, no matter the current state of the upgrade
process.

Signed-off-by: Thomas Altenbach <thomas.altenbach@legrand.com>
2024-07-15 20:03:21 -03:00
Jamie McCrae fb2cf0ec3d docs: release-notes: Add note on fixed nordic boards
Adds a note that building for these boards has been fixed

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-07-10 07:37:43 +01:00
Jamie McCrae 8980799219 boot: zephyr: Fix build for nrf9160dk
Fixes building MCUboot for this board

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-07-10 07:37:43 +01:00
Jamie McCrae 2f5a7f4721 boot: zephyr: Fix build for thingy53
Fixes building MCUboot for this board

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-07-10 07:37:43 +01:00
Jamie McCrae c9e4ab8b24 boot: zephyr: Fix build for thingy52
Fixes building MCUboot for this board

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-07-10 07:37:43 +01:00
David Brown c06f7bb367 Revert "boot: Add MCUBOOT_HW_KEY support for image encryption"
This reverts commit 0fa46270c0.

This breaks:

    samples/synchronization/sample.kernel.synchronization on
    b_u585i_iot02a/stm32u585xx/ns error

as this TF-M configuration uses its own keys.  This change is an API
change that needs to be coordinated with TF-M changes.

Before this revert, compiling this test results in:

    .../encrypted.c:447: undefined reference to
    `boot_enc_retrieve_private_key`

Signed-off-by: David Brown <david.brown@linaro.org>
2024-07-09 09:19:43 -06:00
David Brown 1d79ef35ee boot: Fix ASN.1 for mbedtls >= 3.1
In Mbed TLS 3.1, the private fields in the ASN.1 structure were made private.
This breaks code that accesses these private macros.

Fix this by changing the ASN.1 specific code to use a new field accessor
`ASN1_CONTEXT_MEMBER` that will be conditionally defined based on the version of
Mbed TLS that is present.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-06-28 10:04:35 -06:00
Thomas Altenbach 86acda9ed4 ext: fiat: Use user-defined assert macro
The libc assert macro was used in curve25519.c even if the user provided
its own definition of the assert macro for MCUboot through
mcuboot_assert.h. This commit fixes this issue.

Signed-off-by: Thomas Altenbach <thomas.altenbach@legrand.com>
2024-06-26 16:52:20 -06:00
David Brown a706317769 sim: Increase jmpbuf size
Increase the size of the jmpbuf to accomodate other architectures.
Unfortunately, the size of this is not available in the libc crate.
Increase this so encompass any platforms we wish to support, including
aarch64 on both Linux and MacOS.

Increasing an array beyond 32 means there is no default offered, so
implement this manually.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-06-26 16:43:56 -06:00
David Brown d6a5a7344f sim: Fix resolver warning from cargo
Cargo prints a warning about conflicting resolvers being used.  Fix this
by explicitly setting the resolver in the project file.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-06-26 16:43:56 -06:00
David Brown 847548a9ac sim: Put "C" on externs
Many of these extern functions are missing the "C". It doesn't seem to matter on
any of our targets, but this does make the code more correct, and might be a
problem in the future.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-06-26 16:43:56 -06:00