Commit Graph

162 Commits

Author SHA1 Message Date
Tomi Fontanilles d4394c2f9b mbedtls config: fix too early check_config.h includes
check_config.h was included manually by custom configuration files.
This caused compilation errors when updating MbedTLS to 3.6.0
because check_config.h was processed too early, before the whole
configuration is defined, effectively causing configuration check errors.

MbedTLS already takes care of including check_config.h at the right time.
Remove those erroneous manual check_config.h includes.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2024-04-25 11:05:54 +02:00
Jamie McCrae 8b4c70ab6d boot: zephyr: Update changed Nordic family Kconfig
Updates a Kconfig that was renamed

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-03-07 09:35:41 +00:00
Sylvio Alves b794d335a4 espressif: modify SOC_FAMILY according to new HWMv2
Update FAMILY reference as needed.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2024-03-04 15:47:01 -03:00
Dominik Ermel ca02c75060 boot/zephyr: Define SOC_FLASH_0_ID and SPI_FLASH_0_ID
The defines have been taken from the Zephyr flash_map.h
but as they are provided there for MCUboot only, they can be just
defined here.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-02-23 15:51:40 +01:00
Mateusz Michalek c3a72e9daf boot: zephyr: moonlight watchdogs
adding WATCHDOG_FEED support for WDT30 and WDT31

Signed-off-by: Mateusz Michalek <mateusz.michalek@nordicsemi.no>
2024-01-10 12:46:35 +01:00
Jamie McCrae a88e229346 zephyr: sysflash: Fix if condition for zephyr applications
Fixes an issue when sysflash is included by zephyr (non-mcuboot)
applications

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-12-07 10:43:58 +00:00
Piotr Dymacz 2a74a2b580 zephyr: io: add 'io_led_set()'
The static declaration of 'led0' was moved to 'io.c' which broke
building with the 'MCUBOOT_INDICATION_LED' enabled:

  mcuboot/boot/zephyr/main.c:380:22: error:
    'led0' undeclared (first use in this function)
      380 |     gpio_pin_set_dt(&led0, 1);
          |                      ^~~~

This adds simple function 'io_led_set()' for changing LED's value.

Fixes: 433b8480 ("zephyr: Move IO functions out of main to separate file")
Signed-off-by: Piotr Dymacz <pepe2k@gmail.com>
2023-12-06 10:33:28 +00:00
Jamie McCrae 215345f76a zephyr: Add firmware loader MCUboot operation style
Adds a new operation style in which the secondary slot has an
image which is used to update the primary image only.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-11-28 13:59:00 +00:00
Jamie McCrae 433b8480f7 zephyr: Move IO functions out of main to separate file
Moves IO functions into a separate file to allow reuse

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-11-28 13:59:00 +00:00
Jamie McCrae 268433e0a8 zephyr: Allow user-defined boot serial extensions
This allows for out-of-tree modules to define their own boot serial
functions by using iterable sections.
Note that this also removes the custom img list command, which was
not used in-tree.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-09-28 07:35:31 +01:00
Jamie McCrae 4da510137a zephyr: Add shared data support
Adds the ability to share mcuboot configuration with the
application using Zephyr's retention subsystem.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-09-27 07:49:25 +01:00
Dominik Ermel da65db0076 zephyr: Provide slot definitions for three images
Support for three pairs of slots.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-08-24 14:13:55 +02:00
Dominik Ermel 904d0c4608 bootutil: Add DirectXIP version of boot_set_next
The commit adds DirectXIP version of bootutil boot_set_next
function.
The function is enabled by configuration option:
MCUBOOT_BOOTUTIL_LIB_FOR_DIRECT_XIP.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-08-18 11:10:19 +02:00
Jamie McCrae c9fa60886b boot: boot_serial: Fix issue with encrypted second slot images
Fixes issues whereby encrypted images were not properly listed due
to not treating them as encrypted, also removes a piece of wrong
hack code that would never run as the primary slot cannot be
encrypted.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-08-09 07:45:22 +01:00
Jamie McCrae 5b1d5116a9 boot: bootutil: Add optional boot info shared data saving
Adds the ability to share MCUboot configuration with
applications via shared memory.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-08-08 08:02:25 +01:00
Jamie McCrae fac2cabe98 boot_serial: Add image state set/get
Adds optional image state set/get functionality to serial recovery
mode which allows for listing image states and marking images to
be tested or as confirmed.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-05-25 14:19:20 -06:00
Marek Matej 6769344276 boot: zephyr: esp32: zephyr port
Add support for ESP32xx targets to build
as Zephyr application.

Signed-off-by: Marek Matej <marek.matej@espressif.com>
2023-04-27 20:30:35 -03:00
Jeppe Odgaard 1558e7ab0a boot: zephyr: remove stm32 watchdog defines
The stm32 defines is somewhat redundant due to the generic watchdog
defines which uses the watchdog0 alias. Therefore they are removed in
this commit.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2023-04-26 13:15:51 +02:00
Jeppe Odgaard 4420bb663f boot: zephyr: setup watchdog
The Zephyr watchdog API defines a setup function. This function needs to
be executed before the watchdog is functional in some cases. This commit
adds MCUBOOT_WATCHDOG_SETUP when using the generic watchdog0 alias
otherwise it is an empty define.

Fixes https://github.com/mcu-tools/mcuboot/issues/1659

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2023-04-26 13:15:51 +02:00
Marek Pieta a95a41b3e1 boot: bootutil: loader: Let image version comparison use build number
Change allows using build number in image version comparison.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2023-04-25 12:04:27 +02:00
Jamie McCrae 827118f2e4 boot: serial_recovery: Add image hash support
Adds support for outputting the image hash TLV in serial recovery
mode, which is needed to comply with the img_mgmt MCUmgr group
requirements.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-03-23 10:25:38 +01:00
Dominik Ermel 069aea48a2 zephry: Add flash_area_get_sector
Commits adds implementation of flash_area_get_sector that
is supposed to replace flash_area_sector_from_off.
The flash_area_get_sector gets additional parameter of flash_area
type, while flash_area_sector_from_off uses hardcoded flash_area.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-03-14 08:13:20 -06:00
Dominik Ermel 0119cdb570 zephyr: Add missing flash_map.h to sysflash.h
The sysflash.h defines FLASH_AREA_ macros using FIXED_PARTITION
macros that are provided by flash_map.h, but it does not include
the required header.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-03-01 15:37:22 +01:00
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
Dominik Ermel a4c725109d zephyr: Remove FLASH_AREA_IMAGE_SCRATCH from single app config
Does not have to be set anymore when CONFIG_SINGLE_APPLICATION_SLOT
is set.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-02-14 08:42:15 -07:00
Michael Grand 5047f032c9 fih: Hardening of fault injection countermeasures
Returned values are now hardcoded. Indeed, while it is not
strictly needed (few return values different from SUCCESS
or FAILURE) complexity added by encoding return values might
cause the software to be vulnerable to fault attacks.

Return type changed from fih_int to fih_ret to make
the whole thing much simpler and therefore more robust
to fault attacks. In addition, its easier to predict
compiler behavior.

Affectation of sentive variables has been hardened using macro
FIH_SET (affectation + check wether write access has been properly
done). FIH_DECLARE() is added to ease the declaration of sentive
variables.

Equality tests fih_eq() and fih_not_eq() are now macros because
inlining produce more complex code (and weaker) than macros.
In addition fih_not_eq is modified to be the negation of fih_eq
which was not the case until now.

when FIH_NOT_EQ is used , FIH_SET(fih_rc, FIH_FAILURE) has been added
in some part of the code.

variable image_mask (bootutil_priv.h) is now volatile because a
double IF test is made on it.

some others parts of the code have been hardenned (eg. loop on images)

Signed-off-by: Michael Grand <m.grand@trustngo.tech>
2023-01-30 09:34:34 -07:00
Jamie McCrae 9d3fd7f7eb boot_serial: Add unaligned stack buffer writing
Fixes a bug when writing to devices which have memory alignment
requirements with data being using directly from a zcbor-response
whereby the alignment of the buffer data does not meet the
requirements of the flash driver.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-01-03 12:18:54 +01:00
Jamie McCrae ad1fb3dde2 boot_serial: Allow using a buffer larger than 512 bytes
There are 3 levels of buffers and only the first one seems to be
configurable, this fixes that issue.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-12-04 13:20:46 +01:00
Jerzy Kasenberg b8801fc0ac zephyr/Kconfig: Add downgrade prevention to swaps
Downgrade prevention for swap upgrades that was added to
mcuboot is now configurable in zephyr.

It may be using software version number from image in slot 0,
or security counter from the image in slot 0 (for limited downgrade
availability).

Hardware base security counter check remains unchanged.

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
2022-10-04 08:52:57 -06:00
Fabio Utzig 73d69e9b56 boot: zephyr: fix watchdog device typos
Fix typos for IWDG and watchdog0 alias feeding paths.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2022-09-12 11:13:54 +02:00
Dominik Ermel 3a82b6ff1e zephyr: Switch to using FIXED_PARTITION_ macros
The FLASH_AREA_ macros, which have been using DTS node label property
to identify partitions, have been replaced with FIXED_PARTITION_
macros that use DTS node label to identify partitions.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2022-09-08 12:44:58 +02:00
Bartosz Bilas a1c8c8e632 boot: zephyr: enable watchdog feed by default
Since we have support for nRF and STM32 families,
and non-vendor watchdog implementation let's enable
this functionality by default.
Imply NRFX_WDT && NRFX_WDT0 && NRFX_WDT1 only when
SOC_FAMILY_NRF is being used.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2022-09-02 13:08:07 -03:00
Bartosz Bilas a83715ba54 boot: zephyr: return NULL if stm32 watchdog is not enabled
Return the device pointer if the node identifier
refers to a watchdog node with status “okay”,
otherwise return NULL.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2022-09-01 21:38:10 -03:00
heinwessels 66cdd46b44 zephyr: flash: support 32byte block write size
Signed-off-by: heinwessels <heinwessels93@gmail.com>
2022-08-28 19:16:11 -03:00
Bartosz Bilas b03c098534 boot: zephyr: get rid of device_get_binding for stm32 watchdog
Replace the `device_get_binding` usage with
a `DEVICE_DT_GET` which is being deprecated in the upstream zephyr.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2022-08-04 17:17:33 +02:00
Bartosz Bilas b4c04d3393 boot: zephyr: add support for generic watchdog alias
Add possibility to pass generic watchdog alias
no matter what vendor is used.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2022-08-03 17:08:22 +02:00
Kumar Gala 8eadf8c2d0 zephyr: remove flash_device_get_binding
remove flash_device_get_binding as we can utilizes DEVICE_DT_GET to
get the flash_dev pointer set at build time.  This removes usage of
device_get_binding and handles the lack of 'label' properties in
the devicetree better.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-29 09:05:29 +02:00
Andrzej Puzdrowski f10d13aeaa zephyr: dropped __BOOTSIM__ ifdef-ry from the port
Since #1383 the configuration translation header and
the logging translation header are not used by the simiulator.

Thanks to that __BOOTSIM__ dependence might be removed - what is done
in this patch.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2022-06-23 14:33:33 +02:00
Gerard Marull-Paretas 3cd2cece69 zephyr: migrate includes to <zephyr/...>
Zephyr has prefixed all of its includes with <zephyr/...>. While the
_old_ mode can still be used (CONFIG_LEGACY_INCLUDE_PATH) and is still
enabled by default, it's better to be prepared for its removal in the
future.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2022-06-16 21:47:43 +02:00
Marcin Niestroj 65e1314058 zephyr: remove MBEDTLS_ECP_MAX_BITS from mbedTLS configs
According to mbedTLS' Changelog "Mbed TLS 3.0.0 branch released
2021-07-07" -> "Removals":

   MBEDTLS_ECP_MAX_BITS is no longer a configuration option because it
   is now determined automatically based on supported curves.

Hence remove MBEDTLS_ECP_MAX_BITS from configuration files to fix build
issues with Zephyr when there is unfortunate order of include
statements, like:

  /__w/zephyr/zephyr/modules/mbedtls/zephyr_init.c
  In file included from /__w/zephyr/modules/crypto/mbedtls/include/mbedtls/ssl.h:30,
                   from /__w/zephyr/modules/crypto/mbedtls/include/mbedtls/debug.h:27,
                   from /__w/zephyr/zephyr/modules/mbedtls/zephyr_init.c:16:
  /__w/zephyr/modules/crypto/mbedtls/include/mbedtls/ecp.h:314: error: "MBEDTLS_ECP_MAX_BITS" redefined [-Werror]
    314 | #define MBEDTLS_ECP_MAX_BITS 1
        |
  In file included from /__w/zephyr/bootloader/mcuboot/boot/zephyr/include/mcuboot-mbedtls-cfg.h:25,
                   from /__w/zephyr/modules/crypto/mbedtls/include/mbedtls/build_info.h:59,
                   from /__w/zephyr/modules/crypto/mbedtls/include/mbedtls/debug.h:25,
                   from /__w/zephyr/zephyr/modules/mbedtls/zephyr_init.c:16:
  /__w/zephyr/bootloader/mcuboot/boot/zephyr/include/config-rsa.h:72: note: this is the location of the previous definition
     72 | #define MBEDTLS_ECP_MAX_BITS             2048
        |
  cc1: all warnings being treated as errors

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2022-06-15 14:37:24 -06:00
Dominik Ermel d49cfc14c3 boot_serial: zephyr: Use snprintf to format version string
Move formatting of version string to use snprintf, which Zephyr
provides, instead defining utility function for that purpose.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-06-09 15:43:50 +02:00
Johan Öhman b588907ab1 zephyr: Wrapped the RAM loading mode in Zephyr configs.
The RAM loading mode wasn't wrapped in Zephyr configs like the other boot modes.
Added a config to enable RAM loading as well as two configs to set
IMAGE_EXECUTABLE_RAM_START and IMAGE_EXECUTABLE_RAM_SIZE, respectively. These
two values default to the values from the chosen node sram in the dts.

Signed-off-by: Johan Öhman <johan.ohman@softube.com>
2022-05-31 10:20:19 -06:00
Gerard Marull-Paretas aa041a282d zephyr: remove deprecated DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL
DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL is going to be deprecated, so
remove its usages from the Zephyr port. Definition checks have been
replaced with DT_HAS_CHOSEN(zephyr_flash_controller), and the macro
itself has been replaced by
DT_LABEL(DT_CHOSEN(zephyr_flash_controller)). Note that the code could
likely be refactored to make use of compile time device references, ie
use DEVICE_DT_GET, but that task has been left for the maintainers.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2022-03-28 10:47:22 +02:00
Wouter Cappelle e3ff17535c Add support for the mcumgr echo command in serial boot mode
Signed-off-by: Wouter Cappelle <wouter.cappelle@crodeon.com>
2022-02-22 09:27:57 -07:00
Wouter Cappelle e3822f8180 boot_serial: zephyr: Add optional timeout to enter serial recovery
This PR adds the possibility to only enter the bootloader's
serial recovery mode when a mcumgr command is received within a
given timeout.

Signed-off-by: Wouter Cappelle <wouter.cappelle@crodeon.com>
2022-02-09 16:20:58 -07:00
Wouter Cappelle bb7a39d114 Add config option for caching of validation state of an image in primary slot for single loader
Signed-off-by: Wouter Cappelle <wouter.cappelle@crodeon.com>
2022-02-09 13:31:56 -07:00
Sebastian Bøe c8ba937ee3 zephyr: Use a smaller sha256 implementation
Reduce the size of the sha256 implementation by 1300 bytes by using a
slower implementation.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2022-01-20 16:09:37 +01:00
Wouter Cappelle 953a76180d Add support for signed images in single loader mode
Signed-off-by: Wouter Cappelle <wouter.cappelle@crodeon.com>
2022-01-13 14:05:30 -07:00
Andrzej Puzdrowski a1c43cbea9 zephyr: fix typo in CONFIG_ERASE_PROGRESSIVELY conversion
Kconfig macro was converted with typo to not a MCUboot's
internal macro switch. It was MCBOOT_ERASE_PROGRESSIVELY instead
of MCUBOOT_ERASE_PROGRESSIVELY.
Bug was introduced in
42c985cead

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2021-12-01 18:14:35 +01:00
Hein Wessels 56d28f0c92 boot: zephyr: stm32: watchdog support
Adds support for STM32 IWDG.

Also now feeds watchdog in serial recovery.

Signed-off-by: Hein Wessels <heinwessels93@gmail.com>
2021-11-20 15:58:12 -03:00