Commit Graph

1143 Commits

Author SHA1 Message Date
David Brown a0cb24b84e sim: Remove some extraneous print
These were added during development to make sure conditional compilation
was working.  Now, they just cause excess messages to be printed.
Remove them.

Signed-off-by: David Brown <david.brown@linaro.org>
2019-12-04 11:21:56 -07:00
Fabio Utzig d37d877603 Add html anchors to design and imgtool documents
When pages are built from the markdown sources, the html anchors for
titles are automatically added, but no links are inserted in the pages.
This makes it harder to send URLs to sections; one has to browse the
page source to get the correct link. This fixes the issue by adding
links directly to the generated pages.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-12-03 16:35:58 -03:00
David Brown 586c84e942 README.md: Minor typographical and grammar fixes
These are some minor fixes to the README.md files submitted by Aidan
Earle <a_earle@live.com>.

Signed-off-by: David Brown <david.brown@linaro.org>
2019-12-03 10:37:46 -07:00
Sergey Koziakov 3f0738d29f zephyr: restore removed #endif in target.h
8accafd5c7 has removed #endif statement
belonging to unrelated #if, causing compilation error. Restore it.

Signed-off-by: Sergey Koziakov <dya.eshshmai@gmail.com>
2019-12-03 07:08:37 -03:00
Martí Bolívar 0e3fa72df4 zephyr: Fix board logic
Don't set the board to qemu_x86 either; that's not right by any means.

Remove dts.overlay and build system logic related to it in
boot/zephyr/CMakeLists.txt. This file was a hack for arduino_101,
which is no longer supported by Zephyr.

Remove all the other DTC_OVERLAY_FILE logic in general while we're
here. Zephyr picks up
${APPLICATION_SOURCE_DIR}/boards/${BOARD}.overlay and uses it as
DTC_OVERLAY_FILE "for free" if DTC_OVERLAY_FILE is unset.

Adjust the minimum CMake version while we're here to account for
Zephyr build system changes.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Signed-off-by: David Brown <david.brown@linaro.org>
2019-12-02 11:56:24 -07:00
David Brown 8accafd5c7 zephyr: Remove outdated workaround for Kinetis
Remove this workaround.  The Kinetis flash driver has supported
FLASH_PAGE_LAYOUT since at least January 2018.

Signed-off-by: David Brown <david.brown@linaro.org>
2019-12-02 11:56:24 -07:00
Fabio Utzig 478ad247b3 docs: add URL anchor links to encrypted images md
URL anchors are already generated automatically by the GH markdown
processor, but they are not visible. This adds the proper links to the
page.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-11-29 12:55:33 -03:00
Jon Helge Nistad e58f9bd0eb boot: zephyr: Add check of RESETREAS for nRF SoC
Only execute serial recovery if valid pin condition is detected
during power up reset or pin reset on nRF devices with RESETREAS
register. This is to prevent going into serial recovery when
waking up from power off mode with the same pin conditions that
is configured to trigger serial recovery.

Signed-off-by: Jon Helge Nistad <jon.helge.nistad@nordicsemi.no>
2019-11-26 15:25:52 +01:00
Fabio Utzig 3c44607e16 bootutil: fix enckey issue when reverting
While doing a revert, the image encryption keys might be saved temporarily
in the scratch area; this is required in situations that we need to swap
one of the last sectors of the primary slot. When this happens, and the
device is interrupted just after restarting the revert swap, bootutil will
try to load the encrypted keys from the primary slot, and possibly use them
in reverted order (image in primary uses key of image in secondary and
vice-versa) which was saved in the test upgrade.

This fixes the issue by reverting the order used to check for the swap
metadata, with scratch being checked before the primary slot.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-11-22 15:15:29 -03:00
Fabio Utzig e84f0effb3 sim: add randomly generated image encryption keys
Removes the hard-coded image encryption keys, and updates with keys
generated randomly before use. This tests the correct behavior of
how ephemeral keys should be used when generating new images.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-11-22 15:15:29 -03:00
Fabio Utzig 9a2b5de5d4 sim: derive Default for TlvGen
Avoid having to declare default values in type instantiation.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-11-22 13:57:27 -03:00
Fabio Utzig 23e99b0d7e boot: encrypted: fix HKDF input size macro
Use correct macro for the size of a DH shared secret. The previously
used macro had the same size (SHA-256 digest length) but incorrect
semantics.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-11-22 13:56:18 -03:00
David Brown 005e7a0ff3 travis: Add large-write to all overwrite-only tests
Add the large-write feature to all of the tests that test
overwrite-only.  This verifies that these large writes will work in all
of these configurations.

Signed-off-by: David Brown <david.brown@linaro.org>
2019-11-18 10:48:11 -07:00
David Brown 95de450b64 sim: Add test support for large write alignment
To start adding support for devices with a large write size, modify the
simulator to allow a 'large-write' feature that will also run tests with
128 and 512 byte write alignments.

This requires fixing some places in image generation that assumed a
fairly small alignment (namely, padding the buffer at the end, rather
than individual parts), and detecting the large writes when writing the
MAGIC value to the image.

The flash API still passes the alignment back as a uint_8, but in
overwrite mode, this verifies that the boot code won't use this value.

Currently the 'large-write' feature requires 'overwrite-only' as well.

Signed-off-by: David Brown <david.brown@linaro.org>
2019-11-18 10:48:11 -07:00
David Brown eecae52af8 sim: Don't mark permanent in overwrite mode
Overwrite mode is always a permanent upgrade, so skip trying to mark
this in the images.  This marking is problematic with larger write
alignments.

Signed-off-by: David Brown <david.brown@linaro.org>
2019-11-18 10:48:11 -07:00
David Brown 347dc5726d sim: Remove Option from MAGIC
This constant array is always just unwrapped.  Remove the Option from
its type, and just make it an array.

Signed-off-by: David Brown <david.brown@linaro.org>
2019-11-18 10:48:11 -07:00
David Brown 5a317752fb sim: Use `usize` instead of `u8` for alignment
Some devices have a write alignment larger than 128.  Allow this within
the simulator, by using `usize` instead of `u8` for the write alignment.
The value is still returned to the C code as an 8-bit integer, but this
help start debugging issues found on these devices.

Signed-off-by: David Brown <david.brown@linaro.org>
2019-11-18 10:48:11 -07:00
David Brown ab449187b4 boot: store write align as uint32_t
In overwrite-only mode, the write alignment is not used for much.
Making this a larger value will allow the alignment for a particular
device to be larger than a uint8_t.  This will make the trailer size
very large for these devices (and prevent
!defined(MCUBOOT_OVERWRITE_ONLY) from being used), but at least allows
the overwrite only mode to be used on these devices.

Signed-off-by: David Brown <david.brown@linaro.org>
2019-11-18 10:48:11 -07:00
sigvartmh 477ff5bab0 Bugfix: nRF Cryptocell not being disabled
Copy paste bug in cc310 glue layer for nRF where disable does not set
the enable register to 0. Thanks to @solsbarry for pointing this out.

Fixes: #586

Signed-off-by: sigvartmh <sigvart.m@gmail.com>
2019-11-06 18:35:00 -03:00
Fabio Utzig 8554ed5be6 travis: add sig-ecdsa + enc-ec256 to sim
Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-11-06 06:55:25 -03:00
Fabio Utzig ffc673e7d2 sim: remove deprecated usage of sync::ONCE_INIT
Switch to `Once::new()`.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-11-06 06:55:25 -03:00
Fabio Utzig 90f449ee5c sim: add testing of ECIES-P256 images
Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-11-06 06:55:25 -03:00
Fabio Utzig cbd58e3f83 sim: cargo: update dependencies
Update ring to latest (`0.16.9`) and update crates (`cargo update`).

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-11-06 06:55:25 -03:00
Fabio Utzig 73243918cd sim: add EC256 encryption key
Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-11-06 06:55:25 -03:00
Fabio Utzig 5fde832bbf bootutil: add ECIES-P256 support
Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-11-06 06:55:25 -03:00
Fabio Utzig 5ef883a9b9 caps: add ECIES-P256
Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-11-06 06:55:25 -03:00
Fabio Utzig ccc0280dd8 boot: zephyr: tabs -> spaces in CMakeLists.txt
Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-11-06 06:55:25 -03:00
Fabio Utzig 42cc29abfe boot: zephyr: add ECIES-P256 configuration
Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-11-06 06:55:25 -03:00
Fabio Utzig c67dd70423 boot: mynewt: add config for ECIES-P256 encrypted images
Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-11-06 06:55:25 -03:00
Fabio Utzig 7a3b2605ac imgtool: add creation of ECIES-P256 encrypted images
Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-11-06 06:55:25 -03:00
Fabio Utzig b3f058c0ef docs: describe ECIES-P256 encrypted image support
Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-11-06 06:55:25 -03:00
Iosif Macesanu 2d18f2577b boot: zephyr: boards: add Actinius Icarus board
Add Actinius Icarus board configuration to be able to enter serial
recovery mode

Signed-off-by: Iosif Macesanu <iosif@actinius.com>
2019-11-04 14:37:07 +01:00
Ruth Fuchss 4023d62849 docs: add link to encrypted_images.md and cleanup
Add a link to the topic about encrypted images to the start page.
Clean up the existing links to make the table of contents more
consistent.

Signed-off-by: Ruth Fuchss <ruth.fuchss@nordicsemi.no>
2019-11-01 13:10:41 -03:00
Ruth Fuchss 721cdbc49e docs: add missing heading
Add an H1 heading to encrypted_images.md.

Signed-off-by: Ruth Fuchss <ruth.fuchss@nordicsemi.no>
2019-11-01 13:10:41 -03:00
Fabio Utzig f5556c3eba imgtool: fix header padding value check
Commit 9117fded47 added support for
supplying an `--erased-val`, which defaults to 0xff. When padding a
header, the checks were still validating against 0, which is the
value used for padding by the Zephyr build system. Now when the
user passes `--pad-header` this check is skipped (we already know
the contents).

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-10-31 12:10:31 -03:00
Sam Bristow d0ca0ffc27 Fix up typos
Ran automated checker for common typos [1]. Most of these changes have
no functional change *except* for `./ci/sim_run.sh` where, previously
the `bootstrap` feature wasn't being selected properly.

I didn't touch anything in the `./ext/` folder as anything in there
should probably be fixed in the upstream repo.

[1] https://github.com/codespell-project/codespell

Signed-off-by: Sam Bristow <sam@bristow.nz>
2019-10-30 06:24:10 -03:00
Andy Gross 441e997891 mynewt: Make cflags consistent for if or ifdef usage
This patch changes the cflag entry for MCUBOOT_MYNEWT to make it
consistent when using #if or #ifdef.

Signed-off-by: Andy Gross <andy.gross@juul.com>
2019-10-21 17:22:34 -03:00
Fabio Utzig e47ccd63df mynewt: allow overriding the startup routine
Add a new Mynewt option that allows for overriding the default
`hal_system_start` routine; this allows for startup customizations
required by some BSPs.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-10-21 17:21:27 -03:00
Fabio Utzig e5ac82797f imgtool: release 1.5.0alpha1
Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-10-17 20:00:47 -03:00
Fabio Utzig 8828280d5d imgtool: fix typo in flag name
Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-10-17 20:00:47 -03:00
Fabio Utzig 2269f47eb4 imgtool: Add complete trailer to HEX images
When generating HEX output, instead of just adding the `magic`, also add
the whole trailer (with erased value). This allows for HEX writing tools
to erase the trailer region, avoiding possible issues when garbage
exists there.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-10-17 20:00:47 -03:00
Fabio Utzig 9117fded47 imgtool: add erased-val cli option
Add `-R`/`--erased-val` CLI option when creating images, which accepts
a value to be used for padding. This is useful when creating images
that run in devices that have flash erased to some value different
from 0xff (like STM32L0x and STM32L1x that have 0s).

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-10-17 20:00:47 -03:00
David Brown f5c5dd0d90 Revert version.yml after release
Needed by the MyNewt build/release process.

Signed-off-by: David Brown <david.brown@linaro.org>
2019-10-17 15:47:38 -06:00
David Brown ac55554059 Prepare for v1.4.0 release
Update release notes and various version stamps.

Signed-off-by: David Brown <david.brown@linaro.org>
2019-10-17 15:47:38 -06:00
David Brown d7581779d8 Prepare for release v1.4.0-rc2
Update version stamps as well as the release notes.

Signed-off-by: David Brown <david.brown@linaro.org>
2019-10-15 14:50:09 -06:00
David Brown 9bf95afd43 boot: Check overflow/bounds on image header size
Before using the image and header size fields from the image header,
verify that both of these values are sane.  In this case, sanity means
that there is no arithmetic overflow when they are added, and that the
result is within the bounds of the containing flash region.  This is
done in addition to the check of the header's magic number.

Signed-off-by: David Brown <david.brown@linaro.org>
2019-10-15 09:41:01 -06:00
David Brown effb06e367 boot: Add overflow-safe 32 and 16-bit add functions
To facility better checking for integer overflow, add these two
functions to add while checking for overflow.  If the result overflows,
they will return an error, instead of performing the addition.

Signed-off-by: David Brown <david.brown@linaro.org>
2019-10-15 09:41:01 -06:00
Fabio Utzig c7fe3b061e Document imgtool release process
Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-10-15 12:35:01 -03:00
Fabio Utzig edbabcf623 imgtool: allow address adjustment in output hex
Add a new flag `-x` (or `--hex_addr`) which adjusts the memory address
where this file has to be written to. This is useful when generating
upgrade images that will go to the secondary slot, in cases where the
user is not using mcumgr or some other delivery mechanism, and has to
manually adjust the addresses using `objcopy`.

Also when using hex files, image padding now only adds a segment with
the magic at the end instead of filling the whole output with `0xff`.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-10-15 12:32:33 -03:00
David Brown 1318938006 Upgrade mbedtls submodule to 2.16.3
Upgrade the referenced mbedtls submodule to 2.16.3, the latest stable
release as of this commit.

Signed-off-by: David Brown <david.brown@linaro.org>
2019-10-15 09:29:20 -06:00