Commit Graph

1366 Commits

Author SHA1 Message Date
Andrzej Puzdrowski 907476d701 boot: remove direct fih delay rng inclusion
Direct inclusion of "bootutil/fault_injection_hardening_delay_rng.h"
might cause linking collision as this header belongs to `FIH_ENABLE_DELAY`
mode.
This header is already included by "bootutil/fault_injection_hardening.h"
appropriately.

fixes #831

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-10-07 13:50:16 +02:00
Tamas Ban 82fb41248f boot/bootutil: Clean-up fault injection hardening
Remove  unnecessary includes and create conditionally
the MCUBOOT_FIH_PROFILE_OFF define to avoid redefinition
warnings.

Change-Id: I6a34af2a5e45b81fdedd26bc1fa50ab0b9a05918
Signed-off-by: Tamas Ban <tamas.ban@arm.com>
2020-10-07 13:19:52 +02:00
Marcin Niestroj 4dc12f4807 boot: zephyr: Disable HW stack protection
Some Zephyr boards enable HW stack protection by default, which
propagates in mcuboot build. Bootloader works fine with that option, but
the problem arises when we jump to application code. HW stack protection
catches application code during early init, which results in
"unresponsive" application.

Disable HW stack protection, so it doesn't make any harm for application
code.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-10-06 14:54:49 +02:00
Fabio Utzig 0d02976d56 workflows: enable bootstrap in swap-move
Also enable bootstrap in one of the swap-move tests.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2020-10-05 17:11:14 -03:00
Fabio Utzig 32afe85dc3 bootutil: fix boostrapping in swap-move
Fix boostrapping in swap-move that was being skipped due to the having
an erased header in the primary slot which caused an early return
because of the requirement of having to re-read image headers when
"moving" an image during an upgrade.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2020-10-05 17:11:14 -03:00
Fabio Utzig 3d77c95997 bootutil: fix broken bootstrap functionality
Fix bootstrap functionality which was broken by the fault injection
hardening support.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2020-10-05 17:11:14 -03:00
Fabio Utzig 3c9d5c45ab sim: change MCUBOOT_OVERWRITE_ONLY_FAST usage
Remove `MCUBOOT_OVERWRITE_ONLY_FAST` from overwrite-only upgrades, to
make it compatible with `large-write` tests after the latest changes
to the fast overwrite code; make it default when bootstrapping.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2020-10-05 17:11:14 -03:00
Fabio Utzig b4f8810629 bootutil: copy image size with fast overwrite
Previously when `MCUBOOT_OVERWRITE_ONLY_FAST` was set, the whole amount
of sectors that stored an image were being copied. After this commit
only the exact amount of data used by the image is copied; this avoids
copying some 0xff (or garbage) data between the end of the image and the
end of the last sector storing it.

Extra trailer management was added which suits using the copy upgrade
routine also for bootstrapping.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2020-10-05 17:11:14 -03:00
Fabio Utzig 1edb788695 sim: update alignment (aka write_sz) to u16
The simulated alignment functions were returning u8 which would be
invalid for any alignment beyond 128; as a first step in the direction
of allowing larger alignments, make them u16 which should allow for up
to 2**15 aligment size.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2020-10-05 17:11:14 -03:00
Fabio Utzig d0157343dc sim: add bootstrap test
Add caps for bootstrap option and implement simple bootstrap test
for the simulator.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2020-10-05 17:11:14 -03:00
Ryan Erickson aac99a14c9 boot: zephyr: add support for Pinnacle 100
Add support for the pinnacle_100_dvk board.
The Pinnacle 100 modem slot 1 partition
is located in external QSPI.
Add a board file overlay to enable QSPI flash.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2020-10-03 18:51:41 -03:00
Andrzej Puzdrowski f0ef8b6daf zephyr/cmake: add help message for missing nrfxlib case
nrfxlib need to be cloned manullay.
This patch gives a help message to the user in case it
was missing.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-10-02 12:45:51 +02:00
Andrzej Puzdrowski 7141b52ab2 zephyr/Kconfig: not use cc310 by default
Usage of cc310 by defaults gives poor user
experience out of the box as it requires manual
cloning of nrfxlib repository.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-10-02 12:45:51 +02:00
Tamas Ban 4e8d838d36 cypress: Add fault injection mitigation
Add software countermeasures against fault injection attacks.

Change-Id: I35ae95a3387a0231f81782e22728bf8a3f9b6005
Signed-off-by: Tamas Ban <tamas.ban@arm.com>
Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
Signed-off-by: Roman Okhrimenko <roman.okhrimenko@cypress.com>
2020-10-02 07:31:11 -03:00
Tamas Ban 76177e1b8e boot/mynewt: Add fault injection mitigation
Add software countermeasures against fault injection attacks.

Change-Id: Ibea597fd9ee2bf0693f79f5979304143e2b3db2d
Signed-off-by: Tamas Ban <tamas.ban@arm.com>
Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2020-10-02 07:31:11 -03:00
Tamas Ban ee6615def0 boot/zephyr: Add fault injection mitigation
Add software countermeasures against fault injection attacks.

Change-Id: I82f2d6b529ee2bd8d58ec6d5302c01680b4fd483
Signed-off-by: Tamas Ban <tamas.ban@arm.com>
Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2020-10-02 07:31:11 -03:00
Tamas Ban fce873364e boot/zephyr: Add fault injection hardening profile to Zephyr config
Add fault injection hardening profile configuration to Zephyr config.
Default config is to not have any hardening in SW against hardware level
fault injection like clock or power glitching, EM pulse, laser beam, etc.

Change-Id: I67d22d257ead83e1e288de0ee7621aac32bf50eb
Signed-off-by: Tamas Ban <tamas.ban@arm.com>
Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2020-10-02 07:31:11 -03:00
Raef Coles e8fe6cf259 boot: Harden critical path against fault attacks
Add fault attack mitigation measures to code vital for the correct
validation of images.

Change-Id: If6eb1110a8c2966faf105d07ad2e95482a80a8d9
Signed-off-by: Raef Coles <raef.coles@arm.com>
Signed-off-by: Tamas Ban <tamas.ban@arm.com>
2020-10-02 07:31:11 -03:00
Roman Okhrimenko 1dcc73b0b8 Add ifdefs in crypto abstract function for ec256 to enable compilation when mbedtls used as backend
Signed-off-by: Roman Okhrimenko <roman.okhrimenko@cypress.com>
2020-10-01 14:02:24 -03:00
Håkon Øye Amundsen 6a8dbbadf7 boot: zephyr: reset SPLIM registers before boot
to avoid causing stack overflow in the image being booted.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2020-10-01 15:01:21 +02:00
Fabio Utzig 8ebe53537b doc: fix link to external page in PORTING
Remove a footnote that is not generating a proper link and add an inline
link to the mbed TLS referece for platform.h. This also fixes a warning
when running through recommonmark==0.6.0 because it is unable to parse the
old syntax.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2020-10-01 09:16:47 -03:00
Roman Okhrimenko 6ea44be64f cypress: update user documentation with disclaimer and additional instructions
This change adds Disclaimer section to Cypress related documentation and adds details about custom hardware configuration flow.

Signed-off-by: Roman Okhrimenko <roman.okhrimenko@cypress.com>
2020-09-30 03:46:36 +03:00
Roman Okhrimenko ff026122e1 Cypress: Disable entering deep sleep if no boot/upgrade images found
Entering deep sleep on CM0 without valid application on CM4 caused pyocd error while programming. This fix disables entering deep sleep mode on CM0 if no valid applications found for boot. Waiting for uart complete tx reworked. Code refactoring

Signed-off-by: Roman Okhrimenko <roman.okhrimenko@cypress.com>
2020-09-30 03:22:53 +03:00
Fabio Utzig af48fcea16 ci: re-enable signed-off-by check on workflows
Enable commit signed-off-by check like previously done on Travis-CI.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2020-09-29 16:22:58 -03:00
Håkon Øye Amundsen ee7282dc42 kconfig: zephyr: use ECDSA with CC310 if CC310 hw is present
This is the preferred signing type with this HW available.
Add 'ECDSA' to the kconfig name to align with the tinycrypt variant.
Remove superfluous checks on select operations.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2020-09-29 10:27:53 +02:00
Håkon Øye Amundsen 705c6c2b67 kconfig: zephyr: provide logic for setting key file, simplify prj.conf
Automate process of selecting correct .pem key file.

Zephyr users are familiar with using 'menuconfig' and similar tools
for seeing what options are available, so remove =n choices from
prj.conf which were used to show the available options.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2020-09-29 10:27:53 +02:00
Fabio Utzig 301e9755bd boot: mynewt: fix CI issues with mbedTLS CTR mode
Enable Mynewt syscfg to bring in mbedTLS CTR mode.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
Signed-off-by: Blaž Hrastnik <blaz@mxxn.io>
2020-09-28 09:08:44 -06:00
Blaž Hrastnik 8097d86b2f Compile with MBEDTLS_CIPHER_MODE_CTR set.
Signed-off-by: Blaž Hrastnik <blaz@mxxn.io>
2020-09-28 09:08:44 -06:00
Blaž Hrastnik 4f4833d465 Abstracting mcuboot crypto functions for cleaner porting and less of an ifdef hell.
- The enc_context needs to initialize.

boot_enc_load seems to always be used to start the process, so calling
init inside makes sense.

- Handle boot_encrypt getting called with size of 0.

- No need to free contexts because Zephyr sets MBEDTLS_PLATFORM_NO_STD_FUNCTIONS.

I don't quite like this because it's implicit and will leak memory on
other ports.

Signed-off-by: Blaž Hrastnik <blaz@mxxn.io>
2020-09-28 09:08:44 -06:00
Blaž Hrastnik f62ea0c464 bootutil *should not* import assert.h
bootutil already handles ASSERT definition, allowing us to override it
with a custom implementation. Importing assert.h would pull in stdio.h
and a whole bunch of other stuff by TI compiler into the final
firmware.

Signed-off-by: Blaž Hrastnik <blaz@mxxn.io>
2020-09-28 09:08:44 -06:00
Blaž Hrastnik 453231ca12 Remove unused headers.
Signed-off-by: Blaž Hrastnik <blaz@mxxn.io>
2020-09-28 09:08:44 -06:00
Blaž Hrastnik 30feaf648d hal_flash is unused, remove the import.
All code referencing hal_flash functions was previously removed.

Signed-off-by: Blaž Hrastnik <blaz@mxxn.io>
2020-09-28 09:08:44 -06:00
Fabio Utzig 10c97baa77 ci: split slow tests
Allow slow tests to run as separate jobs, this should speed up CI run.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2020-09-26 07:47:17 -03:00
Fabio Utzig d8e2efdb01 ci: sim: rename workflow
Rename workflow to "sim"

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2020-09-26 07:47:17 -03:00
Fabio Utzig 61a6132cfa ci: mynewt: remove non-required features
Mynewt testing does not need git submodule so avoid cloning them. Remove
MULTI_FEATURE environment variable only used by sim.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2020-09-26 07:47:17 -03:00
Fabio Utzig 78a9fd2a40 workflows: run on PR only
Remove option to run on push because it is triggering two runs for each
test for all PRs.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2020-09-26 07:47:17 -03:00
David Brown 5e3b066e0a github: Add workflow to test mynewt builds
This reproduces the CI test build for Mynewt that is currently run by
Travis.

Signed-off-by: David Brown <david.brown@linaro.org>
2020-09-25 09:13:30 -03:00
David Brown 2d99cba4f2 github: Add workflow test for simulator
This adds a github workflow test that reproduces the same behavior as
the current travis workflow test (for the simulator).  Most of the work
is done by support scripts, and it is the list of tests that is
duplicated from the .travis.yaml file.

Signed-off-by: David Brown <david.brown@linaro.org>
2020-09-25 09:13:30 -03:00
dmiv 8672c8e98a Cypress: Add entering deep sleep in MCUBootApp, code improvements
- improved code in MCUBootApp
- added possibility to enter deep sleep mode after mcuboot app execution
- minor refactoring

Signed-off-by: dmiv <dmiv@cypress.com>
Signed-off-by: Roman Okhrimenko <roman.okhrimenko@cypress.com>
Signed-off-by: Taras Boretskyy <taras.boretskyy@cypress.com>
2020-09-22 18:27:21 +03:00
Roman Okhrimenko 42b32394d6 imgtool: Add possibility to set confirm flag for hex files as well
Fix imgtool does not take into account value of confirm flag, when signing .hex images

Signed-off-by: Roman Okhrimenko <roman.okhrimenko@cypress.com>
2020-09-18 20:30:14 +03:00
David Vincze b2a1a48561 imgtool: Fix 'custom_tlvs' argument handling
When Image.create() is called without the 'custom_tlvs' argument, it
gets its default value (None). It must be checked before performing
any operations on/with it.

Change-Id: I8e0755265f35f9eeb796fe078a6ad8c8d9f2b8da
Signed-off-by: David Vincze <david.vincze@linaro.org>
2020-09-18 14:45:13 +02:00
Tamas Ban 67e3fff047 docs: Revert the moving of design.md
This commit fix the issue reported in #803:
https://github.com/JuulLabs-OSS/mcuboot/issues/803

Signed-off-by: Tamas Ban <tamas.ban@arm.com>
2020-09-18 10:51:22 +02:00
David Brown a84b64761c samples: zephyr: Extract build artifacts from archive
Optionally extract build artifacts from an archive file instead of
building them.  This completes the separation between building the tests
and running them.  To use this, do something like:

    go run test-compile.go

Arrange to have the mcuboot dir and the test-images.zip on the test
target, and then run:

    go run run-tests.go -prebuilt test-images.zip

Signed-off-by: David Brown <david.brown@linaro.org>
2020-09-17 16:49:09 -06:00
David Brown f15a010e74 samples: zephyr: Separate build commands
Instead of just having the build commands part of the test execution,
separate them into a separate value.  This will facilitate having an
option that doesn't actually build the tests, but extracts them from an
archive.

Signed-off-by: David Brown <david.brown@linaro.org>
2020-09-17 16:49:09 -06:00
David Brown c997a607e5 samples: zephyr: Add separate compilation
Create a program that separately compiles the tests and assembles them
into a zip file.  This will help when the build environment and the test
environment are not the same machine.

Signed-off-by: David Brown <david.brown@linaro.org>
2020-09-17 16:49:09 -06:00
David Brown 5e8dbb9944 samples: zephyr: Split out tests from test runner
Move the list of tests to run from the test runner itself into its own
package.  The test can be invoked the same way (Go will find the go.mod
at the top of mcuboot), but this will make it easier to separate a test
runner from a test builder.

Signed-off-by: David Brown <david.brown@linaro.org>
2020-09-17 16:49:09 -06:00
David Brown d662caace2 go: Create a go.mod at the top
This module file tells the Go tools the URL space where this project
lives.  This allows code within the project to refer to these files by
URL.

Signed-off-by: David Brown <david.brown@linaro.org>
2020-09-17 16:49:09 -06:00
Andrzej Puzdrowski 03d96ad1f6 boot/zephyr: Added single-slot Zephyr-RTOS test build
Added configuration for build in Zephyr-RTOS CI MCUBoot
in CONFIG_SINGLE_APPLICATION_SLOT=y mode.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-09-16 12:09:43 +02:00
Andrzej Puzdrowski fdff3e1ea0 boot/zephyr: renamed single-image mode to single-application-slot mode
The terms "single-image boot" and the "single image application"
of Zephyr are confused. It might be might be understood as one-pair image
dual-bank mode in comparison to multi-image mode.

This patch replaces CONFIG_SINGLE_IMAGE_DFU by
CONFIG_SINGLE_APPLICATION_SLOT name,
which makes this mode name unambiguous.

fixes #800

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>

fix
2020-09-16 12:09:43 +02:00
Tamas Ban fe03109ab1 boot: Add ram-load upgrade mode
This patch introduces the ram-load mode in addition to the other
upgrade modes (swap strategies, overwrite-only, direct-XIP). When
ram-load is enabled with the MCUBOOT_RAM_LOAD option, mcuboot
selects the newest valid image based on the image version numbers from
the image header, thereafter the selected image loaded to the RAM and
executed from there. Load address is extracted from the image header.
Therefore the images must be linked to the RAM memory region.
The ram-load mode is very similar to the direct-XIP mode, main
difference is to load the newest image to the RAM beforehand the
authentication and execution. Similar to direct-XIP mode either
of the primary and the secondary slots can hold the active image.

Ram-load can be useful in case of a bit more powerful SoC, which
is not constrained in terms of internal RAM. It could be that image
is stored in external and therefore untrusted flash. Loading image
to internal (trusted) RAM is essential from the security point
of view the system. Furthermore execution from internal RAM is much
faster than from external flash.

This patch is based on the RAM_LOADING upgrade strategy which was
first introduced in the Trusted Firmware-M project.
Source TF-M version: TF-Mv1.0.

Change-Id: I95f02ff07c1dee51244ac372284f449c2efab362
Signed-off-by: Tamas Ban <tamas.ban@arm.com>
2020-09-16 11:06:30 +02:00