Commit Graph

167 Commits

Author SHA1 Message Date
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
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 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 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
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
Fabio Utzig 4541b53a3a Increase Zephyr mempool size for encrypted images
For Zephyr the default mbedTLS mempool size for RSA-2048 signing was not
enough to allow for the calculations done by RSA-2048-OAEP (encrypted
images), so when encrypted image support is enabled, increase it to a
value that is known to work.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-12-17 14:41:02 -02:00
Andrzej Puzdrowski f50054d998 fix zephyr target: corrupted build after zephyr PR #11180
zephyrproject-rtos/zephyr#11180: Zephyr target was corrupted as
recently zephyr's device tree started adding DT_ prefix in
generated labels.

This path aligns flash name macro used.


Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-11-14 14:56:35 +01:00
Emanuele Di Santo 865777ddc9 boot: zephyr: add MCUBOOT config
Add a hidden MCUBOOT config entry to mark a project as MCUBOOT.
It is useful when other parts of the system need to be aware
that they are, in fact, the bootloader.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
2018-11-09 14:08:56 +01:00
Emanuele Di Santo 4d20525195 boot: zephyr: cleanup nrf52840_pca10059 configuration
Cleanup board configuration.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
2018-11-03 12:07:51 +01:00
Emanuele Di Santo fcfff58417 boot: zephyr: add missing sys_clock_disable declaration
Add missing declaration of sys_clock_disable() to fix compiler warning.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
2018-11-03 12:07:51 +01:00
Emanuele Di Santo 4a60ee7c76 zephyr: add support for pca10059
This commit adds a project configuration for the upcoming
nrf52840_pca10059 board.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-10-30 18:17:23 +01:00
Emanuele Di Santo c4bf78009c zephyr: selectable serial device for recovery
This commit adds a choice for the device to use for serial recovery.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>

fixup
2018-10-30 18:17:23 +01:00
Fabio Utzig 0d16482be8 Add mbedtls config with nist_kw enabled
This adds a mbedtls config that will enable the simulator to run tests
for the kw based encrypted images.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-10-12 13:36:13 -03:00
Fabio Utzig 5fe874c34e Add Zephyr support for encrypted images
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-10-12 13:36:13 -03:00
Andrzej Puzdrowski 5f81b127e1 zephyr: fix flash_area_read_is_empty
Implementation of flash_area_read_is_empty introduced recently
uses deprecated hal_flash_read API which caused build failure.

This patch uses zephyr's native flash_area_read() API which
solves the bug.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-10-09 12:45:09 +02:00
Fabio Utzig cea90f970f Add flash_area_read_is_empty to Zephyr port
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-10-01 21:42:20 -03:00
Fabio Utzig 42ad446fb0 Add `flash_area_erased_val` "mock" for Zephyr
For Zephyr assume flash is always erased to 0xff. This allows backward
compatibility of the new flash erased to 0 support.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-09-17 12:42:49 -03:00
Marti Bolivar 5de83b1e47 zephyr: config-rsa.h: remove copypasta
MCUboot doesn't need mbedTLS's entropy code (you don't need random
numbers to check a digital signature), but it enables it. This causes
really scary warnings when building entropy.c, since the test entropy
source is enabled:

    [113/197] Building C object zephyr/ext/lib/crypto/mbedtls/CMakeFiles/ext__lib__crypto__mbedtls.dir/library/entropy.c.obj
    /home/mbolivar/src/zephyr/ext/lib/crypto/mbedtls/library/entropy.c:31:2: warning: #warning "**** WARNING!  MBEDTLS_TEST_NULL_ENTROPY defined! " [-Wcpp]
     #warning "**** WARNING!  MBEDTLS_TEST_NULL_ENTROPY defined! "
      ^~~~~~~
    /home/mbolivar/src/zephyr/ext/lib/crypto/mbedtls/library/entropy.c:32:2: warning: #warning "**** THIS BUILD HAS NO DEFINED ENTROPY SOURCES " [-Wcpp]
     #warning "**** THIS BUILD HAS NO DEFINED ENTROPY SOURCES "
      ^~~~~~~
    /home/mbolivar/src/zephyr/ext/lib/crypto/mbedtls/library/entropy.c:33:2: warning: #warning "**** THIS BUILD IS *NOT* SUITABLE FOR PRODUCTION USE " [-Wcpp]
     #warning "**** THIS BUILD IS *NOT* SUITABLE FOR PRODUCTION USE "
      ^~~~~~~

Delete the bits of the mbedTLS configuration that compile this
file (along with some testing code we don't care about either) to
clean up the warning. This looks like copy/paste code from the initial
mbedTLS config import into MCUboot.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-09-05 20:30:01 -03:00
Marti Bolivar 0e259097fb zephyr: prj.conf: disable CONFIG_BT_CTLR too
Various Zephyr boards (I'm looking at you, every-single-nRF-board)
set CONFIG_BT_CTLR=y as well as CONFIG_BT. Make sure it's disabled for
MCUboot's default prj.conf, where it's not needed and has been causing
very verbose Kconfiglib warnings:

    warning: BT_CTLR (defined at subsys/bluetooth/controller/Kconfig:10) was assigned the value 'y' but
    got the value 'n'. You can check symbol information (including dependencies) in the 'menuconfig'
    interface (see the Application Development Primer section of the manual), or in the Kconfig
    reference at http://docs.zephyrproject.org/reference/kconfig/CONFIG_BT_CTLR.html (which is updated
    regularly from the master branch). See the 'Setting configuration values' section of the Board
    Porting Guide as well.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-09-05 20:30:01 -03:00
Andrzej Puzdrowski c2e30cf2c3 serial recovery: always erase image status
It is possible that while flash was erased progressively
the flash image status page was not erased.
This patch check this case and performs additional eras
if it was required.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-08-04 09:13:23 -03:00
Emanuele Di Santo 205c8c6980 zephyr: erase flash pages progressively
This commit adds the option to erase flash pages while receiving
the firmware, opposed to bulk-erasing the whole image area at
the beginning of the DFU process. This is required on some
hardware that has long erase times, to prevent a long wait
and possibly a timeout during DFU.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-08-04 09:13:23 -03:00
Emanuele Di Santo d1fd3f92b7 zephyr: fix serial ISR in serial_adapter
The UART device ISR in serial_adapter expected the device
to fire an interrupt for each byte that was received.
Although this might have worked for some devices it wouldn't
work for USB. This commit fixed the issue by modifying the ISR
according to the uart.h documentation.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
2018-08-04 09:13:23 -03:00
Carles Cufi 6400f0bf97 zephyr: serial_adapter: Cleanup queue variables
Remove the simple pointers and use the "&" operator throughout to
simplify the understanding of the code.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-07-18 07:03:45 -03:00
Carles Cufi b124e39f79 zephyr: serial_adapter: Fix allocation of buffers
In order to avoid overwriting an existing allocated buffer that has not
yet been processed by the main loop, switch to a new command buffer
whenever we have received a complete one.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-07-18 07:03:45 -03:00
Szymon Janc c48e7f917e boot_serial: Fix build on Zephyr with ECDSA enabled
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2018-07-03 17:46:33 +02:00
Evan Gates 4632d8de5f include soc.h in main.c
While building with Zephyr 1.12 for the nucleo_f091rc I got undefined
reference to __set_MSP() during linking. Including soc.h fixes the
problem. Thanks carlesc.

Signed-off-by: Evan Gates <evan@gnarbox.com>
2018-06-29 11:18:18 -03:00
Andrzej Puzdrowski 3011714194 zephyr: serial_adapter: preserve buffer list against lock
It was possible that free_queue locks on the self referencing
node.
This patch introduce check for this issue

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-06-20 16:08:58 +02:00
Carles Cufi 5e48c55df9 zephyr: Enable interrupts unconditionally
Due to an issue described here:
https://github.com/zephyrproject-rtos/zephyr/issues/8393
interrupts are not enabled when multithreading is disabled.
Enable interrupts to allow the serial recovery mode UART to receive
characters.

Note: This commit must be reverted once the issue is addressed.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-06-20 16:08:58 +02:00
Carles Cufi 5ceeddb413 zephyr: Use sys_slist instead of k_fifo in serial adapter
The k_fifo_* primitives are not available when multithreading is
disabled. Use sys_slist_* instead.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-06-20 16:08:58 +02:00
Carles Cufi df4d9a4de1 zephyr: Disable power management
Power management requires multithreading and other kernel features that
are disabled in MCUboot, so disable it to avoid interrupts being
confused by power management code wrappers.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-06-20 16:08:58 +02:00
Carles Cufi e2a361256e zephyr: Fix assert booleanness
Fix the __ASSERT() statement so it actually checks for success and not
for failure.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-06-20 16:08:58 +02:00
Marko Kiiskila c427af2e7e zephyr/serial_adapter; no need to inject \r on \n anymore.
boot_serial; syscfg tabs to spaces.

Signed-off-by: Marko Kiiskila <marko@runtime.io>
2018-06-14 23:19:06 +03:00
Marko Kiiskila 149b457a22 boot_serial; improve platform abstraction.
Pass function pointers to do reads/writes from uart.

Signed-off-by: Marko Kiiskila <marko@runtime.io>
2018-06-14 23:19:06 +03:00
Andrzej Puzdrowski 82d7395b69 Fix assertions in zephyr main file
For serial recovery enabled Assertions conditions were improperly
which cause runtime assertion whenever __ASSERT macro was enabled
along with the serial recovery mode running.

This patch fixes the issue.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-06-13 21:46:47 +02:00
Carles Cufi 29af9feeb7 zephyr: Default to RSA .pem file in config fragment
In order to provide a pleasant out-of-the-box experience to users,
default to the RSA .pem file so that users do not get a cryptic error
when building with the default .conf file in upstream.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-06-12 17:36:54 +02:00
Ding Tao f97cb7143d zephyr: cmake: Fix a typo in file CMakeLists.txt
Replace "bur" with "but".

Signed-off-by: Ding Tao <miyatsu@qq.com>
2018-06-08 12:11:57 -03:00
Fabio Utzig 806af0ed87 Update old hardcoded keys to use autogenerated
The hardcoded keys for Zephyr were removed and external references were
added for the built time autogenerated variables. A hardcoded key file
was added specifically for the simulator.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-06 11:07:06 -03:00
Fabio Utzig b1e0dc5a03 Add auto generation of keys to cmake
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-06 11:07:06 -03:00
Fabio Utzig c690c76120 Add public/private key file option to Kconfig
Also adds instrutions and defaults to prj.conf.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-06 11:07:06 -03:00
Carles Cufi 69c61d0e91 zephyr: Properly use the same mbedTLS header macros
For both RSA (which uses Zephyr's mbedTLS copy) and ECDSA (which uses
our own for ASN1 parsing) use the common "mcuboot-mbedtls-cfg.h" header
file instead of relying on the default config.h bundled with mbedTLS.
Additionally issue a descriptive error when CONFIG_MBEDTLS is set and we
are building with our own copy.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-06-05 19:16:42 +02:00
Fabio Utzig 48841f28ce Remove per file log level configs
This removes settings of log level on a per file basis. The log level
should be set by the global config, while per file log configuration can
still be set, don't enforce them.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-04 06:54:39 -03:00
Fabio Utzig 9a4b9ba1c0 Add per platform mcuboot_logging.h files
New logging macros were added for all supported platforms, following the
documentation defined in the template config file.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-04 06:54:39 -03:00
Andrzej Puzdrowski 9754328ac4 Reorganize zephyr kconfig
This patch isolates mcuboot settings under `MCUBoot`
menu in menuconfig view. This improves legibility.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-05-16 16:05:17 -03:00
Andrzej Puzdrowski b788c71c08 Replace mcuboot flash_map by zephyr flash_map
The patch introduce usage of zephyr flas_map module instead
of mcuboot zephyr-only implementation. Unused flash_area_to_sectors
API of former flash_map was removed as well.
Size of sector-status-update-map entry is now defined thanks to the
minimum write size supported by the flash driver.

For avoid ambiguity former zephyr-only files flash_map.c
were renamed to flash_map_extended.c (its code now implements
only addition to this what zephyr flash_map implements).

flash_map.h header include is now warped by flash_map_backedn.h headre
because implementations and include pathes are diferent in Zephyr and Mynewt.

Usage of hal_flash_align() were replaced by usage flash_area_align().
This provide consistency between MyNewt and Zephyr implementation as
this API is available in both RTOSes.

flash_map.h was moved to the simulator c-support files as now missing in
the boot/zephyr subdirectories.

f. boot_scratch_fa_device_id was removed as unused.
f. boot_img_fa_device_id was and expanded the only use of it
(on loader.c).

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-05-16 16:05:17 -03:00
Marti Bolivar f9bfddd685 Move max image sector config to mcuboot_config.h
Take the opportunity to clean up a bit of platform cruft that has
gotten into bootutil by moving it to mcuboot_config.h, and ensuring it
is documented in the template config file.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-04-25 18:44:03 -03:00