Commit Graph

18 Commits

Author SHA1 Message Date
Dominik Ermel 453e8bd7de flash_map_backend: Remove flash_area_id_to_image_slot
The function has not been in use and some ports have not been
implementing it anyway.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-02-14 16:40:21 -07:00
Artur Tynecki a3cf3f8041 mbed: Fix calling to BlockDevice::size before initialization
These changes fixes a bug that can cause an uninitialized BlockDevice
to be queried for its size. In some cases, this can return unexpected
results (eg: 0). Move setting block device size after its
initialization.
Co-created: @AGlass0fMilk - George Beckstein

Signed-off-by: Artur Tynecki <artur.tynecki@mobica.com>
Signed-off-by: George Beckstein <george.beckstein@gmail.com>
2022-03-08 09:50:01 -07:00
Artur Tynecki 6822365ecb mbed: Add the size of the MCU boot header area
Add header area size at the start of FLASH parameter in mbed_lib.json
This parameter is not used in MCUboot source code directly but for
example is the argument for imgtool.py sign command which sign
the binary image.
It will be useful to have it in Mbed port settings to use during project
building. For example post build command in cmake which signs image.

Signed-off-by: Artur Tynecki <artur.tynecki@mobica.com>
2022-03-08 09:50:01 -07:00
Artur Tynecki 41c568aba7 mbed: Add enable MCUboot logging parameter and fix logging configuration
This commit add option for a user to enable MCUboot logging from project
configuration level.
Now, logging from MCUboot's sources will be printed in the same way as
mbed-os logs.
Co-created by @AGlass0fMilk - George Beckstein

Signed-off-by: Artur Tynecki <artur.tynecki@mobica.com>
Signed-off-by: George Beckstein <george.beckstein@gmail.com>
2022-03-08 09:50:01 -07:00
Artur Tynecki a91016672e mbed: Add CMake support and fix files paths
The mbed port should be compatible with a new command-line tool
mbed-tools (Mbed CLI 2) which use cmake build system. This allows build
cmake-base applications.
Fix mbed files paths - it's required for the new version of mbed-os
(v6.15)

Signed-off-by: Artur Tynecki <artur.tynecki@mobica.com>
2022-03-08 09:50:01 -07:00
Gustavo Henrique Nihei 4aa286d2db flash_map: Increase minimum supported write align via flash_area_align
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2021-12-16 13:19:12 -07:00
George Beckstein f7319e61fb Add DataShare utility class for Mbed-OS applications
This commit adds a utility class that is available when building an application booted by mcuboot with MCUBOOT_DATA_SHARING enabled.

This utility class, `DataShare`, allows the application to iterate through the shared memory region and get each entry stored there.

Signed-off-by: George Beckstein <george.beckstein@gmail.com>
2021-09-13 15:46:40 -06:00
George Beckstein cb09bd201c Add config params for shared data usage in Mbed-OS
Signed-off-by: George Beckstein <george.beckstein@gmail.com>
2021-09-13 15:46:40 -06: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 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
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
George Beckstein a80e7c6715 Enable no signature verification configuration for Mbed-OS.
This commit introduces changes to allow the Mbed-OS port to disable use of signature verification. Previously this was not possible even though it is a valid mcuboot configuration.

Signed-off-by: George Beckstein <george.beckstein@gmail.com>
2021-05-12 13:30:06 -06:00
Bora Özgen 66f02e30b0 Mbed: Remove unused header size config
Signed-off-by: Bora Özgen <oezgen@nantis.de>
2021-05-08 07:13:09 -03:00
George Beckstein 2877965864 Enable support for building mcuboot for Mbed with direct-xip
This commit also introduces changes that allow users to build for other non-swap type update methods (overwrite only, swap using move, direct xip, or RAM loading). Changes include:

- Adding configuration options relating to XIP
- Updating the Mbed flash map backend to be compatible with XIP updates
- Add default secondary_bd in internal flash for XIP on Mbed OS.

Signed-off-by: George Beckstein <becksteing@embeddedplanet.com>
2020-12-16 20:29:27 -03:00
George Beckstein d1233e1b2d Add reference counting to Mbed OS flash backend
The internal functions of mcuboot are not consistent in opening/closing flash areas and sometimes nested calls happen to `flash_area_open` and `flash_area_close`. With the previous implementation, a nested call to `flash_area_close` would deinitialize the underlying `BlockDevice`. This could cause subsequent flash operations on an "open" flash area to fail.

This PR adds a simple open counter for each flash area and ensures the underlying `BlockDevice` is initialized and deinitialized appropriately. The `BlockDevice` is only initialized when transitioning from an open count of 0 to 1. The `BlockDevice` is only deinitialized when the open count falls to 0.

Signed-off-by: George Beckstein <becksteing@embeddedplanet.com>
2020-12-15 14:43:24 -07:00
George Beckstein ae09770946 Fix Mbed OS logging port when trace is disabled.
This PR prevents the following build error:

```
./mcuboot/boot/mbed/include/mcuboot_config/mcuboot_logging.h:65:30: error: 'IGNORE' was not declared in this scope
   65 | #define MCUBOOT_LOG_ERR(...) IGNORE(__VA_ARGS__)
```

This build error occurs when the bootloader is configured with Mbed's logging library, mbed-trace, disabled or when a logging level other than "MCUBOOT_LOG_LEVEL_DEBUG" is used. Since "bootutil/ignore.h" was not included previously, the "IGNORE(...)" macro was undefined in this scope.

Signed-off-by: George Beckstein <becksteing@embeddedplanet.com>
2020-12-03 09:58:36 -03:00
George Beckstein e42c6482e5 Temporarily disable use of TinyCrypt with Mbed-OS
TinyCrypt uses a modified version of micro-ecc that is also used by the Mbed Cordio BLE stack. When building mcuboot for a target with BLE enabled, this causes multiple-defined symbol errors during linking. Due to the nature of Mbed's current build system, it is difficult to fix this.

Mbed will soon release a more flexible cmake-based build system that will make it possible to exclude these TinyCrypt files from an application build that may also link Cordio BLE sources.

Until then, this commit temporarily disables the use of TinyCrypt with Mbed-OS and excludes its sources from the build to avoid this build error.

Signed-off-by: George Beckstein <becksteing@embeddedplanet.com>
2020-11-06 09:18:27 -03:00
George Beckstein d82afbfaa8 Mbed-OS porting layer implementation for mcuboot
This PR provides a porting layer implementation and framework for building an mcuboot-based bootloader with Mbed-OS. Some symbols are not provided by the Mbed-OS port within mcuboot, namely:

- The secondary storage device (see below)
- The signing keys
- The encryption keys, if used

Use of this port is demonstrated by the following projects:
- https://github.com/AGlass0fMilk/mbed-mcuboot-demo (a complete mcuboot/Mbed-OS-based bootloader)
- https://github.com/AGlass0fMilk/mbed-mcuboot-blinky (example showing how to make an Mbed-OS application that is bootable by mcuboot)

Memory porting implementation:

The underlying implemenation uses Mbed's BlockDevice API as the storage backend for mcuboot's memory operations. This provides a very flexible way of configuring the location and layout of the secondary flash storage area. To build an mcuboot-based bootloader with Mbed-OS, the user must implement a hook function, mbed::BlockDevice* get_secondary_bd(), to provide the secondary BlockDevice that mcuboot will use.

The signing and encryption keys must also be provided by the user. They can be generated using the existing imgtool utility in the same manner used by Zephyr. There are no automated build steps currently provided by Mbed-OS to sign/encrypt build artifacts.

Known limitations:

The update candidate encryption features have not yet been fully tested. A truly secure implementation will require integration with Mbed's TRNG API in the future to inhibit side-channel attacks on the decryption process.

The TinyCrypt backend is currently only supported for Mbed-OS builds when building with the GCC toolchain. The new cmake-based Mbed-OS build system will fix the underlying issue (file name uniqueness).

Signed-off-by: George Beckstein <becksteing@embeddedplanet.com>
Signed-off-by: Evelyne Donnaes <evelyne.donnaes@arm.com>
Signed-off-by: Lingkai Dong <lingkai.dong@arm.com>

Co-authored-by: Lingkai Dong <lingkai.dong@arm.com>
Co-authored-by: Fabio Utzig <fabio.utzig@nordicsemi.no>
2020-11-03 19:16:46 -03:00