Commit Graph

2330 Commits

Author SHA1 Message Date
David Brown 361be7ade7 sim: Return exit status from sim run
Instead of just printing a message, return an exit status so that
scripts running the sim can more easily tell if the tests passed.

Jira: MCUB-45
2017-03-29 13:01:44 -06:00
David Brown 274f7874db sim: Show address for overwrite error
When trying to write to the flash to a non-FF location, put the
location of the failure in the error message to help diagnose the
problem.
2017-03-29 13:01:13 -06:00
David Brown 07fb8fa0c8 sim: Add NRF52840 device
Add the flash device from the NRF52840 SoC.
2017-03-29 13:01:13 -06:00
David Brown 5c6b6798d0 sim: Use simulated flash configuration
There are some instances of hard-coded offsets, which break if the
simulated device doesn't have the same configuration.  Query these
from the flash descriptor rather than hard-coding them.
2017-03-29 13:01:13 -06:00
David Brown 0daa36c99f sim: Remove phantom declaration from CAreaDesc
Although this contains a phantom pointer, because it is passed to C,
this generates a warning on every compile.  Until this is fixed,
remove the lifetime declarations from the structures.  The user will
have to make sure that the pointed-to structures remain until the C
structure is completed.  For the common case of generating the C
structures just to make a call, this should be safe.
2017-03-29 12:58:40 -06:00
David Brown fdd68a1041 Merge pull request #27 from mbolivar/nrf52840
Nrf52840
2017-03-21 14:24:31 -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
aditihilbert 64fdcaba4c Update README.md 2017-03-20 15:42:50 -07: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
David Brown e1942988a4 Merge pull request #26 from andrewboie/master
x86 config updates
2017-03-16 17:25:34 -06: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
Andrew Boie ae790ddd49 Makefile: update location of target-specific .conf
arduino_101.conf was moved up a level, but the toplevel Makefile
was not updated so that it can be located.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-03-16 14:39:04 -07:00
David Brown ff4658e44f Merge pull request #25 from mbolivar/arduino-101-conf
arm fixes from x86 changes
2017-03-16 13:22:35 -06: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
David Brown e4cdf6760a Merge pull request #24 from andrewboie/master
Inital x86 support
2017-03-15 14:40:56 -06:00
Andrew Boie e9470d893a zep2newt.py: recognize x86 padding
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-03-15 13:27:57 -07: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 709b8c34ac zephyr: look for board-specific configuration
To build Zephyr as a bootloader will typically require
overriding the default flash regions where the binary lives,
and possibly other board-specific configuration directives.
Look for boot/zephyr/targets/$(BOARD).conf and include it
in the kernel configuration if it exists.

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 4908b331f7 Merge pull request #20 from rsalveti/zep2newt
zep2newt.py: use /usr/bin/env when searching for python2
2017-03-14 17:43:59 +01:00
David Brown dc278de874 Merge pull request #18 from mbolivar/fix-flash-area-erase
zephyr: fix flash_area_erase()
2017-03-14 17:43:18 +01:00
David Brown e482000015 Merge pull request #21 from ccollins476ad/assert-flash-ops
Assert flash ops
2017-03-14 17:42:35 +01:00
aditihilbert 2253d65f2b Merge pull request #23 from utzig/doc-missing-flags
Add new ECDSA256 flags to design
2017-03-08 15:27:42 +01:00
Fabio Utzig 150ea968e2 Add new ECDSA256 flags to design 2017-03-08 11:25:09 -03:00
Christopher Collins 4772ac4464 Assert flash ops succeed during swap.
Previously, the return of boot_swap_sectors() was discarded.  If a flash
operation failed, this information was lost.

Now, boot_swap_sectors() returns void.  Rather than returning a result,
success is asserted for all flash operations during function execution
(boot_copy_sector() and boot_erase_sector()).
2017-02-27 20:10:50 -08:00
Christopher Collins abfd75b144 Remove dead code. 2017-02-27 20:07:51 -08:00
Christopher Collins b9f15794b1 This closes #19.
Merge remote-tracking branch 'd3zd3z/fix-slot0'

* d3zd3z/fix-slot0:
  Fix slot0 validation
2017-02-27 19:54:08 -08:00
Ricardo Salveti 1a2e4b825b zep2newt.py: use /usr/bin/env when searching for python2
Avoid hardcoding the python2 path by using env python2 instead.

Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
2017-02-27 22:55:39 -03:00
David Brown b38e04494b Fix slot0 validation
commit d930ec69c8
    Author: David Brown <david.brown@linaro.org>
    Date:   Wed Dec 14 07:59:48 2016 -0700

        Validate slot zero before booting

adds a feature to validate slot 0 before booting it.  However, there
is an error in the logic, and if the magic number is written to an
invalid value, but not all 0xFF, it will consider any image to be
valid.

Fix this logic so that slot zero is always validated.
2017-02-24 17:31:21 -07:00
David Brown 2e40f35ff9 Merge pull request #17 from mbolivar/misc-fixups
Miscellaneous minor fixups
2017-02-24 17:14:06 -07:00
David Brown b30b8b8910 Merge pull request #16 from mike-scott/master-upstream-dev
zephyr: targets: update flash driver names to use Zephyr CONFIGs
2017-02-24 16:45:56 -07:00
Sterling Hughes 270f98eba4 Merge pull request #13 from d3zd3z/doc
Update documentation for Zephyr
2017-02-22 13:38:01 -08: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 dba1fc8abf 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 16:48:10 -05: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
Marti Bolivar 47c69d0eea scripts: zep2newt: remove unused argument
The --off argument is unused; delete it.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-02-10 16:44:41 -05:00
Marti Bolivar da223385c5 scripts: zep2newt: delete dead store
Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-02-10 16:44:41 -05:00
Christopher Collins 5741dde4a9 This closes #14.
Merge remote-tracking branch 'ccollins476ad/mynewt-app'

* ccollins476ad/mynewt-app:
  MCUB-3 Add sample Mynewt boot app.
2017-02-09 15:29:07 -08: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
Christopher Collins 9d0afb337c This closes #15.
Merge remote-tracking branch 'mbolivar/logging'

* mbolivar/logging:
  bootutil: log the boot source
  boot: zephyr: use bootutil_log.h, not sys_log.h
  bootutil: add logging
2017-02-09 10:48:35 -08:00
Marti Bolivar fd20c7652a bootutil: log the boot source
Use the bootutil_log.h APIs to log the boot source chosen by the
loader, as well as the image trailer state that led it to its
conclusion.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-02-07 16:59:50 -05: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