Commit Graph

1431 Commits

Author SHA1 Message Date
David Brown 1997f539f7 sim: Remove extraneous static
According to clippy, `&'static` can just be `&` for static definitions,
which always have a static lifetime.  Clean this up in the arrays in the
code, as well as generation code in imgtool.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-03-11 07:25:43 -07:00
David Brown 91de33d9f7 ptest: Some simple cleanups from clippy
Run the clippy Rust linter, and apply the simple cleanups it suggests.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-03-11 07:25:43 -07:00
Dominik Ermel 5b7ed6a831 boot: zephyr: Fix compilation warnings with ZEPHYR_LOG_MODE_MINIMAL
The commit fixes definition and usage of ZEPHYR_LOG_MODE_MINIMAL
to prevent compilation warnings on possibly non-portable code.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-03-01 09:32:15 +01:00
David Brown d602ed85cf sim: Update Cargo lock file
This incorporates changes both from the dependency changes in simflash,
as well as some minor changes that recent versions of Cargo make.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-02-26 10:13:57 -07:00
David Brown c51949d208 sim: simflash: Convert to thiserror
The thiserror crate seems to be getting more momentum in the community
than failure.  Switch to this for deriving our own error type.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-02-26 10:13:57 -07:00
David Brown 218aee74a0 workflow: Test the Mbed TLS ECDSA configuration
Test the use of Mbed TLS with ECDSA in the simulator for the workflow
testing.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-02-23 10:29:31 -07:00
David Brown 641af4530c boot: Support Mbed TLS ECDSA for signatures
Add Mbed TLS ECDSA signature verification as an option (in addition to
Tinycrypt and the CC310 hardware version).  Although the Mbed TLS ECDSA
verification code is both larger and slower, this will still save space
if there is another reason that the Mbed TLS code is already being
brought in for another reason (such as certificate management, for
example).

Mbed TLS's ECDSA verification works at a different level than the other
two libraries, so this takes a bit of reworking.  There are some
additional parameters passed to the various functions, and a new define
MCUBOOT_ECDSA_NEED_ASN1_SIG to indicate that the ecdsa verification
wants the original ASN1 signature, not a decoded key.

This adds the boot changes and simulator support to test this configuration.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-02-23 10:29:31 -07:00
Dominik Ermel 0c8c8d5325 boot: Direct-XIP: Add check for IMAGE_F_ROM_FIXED flag
The commit adds logic that checks if image, that has IMAGE_F_ROM_FIXED
flag set together with proper address in header, has not been mismatched
with slot.
This code will prevent attempting to boot image that has been build for
different ROM address than a slot it currently resides in.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-02-20 07:12:11 -03:00
Dominik Ermel 9590b42c48 boot: Add IMAGE_F_ROM_FIXED flag support to mcuboot
The IMAGE_F_ROM_FIXED, now supported by imgtool and mcumgr, allows to
use image_header.ih_load_addr to store fixed ROM address information.
The address is provided for Direct-XIP mcuboot to be able to verify
if it can boot an image in given slot, by checking if the address
the image has been built for corresponds to slot address.
This flag is not required to be set within image, in which case
the check will not happen, but is highly desired as it allows mcuboot
to detect images that have been mismatched with slot.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-02-20 07:12:11 -03:00
Dominik Ermel aee3be969e boot: Order IMAGE_F_* flags defintions
Little cleanup.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-02-20 07:12:11 -03:00
Dominik Ermel cd07ed3b97 boot/zephyr: Fix Direct-XIP boot messages
The commit changes banner message to indicate that bootloader has been
built for Direct-XIP mode.
It also removes, in Direct-XIP compiled code, information on jumping
into first slot: that information is not always correct for Direct-XIP
and other messages correctly point slot that will be used.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-02-19 08:23:00 -03:00
Fabio Utzig 8a5e49876e imgtool: rollback to 1.7.0 release
Since there won't be anymore alpha releases, rollback to latest official
(from master). The next released versions now can be either 1.7.X from
v1.7-branch or X.Y.Zrc1 for the release candidate of next stable
version.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2021-02-12 09:28:47 -03:00
Fabio Utzig 7bf5179101 ci: add caching for imgtool pip packages
Cache python dependencies for faster install and test times.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2021-02-12 09:28:47 -03:00
Fabio Utzig e58f48f58a ci: update imgtool script to to use python/pip
Switch from hard-coded python3/pip to base python/pip. Also install full
imgtool package.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2021-02-12 09:28:47 -03:00
Fabio Utzig d62631af57 imgtool: fix encrypting hex images
Fixes padding hex images when encrypting. The issues stems from binaries
using `bytes` and IntelHex returning `array` where `bytes` cannot be
appended to, so use `.extend()` instead.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2021-02-11 12:41:39 +01:00
Jared Wolff df8e974ce8 boot: zephyr: adding indication LED and detect pin debounce
Setting LED to initial level before beginning.
Making comment about BOOT_SERIAL_DETECT_DELAY more clear in Kconfig.

Signed-off-by: Jared Wolff <hello@jaredwolff.com>
2021-02-08 19:42:07 +01:00
Jared Wolff 8e4d791839 boot: zephyr: adding indication LED and detect pin debounce
Add LED support and boot delay serial detect pin operation.

Signed-off-by: Jared Wolff <hello@jaredwolff.com>
2021-02-08 19:42:07 +01:00
Andrzej Puzdrowski 360763d80b bootutil/includes/enc_key: move public part to enc_key_public.h
Part of defines which are needed for bootutil_public.c compilation
were moved to separate file, so the bootutil_public library doesn't
need to include cryptographic libraries headers anymore.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-02-05 12:13:32 +01:00
Andrzej Puzdrowski 3af607f4cb botutil: botutil_public.c shall not include bootutil_private.h
Objective for existence botutil_public.c is to provide common code
for MCUboot itself and for an chain-loaded application. Therefor
it shouldn't depend on MCUboot exclusive functions or so.

This path moves missing part of bootutil_private.h to bootutil_private.c

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-02-05 12:13:32 +01:00
Jamie McCrae 816cb6ca66 boot: zephyr: boards: Add BL5340 support for using QSPI
Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
2021-02-03 12:01:17 -07:00
Roman Okhrimenko 0c7aebcfe3 cypress: Add support for watchdog timer update in boot image
Add watchdog timer to MCUBootApp plus BlinkyApp to implement  additional way of boot/upgrade image operation confirmation.

Signed-off-by: Roman Okhrimenko <roman.okhrimenko@cypress.com>
2021-02-01 16:39:18 +02:00
David Brown 79c4fcf403 scripts: Add SPDX headers
Add SPDX headers indicating the Apache-2.0 license to the scripts in the
scripts directory.  This can be assumed due to the presence of the
Apache-2.0 LICENSE file at the top of the project.

Fixes #930

Signed-off-by: David Brown <david.brown@linaro.org>
2021-01-28 09:36:55 +01:00
Gerard Marull-Paretas a513b8e668 boot:zephyr: CONFIG_LOG_MINIMAL converted to CONFIG_LOG_MODE_MINIMAL
CONFIG_LOG_MINIMAL was replaced by CONFIG_LOG_MODE_MINIMAL since
https://github.com/zephyrproject-rtos/zephyr/pull/31404 PR was
merged.
CONFIG_LOG_MINIMAL is still emitted as legacy property, but
can't be assigned so prj.conf was fixed.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-01-27 14:22:57 +01:00
Fabio Utzig d12a8da287 imgtool: fix validation with protected TLVs
After the change to support protected TLVs, the `verify` command was not
updated with proper support. Fix it by skipping any protected TLV found,
and fix the size of the hashed/signed region to also include the
protected TLV area.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2021-01-25 16:49:05 -03:00
Jared Wolff da2580d293 boot: zephyr: boards: update Circuit Dojo nRF9160 Feather conf
Add Circuit Dojo nRF9160 Feather board update. Also
adding configuration for Sparkfun Thing Plus.

Signed-off-by: Jared Wolff <hello@jaredwolff.com>
2021-01-16 08:25:52 -03:00
Fabio Utzig ce503341ad ci: relax signed-off-by checks on forks
Addresses issues when running signed-off-by checks on the Zephyr fork
due to GH rebases done on UX rewriting the commit with the primary email
instead of whatever email was used originally.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2021-01-15 11:13:18 +01:00
Raef Coles 713bb79549 ci: Update TF-M version
To fix a regression caused by f68473814f,
where an older TF-M version was used that didn't support the bootutil
cmake.

Signed-off-by: Raef Coles <raef.coles@arm.com>
2021-01-15 11:11:42 +01:00
David Brown ddd390a8e2 ptest: Allow all test runs to be logged
Check the environment variable `PTEST_LOG_ALL`, and if it is set, write
the output of all test runs to a log file instead of just the failures.
Failed test are still written to failure-nnnn.log, but successful runs
are written to success-nnnn.log.  If the environment variable is not
set, ptest behaves as before, only writing to log files when there is a
failure.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-01-14 13:19:58 -07:00
David Brown ed90fbfe9f ci: Add timing info to test builds
To help determine where time is being spent in tests, add a 'time'
command to the test invocation script.  In addition, split the test
invocation into a separate build and run stage.  This can be useful with
another change to ptest that logs all test outputs instead of just
failures.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-01-14 13:19:58 -07:00
Sherry Zhang 0cfe2ce382 bootutil: Modify boot_add_data_to_shared_area function scope
Modify the function boot_add_data_to_shared_area from static to global
thereby it can be used in the user interface boot_save_shared_data.

Signed-off-by: Sherry Zhang <sherry.zhang2@arm.com>
Change-Id: Ic6a36eb526a0883a156f832942af3138bde86dd6
2021-01-13 17:09:37 -03:00
Fabio Utzig 5b0f220659 doc: update release process with branching
Add extra step with branch creation after stable releases, to be used
for doing patch releases.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2021-01-13 16:53:07 -03:00
Fabio Utzig c1b2983be0 ci: allow imgtool publishing from release branches
Allow imgtool publishing to pypi.org when versions are update on the
release branches.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2021-01-13 16:53:07 -03:00
Andrzej Puzdrowski be64e6ade0 bootutil_public: made boot_read_swap_state_by_id() API
Made boot_read_swap_state_by_id() public API
function.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-01-13 17:49:49 +01:00
Andrzej Puzdrowski 14ef5763cc bootutil_public: documented module API
document API of the public, shared code module.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-01-13 17:49:49 +01:00
Andrzej Puzdrowski 4700b806ae bootutil_public: add function for determine image_ok flag
Added boot_read_image_ok() to public API as reading image_ok
might be used by the chain-loaded application for checking by
image itself its confirmation state.

Additionally extracted common code for determine a trailer flag to
boot_read_flash() function.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-01-13 17:49:49 +01:00
Andrzej Puzdrowski f573b392ec bootutil: extracted app common library from bootutil_misc
Part of code of boot/bootutil/ is re-implemented in zephyr-rtos
repository.
As some code are defined here and there it becomes problem when
need to include it with outstanding feature in a build.
It is possible to mitigate problem using #fdefry - but this was
rather temporary hack.

This patch introduce new module which is common for MCUBoot build
and application build.
Common code were extracted to bootutil_public.c source file and
bootutil_public.h header

MCUboot also select DISABLE_MCUBOOT_BOOTUTIL_LIB_OWN_LOG Kconfig
option, as it must define log configuration on its own for all its
sourcecode.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-01-13 17:49:49 +01:00
Henrik Brix Andersen e512181609 boot: zephyr: fix compilation with CONFIG_LOG_MINIMAL=y
Fix compilation with CONFIG_LOG_MINIMAL enabled by disabling the
custom log handling code.

Fixes e75e33d981

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-01-13 10:44:23 -03:00
Fabio Utzig ac61c2e464 Fix nokogiri<=1.11.0.rc4 vulnerability
Run "bundle update" and upgrade most ruby gems. This should fix a
warning from GH because of a vulnerable nokogiri version.

https://github.com/sparklemotion/nokogiri/security/advisories/GHSA-vr8q-g5c7-m54m

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2021-01-06 19:25:23 -03:00
Fabio Utzig 6907c90e31 ci: pull trusted-firmware-m repo on Travis run
Update volume maps so local directories in the Travis VM map correctly
to the Docker expected PATH for script running. Misc cleanups.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2021-01-06 14:13:44 -03:00
Fabio Utzig bd0ce62073 ci: pull fih-test docker image on install
Update install script to avoid building a docker image and instead pull;
also add proper caching for re-runs.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2021-01-06 14:13:44 -03:00
Fabio Utzig a069befebd ci: docker: remove source repos from fih-test
Update Dockerfile to only build a distro and required tooling, avoiding
adding source repositories, including tfm and mcuboot, so that it can be
reused without the need to rebuild all the time.

This should allow pushing the image under mcuboot/fih-test and
pulling+caching in Travis.

Signed-off-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2021-01-06 14:13:44 -03:00
David Brown 48a4ec3e84 ptest: Use github workflow instead of travis
Now that the travis description is empty, ptest no longer runs any
tests.  Change it to use the github workflow description.  It is still
fairly specific to our particular workflow, and will need to be updated
if the form of what is there changes.

The workflow description is quite a bit simpler, so a bunch of code has
been removed.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-01-06 07:59:21 -07:00
David Brown ae8f8db711 ptest: Update dependencies
The yaml-rust package version in the lock file does not work with recent
versions of Rust.  This is fixed in newer version.  Update the lock file
to represent the latest acceptable versions of all of the dependencies.
This change fixes the error at least up to Rust 1.49.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-01-06 07:59:21 -07:00
Raef Coles f68473814f ci: Pin tf-m-tests version in FIH test
To avoid problems where the latest master of tf-m-tests is incompatible
with the fixed version used by the FIH test. Bump the version of TF-M
used slightly to a commit that allows the version of tf-m-tests to be
easily overridden.

Signed-off-by: Raef Coles <raef.coles@arm.com>
2021-01-05 11:17:14 -03:00
Henrik Brix Andersen 008f4a7a30 boot: zephyr: cleanup NXP MPU configuration before boot
Cleanup the NXP MPU configuration before chain-loading the
application.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-12-18 18:31:38 +01:00
Raef Coles 7cca88ab8e ci: Update tf-m version in FIH test
To a version which uses the new bootutil cmake, allowing the bootutil
files to be moved/renamed without breaking the FIH test.

Signed-off-by: Raef Coles <raef.coles@arm.com>
2020-12-18 10:44:00 +01:00
George Beckstein 2877965864 Enable support for building mcuboot for Mbed with direct-xip
This commit also introduces changes that allow users to build for other non-swap type update methods (overwrite only, swap using move, direct xip, or RAM loading). Changes include:

- Adding configuration options relating to XIP
- Updating the Mbed flash map backend to be compatible with XIP updates
- Add default secondary_bd in internal flash for XIP on Mbed OS.

Signed-off-by: George Beckstein <becksteing@embeddedplanet.com>
2020-12-16 20:29:27 -03:00
Dominik Ermel 50820b1611 mgtool: Add support for setting fixed ROM address into image header
The commit adds support for IMAGE_F_ROM_FIXED flag that allows setting
information on image base address into image_header.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-12-16 18:06:33 +01:00
Raef Coles 81d19f017f bootutil: Add cmake build file
In order to allow other projects to include the bootutil files more
easily. Allows renaming and moving of bootutil files without breaking
external projects' file lists (if they include this cmake file instead
of directly listing the files they use). Prevents an issue where
moving/renaming bootutil files breaks the FIH CI test.

Signed-off-by: Raef Coles <raef.coles@arm.com>
Change-Id: Ic982413c6a26ea2039712437f2d511fbe202e1e4
2020-12-16 14:10:31 +01:00
George Beckstein d1233e1b2d Add reference counting to Mbed OS flash backend
The internal functions of mcuboot are not consistent in opening/closing flash areas and sometimes nested calls happen to `flash_area_open` and `flash_area_close`. With the previous implementation, a nested call to `flash_area_close` would deinitialize the underlying `BlockDevice`. This could cause subsequent flash operations on an "open" flash area to fail.

This PR adds a simple open counter for each flash area and ensures the underlying `BlockDevice` is initialized and deinitialized appropriately. The `BlockDevice` is only initialized when transitioning from an open count of 0 to 1. The `BlockDevice` is only deinitialized when the open count falls to 0.

Signed-off-by: George Beckstein <becksteing@embeddedplanet.com>
2020-12-15 14:43:24 -07:00