Commit Graph

219 Commits

Author SHA1 Message Date
David Brown b748f6fa2a Rename ext/mbedtls to ext/mbedtls-asn1
The ext/mbedtls directory has a copy of the ASN.1 parser from the mbed
TLS library.  To allow a future change to bring the entire mbed TLS
library in as a submodule under ext, rename this to mbedtls-asn1 to make
it clear this is only a subset.

Signed-off-by: David Brown <david.brown@linaro.org>
2019-10-15 09:29:20 -06:00
Andrzej Puzdrowski f000480409 zephyr/serial_recovery: fix serial device binding
zephyr changes the way in which it provide name of
serial device used by serial recover.
see: https://github.com/zephyrproject-rtos/zephyr/pull/18752

This path introduce build time configuration of device name
which is set to exact the same device which was set before.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-10-11 12:11:59 +02:00
Håkon Øye Amundsen 954dd2b8ed kconfig: add option for multi image
To enable multi image support in mcuboot one needs
to set the 'UPDATEABLE_IMAGE_NUMBER' config.
Add this to zephyrs MCUBoot kconfig to allow this.

Signed-off-by: Håkon Øye Amundsen <haakon.amundsen@nordicsemi.no>
2019-10-07 11:39:23 +02:00
Fabio Utzig 61fd888a7f Add TLV iterator API
This introduces an API which allows for iteration over an image's TLVs
without resorting to low-level implementation details. All previous TLV
low-level handling was updated to comply with this new interface, and it
also makes it easier for external code to handle TLVs.

The API provides two functions:

1) To start a new iterator:

```
int bootutil_tlv_iter_begin(struct image_tlv_iter *it,
                            const struct image_header *hdr,
                            const struct flash_area *fap, uint8_t type,
                            bool prot);
```

2) To iterate over existing TLVs of given type:

```
int bootutil_tlv_iter_next(struct image_tlv_iter *it, uint32_t *off,
                           uint16_t *len, uint8_t *type);
```

A type of IMAGE_TLV_ANY was added to allow for iteration over all TLVs.

Low-level TLV access functions were removed from API, but low-level
structs are still visible in the namespace.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-09-18 07:38:50 -05:00
Fabio Utzig cac58f6c72 boot: zephyr: main: tabs -> spaces
Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-09-09 10:00:09 -03:00
Marti Bolivar f84cc4b309 zephyr: enable MULTITHREADING by default except on nRF
CONFIG_MULTITHREADING is generally assumed to be y by the zephyr
kernel, even though that's not reflected in the Kconfig. For example,
semaphores depend on it being y, but CMake will still build sem.c even
if it's n.

The sensible default for this option is thus y.

However, it's a size advantage to disable it if the platform drivers
are all aware of this option, such as nRF.

Let's re-work our use of this option to keep it disabled when we know
it's safe, but enable it by default so more platforms can be expected
to work out of the box.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-08-22 14:21:41 +02:00
Marti Bolivar f2a8b78c98 zephyr: delete arduino_101.conf
This board is no longer supported by Zephyr or its hardware
manufacturer.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-08-22 14:21:41 +02:00
Marti Bolivar 787b5cc2cd zephyr: remove ZEPHYR_BASE "bounce option" from Kconfig
These are not necessary anymore; kconfiglib evaluates $FOO in the
environment.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-08-22 14:21:41 +02:00
Andrzej Puzdrowski ceb43f5f98 zephyr: add minimal footprint configuration for nrf52
Added Kconfig project configuration whit shows the
minimal flash footprint on nRF2832 SoC targets.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-08-13 15:44:17 +02:00
Andrzej Puzdrowski 960a2d616d zephyr: allow to disable timers supports
For some basic mcuboot configurations the zephyr timers are
not required which reduce the flash footprint significantly.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-08-13 15:44:17 +02:00
Fabio Utzig b0f0473352 Remove current_image global and macro updates
Currently to determine which image is being operated on, there is a global
variable called current_image which is used by most macros and APIs to
correctly access the flash areas required by the bootloader. This moves
this variable to the already existing state struct and refactors all
macros and APIs to receive the current image by parameters. To maintain
compatibility some of the macros were not updated and use image 0 when
called.

The definitions of FLASH_AREA_IMAGE_PRIMARY and FLASH_AREA_IMAGE_SECONDARY
for Mynewt compatibility were moved out of bootutil sources to a Mynewt
specific include file.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-08-07 14:33:36 -03:00
David Vincze b75c12a431 Boot: Extend flash layout for multiple images
This patch introduces the BOOT_IMAGE_NUMBER macro and current_image
variable to support multiple updatable images and the associated
extended flash layout.

The FLASH_AREA_IMAGE_* object-like macros are replaced with
function-like ones and therefore some functions have been updated,
because the labels of a switch statement and the initialization
values of objects with static storage duration have to be constant
expressions.

Change-Id: Ib7b26ec3c94233e52db4f97825ddb6a3e55bb1d3
Signed-off-by: David Vincze <david.vincze@arm.com>
2019-07-23 09:11:34 -05:00
Fabio Utzig 853657c23d Add watchdog feeding macro
When HW / OS provides an always enabled watchdog, this macro can
optionally be implemented to avoid resets which are expected to
occur under normal conditions when swapping very large images or
running on slower devices.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-07-12 08:06:13 -03:00
Andrzej Puzdrowski f99a4c790a zephyr: fix include of system_timer.h
Above header was moved to another path.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-07-01 09:34:01 +02:00
Fabio Utzig 1171df91b9 Add Zephyr infrastructure for ed25519
Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-06-13 19:21:05 -03:00
Jun Li 01bef716c2 bugfix: disable usb for all usb funcs
USB should be disabled if any usb func is enabled.

fix #477

Signed-off-by: Jun Li <jun.r.li@intel.com>
2019-05-23 13:51:34 +02:00
Filip Kubicz db6be2d118 boot: zephyr: Update USB CDC ACM device name
Follow the device name changes in Zephyr.

Signed-off-by: Filip Kubicz <filip.kubicz@nordicsemi.no>
2019-05-22 15:18:34 +02:00
Fabio Utzig 105b59a9b9 Add Zephyr config for RSA-3072
Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-05-16 14:01:19 -03:00
Andreas Vibeto 704b8ba481 boot: serial recovery: Add pca10090 default detect pin
Add button 1 as default serial detect pin for nrf9160_pca10090

Signed-off-by: Andreas Vibeto <andreas.vibeto@nordicsemi.no>
2019-04-26 15:49:29 +02:00
Marti Bolivar 36ef25d87a zephyr: fix build for nrf52840_pca10059
The build overflows by 100B using the 7-2018-q2-update GNU Arm
Embedded toolchain. Turn on size optimizations; this leaves about 19%
of the partition's flash available for MCUboot to grow into.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-04-16 15:56:09 +02:00
Marti Bolivar 5c877d5e7d zephyr: fix logging
The removal of CONFIG_BOOT_HAVE_LOGGING in 15aa6ef ("zephyr: remove
BOOT_HAVE_LOGGING Kconfig option") missed some uses. In particular,
the one in mcuboot_config.h that converts Kconfig options to MCUboot's
platform-agnostic configuration macros.

This broke logging even when the relevant Kconfig options were on.

Fix things up by using CONFIG_LOG instead.

Tested logging works again on nrf52840_pca10056. Build tested
nrf51_pca10056 to make sure it still fits. The nrf52840_pca10059 build
overflows flash by 0.16%, but that was a problem before 15aa6ef.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-04-15 14:18:41 +02:00
Piotr Mienkowski 15aa6ef5ab zephyr: remove BOOT_HAVE_LOGGING Kconfig option
This commit removes the non-standard BOOT_HAVE_LOGGING Kconfig option.
Instead the standard LOG / MCUBOOT_LOG_LEVEL can be used to control
logging.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2019-04-10 14:40:15 -03:00
Emanuele Di Santo 288682c0e3 boot: zephyr: do not override TEXT_SECTION_OFFSET
It is no longer necessary to override TEXT_SECTION_OFFSET when
BOARD_HAS_NRF5_BOOTLOADER. The nrf52840_pca10059 board no longer
overrides TEXT_SECTION_OFFSET but sets the correct FLASH_LOAD_OFFSET
instead, automatically.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
2019-04-04 11:55:40 +02:00
Sebastian Bøe ea49cd0b1a cmake: Fix bug where dts.overlay was not being appended
Fix bug #399 where dts.overlay was not being appended.

The build scripts were erroneously modifying the shadowed non-cache
variable instead of the cache variable.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-04-03 19:12:25 -06:00
Sigvart Hovland ebd0503348 boot: Add cc310 options to CMakeLists, Kconfig and mcuboot config
Adds `CC310` define which wraps the generic CC310 interface adds
includes for using `NRF_CC310_BL` to CMakeLists. This requires `nrfxlib`
to be located outside of the mcuboot folder by 1 directory level. Also
add the Kconfig defines needed for this to build while trying to make it
generic enough to be used by other vendors that have implemented
`CC310`.

Signed-off-by: Sigvart Hovland <sigvart.m@gmail.com>
2019-03-25 07:12:34 -03:00
Andrzej Puzdrowski 23d3c66844 zephyr bugfix: mcuboot doesn't link into code-partition
Select the code partition as the target for link into.
This patch together with
https://github.com/zephyrproject-rtos/zephyr/pull/14620
fixes the issue which was imposed while zephyr moves
DTC before Kconfig processing in its build process.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-03-19 13:31:30 +01:00
Andrzej Puzdrowski e575fe9ead image encryption: fix enc_state array indexing for zephyr
enc_state table was indexed with assumption that
image flash area are subsequent and increasing numbers.
It might not be true while building zephyr.

Patch introduce flash_area_id_to_image_slot() implementation for
the zephyr port and uses it to assign proper slot number.
This API is already available in MyNewt.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2019-03-14 16:10:54 +01: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
Sebastian Bøe 0717552dfb zephyr: cmake: Don't declare the deprecated macro set_conf_file
The pattern that 'set_conf_file' has been added to the Zephyr build
system, so it is not necesary for the application build script to
implement it.

Also, the macro has been deprecated, so it should not be used.

This change is a pure refactoring.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-03-12 07:09:35 -03:00
Rajavardhan Gundi e2747487df intel_s1000: Enable CONFIG_BOOT_HAVE_LOGGING
The logger issue on Xtensa is resolved in mainline Zephyr with
239805b2d82aebee4969c3ae57fbf8025c4fb60d. Hence logging can be
enabled now.

Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2019-03-08 16:31:48 +01:00
Rajavardhan Gundi edea467300 dfu: Enable CONFIG_BOOT_WAIT_FOR_USB_DFU for intel_s1000
Signed-off-by: Rajavardhan Gundi <rajavardhan.gundi@intel.com>
2019-03-08 16:31:48 +01:00
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
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
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
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