Commit Graph

385 Commits

Author SHA1 Message Date
David Brown 74b3c58f53 zephyr: Add braces around single lines
The coding guidelines for mcuboot specify using braces around all
single-line constructs.  Add these to those lines missing this.
2017-04-11 17:59:05 -06:00
David Brown 0d0652a10f zephyr: use indentation consistent across mcuboot
The original Zephyr platform support files use tabs for indentation
(to match the Zephyr project).  Since this code is all together, and
will be used as the basis for other platforms, fix this indentation to
match that used by the rest of mynewt.

This change is clean with respect to "git show -b", and only changes
the indentation of the beginning of lines.
2017-04-11 17:59:04 -06:00
Marti Bolivar 7f6ea1599d zephyr: add nrf52840_pca10056 target
This board, called the NRF52840-PDK in marketing materials, is a
preview development board for the nRF52840 SoC.

Flash layout (4 KiB sectors):

        User    Start   End     Size (KiB) Size (B)
        ------- ------- ------- ---------- --------
        mcuboot 0x00000 0x07FFF         32  0x08000
        Image 0 0x08000 0x73FFF        432  0x6C000
        Image 1 0x74000 0xDFFFF        432  0x6C000
        Scratch 0xE0000 0xFCFFF        116  0x1D000

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-03-21 15:48:17 -04:00
Marti Bolivar 29d3a77d3b zephyr: fix flash_area_to_sectors()
This fixes MCUB-39.

On Zephyr targets, flash_area_to_sectors() assumes that the flash
device's sector size is equal to the size of the scratch area.

That breaks swap and rollback when scratch size doesn't divide image
size, since the image flash areas will not be correctly configured.
This is a valid configuration supported by the rest of mcuboot.

The best way to fix this would be to get the flash layout from Zephyr,
but that's not possible yet.

Instead, provide a new FLASH_AREA_IMAGE_SECTOR_SIZE define from
target.h. This must be the sector size for these areas:

       - FLASH_AREA_IMAGE_0
       - FLASH_AREA_IMAGE_1
       - FLASH_AREA_IMAGE_SCRATCH

Other areas on the device may have sizes different than
FLASH_AREA_IMAGE_SECTOR_SIZE.

This won't work on platforms where those areas have nonuniform sector
sizes, but we'll cross that bridge when we come to it. (At that point,
an upstream Zephyr change to the flash API really seems needed.)

Revert to the old/buggy behavior when FLASH_AREA_IMAGE_SECTOR_SIZE
isn't provided, but emit a warning. Additionally, touch up the logging
and error handling while we're here.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-03-21 15:48:15 -04:00
Marti Bolivar 94f3f91ca7 zephyr: 96b_nitrogen: increase scratch space
The current configuration only allows ~170 updates before we can
expect wear on the flash device (per product spec that the flash
device supports 10,000 erase cycles). Increase the scratch size to
make this better by removing some application space, to allow for
~2500 application updates or rollbacks.

The new configuration is 52 KiB (13 sectors) for scratch, and 208
KiB (52 sectors) for each application image.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-03-21 15:39:53 -04:00
Marti Bolivar 51181cf34f zephyr: add "real" target header
MCUBOOT_TARGET_CONFIG is included in several places now,
not just boot/zephyr/main.c. This seems likely to continue.

Let's avoid trouble and make it a real header file, target.h, that
pulls in MCUBOOT_TARGET_CONFIG. That done, include target.h instead
everywhere MCUBOOT_TARGET_CONFIG is included.

This will make it easier to provide values at an SoC/family level
later.  We can expect different Zephyr boards to have the same SoC and
thus likely the same mcuboot flash layout, so this will avoid
duplication.

All supported boards are compile-tested.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-03-21 15:39:46 -04:00
Marti Bolivar 1011b433c2 zephyr: flash_map: fix up logging
The Zephyr log backend already prepends the function, so it's
redundant to do it here.

Also convert a stray SYS_LOG_ERR to BOOT_LOG_ERR().

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-03-20 09:00:58 -04:00
Ricardo Salveti 8e4d44d1e4 zephyr: disable clock before reset
Avoid clock related interrupts before jumping into the first image. Safe
to disable as the first application will enable the clock/timer again
once booted.

Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
2017-03-17 15:12:17 -04:00
Andrew Boie c41cb110bd arduino_101: disable some additional options
We won't need the GPIO, timer, or pinmux drivers for
functioning asa bootloader, and some extra exception
debug info has been disabled.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-03-16 15:22:25 -07:00
Marti Bolivar 836768b2da zephyr: fix do_boot() warning on ARM
Commit 7238f51 ("zephyr: add support for x86 booting method")
introduced a backend-specific do_boot() function. On ARM, this casts
to an undefined type 'struct vector_table*'.  Fix this by using the
'struct arm_vector_table*' introduced in that patch.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-03-16 15:14:21 -04:00
Marti Bolivar 77683adc20 Move arduino_101.conf to boot/zephyr/.
It's currently one level down, in boot/zephyr/targets, from the rest
of the .conf files.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-03-16 15:06:20 -04:00
Andrew Boie 7238f511d9 zephyr: add support for x86 booting method
For x86 you just need to jump into the beginning of the image.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-03-15 13:19:31 -07:00
Andrew Boie 91c23f214a zephyr: add arduino_101 demo configuration
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-03-15 10:16:17 -07:00
Andrew Boie 240ac64e83 zephyr: disable multithreading
The bootloader is just using Zephyr as a HAL and doesn't require
thread scheduling. Build Zephyr in single-threaded mode and gain
some footprint savings.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-03-15 10:16:17 -07:00
David Brown 2e40f35ff9 Merge pull request #17 from mbolivar/misc-fixups
Miscellaneous minor fixups
2017-02-24 17:14:06 -07:00
Marti Bolivar 53cfdb9988 zephyr: fix flash_area_erase()
Flash must be unlocked before it can be erased.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-02-10 15:33:14 -08:00
Michael Scott 72559a4681 zephyr: targets: update flash driver names to use Zephyr CONFIGs
Let's stay in-sync automatically with Zephyr master by referring
to CONFIGs for the flash device names.

Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-02-10 15:33:14 -08:00
Marti Bolivar a9d55180b0 hal_flash.c: delete obsolete comment
Multiple supported targets (NRF52, K64F) do not support single byte
writes.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-02-10 16:44:41 -05:00
Marti Bolivar 2649aafa55 flash_map: delete obsolete flash_map* declarations
The following declarations are undefined and unused in both simulator
and zephyr builds (96b_nitrogen, 96b_carbon, frdm_k64f):

- flash_map
- flash-map_entries
- flash_map_init()

Delete them.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-02-10 16:44:41 -05:00
Christopher Collins 871054f067 This closes #11.
Merge remote-tracking branch 'd3zd3z/zephyr'

* d3zd3z/zephyr:
  zephyr: Make makefile clearer about configuration
  zephyr: Support RSA, and ECDSA P-256 signing
  bootutil: ecdsa P-256: Fix handling of sizes
2017-02-09 15:25:16 -08:00
Marti Bolivar 4a97b4c0b1 boot: zephyr: use bootutil_log.h, not sys_log.h
Now that mcuboot has its own logging subsystem, use that instead.

Note that this changes the domain from "[BOOTLOADER]" to "[MCUBOOT]".

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-02-07 16:59:50 -05:00
Marti Bolivar 5e6a1a6245 boot: zephyr: Fix 96b_nitrogen flash alignment
The Zephyr flash driver transparently handles non-word-aligned writes,
but the NRF52's flash write alignment is 4 bytes. Fix that.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-02-03 16:25:14 -08:00
Michael Scott de6ee59daf zephyr: generate mutliple records in flash_map when required
Currently, the flash map is a single entry sized to fit the
FLASH_AREA_IMAGE_0_SIZE.  This works for HW where
FLASH_AREA_IMAGE_SCRATCH_SIZE is the same or larger than
FLASH_AREA_IMAGE_0_SIZE.

However, if FLASH_AREA_IMAGE_SCRATCH_SIZE is smaller than
FLASH_AREA_IMAGE_0_SIZE, we need to generate enough write blocks in the
flash_map so that each will fit in FLASH_AREA_IMAGE_SCRATCH_SIZE.

Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-02-03 16:25:14 -08:00
Michael Scott e12746c4a2 zephyr: flash HAL requires flash_write_protection_set() calls
In Zephyr there is a flash HAL function: flash_write_protection_set()
which for many SoCs is a stubbed function with no functionality,
but for others performs the unlock / lock procedures required before
writing to flash.

We need to add this function to our flash_area_write() wrapper
to support the hardware that requires it.

This fixes mcuboot flash writing for the nRF5x SoCs.

Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-02-03 16:25:14 -08:00
Michael Scott db8ac52c2d zephyr: fix _scs_relocate_vector_table build break
Zephyr now supports moving the vector table for Corext M* targets.
Let's remove this code from mcuboot as this has been changed
upstream and breaks mcuboot build.

Signed-off-by: Michael Scott <michael.scott@linaro.org>
2017-02-03 16:25:14 -08:00
David Brown 3869e76090 zephyr: Support RSA, and ECDSA P-256 signing
Make it clear in the top-level Makefile how to configure mcuboot for
Zephyr for a particular signing algorithm.  Currently supported, are the
RSA signatures, and ECDSA with the P-256 curve.  These configuration
lines will select the code built in the bootloader, as well as which
public key gets included with the image.

This also adds a demo public key for the P-256 signatures.
2017-02-02 08:39:18 -07:00
Ricardo Salveti e156e57012 zephyr: add target header file for nucleo f401re
Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
2017-01-26 22:11:19 -02:00
David Brown 79fdfe5dfc k64f: change flash device name
Recent Zephyr changes the flash device name.  Change to match it.
2017-01-23 16:01:01 -07:00
Ricardo Salveti 7cf3d9ec91 zephyr: use SYS_LOG instead of printk
Easier to manage and can be easily disabled via config.

Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
2017-01-19 19:51:35 -02:00
Ricardo Salveti 3dbf2229e6 boot/zephyr/prj.conf: disable bluetooth support by default
Bluetooth is enabled by default with some boards, so just make sure that
it gets disabled here to avoid having a large bootloader firmware.

Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
2017-01-19 19:51:01 -02:00
Ricardo Salveti 43fc2cd556 boot/zephyr/prj.conf: remove SOC_FLASH_STM32F4, make it generic
Make it generic and let the SoC itself handle the FLASH driver support
as part of the Zephyr build system.

Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
2017-01-19 19:51:01 -02:00
Ricardo Salveti 88303ff1da zephyr: targets: add support for 96b_nitrogen
Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
2017-01-19 10:50:46 -02:00
Ricardo Salveti 3a2c1242f1 zephyr: restructure the build process to use board config files
Move the board specific configurations into its own header file, which
can now be created per board, once it gets tested and validated by the
bootloader.

Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
2017-01-19 10:26:40 -02:00
David Brown e7c66635cf zephyr: Include mbedtls config file
Rather than commit our specific mbedtls config file into the Zephyr
tree, include it here, and add a path early in the make process so that
it will get picked up when building the library.
2017-01-10 09:51:39 -07:00
David Brown 299245d7de zephyr: Move code under 'boot' directory
The Zephyr build systems makes some assumptions about the directory
layout, and encounters problems if the necessary path contains "../..".
To help this, place the zephyr directory next to the bootutil directory
so that the Makefile can just refer to "../bootutil".  This keeps all of
the build artifacts under the proper top-level directory.
2017-01-10 09:49:47 -07:00