Commit Graph

530 Commits

Author SHA1 Message Date
Fabio Utzig f0e5419535 Use travis env variable to control check-signed-off-by
Instead of trying to determine current branch using git, just rely
on travis to know if this is a PR and if it is not, don't do
signed-off-by checking.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2017-12-06 16:46:58 -07:00
Andrzej Puzdrowski 8e96b8352f enable serial recovery functionality on the zephyr mcuboot
This patch introduced serial bootloader functionality ported
from mynewt targets tree.

For achieving this following changes were applied:
- Modified boot_serial module for using, zephyr-os modules
  (crc driver, mbedtls-base64 library) and the zephyr serial adapter module
  introduced recently.
- Added service of boot serial recovery mode to main.
- Adapted the input parser to using static buffers.

Default serial-boot-pin configuration was added for nrf52_pca10040
and nrf52840_pca10056 boards.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2017-12-06 16:11:10 -07:00
Andrzej Puzdrowski 614c4e54a0 Add cboorattr library for zephyr
The library is needed for support mcuboot serial recovery interface.
This library wraps the tinycbor decoder with a attribute based decoder
suitable for decoding a binary version of json.

Origin: apache Mynewt
License: Apache-2.0
URL: https://github.com/apache/mynewt-core/tree/master/encoding/cborattr
commit: bf4b3f6f4cf293fc5a71d7787d5b81555434b6f8
Maintained-by: External

f. cbor_read_mbuf_attrs was removed as it was Mynewt specific.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2017-12-06 16:11:10 -07:00
Andrzej Puzdrowski 217c4e06e1 Add tinycbor library for zephyr
The library is needed for support mcuboot serial recovery interface.
Tinycbor lib from mynewt is imported because it is already modified for
Add tinycbor library for zephyr

mcuboot serial recovery protocol.

Origin: apache Mynewt
License: Apache-2.0
URL: https://github.com/apache/mynewt-core/tree/master/encoding/tinycbor
commit: bf4b3f6f4cf293fc5a71d7787d5b81555434b6f8
Maintained-by: External

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2017-12-06 16:11:10 -07:00
Andrzej Puzdrowski f6f652e204 Add serial adapter module for support serial communication for zephyr
Serial adapter uses the zephyr UART driver in interrupt mode for
providing communication capabilities needed for the boot serial
recovery mode.
This module provide API similar to mynewt console module.

Serial adapter module can not be compiled along with
the zephyr uart console module so this case is checked.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2017-12-06 16:11:10 -07:00
Andrzej Puzdrowski 64ad092bde Add Kconfig for the zephyr's build of mcuboot
This path introduces settings related to zephyr mcuboot
serial recovery mode. It force selection on modules which are
necessary to compile this project.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2017-12-06 16:11:10 -07:00
Fabio Utzig efe67ae52d Disable script debugging
Signed-off-by: Fabio Utzig <utzig@apache.org>
2017-12-06 13:46:40 -02:00
Fabio Utzig 5f9fbcc9d0 Only check signed-off-by in PRs
Signed-off-by: Fabio Utzig <utzig@apache.org>
2017-12-06 13:46:40 -02:00
Fabio Utzig 6da40d077b Update to use parent commits
Signed-off-by: Fabio Utzig <utzig@apache.org>
2017-12-05 13:24:03 -02:00
Fabio Utzig 0b56138c8a Besides author also check committer
Signed-off-by: Fabio Utzig <utzig@apache.org>
2017-12-05 13:24:03 -02:00
Fabio Utzig 5101b0f812 Try using tail again
Signed-off-by: Fabio Utzig <utzig@apache.org>
2017-12-05 13:24:03 -02:00
Fabio Utzig 311801775e Fix review issues
- Use git options to remove last commit from list to verify.
- Check each line of a commit for a "Signed-off-by" line.
- Exit with error in the event of no commits in PR!

Signed-off-by: Fabio Utzig <utzig@apache.org>
2017-12-05 13:24:03 -02:00
Fabio Utzig 5b989104a5 Add travis' validation of "Signed-off-by:" line
Signed-off-by: Fabio Utzig <utzig@apache.org>
2017-12-05 13:24:03 -02:00
Fabio Utzig cd5774b7ba Fix for gcc warnings
Fixes warnings treated as errors when upgrading gcc crate to 0.3.54.
Warnings are due to non-used variables and comparison between signed
and unsigned.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2017-12-05 09:55:36 -02:00
Ding Tao 446d3759f8 zephyr: Fix an invalid url in file CMakeLists.txt
Replace https://www.zephyrproject.org/doc/dts/device_tree.html with
http://docs.zephyrproject.org/devices/dts/device_tree.html

Signed-off-by: Ding Tao <miyatsu@qq.com>
2017-11-21 08:22:32 -07:00
Marti Bolivar 38d67f76f0 zephyr: add script for running mcuboot tests
It's onerous to work through the tests in docs/testplan-zephyr.md by
hand. Add a script which takes the thinking out of it.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2017-11-20 18:10:29 -07:00
Marti Bolivar c1f939d63f bootutil: fix edge case when not validating slot 0
When not validating slot 0, we could be booting into an empty
chip. This means we jump based on garbage data.

Try to make this better by at least checking the magic number. Without
this patch, booting with just the bootloader fails the Zephyr release
tests.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2017-11-20 18:10:29 -07:00
Marti Bolivar bf909a1fcc zephyr: port build system to CMake
Convert the Zephyr build to the new CMake-based sytem.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2017-11-20 18:10:29 -07:00
Marti Bolivar 7ad18358f2 zephyr: delete build_boot.sh
Zephyr has moved on to CMake, and no longer supports in-tree builds as
assumed by this script. Let's just delete it and recommend that people
use the standard Zephyr build mechanisms.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2017-11-20 18:10:29 -07:00
kYc0o 900be6eb27 Fix repository for v1.0.0
Signed-off-by: kYc0o <fco.ja.ac@gmail.com>
2017-11-20 14:06:41 -02:00
David Brown e9771ef62f Fix ECDSA Zephyr configuration of mbed TLS
The Zephyr configuration was enabling the memory buffer allocator (but
not using it) without defining enough other features to allow it to
compile (undefined reference to `exit()`).

Disable the memory buffer allocator when just using the ASN.1 library,
and conditionalize the heap itself to avoid using the RAM for that.

Signed-off-by: David Brown <david.brown@linaro.org>
2017-11-14 19:12:53 -07:00
David Brown da21ad73c4 sim: Update README for new test organization
Now that the tests can be run using `cargo test`, update the
instructions to reflect this.

Signed-off-by: David Brown <david.brown@linaro.org>
2017-11-07 09:39:45 -07:00
David Brown 577f48a4f9 Change travis to use the new test runner
Instead of running an executable, use cargo to run the test suite.

Signed-off-by: David Brown <david.brown@linaro.org>
2017-11-07 09:39:45 -07:00
David Brown a4167efc8e sim: Create cargo tests for each testcase
Now that the test infrastructure has changed so that the tests can be
run independently, create a series of cargo tests that run them.  This
allows the tests to simply be run as:

    cargo test

or possibly with feature flags

    cargo test --features overwrite-only

It is also possible to run individual tests by giving their name after
the "cargo test" command.

Signed-off-by: David Brown <david.brown@linaro.org>
2017-11-07 09:39:45 -07:00
David Brown c49811e855 sim: Move total count into `Images`
In order to allow the tests to be run independently, compute the total
count for each image that is generated, and store it in the images
struct.  This causes a basic upgrade to be run an additional time for
each top-level test.

Signed-off-by: David Brown <david.brown@linaro.org>
2017-11-07 09:39:45 -07:00
David Brown f48b95022a sim: Make `Run` a factory for `Images`
Generate the various test images as methods of the `Run` struct.

Signed-off-by: David Brown <david.brown@linaro.org>
2017-11-07 09:39:45 -07:00
David Brown 5f7ec2b403 sim: Move `Images` methods to be methods
Now that most of the relevant data is assembled into a single `Images`
struct, make the test operations on it into methods on this type.

This change looks larger than it really is because of the indentation
change of moving top-level functions into methods.  There is also a lot
of change of `image` to `self`.

Signed-off-by: David Brown <david.brown@linaro.org>
2017-11-07 09:39:45 -07:00
David Brown 3f687dc5bc sim: Move `areadesc` into `Images` struct
Move this struct into the images struct as well to avoid passing it
around with every call.

Signed-off-by: David Brown <david.brown@linaro.org>
2017-11-07 09:39:45 -07:00
David Brown dc9cba140b sim: Move `flash` inside of `Images` struct
Every use of `Images` uses the same flash device as a base.  Move this
value into the struct, instead of having to pass it around in parallel.

Signed-off-by: David Brown <david.brown@linaro.org>
2017-11-07 09:39:45 -07:00
David Brown db9a395dd9 sim: Move data into `Run` struct
Refactor the tests so that most of the test data is inside of a new
`Run` structure instead of needing to be passed around.

Signed-off-by: David Brown <david.brown@linaro.org>
2017-11-07 09:39:45 -07:00
David Brown 353610dea2 sim: Prevent reentrancy on simulation
Lock the simulation with a mutex to prevent concurrent access.  The C
code being tested uses globals, and can only be run in one context at a
time.  The Rust test framework may run tests concurrently, so use the
mutex to prevent this.

Signed-off-by: David Brown <david.brown@linaro.org>
2017-11-07 09:39:45 -07:00
David Brown 541860c28c sim: Pass alignment into `boot_go`
Move the alignment into the `boot_go` wrapper.  Instead of relying on
this as a global, pass it around, ultimately setting it in the C
wrapper.  This is in preparation to protecting the `boot_go` call with a
mutex to prevent reentrancy.

Signed-off-by: David Brown <david.brown@linaro.org>
2017-11-07 09:39:45 -07:00
David Brown ee61c8309a sim: Pass counter through boot_go API
Instead of setting/reading a global, pass a reference through the Rust
wrapper to `boot_go`.  This is one change needed so that `boot_go` can
be reentrant.

Signed-off-by: David Brown <david.brown@linaro.org>
2017-11-07 09:39:45 -07:00
David Brown ca7b5d33da sim: Enable logging in simulator test cases
When running simulations as unit tests, use a workaround from
https://stackoverflow.com/questions/30177845/how-to-initialize-the-logger-for-integration-tests
to initialize the logging system.

Signed-off-by: David Brown <david.brown@linaro.org>
2017-11-07 09:39:45 -07:00
David Brown dd2b118b21 sim: Run main test as a Rust unit test
As a start of doing the testing using Rust/Cargo's test framework, write
a test runner that just runs the existing tests.  They run as they do
now, except that there is an assertion that there were no failures.

Signed-off-by: David Brown <david.brown@linaro.org>
2017-11-07 09:39:45 -07:00
David Brown d5e632c43d Move Slotinfo values into Images struct
So that this can be stored in its own structure, make it own the slot
info (which is only two usize values).

Signed-off-by: David Brown <david.brown@linaro.org>
2017-11-07 09:39:45 -07:00
David Brown decbd04644 sim: Extract flash builder
Move the code to build a flash device into its own function.

Signed-off-by: David Brown <david.brown@linaro.org>
2017-11-07 09:39:45 -07:00
David Brown 2639e074fb sim: Move main code into lib crate
In preparatio for separable unit tests, move the main body of the
simulator into a library crate, and make the main program just a small
function that initializes the logger, and calls it.  The main entry
point is still called main.

Signed-off-by: David Brown <david.brown@linaro.org>
2017-11-07 09:39:45 -07:00
David Brown 0bae965fd8 Zephyr: Use mbed TLS allocator
Instead of the overly-simplistic allocator in Zephyr, use the still
simplistic allocator in mbed TLS.

On K64f, this saves 848 bytes of text, 44 bytes of data, and 208 bytes
of bss.

Signed-off-by: David Brown <david.brown@linaro.org>
2017-10-30 22:33:08 -06:00
Ryan C Johnson ce4fa4400a Correction to swap procedure design documentation
The swap procedure as documented doesn't match the code, and it would
loose the contents of slot1[index] as it's erased before it is copied
anywhere. Also, add the missing word 'to'.

Signed-off-by: Ryan C Johnson <ryan.johnson@flex.com>
2017-10-19 17:41:59 -02:00
Fabio Utzig 13d9e35d52 Add faster copy/erase to overwrite-only mode
This add a new option to overwrite-only mode that enables copy/erase of
only the amount of sectors that are required to store the source image.

This is enabled by default when overwrite-only mode is used.

MCUB-70

Signed-off-by: Fabio Utzig <utzig@apache.org>
2017-10-19 09:28:37 -06:00
Fabio Utzig 33fa8ad78c Avoid memcpy'ing a public key by reusing buf
This implements a TODO, removing a memcpy of the public key by doing all
buffer calculation in place.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2017-10-19 09:27:45 -06:00
Fabio Utzig a8f06aaf4d Remove duplicated choices by using existing dict
Signed-off-by: Fabio Utzig <utzig@apache.org>
2017-10-17 20:25:42 -02:00
Marti Bolivar dc4c42bf62 boot: zephyr: fix flash page layout hacks
Zephyr now has proper page layout APIs in its flash driver. Use these
to implement flash_area_get_sectors() and flash_area_to_sectors() when
they are available. Leave the existing implementation behind as a
"legacy" version, for flash drivers which lack page layout support.

This lets us obtain all the target support we need for nRF and STM32
targets entirely from the operating system.

There are two cases where OS-level support is still not enough:

- NXP K6x targets still need an SoC family header, because their flash
  driver does not yet support CONFIG_FLASH_PAGE_LAYOUT.

- The arduino_101 target needs partition and flash alignment
  definitions in its DTS, and a flash driver with page layout support
  as well, so its board-specific header must remain for now.

Fixing these is left to future work. Once that is done,
boot/zephyr/targets/ can be removed completely.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-10-10 13:57:02 -06:00
Marti Bolivar 3d9e3eb974 boot: zephyr: obtain FLASH_DRIVER_NAME, FLASH_ALIGN from OS
Zephyr now provides defines for FLASH_DRIVER_NAME and
FLASH_WRITE_BLOCK_SIZE (which is what we call FLASH_ALIGN) in
the SoC headers for most targets supported by mcuboot. Use that
information when it's available, falling back on MCUBOOT_TARGET_CONFIG
otherwise.

The soc_family_foo.h files remain for FLASH_AREA_IMAGE_SECTOR_SIZE.  A
subsequent patch can remove these files when the relevant SoC flash
driver provides a page layout.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-10-10 13:57:02 -06:00
Fabio Utzig f0355743a8 Add back tinycrypt Makefiles
Signed-off-by: Fabio Utzig <utzig@apache.org>
2017-10-10 14:34:17 -03:00
Fabio Utzig 3efe6b6206 Add tinycrypt 0.2.8
Signed-off-by: Fabio Utzig <utzig@apache.org>
2017-10-10 14:34:17 -03:00
Szymon Janc 161848825d This requires Tinycrypt 0.2.7.
Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2017-10-10 14:34:17 -03:00
Fabio Utzig b6297af620 Log error message when slot fails validation
Signed-off-by: Fabio Utzig <utzig@apache.org>
2017-10-09 16:42:01 -03:00
Fabio Utzig e30e9b0bf7 Fixes a make param typo
Signed-off-by: Fabio Utzig <utzig@apache.org>
2017-10-06 06:31:34 -03:00