Commit Graph

38 Commits

Author SHA1 Message Date
Fabio Utzig 1e19c5afc7 zephyr: fix include in hello-world app
Update include due to changes in Zephyr. This is related to commit
f1d189c486.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2019-12-16 16:08:00 -03:00
David Brown 2b951c920b samples: zephyr: Remove redundant extra chip erase
Remove a redundant chip erase from run-tests.go.  The '-e chip' should
tell pyocd to perform a chip erase.  There seem to be some combinations
of daplink and pyocd that if an invalid image is loaded into the device,
it can no longer be flashed by pyocd.  Performing the chip erase as a
separate command easily gets it into this state.  It can be recovered by
using the DAP filesystem to write the image.

Signed-off-by: David Brown <david.brown@linaro.org>
2019-12-05 11:32:26 -07:00
David Brown 358ca1ae4f Use Ninja instead of Makefiles for Zephyr
Zephyr builds use 'cmake' which can generate either makefiles, or use
the Ninja build tools.  There are several significant advantages to
using Ninja as the build tool:

  - It is significantly faster.  Ninja reads a directory and stats the
    files in it once.  Make often stats a given directory thousands of
    times, many for files that don't even exist.

  - It has better output.  Ninja collects commands together with their
    error output.  When doing multi-cpu builds, Ninja prints a status
    indicator, and only prints fully verbose commands when that command
    fails.  Instead of having to try an piece together a given command
    with its errors, they will always be together.

  - Make's support of multiple CPUs is a crude hack.  Make forks off
    multiple processes to use multiple CPUs.  These processes don't
    communicate with each other (very much), which causes make to often
    continue after enountering errors.  It is common for a multi-CPU
    make invocation to print hundreds or thousands of additional lines
    after an error message.

Nearly all distros have a version of Ninja available in their package
manager, making this change of low cost.

Signed-off-by: David Brown <david.brown@linaro.org>
2019-07-29 11:29:21 -05: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
Chris Bittner 520c727a62 zephyr: cmake: Remove obsolete code
set_conf is not used anymore.
This functionality was replaced.

Signed-off-by: Chris Bittner <chris.bittner@nordicsemi.no>
2019-04-10 10:06:35 -03: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
Maureen Helm 0e0c488ab4 docs: samples: Update pyocd calls to unified tool subcommands
pyocd 0.14.0 merged its command-line tools into a unified pyocd tool
with subcommands. The separate command-line tools still remain, but are
deprecated. Update all pyocd calls in samples and documentation to use
the new unified pyocd tool with subcommands.

Note that pyocd 0.15.0 has an issue with the command 'pyocd erase',
which was fixed in pyocd 0.16.0.

Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2019-02-19 14:09:36 -03:00
David Brown 038e299e79 samples/zephyr: Build ECDSA tests with ECDSA key
Set the public key for ECDSA tests to use the ECDSA.  This avoids a link
error with:

    ../app/libapp.a(keys.c.obj):(.rodata.bootutil_keys+0x0): undefined reference to `ecdsa_pub_key'
    ../app/libapp.a(keys.c.obj):(.rodata.bootutil_keys+0x4): undefined reference to `ecdsa_pub_key_len'

Signed-off-by: David Brown <david.brown@linaro.org>
2019-01-22 16:08:46 -07:00
Emanuele Di Santo 20ba65e151 samples: mcuboot_config: introduce MCUBOOT_LOG_MODULE macros
Introduce MCUBOOT_LOG_MODULE_REGISTER and MCUBOOT_LOG_MODULE_DECLARE.

- MCUBOOT_LOG_MODULE_REGISTER
    Register a new log module and add the current C file to it.

- MCUBOOT_LOG_MODULE_DECLARE
    Add the current C file to an existing log module.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
2019-01-10 19:11:15 +01:00
Emanuele Di Santo ccc98aa42d samples: mcuboot_config: simplify log configuration template
- Removed MCUBOOT_LOG_LEVEL macros.
The global log level shall be set using a port's configuration
management system of choice instead e.g Kconfig.

- Removed BOOT_LOG_LEVEL macro, which was not honored by
either Zephyr or mynewt ports.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
2019-01-10 19:11:15 +01:00
Marti Bolivar 08b8058b5c zephyr: hello-world: remove BUILD_TIMESTAMP from prj.conf
This feature has been deleted in Zephyr upstream. The project won't
build with this line in anymore due to Kconfig errors.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-10-01 21:41:40 -03:00
Marti Bolivar 5f15fe87e9 zephyr: hello-world: add cmake_minimum_required
The sample fails to build without it now due to changes in the
boilerplate file.

Signed-off-by: Marti Bolivar <marti@foundries.io>
2018-10-01 21:41:40 -03:00
Fabio Utzig ffffbaded0 Fix multi-line script call
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-07-10 09:51:06 -03:00
Fabio Utzig 44588eff41 Update `--included-header` parameter
The `--included-header` was "mandatory" when using imgtool with firmware
images generated by the Zephyr build system and it was a source of
issues when it was forgotten. This removes `--included-header` and adds
a new parameter `--pad-header` with inverted semantics, to be used only
when a zeroed header is required to be added to the firmware image.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-22 07:58:14 -03:00
Fabio Utzig 263d4398fa Add --slot-size to allow size checking without pad
Add the new `--slot-size` and make `--pad` a bool flag, to allow
checking that firmware fits in the slot without overflowing into the
trailer region even when no padding was requested.

Fixes #241

Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-07 14:29:33 -03:00
Fabio Utzig 7d81786a14 Add template docs for MCUBOOT_HAVE_LOGGING
Signed-off-by: Fabio Utzig <utzig@apache.org>
2018-06-04 06:54:39 -03:00
Marti Bolivar 248da08849 Move bootsim-specific assert behavior behind mcuboot_config.h
Continue removing platform-specific conditional compilation from
bootutil by adding a new MCUBOOT_HAVE_ASSERT_H configuration option
and associated header file. Right now, that's only used by the
simulator.

That leaves just bootutil_log.h with platform-specific contents, but
since it's meant to be an abstraction layer for logging, we'll let it
stand for now.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-04-25 18:44:03 -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
Marti Bolivar a87984327a zephyr: migrate upgrade-only to Kconfig
Handle CONFIG_BOOT_UPGRADE_ONLY in mcuboot_config.h, and switch the
release test Makefile to using an OVERLAY_CONFIG fragment.

This removes the last user of the Makefile BOOTLOADER_CONFIG variable,
so delete it as well.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-04-25 18:44:03 -03:00
Marti Bolivar 15c9b6f944 zephyr: migrate slot 0 validation to Kconfig
Handle CONFIG_BOOT_VALIDATE_SLOT0 in mcuboot_config.h, and switch to
setting it with an OVERLAY_CONFIG fragment in the test Makefile.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-04-25 18:44:03 -03:00
Marti Bolivar a4818a5565 zephyr: migrate signature type to Kconfig
Handle the CONFIG_BOOT_SIGNATURE_TYPE_xxx values in Zephyr's
mcuboot_config.h by converting them into the platform-agnostic MCUboot
definitions.

This requires some changes to the way the release test Makefile is
structured, since Kconfig symbols cannot be set from the command line.

Instead, use the OVERLAY_CONFIG feature of the Zephyr build system,
which allows specifying extra fragments to merge into the final
.config. (This is an orthogonal mechanism to setting CONF_FILE; it is
used by Zephyr's CI script sanitycheck to add additional fragments, so
it's appropriate for use by MCUboot's testing scripts as well.)

We additionally need to move to a single prj.conf file due to a
dependency issue. We can no longer determine CONF_FILE from the
signature type, since that is now determined from the final .config or
autoconf.h, which is a build output that depends on CONF_FILE.

To move to a single prj.conf:

- delete prj-p256.conf and adjust prj.conf to serve both signature types
- add a top-level mbedTLS configuration file which dispatches to
  the right sub-header depending on the key type
- as a side effect, have the simulator pick the right config file
  depending on the case

This fixes and cleans up quite a bit of the signature type handling,
which had become something of a mess over time. For example, it fixes
a bug in ECDSA mode's configuration that wasn't actually selecting
config-asn1.h, and forces the simulator to use the same mbedTLS
configuration file as builds for real hardware.

Finally, we also have to move the mbedTLS vs. TinyCrypt choice into
mcuboot_config.h at the same time as well, since CMakeLists.txt was
making that decision based on the signature type.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
2018-04-25 18:44:03 -03:00
Marti Bolivar f91bca51a6 Mandate the presence of mcuboot_config/mcuboot_config.h
Mynewt uses this file to convert MYNEWT_VAL(xxx) to MCUBOOT_xxx config
options. Zephyr currently adds config options via the compiler command
line, but it should use this instead.

As prep work for that conversion, add an empty mcuboot_config.h to the
Zephyr port, and include this file unconditionally wherever it's
needed. This takes care of the simulator as well, since that puts
boot/zephyr/include on its C file include path.

This turned up a couple of files (bootutil_priv.h and caps.c) that
were using the MCUBOOT_xxx config values without including the
file. Add the includes there, as they'll be needed later.

To make this official, add it to the requirements in the porting guide
and provide a template file porters can use while getting started.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>

fixup! Mandate the presence of mcuboot_config/mcuboot_config.h
2018-04-25 18:44:03 -03:00
Carles Cufi b791138c0c samples: zephyr: Use BOOTLOADER_MCUBOOT
Instead of manually setting the text section offset and the overlay
file, use the now readily available BOOTLOADER_MCUBOOT Kconfig option to
provide that automatically.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-03-27 10:09:18 -03:00
David Brown 8e0016eb14 zephyr: Create a test runner for the samples
Enhance the test runner so that it can verify the output of the tests by
itself.  This needs the console to be logged to a file, but otherwise
works the same as the current test runner.

Also, the build results are placed in a log file, so that it is easier
to see what is happening.

Signed-off-by: David Brown <david.brown@linaro.org>
2018-01-29 14:29:48 -07:00
Sebastian Bøe 9c38d76677 zephyr: hello-world: Samples should not define default boards
hello-world is serving as a sample application and should therefore
not define a default board as Zephyr samples do not either.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-29 16:19:37 -02:00
Sebastian Bøe 688a216a1a zephyr: hello-world: Remove documentaiton for non-existant feature
The documentation claims that one can place per-board overlay files in
the boards/ directory. But no such support has been implemented.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-29 16:19:37 -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 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
David Brown 1d3f67d36e zephyr: Move testplan into sample Makefile
Instead of a bunch of patches that tend to become conflicting, use the
newly parameterized Makefile to make all of the test plans into make
targets.  Update the instructions to match this.

Signed-off-by: David Brown <david.brown@linaro.org>
2017-09-14 16:10:50 -06:00
Marti Bolivar b9f5a68dac samples: zephyr: use unified application
Replace the hello1 and hello2 applications with hello-world.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-08-03 07:19:06 -06:00
Marti Bolivar 7135410196 samples: zephyr: trivial Makefile fixes
Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-08-03 07:19:06 -06:00
Marti Bolivar eba58fa360 samples: zephyr: add hello-world
This is a minimal example application that works on various boards,
without target-specific definitions, device tree overlay files, etc.

It's been tested on frdm_k64f, 96b_carbon, and 96b_nitrogen.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
2017-08-03 07:19:06 -06:00
David Brown 84a67af32c zephyr: sample: Add flash for full.bin
Previous commits added the full.bin target.  Add a flash_full target to
be able to flash this full image for testing.

Signed-off-by: David Brown <david.brown@linaro.org>
2017-07-26 18:42:29 -06:00
David Brown dbc5727902 samples: Add a 'full.bin' target to Zephyr sample
This full.bin target demonstrates how to assemble all of the images into
a single file which can be flashed to the device.  As it is, it will
then boot into the first "primary" image.  The second image will be
present, but will not ever be run.

Signed-off-by: David Brown <david.brown@linaro.org>
2017-07-20 14:55:50 -06:00
David Brown 51513afc07 samples: Add .gitignore to ignore output files
Signed-off-by: David Brown <david.brown@linaro.org>
2017-07-20 14:55:50 -06:00
David Brown ada28e1b69 samples: Create a zephyr sample
Most of the meat of this is in the Makefile, which is able to build the
bootloader, and two small applications, along with instructions on how
to load these into flash and test that upgrades work.

JIRA: MCUB-62
Signed-off-by: David Brown <david.brown@linaro.org>
2017-07-10 11:16:25 -06:00