Commit Graph

104 Commits

Author SHA1 Message Date
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 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
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 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
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
Fabio Utzig f0131cd5b7 imgtool: add mailing list email to setup
Seems like pypi.org is not accepting "None" for email anymore, so this
just adds the mailing list in case someone needs to contact the project.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-10-12 18:47:05 -03:00
Fabio Utzig 510fddb8e0 imgtool: update to new protected TLV format
Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-10-01 18:30:05 -03:00
Fabio Utzig 649d80f685 imgtool: fix trailer size calculation
Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-10-01 18:30:05 -03:00
Fabio Utzig 4f0ea747c3 Fix pep-8 (long line)
Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-09-17 14:03:58 +02:00
Fabio Utzig b916e8dbb0 Fix author_email UNKNOWN in pip show
Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-09-17 14:03:58 +02:00
Fabio Utzig 25c6a1590a Add versioning to imgtool
Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-09-17 14:03:58 +02:00
Håkon Øye Amundsen df8c8918b7 scripts: allow user to set load_addr
Allow the user to set the load_addr field of the header.
This could be useful in multi image situations to help
deduce the image number of an update without having to
look at the swap info.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2019-09-06 12:18:07 -03:00
Fabio Utzig 539d7662d1 Fix assemble.py tool for compatibility
This accounts for changes in the Zephyr build which include:

1) Flash areas are prefixed with `DT_`
2) The generated DTS was renamed to generated_dts_board_unfixed.h
3) The build tree has an extra "zephyr" dir.

Fixes #408

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-09-06 09:31:57 -03:00
David Brown 297029ab72 sim: Add debugging ptable to image dumps
Add a `debug_dump()` method to `Images` to allow the images to be
written to a file.  The dependency test will call this if the
environment variable MCUBOOT_DEBUG_DUMP is set.

In order to make these debug dumps more useful, add a simple partition
table to the beginning of the image (where MCUboot would reside on
target).  This has a simple header, and then entries for each partition,
using the partition ids used within the simulator.  This allows the
image to be more easily used by external tools.

As an example, `scripts/mcubin.bt` is a binary template for the [010
Editor](https://www.sweetscape.com/010editor/), allowing it to decode
and show the details of images from MCUboot.

Signed-off-by: David Brown <david.brown@linaro.org>
2019-08-15 14:23:37 -05:00
Christian Skubich f13db126bd bugfix imgtool verify()
Signed-off-by: Christian Skubich <christian@skubware.de>
2019-08-09 06:58:18 -03:00
Marek Pieta e955510d13 scripts: Show image version while verifying
Change adds showing image version while verifying.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2019-08-08 12:00:21 -03:00
David Brown bd7925e39e image: use explitic padding on dependency version
This struct currently relies on padding being done by the C compiler.
Although this is generally done the same across targets, this isn't
required, and it is better to make any padding explicit.  This also
makes it clear that there is extra space in this structure that can be
used for another purpose.

The python imgtool is also fixed to match.  It was using a 32-bit int,
which only worked in the little endian case.

Signed-off-by: David Brown <david.brown@linaro.org>
2019-07-31 09:59:38 -05:00
Szymon Janc 7fea84665f Release 1.3.1
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2019-07-08 08:50:16 -03:00
Fabio Utzig 4bd4c7cfb9 Allow imgtool to generated encrypted ed25519 keys
Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-06-28 08:46:12 -03:00
Andrzej Puzdrowski 9686e702e4 requirements.txt: bump cryptography Py package version
Since Ed25519 curve primitives are available since cryptography package
version 2.6 need to bump its version.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-06-18 14:08:27 +02:00
Fabio Utzig 8101d1fa44 Add ed25519 signing support to imgtool
This adds ed25519 signature support using the "prehash" method. Instead
of using the direct contents of the image and header payloads, a sha256
is generated and signed (SHA256-Ed25519). This allows for compatibility
with already existing tools that use the sha256 hash, like mcumgr, etc.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-06-13 19:21:05 -03:00
Fabio Utzig 4a5477ad96 Add new verify command
imgtool verify -k <some-key.(pub|sec)> <img-file>

Allow imgtool to validate that an image has a valid sha256sum and that
it was signed by the supplied key.

NOTE: this does not yet support verifying encrypted images

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-05-29 08:56:12 -03:00
Fabio Utzig 19fd79a496 Add RSA-3072 support to imgtool
Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-05-16 14:01:19 -03:00
David Vincze da8c91993d imgtool: Add support for dependency description
This commit aims to add the ability to specify and add dependency
TLVs to MCUBOOT. Due to the private nature of this feature, having
dependency TLVs mean that the TLV Info header and these TLVs become
part of the protected area (they are supposed to get signed as well).
Since the TLV Info header containing the whole TLV section's size
becomes protected, this size needs to be calculated in advance to get
proper hash values.

Change-Id: I13277a3b595acc2bb8c5084420f3d61c8d301dc2
Author: Bence Kaposzta <bence.kaposzta@arm.com>
Signed-off-by: David Vincze <david.vincze@arm.com>
2019-04-11 15:07:54 -03:00
Chris Bittner fda937ab02 imgtool: Discard public RSA if set for signing
If imgtool is used for signing with encryption
it will disallow using public RSA key for
signing.

Signed-off-by: Chris Bittner <chris.bittner@nordicsemi.no>
2019-03-29 08:13:57 -03:00
David Vincze 2d736ad4c5 Replace flash partitioning terminology
This change replaces the slot 0/1 terminology with primary/secondary
slot and replaces FLASH_AREA_IMAGE_0/1 with
FLASH_AREA_IMAGE_PRIMARY/SECONDARY. This naming convention may be more
understandable, fits better to MCUs with multiple images and it is an
architecture agnostic alternative as well.

Change-Id: I655a585f6ae023852c671ee6635399efe25209c9
Signed-off-by: David Vincze <david.vincze@arm.com>
Signed-off-by: David Brown <david.brown@linaro.org>
2019-03-13 15:40:21 -06:00
Fabio Utzig 94a9b261da Create CI resources directory
Add a new directory "ci", to easily add new tests with setup/run phases
that don't require direct setup in .travis.yml. This also avoids
polution of scripts/.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-03-12 10:37:49 -03:00
David Brown 5e9078f1e0 Bump version to 1.3.0-rc1
First pre-release for v1.3.0.

Signed-off-by: David Brown <david.brown@linaro.org>
2019-01-24 10:03:37 -07:00
Fabio Utzig 79df58e695 Allow bootstrap feature on CI
Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-01-12 14:38:18 -07:00
Fabio Utzig 7c00acd737 imgtool save to format of given output filename
Updates imgtool to infer, based on output image filename, which format
should be use for output file. Filenames that end with extension `.hex`
are saved in Intel HEX, otherwise saves a binary image.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-01-09 06:28:55 -02:00
Fabio Utzig e89841d5ea Add imgtool publishing support
This adds initial support for publishing imgtool to pypi.org.

The main imgtool.py was moved to imgtool package and made into the main
file, and a new imgtool.py that calls into the package, was added allowing
for the old usage behavior to remain functional.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-01-08 07:29:24 -02:00
Fabio Utzig cd28406e9a Fix image creation without sign/encryption
Generating images with no signature or encryption was broken by commit
06b77b8353

This allows generating images with just sha256 again, and fixes a few
leftovers from the imghash TLV change.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-12-17 10:51:46 -02:00
Fabio Utzig 71a697a4ea Add minimum size validation for header parameter
Throw exception on values that are less than the minimum acceptable size
of 32 bytes.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-12-17 09:45:55 -02:00
Fabio Utzig 38609e0c9c Fix typo in signed-off-by check error message
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-11-27 13:47:14 -03:00
Fabio Utzig 0e12f6ce98 Travis speed ups
Because the amount of features that the simulator is testing is growing,
the test time is taking a long time. This distributes simulator's tests
over three travis machines to decrease test time.

Add options to defined tests that run one-by-one in a sequential fashion
by defining them in $SINGLE_FEATURES, and allow defining features that
should run together by providing a string of ',' separated list of
multiple tests in $MULTI_FEATURES.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-11-27 13:47:14 -03:00
Fabio Utzig e3937255d7 Fix imgtool encrypt rebase issue
Avoid passing invalid `encrypt` param to image constructor.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-10-14 06:00:15 -07:00
Fabio Utzig 06b77b8353 Add imgtool support for encrypted image creation
Adds a new flag to imgtool, -E/--encrypt which accepts a public rsa-2048
key file that will be used to encrypt the image.

The encryption method uses AES-128-CTR to encrypt the image data (ignores
the header and TLVs), using a random key that is itself encrypted using
RSA-2048-OAEP and added to the generated image as a new TLV.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-10-12 13:36:13 -03:00
Fabio Utzig 73d8b03312 Remove redundant text in SoB error message
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-10-12 12:35:29 -03:00
Fabio Utzig d8f84bcc39 Print missing Signed-off-by line info
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-10-11 10:06:27 -03:00
Mark Schulte a66c68732e [imgtool] Add big endian support
Add big endian support to imgtool so that it can be used on big endian
targets.

Signed-off-by: Mark Schulte <mschulte@lyft.com>
2018-09-27 13:55:58 -03:00
Mark Schulte 884be206f9 imgtool: Adjust base_addr when injecting header
If adding a header to a .hex file (using the command line
"--pad-header"), the hex file gets shifted by header size. This may
cause hard coded addresses to be off by "header-size", making the
firmware unusable. Instead, adjust the base address by the header
size, so the existing firmware in the hex file is loaded to the
proper addresses.

Signed-off-by: Mark Schulte <mschulte@lyft.com>
2018-07-17 12:04:17 -03:00
Evan Gates 0ccee8741d fix the offset and size regular expressions in assemble.py
Given the example lines:

 #define FLASH_AREA_MCUBOOT_OFFSET_0 0x0
 #define FLASH_AREA_MCUBOOT_OFFSET   FLASH_AREA_MCUBOOT_OFFSET_0

Changing OFFSET_0 to OFFSET(_0)? allows the re to possibly match the
second line where it would have stopped the match before. This combined
with the (0x)? means that the re does match the second line, with the
third group being just the F of FLASH_AREA_IMAGE_1_OFFSET_0. The int()
function fails because F is not a valid number. This commit makes the
matching more precise by 1) matching the 0x when there are hex digits
and without the 0x when there are decimal digits and 2) matching until
the end of the line.

Signed-off-by: Evan Gates <evan@gnarbox.com>
2018-07-10 11:11:52 -03:00
Fabio Utzig 44588eff41 Update `--included-header` parameter
The `--included-header` was "mandatory" when using imgtool with firmware
images generated by the Zephyr build system and it was a source of
issues when it was forgotten. This removes `--included-header` and adds
a new parameter `--pad-header` with inverted semantics, to be used only
when a zeroed header is required to be added to the firmware image.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-22 07:58:14 -03:00
Fabio Utzig dcf0c9b2b7 Allow passing in `--overwrite-only` flag
Overwrite only requires just magic + image_ok + copy_done. This fixes
issues generating images in overwrite only mode when the firmware image
is too big and overflows the swap status area.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-13 10:42:40 -07:00
Fabio Utzig 263d4398fa Add --slot-size to allow size checking without pad
Add the new `--slot-size` and make `--pad` a bool flag, to allow
checking that firmware fits in the slot without overflowing into the
trailer region even when no padding was requested.

Fixes #241

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-07 14:29:33 -03:00