Commit Graph

1552 Commits

Author SHA1 Message Date
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
Gustavo Henrique Nihei 8c5ec5a6cf bootutil: Prevent the redefinition of ASSERT
Some OSes may also define the ASSERT macro.

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2021-07-16 13:09:34 -06:00
Gustavo Henrique Nihei 82350d2b0e bootutil: Include missing header on bootutil_public.h
It is required to include "mcuboot_config.h" header for the evaluation
of the MCUBOOT_HAVE_ASSERT_H definition. Otherwise it will implicitly
depend on that header being included somewhere else.

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2021-07-16 13:09:34 -06:00
Sherry Zhang f4580cb672 Update mbedtls to mbedtls-3.0.0
Signed-off-by: Sherry Zhang <sherry.zhang2@arm.com>
Change-Id: If406625c09949cca7575d234807e49c00cbc2fa7
2021-07-16 09:42:57 +02:00
Sherry Zhang 8bdac69921 Update ext/mbedtls-asn1 to mbedtls-3.0.0
The files are copied from mbedtls-3.0.0 without any modification.

Signed-off-by: Sherry Zhang <sherry.zhang2@arm.com>
Change-Id: I164dbb0caa0600b9002fe4e37941eb10e036ffdf
2021-07-16 09:42:57 +02:00
Sherry Zhang 17adf8dd96 zephyr: upgrade mbedtls library to mbedtls-3.0.0
Signed-off-by: Sherry Zhang <sherry.zhang2@arm.com>
Change-Id: I306a9adc2e2a9c7933f637224f87c21dbd1bc5a4
2021-07-16 09:42:57 +02:00
Sherry Zhang b111f98f62 boot: Add the support of MBEDTLS version 3.0.0
Signed-off-by: Sherry Zhang <sherry.zhang2@arm.com>
Change-Id: Idd7ce989fe259e9003732e80beaf3dccdedd3050
2021-07-16 09:42:57 +02:00
Sherry Zhang 50b06aeaa4 boot: Fix build time error in DIRECT_XIP mode
Signed-off-by: Sherry Zhang <sherry.zhang2@arm.com>
Change-Id: I18ce06e008f858a1fef246bf1a4e527320ba6912
2021-07-15 14:22:09 +02:00
Dominik Ermel a09ca5b964 boot: Add MCUBOOT_PERUSER_MGMT_GROUP_ENABLED to platforms
The commit adds the MCUBOOT_PERUSER_MGMT_GROUP_ENABLED configuration
option to cypress, mbed and mynewt configurations.
The options is used to enable custom, system specific, mcymgr
commands parsing in mcuboot serial recovery.
For the listed platforms it is set as not enabled (0), as neither
of the platforms currently provide supporting callback.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-07-13 11:39:35 +02:00
Dominik Ermel 97b4c79564 zephyr: Add processing of PERUSER mgmt group for serial recovery
The commit adds Zephyr specific function for processing commands
from PERUSER and above groups; current addition is command
that allows to erase storage partition.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-07-13 11:39:35 +02:00
Dominik Ermel 3d51e430a6 boot_serial: Add optional processing of PERUSER group
The commit adds optional processing of MGMT_GROUP_ID_PERUSER,
as defined by mcumgr library, and above; the processing requires
systems to provide own functions as these groups are system
specific.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-07-13 11:39:35 +02:00
Dominik Ermel 260ae0906a boot: Modify common code access for flash_area objects
The commit changes direct access to flash_area, and flash_structure,
objects via filed names to access via getter functions
Purpose of this change is to make common code agnostic to internal
implementation of flash_area, and flash_sector, objects.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-07-06 14:42:53 -06:00
Dominik Ermel c304a7f84a sim: Add flash_area_get_device_id implementation
With switch to getter functions the implementation of the function
is now required.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-07-06 14:42:53 -06:00
Dominik Ermel 036d52131b zephyr: Switch single loader to use flash map getters
The commit changes single loader code that has been accessing
flash_area type object directly, to use the new getter functions.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-07-06 14:42:53 -06:00
Dominik Ermel dc1b9f0579 boot/ports: Provide getter function for flash area object access
The commit provides set of getter functions that allow to
access fields of flash_area and flash_sectors objects.
Usage of these function, instead of direct field access, allows
to keep common code intact when internal, system specific,
implementation changes.
The commit contains the implementation of getters for following
ports: cpress, mbed, mynewt, zephyr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-07-06 14:42:53 -06:00
Dominik Ermel d3f36092fc doc: Rework PORTING.md to reflect changes to flash_area API
The commit removes requirement that each system should exactly
follow proposed layout of struct flash_area and adds information
of flash_area API being extended by getter function that access
information inside flash_area type objects, allowing systems freedom
in internal implementation of flash_area.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-07-06 14:42:53 -06:00
Andrzej Puzdrowski d874417787 zephyr: add slot-1 in RAM confg for nrf52840dk_nrf52840
Added configuration for emulate the secondary image flash.
Thanks to that it is easy to test mcuboot behavior while
the secondary flash device stop working.
Need additionally to modify the zephyr/drivers/flash/flash_simulator.c
driver, soflash_sim_read() always returns an error e.g: -EINVAL.

For building mcuboot use following comand-line:
west build -d build/mcuboot_y -b nrf52840dk_nrf52840 \
bootloader/mcuboot/boot/zephyr/ -- \
-DDTC_OVERLAY_FILE=./boards/nrf52840dk_ram.overlay \
-DOVERLAY_CONFIG=./boards/flash_sim_driver.conf

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-07-06 12:11:03 -06:00
Andrzej Puzdrowski 85da97f2fb bootutil/bootutil_public: Treat unreachable image swap state as empty
Treat state of unreachable image device as if it is empty image.

This is required for boot the primary image if it is still available.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-07-06 12:11:03 -06:00
Andrzej Puzdrowski 54b4ad9fd7 bootutil/loader: Allow not working secondary image device
Let's distinguish a case when secondary image device has a malfunction
from case when primary has a such.
It might be still possible to boot the primary image.

This make sens especially if the secondary image resides in an
external flash which might be damaged while SoC is still working.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-07-06 12:11:03 -06:00
David Vincze 1c4562473e boot: Correct MCUBOOT_DIRECT_XIP_REVERT enablement
To avoid potential errors caused by misconfiguration make sure the
conditionally compiled snippets of code surrounded by the
MCUBOOT_DIRECT_XIP_REVERT macro are only used when direct-xip mode
is selected.

Change-Id: I6178d8186a7ca05887bc7590f5fa0c8f83f3d731
Signed-off-by: David Vincze <david.vincze@arm.com>
2021-07-01 10:22:23 +02:00
David Vincze dd6a84e330 boot: Check shared area more carefully before init
When the shared data area is not exclusively used by MCUboot, but also
by other boot stages it is inappropriate to initialize (erase) the
shared area based on a global variable. It must check the magic value
at the beginning of the area plus it should sanity-check other
available values for a case when memory garbage matches the magic
value.

Change-Id: I3a4552ad2863a61d81de9374ef6302ae0609f7bf
Signed-off-by: David Vincze <david.vincze@arm.com>
2021-07-01 10:22:23 +02:00
Philip Colmer 2a22bcc4c7 Delete CNAME 2021-06-28 07:48:14 +01:00
David Brown 8abacc834b workflow: Back off stale bot a bit
Change the stale bot to 180 days before initial flag.  In addition,
avoid issues entirely that have the 'someday' label applied.

Signed-off-by: David Brown <david.brown@linaro.org>
2021-06-25 12:53:49 -06:00
Carlos Falgueras García ae13c3c183 bootutil: Fix some misspelling variables
There are a couple of misspelled variables (slot -> active_slot).

fix #1028

Signed-off-by: Carlos Falgueras García <carlos.falgueras@wslw.es>
2021-06-25 11:34:36 -06:00
Carlos Falgueras García afb424dd49 bootutil: Fix bug defining slot_usage_t structure
There is a missing semicolon.

Signed-off-by: Carlos Falgueras García <carlos.falgueras@wslw.es>
2021-06-23 16:24:14 +02:00
Andrzej Puzdrowski aea38eb03a boot/boot_serial: call idle for reducing power in single thread
Sine zephyr https://github.com/zephyrproject-rtos/zephyr/pull/34279
was merged there is no silent idle thread created automatically while
CONFIG_MULTITHREADING=n. Since that any single thread application
needs to call k_cpu_idle() (wrapped by MCUBOOT_CPU_IDLE)
by itself for entering idle mode, which allows for reduction
power consumption.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-06-17 12:42:21 +02:00
Andrzej Puzdrowski 142b339667 boot: introduce MCUBOOT_CPU_IDLE() for support low power single thread
Introduced MCUBOOT_CPU_IDLE() macro.
If a port supports single thread or is bare-metal then might be need
to switch to idle mode explicitly form MCUboot code.
The call allows to enable lower power consumption while waiting for
incoming transmission in serial recovery etc.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-06-17 12:42:21 +02:00
Mariusz Poslinski d5e9902352 zephyr: Fix for issue with path length on windows
Switch to use zephyr_library_named() which creates a shorter library name.

Signed-off-by: Mariusz Poslinski <mariusz.poslinski@nordicsemi.no>
2021-06-16 14:21:26 +02:00
Flavio Ceolin 5442658d32 zephyr: Replace deprecated build option
CONFIG_SYS_POWER_MANAGEMENT is a deprecated option that was replaced
by CONFIG_PM.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-06-11 14:22:40 +02:00
Philip Colmer 339d9c4a5c Create CNAME 2021-06-10 11:30:15 +01:00
Philip Colmer cd394ff65d Delete CNAME 2021-06-10 10:52:07 +01:00