Commit Graph

1752 Commits

Author SHA1 Message Date
Andrzej Puzdrowski c9ac5cc6ff boot_serial: cleanup max output size calculation
Calculation of BOOT_SERIAL_OUT_MAX was based on MCUBOOT_IMAGE_NUMBER
while in other places BOOT_IMAGE_NUMBER is taken into account as
number of images. Let's align the calculation to use same literal value
as others.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-12-01 16:36:51 +01:00
Andrzej Puzdrowski 94dc19d4a6 bootutil: move BOOT_IMAGE_NUMBER definition to bootutil.h
Definition is used (and redefined) by boot_serial.c module as well.
Let's allow to use one definition for all.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-12-01 16:36:51 +01:00
Andrzej Puzdrowski 961a6107ad doc/design: fix typo in swap-using-scratch description
`image-trailer-size` should be mentioned instead
of `image-trailer-sectors-size` in the maximal-image-size
evaluation description.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-12-01 14:42:29 +01:00
Jerzy Kasenberg cbb5b23070 mynewt: Add call to custom pre-boot function
Custom boot_preboot() function can be used to start
DFU in similar way as is already done in zephyr.

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
2021-11-30 18:47:25 -03:00
Gustavo Henrique Nihei 1d7f496e1d sim: Calculate offsets from boot_max_align instead of hardcoding them
This patch prepares the simulator to execute images with a max align
value other than 8 bytes.

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2021-11-30 13:42:52 -03:00
Mikkel Jakobsen e0a8061af5 boot: zephyr: configure mimxrt1024_evk board
The mimxrt1024_evk board have a large slot so we need
to increase CONFIG_BOOT_MAX_IMG_SECTORS from the default.

Signed-off-by: Mikkel Jakobsen <mikkel.aunsbjerg@prevas.dk>
2021-11-30 17:39:30 +01:00
Andrzej Puzdrowski 9abda329fe doc/design: Add header for swap using scratch algorithm
Added sub-header for point where swap-using-scratch algorithm
is described.
Added note on the maximum image size allowed for this mode.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-11-30 14:58:34 +01:00
Andrzej Puzdrowski cd35fef32d doc/design: note on the image trailer size
Image trailer might consume notable amount of image slot size.
This path adds note for emphasize that fact.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-11-30 14:58:34 +01:00
Andrzej Puzdrowski 3c1e6d3873 doc/design: Explain swap without using scratch algorithm
Added description for explain how the algorithm works.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-11-30 14:58:34 +01:00
Petro Karashchenko 7c890f4b07 nuttx: fix compilation warnings
improved code consistency

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2021-11-25 13:34:34 -03:00
Andrzej Puzdrowski 5e76264377 zephyr: clean up CONSOLE and CONSOLE_HANDLER project configurations
CONSOLE_HANDLER is not needed for MCUboot configuration for
doing anything. Also not need to disable others CONSOLE's properties
if CONSOLE=n.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-11-22 15:03:00 +01:00
Hein Wessels 56d28f0c92 boot: zephyr: stm32: watchdog support
Adds support for STM32 IWDG.

Also now feeds watchdog in serial recovery.

Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
2021-11-20 15:58:12 -03:00
Francesco Servidio 5dad5b79a2 doc: fix submittingpatches.md
Fixed H2 title in 2nd section
Rephrased the 1st section to remove duplicate content.

Signed-off-by: Francesco Servidio <francesco.servidio@nordicsemi.no>
2021-11-18 15:09:13 -07:00
Håkon Øye Amundsen e829e9d9aa loader: add checking of reset address
In a multi image context it is possible for a user to upload an image
to the wrong secondary slot. As the same key is used for both images
MCUboot will overwrite image 0 with a variant of image 1.

If direct overwrite is enabled it is not trivial to recover from this.

To mitigate this issue we introduce a check of the reset address within
the vector table.

If the reset address in the new image is not contained within the
primary slot the image is deemed incorrect and is deleted from the
secondary slot

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2021-11-18 15:07:01 -07:00
Francesco Servidio 4b2f9ce62f doc: Updated security.md
Updated security.md:
- Fixed small formatting issues
- Fixed a pair of sentences.
- Added mention to hackerone page.

Signed-off-by: Francesco Servidio <francesco.servidio@nordicsemi.no>
2021-11-18 14:41:07 -07:00
Andres Sanchez 9eff1e08bd nuttx: solve referenciation error in memset call
Signed-off-by: Andres Sanchez <tito97_sp@hotmail.com>
2021-11-16 10:45:59 -03:00
David Brown b408b43a9f sim: Reduce most false failures due to ECDSA size change
The encoding of ECDSA signatures is variable sized.  Better support this
by allowing the TLV size estimate to be off by as much as 6, but only in
the case of ECDSA signature.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-11-15 10:38:24 -07:00
David Brown c8d62018b9 sim: Update Linaro copyrights
Update to current year for files modified.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-11-15 10:38:24 -07:00
David Brown 7e0d3b427a sim: Remove profile config from mcuboot-sys
Having profile configuration in sub crates generates a warning every
time Cargo is run.  Remove these lines, as the top-level Cargo.toml file
defines these values.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-11-15 10:38:24 -07:00
David Brown 07dd5f0ae1 sim: Test maximally sized images in some cases
When passed `Largest`, as the image size, compute the largest possible
image for the test.

This currently fails when 'swap-move' is enabled or
'overwrite-only,large-write' is enabled.  Allow this by not testing
maximal images in these cases.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-11-15 10:38:24 -07:00
David Brown a62c3eb628 sim: Prepare for largest possible image sizes
Instead of just passing in a numeric value for the image size, create an
enum that can use a given size, or supports a `Largest` size.  Largest
is not implemented yet, but this gets the types in place for this.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-11-15 10:38:24 -07:00
David Brown ef4f074c9b sim: Add size estimate to TLV
In order to generate images that match exact sizes, we need to know the
size of the TLV.  We can estimate this size before the payload is added
(since the payload doesn't directly affect the size).

This patch adds the size estimate, and compares it with the actual TLV
size.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-11-15 10:38:24 -07:00
David Brown ac655bbddb sim: Functionalize the code a bit
Instead of setting a mutable variable and possibly assigning to it, just
set the variable to the result of the conditional.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-11-15 10:38:24 -07:00
David Brown 0bd8c6bf2a sim: Add doc comment to `make_tlv`
Document this function.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-11-15 10:38:24 -07:00
David Brown d8713a5d48 sim: Fix ordering on TlvFlags
This enum ended up with some fields out of order.  Fix the order.  No
impact to the code, as each enum entry has a specific value, this just
makes the whole enum more consistent.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-11-15 10:38:24 -07:00
Andrzej Puzdrowski fa39e3a56e loader: clear calculation in boot_copy_region()
Introduced mediate variable for express data chunk offset
from the beginning of the region.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-11-15 13:48:03 +01:00
Andrzej Puzdrowski 5a32592813 zephr: add mbedtls/library to inclusion directories for RSA encryption
Zephyr's MbedTLS module gives its interface header directory to inclusion
directory list. RSA encryption implementations requires internal header file
which resides in mbedtls/library directory.

This path adds missing inclusion directory path exclusively for
encrypted.c in zephyr-rtos port.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-11-15 13:48:03 +01:00
Andrzej Puzdrowski 6191b86d88 zephyr: Increase mbedTLS Heap while RSA is used
Since mbetTLS was upgrades to 3.0.0 it requires
slight more memory

fixes #1200

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-11-15 13:48:03 +01:00
Andrzej Puzdrowski e38b0afa6a loader: Allow image header bigger than 1 KB for encrypted images
boot_copy_region() was written so it assumes that the image header
must fit int the intermediary buffer of 1 KB size. A bigger header
will cause a overflow in calculation of size of data chunk to be
decrypted.

This patch allow to use header bigger than that buffer size and
mitigate the limitation described above.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-11-15 13:48:03 +01:00
Håkon Øye Amundsen 21f0376faa kconfig: add name to choice option
Facilitate extending the kconfig definition by adding names to all
choices.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2021-11-15 13:14:10 +01:00
Gustavo Henrique Nihei d985d22abe espressif: Use BOOT_LOG_* macros instead of the MCUBOOT_LOG_*
Also refined the include directives, by removing unused headers and
making the usage of brackets and quotes a bit more coherent,

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2021-11-14 10:26:55 -03:00
David Brown b8c5a6da3c Create CNAME 2021-11-10 16:43:57 -07:00
Gustavo Henrique Nihei 33a3831b13 espressif: Remove write alignment handling
Write operations are always expected to be aligned according to the port
configuration.

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2021-11-05 15:23:42 -06:00
Gustavo Henrique Nihei 74a2742c3d espressif: Fix flash_area_read support for unaligned accesses
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2021-11-05 15:23:42 -06:00
Raef Coles 3fd3ecca7a sim: add tests for partial ram-loading
Signed-off-by: Raef Coles <raef.coles@arm.com>
2021-11-05 09:38:10 -06:00
Raef Coles f11de6494c boot: enable partial multi-image booting
Signed-off-by: Raef Coles <raef.coles@arm.com>
2021-11-05 09:38:10 -06:00
Raef Coles fe57e7defd boot: Move slot usage into boot state
Signed-off-by: Raef Coles <raef.coles@arm.com>
2021-11-05 09:38:10 -06:00
Gustavo Henrique Nihei 38453f679c ci: Enable build of espressif port for supported chips
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2021-11-04 06:32:43 -03:00
Gustavo Henrique Nihei 72627c5029 espressif: Allow use of imgtool other than the one from repository
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2021-11-04 06:15:47 -03:00
Francesco Servidio 2fe449d116 doc: Fixed notes formatting
Fixed the style used to format notes.

Signed-off-by: Francesco Servidio <francesco.servidio@nordicsemi.no>
2021-11-03 16:21:47 -06:00
Francesco Servidio 5bc983276f doc: Fix case in titles
Unified case in titles.
Fixed small grammar issues.

Signed-off-by: Francesco Servidio <francesco.servidio@nordicsemi.no>
2021-11-03 17:05:40 +01:00
Ross Burton a6df132b68 imgtool: prefer cbor2 over cbor
The cbor module is unmaintained, with the last release in 2016[1]. The
cbor2 module however is under active development and was last released
just last month[2].

As the APIs are identical, we can import cbor2 and if that fails fall
back to cbor.

[1] https://pypi.org/project/cbor/#history
[2] https://pypi.org/project/cbor2/#history

Closes #1189

Signed-off-by: Ross Burton <ross.burton@arm.com>
Change-Id: Iaf2d0df625a200a5cebf72dec4a89877a26194ea
2021-11-03 14:19:31 +01:00
Fabio Utzig 1a9c6d8495 mynewt: remove #error on ec256 with Mbed TLS
Allow building ec256 signature validation on Mynewt using Mbed TLS.
Related to https://github.com/apache/mynewt-artifact/pull/33

Signed-off-by: Fabio Utzig <utzig@apache.org>
2021-11-01 14:43:52 -03:00
Dominik Ermel 9479af0ae8 boot/bootutil: Fix probable uninitialized flash_area access
The commit fixes issue where failed flash_area_open in
boot_write_status would result in flash_area_close call on
uninitialized flash_area object.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-10-27 09:31:17 +02:00
Rajeev Piyare 29fc848dc2 Add Conexio Stratus board configuration for DFU button operation
Signed-off-by: Rajeev Piyare <rajeev@conexiotech.com>
2021-10-24 19:59:22 -03:00
Dominik Ermel ec6dac5010 bootutil: Fix boot_find_status leaving flash area open
The commit fixes boot_find_status leaving flash area object in open
state on success.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-10-24 08:04:20 -03:00
Francesco Servidio 482921f724 doc: Fixed consistency of bootloader term
Fixed the consistency of the term bootloader.

Signed-off-by: Francesco Servidio <francesco.servidio@nordicsemi.no>
2021-10-21 06:45:13 -03:00
Francesco Servidio 582367cfeb doc: Fixed consistency of Mbed term
Fixed the consistency of the case used for the Mbed term.

Signed-off-by: Francesco Servidio <francesco.servidio@nordicsemi.no>
2021-10-21 06:45:13 -03:00
Francesco Servidio 4ff0c18693 doc: Fixed consistency of MCUboot
Fixed the consistency of the case used in the term MCUboot.

Signed-off-by: Francesco Servidio <francesco.servidio@nordicsemi.no>
2021-10-21 06:45:13 -03:00
Dominik Ermel 6138b4f71a bootutil: Fix boot_read_image_header error path
The error path of boot_read_image_header could invoke
flash_area_close on uninitialized flash_area object.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-10-20 17:28:34 -06:00