Commit Graph

2324 Commits

Author SHA1 Message Date
Andrej Butok 1c47465cd1 boot: zephyr: use EXTRA_CONF_FILE instead of deprecated OVERLAY_CONFIG
Use EXTRA_CONF_FILE that replaced OVERLAY_CONFIG
since the Zephyr v3.4 release.

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
(cherry picked from commit 5c21093af5)
2024-11-04 14:28:55 +00:00
Andrej Butok 8e8ecd916f boot: zephyr: Fix serial recovery for NXP IMX.RT platforms
Serial recovery failed for NXP IMX.RT platforms
unless BOOT_ERASE_PROGRESSIVELY is set.

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
(cherry picked from commit a91a61564a)
2024-11-04 14:28:52 +00:00
Andrej Butok 52c7231add boot: zephyr: Fix Warning 'boot_serial_enter defined but not used'
Fix possible warning "boot_serial_enter defined but not used".

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
(cherry picked from commit a967c66ed0)
2024-11-04 14:28:50 +00:00
Andrej Butok a58d902659 zephyr: hello_world: Fix the main() return type warning
Fixes the "return type of 'main' is not 'int'" warning.

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
(cherry picked from commit a5e3d16326)
2024-11-04 14:28:47 +00:00
Thomas Altenbach 50b7b9ee2c bootutil: Fix AES and SHA-256 contexts not zeroized with mbedTLS
For some reason, the calls to mbedtls_aes_free, mbedtls_nist_kw_free and
mbedtls_sha256_free_drop were commented out which means the AES and
SHA-256 contexts were not properly de-initialized after usage when
mbedTLS is used. In the case of AES-KW it seems that might lead to a
memory leak depending on the mbedTLS configuration, but in any case and
independently of the mbedTLS configuration, this leads to the contexts
not be zeroized after usage.

Not zeroizing a context means it stays in RAM an undefined amount of
time, which might enable an attacker to access it and to dump the
sensitive data it contains.

Signed-off-by: Thomas Altenbach <thomas.altenbach@legrand.com>
(cherry picked from commit 5d5f04923f)
2024-11-04 14:28:43 +00:00
Jamie McCrae 9b1b95c17f ci: Fix zephyr workflow
Updates the upload artifact version

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit 84b56b6111)
2024-11-04 14:28:40 +00:00
Jamie McCrae 809b0e42fe bootutil: Add better mode selection checks
Improves the mode selection checks to prevent selecting multiple
conflicting modes as has been seen in TFM

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit 43a49a3b92)
2024-11-04 14:28:38 +00:00
Fabio Utzig 0fe7ffd803 ci: Fix FIH Docker image release usage
The scripts for fih tests install and run where running different
versions of the docker images, since the install specified a version and
not version was specified for run, defaulting to `latest`.

This commits adds a new file for specifying the docker image to be used.

Signed-off-by: Fabio Utzig <utzig@apache.org>
(cherry picked from commit 4619da5660)
2024-11-04 14:28:34 +00:00
Fabio Utzig a990c6b66a ci: Update FIH docker to Ubuntu Jammy (22.04)
- Ubuntu Jammy brings CMake 3.22.1 required by newer TFM builds.
- Python requirements were updated following requirements in TFM.
- Added git configuration to ignore repo ownership checks (since 2.35.3).

Signed-off-by: Fabio Utzig <utzig@apache.org>
(cherry picked from commit a6ae770df6)
2024-11-04 14:28:31 +00:00
Jamie McCrae 03d1a443dc boot: zephyr: board: Fix nrf54l15pdk Kconfig fragment
Fixes an issue with this file as it was wrongly disabling QSPI
NOR, which the hardware does not support, when it should have been
disabling SPI NOR

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit 651775b550)
2024-11-04 14:28:27 +00:00
Mahesh Mahadevan 323eb8d1e7 boot: zephyr: MCXN947 currently only does not support swap mode
Update the configuration to remove swap mode support.
MCXN94x ROM Flash API supports writing of 128byes page.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
(cherry picked from commit a3762626f8)
2024-11-04 14:28:24 +00:00
Lluis Campos 0a88733ddd boot_serial: Fix `format` warning
By explicitly casting to unsigned int.

Signed-off-by: Lluis Campos <lluis.campos@northern.tech>
(cherry picked from commit 52e2afc2f8)
2024-11-04 14:28:21 +00:00
Lluis Campos 157547c889 boot_serial: Fix `incompatible-pointer-types` warning
The variable `rc` was declared as int and then implicitly casted to
`size_t` when passed to `base64_decode`, which on 64 bit architectures
is wrong.

Signed-off-by: Lluis Campos <lluis.campos@northern.tech>
(cherry picked from commit dd4d6541c8)
2024-11-04 14:28:18 +00:00
Jamie McCrae 60ac682a12 bootutil: loader: Verify image header before checking image
Changes the order of operations to validate the image header
before checking the image, it does not make sense to check the
image if the header itself is invalid

Note: This PR has been modified from the upstream commit due to
a merge failure from other changes that are not being brought into
Zephyr 3.7

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit 2939d30545)
2024-11-04 14:28:09 +00:00
Sylvio Alves 1cd53982e1 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>
(cherry picked from commit 334d2c28f6)
2024-11-04 14:27:56 +00:00
Jamie McCrae 587289d650 bootutil: Fix missing include
Fixes a missing include in the header

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit 034f58cbf1)
2024-11-04 14:27:53 +00:00
Jamie McCrae 610b8e2b1b 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>
(cherry picked from commit e2e1e945fa)
2024-11-04 14:27:50 +00:00
David Vincze a4800ce0cf imgtool: Add missing encodings to emitter tests
Signed-off-by: David Vincze <david.vincze@arm.com>
Change-Id: Iff37cb62514b181a30f5537d6692d55e3d9c73ed
(cherry picked from commit f763c5ffee)
2024-11-04 14:27:47 +00:00
Rustam Ismayilov 80397e0f28 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
(cherry picked from commit ef598b13b5)
2024-11-04 14:27:44 +00:00
Jamie McCrae e29a123de8 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>
(cherry picked from commit 078874fbf0)
2024-11-04 14:27:41 +00:00
Jamie McCrae a375a14d87 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>
(cherry picked from commit 8456464c04)
2024-11-04 14:27:39 +00:00
Fabio Utzig 77b03c7fe7 Fix style issues
Convert tab to spaces; fix opening brace position.

Signed-off-by: Fabio Utzig <utzig@apache.org>
(cherry picked from commit d5e0e89568)
2024-11-04 14:27:31 +00:00
Dominik Ermel 35bf48c5b7 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>
(cherry picked from commit 7f9ac97951)
2024-11-04 14:27:23 +00:00
Jamie McCrae 9083649931 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>
(cherry picked from commit 71120e4224)
2024-11-04 14:27:17 +00:00
Jamie McCrae 24de0fbc7c 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>
(cherry picked from commit 7fc3ad3d0b)
2024-11-04 14:24:48 +00:00
Rustam Ismayilov 197287cea1 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
(cherry picked from commit 49976dc678)
2024-11-04 14:24:00 +00:00
Dominik Ermel 7566edaf88 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>
(cherry picked from commit 335573520d)
2024-11-04 14:23:56 +00:00
Dominik Ermel 86b1ef198b 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>
(cherry picked from commit 2371c0aa7f)
2024-11-04 14:23:53 +00:00
Hudson C. Dalpra 597a1996d5 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>
(cherry picked from commit 4b9d07dc4f)
2024-11-04 14:23:50 +00:00
Andrej Butok 2fa42bface 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>
(cherry picked from commit 50f35144e4)
2024-11-04 14:23:47 +00:00
Dominik Ermel f2971d2014 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>
(cherry picked from commit 7e3a1cecd7)
2024-11-04 14:23:36 +00:00
Dominik Ermel 071b3b8e0f 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>
(cherry picked from commit 4da4a72cb1)
2024-11-04 14:23:33 +00:00
Thomas Altenbach 2cd6ce9fb9 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>
(cherry picked from commit 60806bce8e)
2024-11-04 14:23:28 +00:00
Thomas Altenbach 3c2f837528 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>
(cherry picked from commit f515bb1c44)
2024-11-04 14:23:22 +00: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
David Brown 1b1d495338 FIH: Disable FIH labels on Apple targets
The symbols injected here cause some kind of poor interaction with the linker on
MacOS, which results in most of the code becoming hopelessly corrupt.  For now,
just disable these symbols on this target.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-06-26 16:43:56 -06:00
David Brown 9cc8dac569 sim: Put AreaDesc in an Rc
Since there are references to this struct passed to C code, put it into an Rc so
that it won't move around when the data is moved.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-06-26 16:43:56 -06:00
David Brown 5d155132dc sim: Don't take address of movable struct
This struct was having addresses taken of fields within it, and then being
returned.  It is platform-specific whether this causes a move.  It seems to be
working on x86_64, but causes a segfault on aarch64.  Box the struct so that it
isn't moved after being initialized.

Signed-off-by: David Brown <david.brown@linaro.org>
2024-06-26 16:43:56 -06:00
Thomas Altenbach 9ae634f3bf bootutil: Fix signed/unsigned comparison in boot_read_enc_key
When MCUBOOT_SWAP_SAVE_ENCTLV is enabled, a comparison between a signed
and an unsigned integer is made in boot_read_enc_key. This might cause a
warning to be emitted at compile-time.

Signed-off-by: Thomas Altenbach <thomas.altenbach@legrand.com>
2024-06-20 17:54:01 -03:00
David Vincze 8be24f87e3 docs: Replace Slack channel links with Discord
Replace Slack channel links with MCUboot Discord channel
as the discussions have moved there.

Signed-off-by: David Vincze <david.vincze@arm.com>
Change-Id: I132279574e674408dffc9ed377d216775a54fd56
2024-06-14 15:31:51 +02:00
Rustam Ismayilov 533fef2ad7 imgtool: Update version.py to take command line arguments
Main method printed hardcoded versions, update to take argument
to enable the possibility of testing version strings by invoking
the command through command line.

Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: If75769ef223944865313ed95336e859ebef85fd6
2024-06-14 13:56:40 +02:00