Commit Graph

371 Commits

Author SHA1 Message Date
Rajavardhan Gundi 51c9d707fb dfu: Introduce CONFIG_BOOT_WAIT_FOR_USB_DFU
This Kconfig parameter makes MCUboot wait for a prescribed duration
of time to allow for USB DFU to be invoked.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2019-03-08 16:31:48 +01:00
Sebastian Bøe 048168aa37 zephyr: Fix bug where prototype of SNPRINTF was not declared
Fix #10990.

A warning is triggered when snprintf is used because it is being
declared / configured incorrectly. The MBEDTLS configuration is
defaulting to disabling all of LIBC, and then explicitly enabling the
LIBC functions in use, this has been done for printf with
MBEDTLS_PLATFORM_STD_PRINTF, but not for
MBEDTLS_PLATFORM_STD_SNPRINTF.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-03-04 09:20:14 -03:00
Sebastian Bøe c2216cc5b5 zephyr: Minor refactoring for readability
Minor refactoring of Zephyr config file for readaiblity, STD functions
are now grouped.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-03-04 09:20:14 -03:00
Andrzej Puzdrowski b26a4a9c40 zephyr: align uart device name
Zephyr changed way of generation UART device name label
which implies device name label text change.

Patch aligns the code to above change.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-02-27 12:51:04 +01:00
Andrzej Puzdrowski 0cd178d0e9 zephyr: fix build with zephyr
zephyr macro min() was hanged to MIN()
Kconfig key CDC_ACM_PORT_NAME was changed to CDC_ACM_PORT_NAME_0

zephyr sha of the fixing time is 406dc2cb0e2868392f444677ace416440695829f.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-02-22 10:36:41 +01:00
Johannes Bruder 4b4ac906e3 Do not use an ASSERT to catch the case if no image is loaded
Signed-off-by: Johannes Bruder <johannes.bruder@plating.de>
2019-02-19 11:54:45 -07:00
Rajavardhan Gundi 5b39d3c7a4 Clean up intel_s1000_crb.conf file
Cleaned up the conf file for intel_s1000_crb by defining only
those values that are different from prj.conf.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-02-19 11:52:31 -07:00
Rajavardhan Gundi 24321c3926 Replace DT_SPI_NOR_DRV_NAME with DT_JEDEC_SPI_NOR_0_LABEL
Zephyr mainline now generates DT_JEDEC_SPI_NOR_0_LABEL instead of
DT_SPI_NOR_DRV_NAME.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-02-19 11:52:31 -07:00
Maureen Helm 4df602aeab boot: zephyr: Fix pyocd board runner args
The pyocd runner in zephyr changed its arguments slightly when it
converted to the new unified pyocd tool with subcommands. Change the
board runner args here similarly so we can use 'west flash' again for
the zephyr bootloader.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2019-02-19 14:09:36 -03:00
Michael Scott f9be7a9fae boot: zephyr: ensure LOG_LEVEL resource savings
Let's ensure that random Zephyr changes in logging don't affect
the resource usage in MCUBOOT, by setting LOG_LEVEL_DEFAULT
to 0.

Signed-off-by: Michael Scott <mike@foundries.io>
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-02-11 10:47:04 +01:00
Michael Scott 74ceae5ba6 boot: zephyr: establish an MCUBOOT_LOG_LEVEL config
Rather than use LOG_DEFAULT_LEVEL to control MCUBOOT's log output,
let's create an MCUBOOT specific log level setting.

Signed-off-by: Michael Scott <mike@foundries.io>
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-02-11 10:47:04 +01:00
Michael Scott cef4427d8d zephyr: kconfig: replace LOG_INPLACE_PROCESS setting w/ LOG_IMMEDIATE
Commit 1d9e5ee1 ("logging: Refactoring 'in place' mode to reduce memory
footprint") changed the resource restrained version of LOGGER from
LOG_INPLACE_PROCESS to LOG_IMMEDIATE.

Signed-off-by: Michael Scott <mike@foundries.io>
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-02-11 10:47:04 +01:00
Andrzej Puzdrowski 419a47531b zephyr: allow dynamic numeration of flash_areas
Zephyr flash_map reworks caused that areas id exact number are
assigned dynamically.

This patch i counterpart to
https://github.com/zephyrproject-rtos/zephyr/pull/8837

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-02-10 16:08:38 +01:00
Marti Bolivar 23e3853c0a zephyr: CMakeLists.txt: support nrfjprog mass erase flag
The upstream Zephyr runner for nrfjprog now supports an --erase
toggle, which controls whether a mass-erase is done. Add that to its
invocation when CONF_ZEPHYR_TRY_MASS_ERASE is given, just like is done
for dfu-util and pyocd.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2019-02-04 17:04:41 -07:00
Christopher Collins ae01f153b1 Set pending: don't crash when image slot corrupt
This change affects the "set pending" operation.  That is, the operation
that configures mcuboot to temporarily swap images on the next boot.

PRIOR TO COMMIT:

If the slot 1 trailer contained an invalid 128-bit magic number, an
assertion would fail, causing a crash.

AFTER COMMIT:

If corruption is detected in the slot 1 trailer, the entire image slot
is erased, and the "set pending" operation fails with a `BOOT_EBADIMAGE`
status.

RATIONALE:

mcuboot cannot meaningfully recover from data corruption.  The only
recourse is to erase the bad data so that future upgrades can be
performed.  I was tempted to add a build-time setting to control whether
the image slot gets erased when corruption is detected, but I dont think this
freedom justifies the cost of extra config.  A device with a corrupt
image slot can no longer be upgraded, so the only reason someone would
want to preserve the corrupt data would be for debugging.

Signed-off-by: Christopher Collins <ccollins@apache.org>
2019-01-31 18:13:52 -02:00
Andrzej Puzdrowski e82e3163de zephyr:board: squash nrf51_pca10028 flash footprint
Disable logging and enable size optimizations on
nrf51_pca10028 target in order to fit in boot slot size
for out-off-the-box build.

fixes #411

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-01-30 14:45:38 +01:00
Rajavardhan Gundi 73bb71b0c6 CONFIG_FLASH_BASE_ADDRESS is defined only for memory-mapped Flash
Made FLASH_DEVICE_BASE 0 for non-memory-mapped Flash.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2019-01-28 12:26:08 +01:00
Fabio Utzig ed0ca4356a Fix trailer erase for some devices
Previously it was assumed that the trailer would fit one sector. While
this works for most devices, some which happen to have lots of sectors
end up using lots of space for their swap status area. The same issue
could also happen if sectors are small (less than 2K/4K, for example).

This fixes the issue by checking the trailer size and erasing all
sectors that encompass it.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-01-23 14:04:47 -07:00
Sebastian Bøe be972176f1 cmake: zephyr: Misc. modernizations of the build scripts
Modernize and simplify the build scripts of the Zephyr
bootloader. Most notably, the new build scripts are targeting the
'zephyr_library_' API instead of the 'target_' API.

In addition to simplifying the build scripts, this permits us to be
automatically compatible with an upcoming change that will break the
'target_' API but not the 'zephyr_library_' API.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-01-22 16:09:02 -07:00
Sebastian Bøe 913a385137 boot: zephyr: Detect invalid Kconfig'uration earlier
Instead of detecting an invalid Kconfiguration during CMake
Configure-time we detect it where it belongs, in Kconfig.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-01-22 16:09:02 -07:00
Sebastian Bøe b94bda03aa zephyr: boot: Correct how the default board is set
The default board should be set simply by 'set'ing the BOARD. This has
the lowest precedence of all possible inputs.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-01-22 16:09:02 -07:00
Sebastian Bøe 90c70e31ad cmake: KCONFIG_ROOT does not need to be set explicitly
The presence of a Kconfig file will be checked by the build system so
it is not necessary to explicitly set KCONFIG_ROOOT.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-01-22 16:09:02 -07:00
Fabio Utzig 432c32c928 Fix ECDSA signature builds in Zephyr
Commit 3ac36ead3 updated the bundled asn1parser, which now consists of
two files. The Zephyr build system was not updated with that commit which
has broken ECDSA signature builds. This adds the new file.

This fixes #397.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-01-18 12:33:19 -07:00
Emanuele Di Santo 30a9265bc8 boot: zephyr: select GPIO when MCUBOOT_SERIAL is enabled
Select GPIO when MCUBOOT_SERIAL is enabled.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
2019-01-18 12:31:24 -07:00
Fabio Utzig 006994b754 Fix a buffer overflow on EC point load
While loading a new EC point, when it was smaller than the expected
number of bytes, a zero padding was being written beyond the end of the
buffer instead of at the initial position.

While this has been working before, it broke when images were signed using
the ring API.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-01-18 09:44:48 -07:00
Emanuele Di Santo c7514ad7a0 boot: zephyr: pca10059: disable logging by default
The board cannot output logs on the UART because it is used
by MCUBoot's serial recovery for DFU. Remove logging and
the RTT console from project defaults.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
2019-01-14 10:10:54 +01:00
Christopher Collins fea163c6a4 Fix Mynewt builds; add log stub dependency
A recent change in the Mynewt repo
(b10cbea5ef882e7f91d1c34ffcf2506d3e183003) imposes the LOG API
requirement on the `sys/mfg` package.  To fix broken builds, make the
Mynewt app and test package depend on `sys/log/stub`.

Signed-off-by: Christopher Collins <ccollins@apache.org>
2019-01-12 14:38:41 -07:00
David Brown 8d0afa737c boot: bootutil add cap for slot 0 validation
Add a capability to query if MCUboot has been built to verify slot 0.

Signed-off-by: David Brown <david.brown@linaro.org>
2019-01-12 14:35:54 -07:00
David Brown c4a60a3686 boot: bootutil: Add caps for encryption
Add a capability query for the two encryption options.

Signed-off-by: David Brown <david.brown@linaro.org>
2019-01-12 14:35:54 -07:00
Emanuele Di Santo 401d7b33d3 zephyr: boot_serial: fix CRC header warning
The crc16.h header has been deprecated in Zephyr.
Update include directive to use the new header.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
2019-01-11 13:39:22 +01:00
Emanuele Di Santo 9f1933d1a5 boot: zephyr: migrate to new log subystem
The old log subsystem has been deprecated in Zephyr.
Migrate to the new subsystem to avoid compilation warnings.

In-place log processing is selected as it is required as MCUBoot is
one thread application.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-01-10 19:11:15 +01:00
Emanuele Di Santo 2733f515cd boot: bootutil: remove unused BOOT_LOG_LEVEL macros
Remove unnused BOOT_LOG_LEVEL macros.
These are not honored, nor usable since they are supposed to be
defined before including the header in which they are defined.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
2019-01-10 19:11:15 +01:00
Emanuele Di Santo 0752d8aee4 boot: bootutil: include mcuboot_logging.h unconditionally
The mcuboot_logging.h header includes the header for the log subystem,
which needs to be included regardless of whether logging is enabled
for logging macros to compile correctly.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
2019-01-10 19:11:15 +01:00
Emanuele Di Santo a0ed10b5ae zephyr: kconfig: set TEXT_SECTION_OFFSET to zero
Ensure that the offset in .text is zero.
This is necessary to ensure that MCUBoot is linked at
the beginning of the boot partition, as intended.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
2019-01-07 16:29:20 +01:00
Fabio Utzig a32f1af386 Fix overwrite-only under Zephyr
As reported by issue #384, some #ifdefery was wrongly done, which broke
overwrite-only mode under Zephyr.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-01-07 10:59:20 -02:00
Christopher Collins 4b2591285a boot/bootutil: Add missing #include
Mynewt builds require the `mcuboot_config.h` file to translate syscfg
setting names to MCUboot setting names.  This change fixes a build error
that occurs when MCUboot is built with mbedTLS support:

Error: In file included from keys/bootkeys/src/bootkeys.c:2:0:
repos/mcuboot/boot/bootutil/include/bootutil/enc_key.h:29:10: fatal error: tinycrypt/aes.h: No such file or directory
 #include "tinycrypt/aes.h"
          ^~~~~~~~~~~~~~~~~

Signed-off-by: Christopher Collins <ccollins@apache.org>
2019-01-04 14:57:41 -08:00
Fabio Utzig 38f5ffea35 Add key unwrap functionality using tinycrypt
This implements AES key unwrapping following RFC-3394 section 2.2.2
using tinycrypt for AES-128 decryption. It is enabled when ECDSA was
chosen as the signature algorithm.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-01-03 11:22:05 -02:00
Fabio Utzig 3b091f6afd Enable ASN1 parsing for KW
Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-01-03 11:22:05 -02:00
Fabio Utzig d0533ed117 Add Zephyr config for boostrap feature
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-12-27 10:58:50 -02:00
Fabio Utzig 251ef1d98a Add rsa+kw testing support to simulator
Allows simulating images signed with RSA-2048 and encrypted with
AES-128-KW.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-12-27 10:58:50 -02:00
Fabio Utzig 338a19f70d Add boostrapping from slot1 support
This adds a new option that allows copying slot0, from the contents
of slot1, if slot0 is found out to be erased and not validated, and
the contents of slot1 are validated.

This mechanism basically enables a device to "bootstrap" from the
contents of an external flash that has a valid image, given that the
only flashed thing in the internal flash is the bootloader.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-12-27 10:58:50 -02:00
Rajavardhan Gundi 07ba28f058 MPU_ALLOW_FLASH_WRITE is defined only for ARM platforms.
Remove MPU_ALLOW_FLASH_WRITE from prj.conf and put it in
boot/zephyr/Kconfig enabling it only for every ARM_MPU
equipped device.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2018-12-27 08:13:41 -02:00
Rajavardhan Gundi 40c28e3676 Add support for intel_s1000 SoC which is based on Xtensa arch
Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2018-12-27 08:13:41 -02:00
Rajavardhan Gundi 3b8b58dcb5 Add DT_SPI_NOR_DRV_NAME check towards sanitycheck in target.h
Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2018-12-27 08:13:41 -02:00
Rajavardhan Gundi c3353b240e Call device binding for DT_FLASH_DEV_NAME only if it is defined
Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2018-12-27 08:13:41 -02:00
Rajavardhan Gundi 1b8d7fb355 Use BUILD_ASSERT_MSG instead of _Static_assert in Zephyr
Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2018-12-27 08:13:41 -02:00
Marko Kiiskila e5aeee4ad1 boot_serial; check CRC for RX only if all data has arrived.
Signed-off-by: Marko Kiiskila <marko@apache.org>
2018-12-24 08:47:25 -02:00
Marko Kiiskila 8e7b7ac9e0 boot_uart: mynewt; option for faster speed with serial.
Make RX buffer size configurable for UART. Allow incoming
interrupts while copying data out of that buffer.

Signed-off-by: Marko Kiiskila <marko@apache.org>
2018-12-24 08:47:25 -02:00
Timo Kröger e280e1166e Remove unused hal includes from bootutil
Signed-off-by: Timo Kröger <timokroeger93@gmail.com>
2018-12-21 06:47:40 -02:00
Fabio Utzig 2bd980a50d Add support for slots with different sector sizes
This adds bootutil support for slots on different flash devices
the happen to have different sector sizes.

It consists basically in relaxing the `boot_slots_compatible` to
allow swaps as long as the sectors that are required to fit both
images are able to fit inside scratch and both slot's sectors have
sizes that are multiple of each other.

This is now tested on the simulator and was tested in a Nordic's
pca10056 using slot0 in internal flash, and slot1 in the external
QSPI flash, configured with 4K, 8K and 16K sized sectors (the HW
is 4KB but Mynewt allows emulating multiples of that!)

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-12-18 15:16:11 -02:00