Commit Graph

1632 Commits

Author SHA1 Message Date
David Brown 78e4441bd3 Move Cargo.toml to top level
Instead of requiring cargo to be run in the sim directory, create a
top-level "workspace" Cargo file, that references the others.  The main
result of this is that cargo can now be run in the top of the workspace,
and the 'target' directory will be placed there, rather than in the sim
directory.

This is primarily of benefit to tools such as RLS, Rust-analyzer and
various IDEs that expect a crate at the top level of the tree.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-08-17 09:28:37 +02:00
Sudarshan Sreeram 900249cc98 Add espressif directory to .mbedignore
The old mbed CLI 1 tool, currently used to compile the MCUboot port for
Mbed™ OS, compiles all files unless otherwise specified in .mbedignore.
The espressif directory in the boot folder was added to the ignore file
to prevent failed builds.

Signed-off-by: Sudarshan Sreeram <sudarshan.sreeram@arm.com>
Signed-off-by: David Brown <david.brown@linaro.org>
2021-08-13 10:22:31 -06:00
Sigvart Hovland e933e586ec boot: zephyr: Do not use `irq_lock()` if using arm cleanup
`irq_lock()` sets `BASEPRI_MAX` aka. the `BASEPRI` mask to whatever
zephyr has configured it to be by the value of `_EXC_IRQ_DEFAULT_PRIO`.

However by calling arm_cleanup() we also do the call to
`__disable_irq()` setting the PRIMASK to 1. Meaning the only exceptions
we can recive is fault exceptions. Masking out more exceptions does not
really make sense.

Sometimes applications booted by MCUBoot will not expect the `BASEPRI`
to be set to something else than 0(No effect). Meaning if they depend on
using some exception which now is masked out by `BASEPRI` they will
fail.

Signed-off-by: Sigvart Hovland <sigvart.hovland@nordicsemi.no>
2021-08-12 15:23:04 -06:00
Dominik Ermel 4a4d1acec3 boot: Fix log reporting magic from incorrect header
Magic for different header was reported than the one that had failed
the check.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-08-12 14:53:52 -06:00
Øyvind Rønningstad 6693067b3a boot_serial: Reintroduce change from fc1ad8d
Also, keep casts to make build pass.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2021-08-10 16:58:54 -06:00
Øyvind Rønningstad 1e63e8f1d9 boot_serial: Update cddl-gen version
To bring in bugfixes.
Regenerate code.

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2021-08-10 16:58:54 -06:00
Carlos Falgueras García 391b19781e bootutil: Only include <os/malloc.h> if it going to be used
When no dynamic memory is used, there is no need for include "os/malloc.h",
and do so will force the user to create an empty "os/malloc.h" file.

Signed-off-by: Carlos Falgueras García <carlos.falgueras@wslw.es>
2021-08-09 15:10:19 -06:00
Shubham Kulkarni 8787bb04ae boot/espressif: Update main.c to call init and loader functions
Add ESP specific loader code to load host application

Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com>
2021-08-09 14:57:53 -06:00
Shubham Kulkarni cd86965429 boot/espressif: Update MCUBoot port to use bootloader_flash_* APIs
Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com>
2021-08-09 14:57:53 -06:00
Shubham Kulkarni c75b3c74f2 boot/espressif: Add hal subdirectory for IDF sources and headers
Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com>
2021-08-09 14:57:53 -06:00
Shubham Kulkarni 052561dcc0 boot/espressif: Add CMakeLists.txt and mcuboot_config.h
Add sources and headers required for build

Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com>
2021-08-09 14:57:53 -06:00
Andrzej Puzdrowski 420ad9adbd zephyr/boot_serial_extension: kconfig of custom command for get images status
made he command implementation selectable.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-07-30 12:26:43 +02:00
Andrzej Puzdrowski 1b62cf2c10 zephyr/boot_serial_extension: added custom command for get images status
Added service for custom command for fetch non-standard image status.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-07-30 12:26:43 +02:00
Piotr Mienkowski 01c84425b6 zephyr: do not set defaults for LOG_IMMEDIATE Kconfig
LOG_IMMEDIATE Kconfig option has been repurposed and is now a Zephyr's
internal, non-visible symbol that should not be used by the end user.

The logging mode used by MCUBoot is defined in prj.conf

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2021-07-30 09:39:50 +02:00
Dominik Ermel bd69c3dd4b boot_serial: Allow platforms to catch any unprocessed groups
The commit modifies mcumgr group processing in boot_serial_input
to allow catching any group that has not been processed by user
provided function.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-07-30 09:17:05 +02:00
Martí Bolívar 994816d04a zephyr: Kconfig: fix board references
Upstream Zephyr has renamed the 'nonsecure' variants for boards that
support TF-M. The rename consistently uses '_ns' or '_NS' (with
underscore) as the postfix which distinguishes these variants from
their 'secure' versions.

This affects Kconfig symbols used by MCUboot, so fix them to keep
working with the latest zephyr main branch.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-07-29 14:53:22 +02:00
Andrzej Puzdrowski fc1ad8d080 cbor_encoder: fix str encoding macros
Fix structure member assignment in tstrx_put() tstrx_put_term()
macro.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-07-29 12:00:52 +02:00
Ioannis Glaropoulos eb4c2fe3b2 boot: zephyr: add integration platforms to the allow list
The platforms that are listed as integration platforms in
the Zephyr boot sample need to be included in the platform
allow list, otherwise zephyr CI will throw an error. This
commit removes the common list of integration platforms and
adds integration platform entries in each test variant, in
accordance with the allow-list in each of the variants.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2021-07-29 11:40:37 +02:00
Carl-Johan Landin f44fd6199c zephyr: update devicetree py package lib files include path in assembly
This PR updates the path to the devicetree python package lib files according to the Zephyr PR
zephyrproject-rtos#33746 which moved the devicetree lib files.

Old path: ZEPHYR_BASE/scripts/dts/
New path: ZEPHYR_BASE/scripts/dts/python-devicetree/src/devicetree/

Signed-off-by: Carl-Johan Landin <carl-johan.landin@endian.se>
2021-07-26 10:19:14 +02:00
Salome Thirot 2386267279 boot: Fix IS_ENCRYPTED macro definition
The previous definition did not work as setting any type of flag would
make IS_ENCRYPTED true.

Signed-off-by: Salome Thirot <salome.thirot@arm.com>
2021-07-23 15:52:39 +02:00
Carlos Falgueras García 082be24c5e bootutil: Do not include mcuboot_logging.h when logging is disabled
This frees the user from the need of create an empty "mcuboot_logging.h"
when the logging is disabled.

Signed-off-by: Carlos Falgueras García <carlos.falgueras@wslw.es>
2021-07-21 11:47:58 +02:00
Carlos Falgueras García a4b4b0f0a9 bootutil: Refactor MCUBOOT_LOG_MODULE_(DECLARE|REGISTER) macros
The "MCUBOOT_LOG_MODULE_(DECLARE|REGISTER)" macros should have a name
coherent with the rest of the logs macors, ie "BOOT_LOG_*". Also,
"bootutil_log.h" should define them as empty when the logs are disabled and
as "MCUBOOT_LOG_MODULE_*" when they are not.

With this change, the mcuboot user doesn't have to define
MCUBOOT_LOG_MODULE_* macros if the logs don't going to be used.

Signed-off-by: Carlos Falgueras García <carlos.falgueras@wslw.es>
2021-07-21 11:47:58 +02:00
Dominik Ermel 2ae1f16516 zephyr: Relocate BOOT_ERASE_PROGRESSIVELY option
The Kconfig option is applied only when MCUBOOT_SERIAL is enabled
so it has been moved into MUCBOOT_SERIAL dependent section
of Kconfig.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-07-21 09:33:45 +02:00
Dominik Ermel 3d4e55d582 boot_serial: Switch to MCUBOOT_ERASE_PROGRESSIVELY
The code switches conditional compilation of progressive erase
code from Zephyr specific CONFIG_ option to more platform
agnostic MCUBOOT_ERASE_PROGRESSIVELY.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-07-21 09:18:58 +02:00
Dominik Ermel 42c985cead zephyr: Add MCBOOT_ERASE_PROGRESSIVELY config option
The commit adds generalized MCBOOT_ERASE_PROGRESSIVELY options
that can be used to enable progressive erase of flash in
boot_serial DFU code.
The progressive erase is used to erase flash pages as image
update fragments come, instead of erasing the whole needed
image at the beginning.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-07-21 09:18:58 +02:00
Sherry Zhang 4f8091318b boot: Revert "boot: Check shared area more carefully before init"
The commit "boot: Check shared area more carefully before init" adds
the support that the shared area can be used by other boot stages.
Before this commit, MCUboot initialize the shared memory based on a
global variable which indicates whether the shared memory has been
initialized by MCUboot. After this commit, MCUboot also checks the magic
value as well as the sanity check before initialization. So if the data
in shared memory retains after a reset, MCUboot does not initialize the
shared memory thus 'SHARED_MEMORY_OVERWRITE' error happens in
'boot_add_data_to_shared_area'.

So reverted this commit temporarily.

Signed-off-by: Sherry Zhang <sherry.zhang2@arm.com>
Change-Id: I1fc390bc17f90c2624024bc101ba8b4d5a75fe23
2021-07-19 21:50:52 -06:00
David Brown d505bcf99d ci: Add multiimage ram-load and direct xip tests
Now that these are supported, add tests for them to regular CI.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-07-19 11:22:13 -06:00
David Brown f17d39112f sim: Test ram-loading with DIRECT_XIP
Combine all of the pieces to be able to test ram loading with multiple
images.  We construct a model `RamData` that indicates where each image
should be loaded into RAM.  This has to be made early enough to compute
signatures on the images, and then used later to verify that the images
were loaded properly.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-07-19 11:22:13 -06:00
David Brown bf32c27f14 sim: Add RamData for ram loading testing
This RamData is filled in with a mapping between partitions and
information about where the data should be loaded into RAM when booting
in RamLoad mode.  This commit creates the data, but does not yet use it.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-07-19 11:22:13 -06:00
David Brown 8a4e23bb6b sim: Basic ram-load test
Test the basic configuration for ram loading.  Instead of a fixed
address for RAM, the values come dynamically from a thread-local
variable (allowing the tests to run in parallel).  The size of the ram
along with the address of the buffer in the test address space are
passed in this way.

This tests the single-image configurations of ram loading.  Testing
multi-image will take additional work, as the RAM will need to be large
enough for both images, and the second image will need a meaningful
offset address in RAM.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-07-19 11:22:13 -06:00
David Brown 0dfb810d36 sim: Test DIRECT_XIP configuration
Perform simplistic test of the DIRECT_XIP configuration (both with
single and multi-images).  This verifies that the bootloader indicates
the upgrade image should be booted.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-07-19 11:22:13 -06:00
David Brown 695e591cf5 boot: Warning fixups after dual image XIP/ram-load
This change introduced a few warnings that weren't caught until enabling
simulator builds with these features enabled.  Add some simple
workarounds to avoid the warnings.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-07-19 11:22:13 -06:00
David Brown fb40f0c5f5 ci: Add workflow tests for direct-xip and ram-load
Although there are no tests for these cases, the configurations now are
built.  Enabling them in CI will ensure they continue to build.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-07-19 11:22:13 -06:00
David Brown 11ffa0a56b sim: Support direct-xip configuration
Add simulator support for building the direct-xip configuration.
Although this builds, there are no tests that test any of the
functionality, so all current tests trivially pass.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-07-19 11:22:13 -06:00
David Brown 812a84b0f9 Add capability for DIRECT_XIP feature
Add capability detection for the MCUBOOT_DIRECT_XIP feature.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-07-19 11:22:13 -06:00
David Brown 7e377ab17b sim: Enable sim building with ram-load
Allow the sim to test configurations with MCUBOOT_RAM_LOAD defined.
This does not define any tests for this mode.

This adds definitions for simulated RAM offsets to the simulator.  This
will define the offset (from `IMAGE_RAM_BASE`) to where the simulated
RAM will be located.  For now, just give these somewhat reasonable
values so that we are able to at least compile the RAM_LOADING code in
the simulator.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-07-19 11:22:13 -06:00
David Brown 4b82c671cf sim: Implement function in sim
The function `flash_area_id_from_image_slot` is used in the RAM_LOAD and
DIRECT_XIP configurations.  Define a version for use in the simulator.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-07-19 11:22:13 -06:00
David Brown 6db44d7a00 sim: Skip (most) tests when flash is not modified
Some configurations of MCUboot do not modify the flash, but instead
MCUboot operates in a mode where it detects the best image to run.

Detect this, and skip what is currently a majority of the tests that
expect the upgrade to be moving data around in flash.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-07-19 11:22:13 -06:00
David Brown 9bd7f90e3f boot: Add a RAM base to support testing
Add a macro `IMAGE_RAM_BASE` that will support a simulated device RAM
that can be different per test.  This will be zero on targets.  Define
an invalid value (3) in the simulator environment.  As there are not yet
tests of this configuration, all tests will continue to pass.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-07-19 11:22:13 -06:00
David Brown 94ed12c401 boot: Fix ifdefs in DIRECT_XIP and RAM_LOAD case
The function `boot_erase_region` is used in some cases when DIRECT_XIP
or RAM_LOAD are defined, however it is specifically not compiled in in
these cases.  Correct the ifdefs so this function will be available.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-07-19 11:22:13 -06:00
David Brown dcea564e0a boot: Add capability for ram loading
The MCUBOOT_RAM_LOAD feature supports configurations where code is
loaded from flash into RAM before execution.  As such, it is not
necessary for upgrades to move data around in flash.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-07-19 11:22:13 -06:00
David Brown 122f9e7099 boot: Add some missing unused arguments
In MCUBOOT_RAM_LOAD mode, bootutil_img_hash has some arguments that end
up being unused, which creates warnings.  Add these to the list of
variables intentionally unused.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-07-19 11:22:13 -06:00
David Brown d82de8c7de sim: Allow access to the boot response
When the bootloader completes, it fills a response structure with
various information.  Move this into the BootGoResult and provide an
accessor for it.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-07-19 11:22:13 -06:00
David Brown 6d47d42eb6 sim: Make BootGoResult into an enum
Now that this result is abstracted, take the special case for a sim stop
and make it its own field.  This hides the magic number we use to
indicate this to be entirely within mcuboot-sys.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-07-19 11:22:13 -06:00
David Brown c423ac4517 sim: Return abstract value from boot_go
Instead of a tuple of values that is matched, return an abstract type
that has methods for querying the information we need.  Abstracting this
will allow us to return additional information without having to change
all of the code that matches against these patterns.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-07-19 11:22:13 -06:00
David Brown d216b20883 sim: Pass boot_rsp down from the simulator
Instead of having this struct at a fairly low level in the simulator,
with the filled-in values effectively discarded after each call, pass
the value from higher up in the simulator.  This prepares us for being
able to use the resulting data in upcoming tests.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-07-19 11:22:13 -06:00
David Brown f1ae694fa1 sim: Fix flash_area_get_device_id in sim
commit c304a7f84a
(refs/bisect/good-c304a7f84a7e7e345457e23b179fa302b8732fb9)
Author: Dominik Ermel <dominik.ermel@nordicsemi.no>
Date:   Mon Jun 14 16:08:42 2021 +0000

    sim: Add flash_area_get_device_id implementation

Adds an implementation for this function in the simulator that just
returns 0.  Fix this to return the proper ID so that when tests start
checking for this, it will return the right value.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-07-19 11:22:13 -06:00
Marek Pieta e51ec0707b boot: bootutil: Fix memory alignment of RAM buffer
Change fixes memory alignment of the RAM buffer that is used to
temporarily store data during swap. Some FLASH drivers require
word-aligned input data buffer. Using unaligned buffer results
in FLASH write error.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2021-07-16 13:26:43 -06:00
Dominik Ermel 6c8932e9d0 zephyr: Add support for direct image upload
The commit enables direct image upload for the Zephyr platform.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-07-16 13:24:26 -06:00
Dominik Ermel 48deccaaee boot_serial: Allow direct image upload
The commit provides support for "image" parameter in mcumgr image
update frame, that is used to select image number to be updated;
for the purpose, the option MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD
that enables the feature.
Platform that enables the feature needs, to provide an implementation
of the flash_area_id_from_direct_image function that will match
the image number to flash area to upload to.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-07-16 13:24:26 -06:00