Commit Graph

1589 Commits

Author SHA1 Message Date
Marek Pieta 4960d12cc1 boot_serial: cbor_encode: Fix encoding data length
Change fixes encoding data length and adds support for big endian
byte ordering. According to specification, data length can be
encoded either on 1, 2, 4 or 8 bytes.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2021-08-19 12:48:19 +02:00
Dominik Ermel 428d3ee78b zephyr: Make boot_serial_extension.c compilation conditional
The commit modifies CMakeLists.txt to include the file into compilation
only when CONFIG_ENABLE_MGMT_PERUSER is selected.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-08-19 11:12:38 +02:00
Dominik Ermel 0435d5d9b7 zephyr: Add option for enabling the storage erase command
The commit adds Kconfig option that enables the storage erase mgmt
command.
Addition of the Kconfig option fixes the problem where Zephyr spcyfic
mgmt commands support fails to compile when board does not define
a storage partition.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-08-19 11:12:38 +02:00
David Brown e182977199 Revert "Move Cargo.toml to top level"
This reverts commit 78e4441bd3.

Although it shouldn't, this change is provoking numerous errors in
CI.  In order to allow CI to continue, revert this change, and it can be
redone later, after fixing whatever is causing the CI build failures.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-08-19 09:28:04 +02:00
Gustavo Henrique Nihei 9d67f01efc README.md: Add references to the NuttX port
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2021-08-18 18:37:50 -03:00
Gustavo Henrique Nihei 93c029a4c5 docs: Add documentation for NuttX port
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2021-08-18 18:37:50 -03:00
Gustavo Henrique Nihei 7bcf9862de boot: Add support for the Apache NuttX RTOS
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2021-08-18 18:37:50 -03:00
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