Commit Graph

1239 Commits

Author SHA1 Message Date
Øyvind Rønningstad a899390056 zcbor: Add copy notice to all copied files
And update script

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2024-01-25 08:16:49 +00:00
Øyvind Rønningstad ad5f0ac1b2 zcbor: Copy source and header files
from zcbor 0.8.0

Signed-off-by: Øyvind Rønningstad <oyvind.ronningstad@nordicsemi.no>
2024-01-25 08:16:49 +00: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 4d75fc8e07 bootutil: Fix compatible sector checking
Fixes an issue whereby slot sizes were checked but the check was
not done properly. This also adds debug log messages to show the
sector configuration including if slot sizes are not optimal

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-01-08 15:35:53 +00:00
Jamie McCrae 35e9931c78 bootutil: Add debug logging for boot status write
Adds debug level logging which shows the offset of where a
sector swap status write is occurring at

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-01-08 15:35:53 +00:00
Jamie McCrae db9a7f5822 boot: zephyr: cmake: Fix issue with missing dts entries
Fixes an issue whereby a device might not have a write or erase
entry for the flash controller in devicetree. In the case whereby
the other slot has this information, use that instead. In the case
whereby neither slot has this information, use default values and
show a warning to the user

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-01-08 15:35:44 +00:00
Xudong Zheng 8cee355095 zephyr: kconfig: make MBEDTLS_PROMPTLESS depend on MBEDTLS
This addresses compilation error when MBEDTLS module is not present.

Signed-off-by: Xudong Zheng <7pkvm5aw@slicealias.com>
2024-01-02 10:21:59 +00:00
Jamie McCrae e9131ee8b8 zephyr: kconfig: Make saving encrypt TLVs depending on encryption
Prevents enabling the option to save encrypted TLVs if encryption
support is not enabled, as it is required to make use of this
functionality.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-12-12 10:41:26 +00:00
Jamie McCrae 4c7942e58c zephyr: Add estimated image footer size to cache in sysbuild
Adds MCUboot's estimated overhead footer size to the application's
cache when using sysbuild, this allows that information to be
propagated to applications which can use the information to reduce
the available size for an application, preventing the MCUboot
error of image too large to swap.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-12-12 10:41:26 +00:00
YuLong Yao 26d6423b00 boot: zephyr: esp32: zephyr port
Add support for ESP32xx_luatos_core targets to build
as Zephyr application.
This target is simular to esp32 devkitm,
copy conf file from esp32xx_devkitm

Signed-off-by: YuLong Yao <feilongphone@gmail.com>
2023-12-07 14:48:45 -03:00
Jamie McCrae 212997395e zephyr: firmware/single_loader: Fix compile warning
Fixes an issue of an unused function calling an undefined function

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-12-07 10:43:58 +00: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
Piotr Dymacz 8c6c67016a zephyr: io: include 'bootutil_log.h' and declare log module membership
This fixes below error when building with 'MCUBOOT_INDICATION_LED' and
'LOG' enabled:

  In file included from zephyr/include/zephyr/logging/log.h:11,
                   from zephyr/include/zephyr/usb/usb_device.h:43,
                   from bootloader/mcuboot/boot/zephyr/io.c:26:
  mcuboot/boot/zephyr/io.c: In function 'io_led_init':
  zephyr/include/zephyr/logging/log_core.h:151:20: error:
    '__log_level' undeclared (first use in this function)
    151 |         (_level <= __log_level) &&                                          \
        |                    ^~~~~~~~~~~

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
Piotr Dymacz d99154f441 zephyr: rename 'led_init()' to 'io_led_init()'
This fixes below warning when building with 'MCUBOOT_INDICATION_LED'
enabled:

  mcuboot/boot/zephyr/main.c:410:5:
    warning: implicit declaration of function 'led_init';
             did you mean 'io_led_init'? [-Wimplicit-function-declaration]
      410 |     led_init();
          |     ^~~~~~~~
          |     io_led_init

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
Andrej Butok c43a20fd19 boot: zephyr: add support for mimxrt1040_evk
Add default configuration for mimxrt1040_evk.

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
2023-12-05 15:41:56 +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 5e6cffbf4a boot: boot_serial: Fix single slot encrypted image list
Fixes an issue whereby MCUboot is configured in single application
slot mode with serial recovery with encryption and an encrypted
image has been loaded, if valid this will have been decrypted, so
should not be treated as encrypted

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-11-28 09:26:28 +00:00
Andrej Butok 3f0b89d680 boot: zephyr: add support for mimxrt101x_evk
Add default configuration for mimxrt1010_evk and mimxrt1015_evk.

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
2023-11-28 09:26:11 +00:00
Jamie McCrae 47b3436255 zephyr: kconfig: Prevent MBEDTLS selection when tinycrypt is used
Prevents an issue which occurs when the MCUboot configuration is
changed which then selects multiple conflicting symbols

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-11-21 13:30:10 +00:00
Andrej Butok cd82f8bf7a boot: zephyr: add support for lpcxpresso55s28
Add default configuration for lpcxpresso55s28.

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
2023-11-21 13:29:34 +00:00
Jamie McCrae e9fccef5dd boot_serial: Fix missing response if echo command disabled
Fixes an issue whereby when an echo command is sent in serial
recovery mode, if it is disabled, there would just be no response
at all, which is invalid operation

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-11-07 10:22:02 +00:00
Jamie McCrae 013c9e7654 boot: zephyr: board: various: Remove size optimisation
This value is now the default, remove explicitly setting it for
some boards

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-11-07 09:08:27 +00:00
Jamie McCrae 0a8bbbf4b7 boot: zephyr: Fix USB configs
Fixes USB configurations so that they build out of the box, this
previously falsely built successfully but would not run

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-11-07 07:44:00 +00:00
Jamie McCrae d5c963c549 boot: zephyr: serial_adapter: Add error if main thread not preemptible
Adds a build failure if the main thread priority is not preemptible
and USB CDC ACM serial recovery is used, this is because if this is
the case, USB events will never be able to be processed and serial
recovery cannot ever enumerate

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-11-07 07:44:00 +00:00
Jamie McCrae 822b6cb710 boot: zephyr: serial_adapter: Fail if USB CDC enabled with console
This prevents MCUboot from successfully building if console and
serial recovery (USB CDC) are both enabled and they both point to
the same device

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-11-07 07:44:00 +00:00
Jamie McCrae 4a1effbc30 zephyr: Remove deprecated ZEPHYR_TRY_MASS_ERASE option
This option was deprecated 8 months ago, remove it.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-11-01 15:55:46 +00:00
David Brown 301d565560 readme: update for next dev release
Bump version described in README to a development version of the next release.

Signed-off-by: David Brown <david.brown@linaro.org>
2023-11-01 09:51:15 -06:00
David Brown e0bdcdecec Update version files for 2.0.0
Update documentation and version tags for final 2.0.0 release.

Signed-off-by: David Brown <david.brown@linaro.org>
2023-10-23 17:36:54 -06:00
Almir Okato d3819c90b4 espressif: allow the use of a different toolchain for building
TOOLCHAIN_BIN_DIR can be defined for a different toolchain use.

Signed-off-by: Almir Okato <almir.okato@espressif.com>
2023-10-17 04:41:37 -03:00
Andrej Butok 9b92ee918f boot: zephyr: add support for LPC55Sxx
Add configuration for LPC55Sxx to MCUBoot.
It supports the upgrade only mode.

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
2023-10-10 11:10:18 +01:00
Andrej Butok 13767d0b72 bootutil: Disable MCUBOOT_BOOT_MAX_ALIGN assert for non-swap modes
- Assert should be checked only for SWAP update modes.
- Allow platforms with page size >32 Bytes (e.g. LPC) to use
  MCUBoot, at least for non-SWAP update modes.

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
2023-10-05 10:25:10 +01:00
David Brown 4fe28b3cf6 Update zephyr version files for 2.0.0-rc1
Update for the rc1 release.

Signed-off-by: David Brown <david.brown@linaro.org>
2023-09-29 08:19:05 -06:00
Jamie McCrae 2929a975c7 bootutil: Show error if flash area open fails
Shows an error if a particular flash area fails to open

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-09-28 15:10:46 +01: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 50f8b5f742 bootutil: Add shared data support for XIP with revert mode
Adds support for sharing the direct-XIP MCUboot mode with revert
to applications using shared data

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-09-27 18:11:56 +02:00
Jamie McCrae 8d0b35a1e9 bootutil: Add mode for XIP with revert
Adds a new define if bootloader in built in direct-XIP with revert
mode

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-09-27 18:11:56 +02: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
Roland Mikhel 9bef51ce4a bootutil/crypto: Do not include import key with PSA
This fixes a build error when PSA Crypto API is being used
as it has no need for bootutil_import_key but it's included
currently since it's allowed to have both Mbed TLS and PSA defined.

Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: If38d3011fc4fa2d317f8be65df9e231d7d57dcbf
2023-09-26 07:55:30 +02:00
Almir Okato db2024eb20 espressif: update secure boot and flash encryption
Adjust secure boot and flash encryption after IDF v5.x updates.
It also allows to enable secure boot on ESP32-C2.

Signed-off-by: Almir Okato <almir.okato@espressif.com>
2023-09-20 09:46:27 -03:00
Jamie McCrae c7aa2c029e boot_serial: Fix issues with single slot mode/encrypted images
Fixes 2 issues, one whereby multiple slots were checked despite
operating in single slot mode, and another whereby decrypted
images would not appear on serial recovery image listing, due
to assuming that the images were still encrypted.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-09-20 10:55:24 +01:00
Jamie McCrae 6ba46c0b82 boot_serial: Fix issue with queued commands
Fixes an issue whereby multiple commands are received and some
are still being processed. This generally arises when a response
takes a long time (e.g. when image decryption is required),
duplicate commands will now send multiple responses but avoids
the bug of future commands being sent to which previous responses
are received.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-09-20 09:58:09 +02:00
Roland Mikhel 03c9ad0781 bootutil: Replace hash with SHA384 when P384 is used
Currently all the hashing functionality is done with SHA256
but if we would like to use ECDSA-P384 that requires SHA384
as the hashing algorithm, but MCUboot is using SHA256
for image hashing and public key hashing. This commit modifies
the hashing operations to use SHA384 thus SHA256 can be omitted
which is beneficial from a code size standpoint.

Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: I59230f76f88e0b42ad6383b2c9b71b73f33d7dd7
2023-09-12 16:29:11 +02:00
Roland Mikhel 274547ce06 bootutil: PSA Crypto ECDSA enablement
This commit enables ECDSA signature verification using
PSA Crypto API.

Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: I51c7aadba03348f335e89d9252e70c09f8787f30
2023-09-12 16:29:11 +02:00
Jamie McCrae 8f8fbf9956 zephyr: Fall back to minimal C library
Changes back to the minimal C library instead of picolibc to
reduce flash usage

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-09-12 14:16:03 +01:00
Jamie McCrae 5c5222f884 boot_serial: Fix include
Fixes an include which is needed for multiple options by just
always including it, and fixing the path so it can be included.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-09-12 12:56:39 +02:00
Sylvio Alves b847a33ba2 espressif: use minimal libc as default for ESP32 boards
Make MINIMAL_LIBC as default for MCUboot app build instead
of picolibc. Footprint is lower and no need to
MULTLTHREADING enabled for SoC build.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2023-09-08 11:01:07 -03:00
Benjamin Bigler 480b97f2e2 boot_serial: Fix missing point if using snprintf
Adds missing point in version when snprintf is used

Signed-off-by: Benjamin Bigler <benjamin.bigler@securiton.ch>
2023-09-08 07:40:03 +01:00
Piotr Dymacz 3790f5f055 boot: zephyr: use indication LED also in timeout based recovery
This adds support for indication LED option (MCUBOOT_INDICATION_LED) in
the timeout based recovery. Configured LED will be enabled when entering
the recovery and disabled after selected timeout (if no mcumgr command
was received).

Signed-off-by: Piotr Dymacz <pepe2k@gmail.com>
2023-09-07 11:37:34 +01:00
Dominik Ermel 0035c33b44 zephyr: Provide third image cases for direct image upload
The commit adds missing support for direct upload of third
image slots.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-09-06 17:49:33 +02:00
Lucas Tamborrino 9bf7ce8c5f zephyr: Fix build for non-arm archs
Guards the inclusion of cmsis_core header for
ARM targets only.

Fixes #1799

Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
2023-09-06 10:07:09 +01:00
Jamie McCrae e188dbb0e1 zephyr: Fix boot serial extensions
Fixes building the bootloader with serial recovery mode and boot
serial extensions enabled due to changes in Zephyr's MCUmgr file
and naming changes.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-08-29 16:01:02 +02:00
Gerard Marull-Paretas 11ecbf639d zephyr: use cmsis_core.h header
CMSIS glue code is now provided by the CMSIS Zephyr module in
<cmsis_core.h>. Header is generic for M/A/R.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-08-25 11:30:17 +02: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 4ff95da6f6 bootuil: Replace flash_area_id_to_image with flash_area_to_image
Move flash_area_get_id inside the function and rename it.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-08-22 14:24:03 +02:00
Dominik Ermel 2c61caf606 bootutil: Move flash_area_id_to_image under ifdef
The commit moves the flash_area_id_to_image to section compiled
only when not in DirectXIP mode, to prevent warnings about unused
static functions.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-08-22 10:52:52 +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 2a874b6e9c zephyr: Do not build in debug mode
Builds in the default zephyr mode (optimised for size) which
saves about 6KiB of flash on a default nrf52840dk build.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-08-18 09:05:13 +01:00
Jamie McCrae 258a6c7dc2 bootutil: Fix support for more than 2 flash areas
Fixes a function which converts from an ID to an image number
to support more than 2 images.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-08-17 16:00:12 +02:00
Almir Okato 4a051181c4 espressif: esp32xx: adjust memory map on linker script
Reorganize memory mapping and document the address ranges that
the OS must avoid overlapping.

Signed-off-by: Almir Okato <almir.okato@espressif.com>
2023-08-10 10:59:33 -07:00
Almir Okato 68a2980f97 espressif: esp32c2: remove unsupported configs
Remove unsupported USB JTAG configuration
Remove unsupported Secure Boot V2 configuration

Signed-off-by: Almir Okato <almir.okato@espressif.com>
2023-08-10 10:59:33 -07:00
Almir Okato 2f17549ef3 espressif: esp32c6 esp32h2: fix custom uart and secure boot build
Fix missing header on console_uart_custom.c
Update secure_boot.c includes removing soc ifdefs

Signed-off-by: Almir Okato <almir.okato@espressif.com>
2023-08-10 10:59:33 -07: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 25d2f2cfe0 zephyr: encryption: Improve Kconfig and key generation
Improves the Kconfig layout for encrypted image support and allows
using key files instead of just using a pre-defined, insecure dummy
key.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-08-09 07:45:22 +01:00
Michael Grand 99613c672f bootutil: fix downgrade prevention
Downgrade prevention check moved to secure both TEST
and PERMANENT upgrade modes. Downgrade can still be
performed during REVERT.

Signed-off-by: Michael Grand <m.grand@trustngo.tech>
2023-08-08 09:02:39 +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 ea88860904 bootutil: Add bootloader info TLV entries
Adds TLV defines for use with the bootloader shared data
feature.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-08-08 08:02:25 +01:00
Jamie McCrae 3016d00cd7 bootutil: Add active slot number and max app size to shared data
This allows the currently executing slot number to be checked by
the external function, which can be used by XIP images to know
which slot is currently being executed from to allow for correct
uploading/positioning of firmware files, and also provides the
maximum size of an upgrade that can be loaded so that applications
can reject images that are too large.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-08-08 08:02:25 +01:00
Dominik Ermel 0540d0fb3f bootutil: Fix for flash_area_id_to_image
The function was incorrectly identifying partition of secondary slot
of image 0 as belonging to image 1, at the same time failing to
identify partition of primary slot of image 1.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-08-07 14:35:39 +02:00
Dominik Ermel f17b005ca1 bootutil: Fix boot_set_next passing wrong image number
The commit fixes boot_set_next always passing image 0 to
boot_write_swap_info, instead of the proper image number.
This has been affecting applications that tried to call boot_set_next
in multi-image MCUboot configuration using scratch-swap algorithm.

Fixes #1762

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-08-04 16:17:38 +02:00
Michal Lenc aa7e2b1faa nuttx: switch to flash_area_get_sector
Function flash_area_sector_from_off is replaced with newly used
flash_area_get_sector to cope with calls in bootutil_misc.c file.

This is required for CONFIG_MCUBOOT_SWAP_USING_MOVE to work correctly.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2023-08-02 11:28:34 +02:00
Jamie McCrae 61898dad92 boot: boot_serial: Add updated SMP header
Adds missing fields which were wrongly treated as part of the
operation value, which they were not, and adds a big/little
endian check.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-31 08:32:50 +01:00
Marcin Niestroj 36ae4fdabf boot: zephyr: split esp32 to esp32_devkitc_{wroom,wrover}
This is a follow-up on upstream Zephyr split from `esp32` to distinct
esp32_devkitc_wroom and esp32_devkitc_wrover (see [1] and [2]).

[1] https://github.com/zephyrproject-rtos/zephyr/pull/58454
[2] 3776402f40

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2023-07-29 09:54:47 -03:00
Jamie McCrae 2c86755278 boot: zephyr: Fix indication LED not selecting GPIO
Makes indication LED Kconfig select GPIO so that it can work.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-27 16:35:01 +01:00
Michal Gorecki 5404130e20 boot_serial: Fix build for 64-bit architectures
Typecasting pointer variables to uint32_t
instead of uintptr_t was causing build error
on 64-bit architecture.

This is useful, because I am currently working
on implementing support for 64-bit native target
in Apache Mynewt. There is unit test for boot_serial
and it cannot be compiled without this changes.

Signed-off-by: Michal Gorecki <michal.gorecki@codecoup.pl>
2023-07-26 13:16:21 +01:00
Jamie McCrae 76d19b3b88 boot: bootutil: Fix missing packed attributes, add hash size define
Fixes an issue with missing packed attributes on image.h's
structures which would lead to faults on some devices e.g. ARM
Cortex M0, and adds a define for the SHA256 hash size.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-25 09:10:14 +01:00
Almir Okato c3fe516f44 espressif: ESP32-C2 initial support
Signed-off-by: Almir Okato <almir.okato@espressif.com>
2023-07-24 22:51:11 -03:00
Almir Okato d43cf8956d espressif: ESP32-H2 initial support
Signed-off-by: Almir Okato <almir.okato@espressif.com>
2023-07-24 22:51:11 -03:00
Almir Okato ecaf8bd521 espressif: ESP32-C6 initial support
Signed-off-by: Almir Okato <almir.okato@espressif.com>
2023-07-24 22:51:11 -03:00
Almir Okato 3ccc6a6a59 espressif: add flash parameters to esptool command for building
Signed-off-by: Almir Okato <almir.okato@espressif.com>
2023-07-24 22:51:11 -03:00
Almir Okato 54ef484afa espressif: remove IDF git submodule and add its reference by param
Remove the ESP-IDF from git submodules to avoid potential
duplicated repo clones on the user system. IDF HAL code is still
a dependency for Espressif port, therefore now the HAL code
reference needs to be passed by parameter when building.

The Espressif port was also updated to work with last v5.1 IDF
code.

Signed-off-by: Almir Okato <almir.okato@espressif.com>
2023-07-24 10:03:18 -03:00
Almir Okato 26ed3f448f espressif: preferred use of a installed esptool
Signed-off-by: Almir Okato <almir.okato@espressif.com>
2023-07-24 10:03:18 -03:00
Jamie McCrae 9fad4c1f16 boot: boot_serial: Fix wrong cbor type for confirm
Fixes the wrong variable type being used for the confirm element.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-20 17:00:09 +01:00
Jerzy Kasenberg 52cac94c0e mynewt: Make sysinit() call configurable
In same cases (loging, hash, crypto) main function called
newt tool generated sysinit() function to create
uart device and crypto.

Now user can specify that sysinit should be called for
other cases if needed. This can be useful if some other
package should be included in the build and it has
package initialization function.

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
2023-07-17 19:39:05 -03:00
Jerzy Kasenberg 8581168331 boot: mynewt: Respect minimum write size
For MCUs with restriction on minimum write size (STM32H7)
unaligned writes resulted in flash write errors preventing
any sort of update.

Now MCUBOOT_BOOT_MAX_ALIGN can be set accordingly to value
that flash driver uses.
For alignment <= 8 default value provided by mcuboot config
is still used.

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
2023-07-17 19:38:11 -03:00
Jerzy Kasenberg 7abfe4fa51 boot: mynewt: Add build version comparison
For downgrade prevention it's possible to use build number
for grater control.
So far only Zephyr has this option in Kconfig now
option is also available in mynewt.

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
2023-07-17 19:37:22 -03:00
Jerzy Kasenberg e486b533c1 boot: mynewt: add support for the mcumgr echo command in serial boot mode
This allows user to enable echo for mcumgr command in serial boot.
Code was enabled in zephyr only so far.
Now mynewt build can also have this feature if enabled.

No code changes just option in mynewt build to enable existing
mcuboot feature.

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
2023-07-17 19:36:07 -03:00
Michal Lenc daabd6a8db nuttx: add support for swap without scratch area
Definition of MCUBOOT_SWAP_USING_MOVE in case swap without scratch area
is configured in NuttX was missing from mcuboot_config.h file.

Also necessary function flash_area_sector_from_off() is defined and
declared in order to support swap without scratch.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2023-07-08 08:02:31 -03:00
Piotr Dymacz 6a8746d7ac boot_serial: fix image number handle in image upload request
According to the SMP protocol documentation [1], 'image number' value
in 'image upload request' is optional and can be included only in packet
with 'off' (data offset) set to '0' (first packet in upload request).

In one of recent changes (commit 'cb07e888691d'), initialization of the
'img_num' variable was removed which, in extreme case (no image number
provided in upload request), results in use of its uninitialized value
in flash_area_open() call which then might lead to request abort.

This fixes above regression and also makes MCUboot implementation of the
'image upload request' aligned with Zephyr documentation of the protocol
by considering image number only from first (off == 0) 'image upload
request' SMP packet. In addition, 'image number' value is set to '0' if
the request doesn't provide this field.

[1] docs.zephyrproject.org/latest/services/device_mgmt/smp_groups/smp_group_1.html

Fixes: cb07e88869 ("boot_serial: Replace cbor auto-generated code with zcbor functions")
Signed-off-by: Piotr Dymacz <pepe2k@gmail.com>
2023-07-05 16:59:19 -06:00
Piotr Dymacz f2cb55027c boot_serial: fix misuse of 'matched' param from zcbor_map_decode_bulk()
The 'matched' param in zcbor_map_decode_bulk() function is 'pointer to
the counter of matched keys', not length of payload buffer.

Fixes: fac2cabe98 ("boot_serial: Add image state set/get")
Signed-off-by: Piotr Dymacz <pepe2k@gmail.com>
2023-07-05 16:58:09 -06:00
Jamie McCrae 82feb9a4c5 boot_serial: Fix showing images that are not valid
Fixes an issue which was introduced in commit
fac2cabe98 which would show all
images, including those with invalid headers in the output of
images being listed.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-07-05 16:57:12 -06:00
Roland Mikhel c5c2b4d7a7 bootutil: Revert changes to cap values
This commit reverts the changes to the cap values made in 206b914.

Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: Ie47c3f253409932b960f4fc12e3b722b000b3093
2023-06-30 18:02:20 +02:00
Roland Mikhel 82670c71f6 bootutil: Add capability to test hw-rollback-prot
Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: I3dee0baf27b8cae78b87135ea7447556b06fdefd
2023-06-27 14:42:34 +02:00
Roland Mikhel 61962b94f3 bootutil: fix FIH int conversion for security_cnt
Currently there's a compile error when building MCUboot
with HW_ROLLBACK_PROT due to a comparison
when decoding the security_cnt fih_int value. In the security_cnt.h
it is stated that this value must be between 0 and UINT32_MAX
so this cast would not cause any undefined behaviour.

Signed-off-by: Roland Mikhel <roland.mikhel@arm.com>
Change-Id: Iee158a31955ff43b73e67a0c08e7a086077b9eb5
2023-06-27 14:42:34 +02:00
Dominik Ermel e6e4801ce2 zephyr/boot_serial_extension: Fix zcbor header path
Include directory path is now set by CMake.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-06-21 13:48:05 +02:00
Antonio de Angelis a5db515161 bootutil/crypto: SHA256 abort function return state
Similarly to what has been done for the init function, also
the abort function should return a state in case the caller
needs to implement some error recovery procedure, or even
just for debugging reasons.

Signed-off-by: Antonio de Angelis <Antonio.deAngelis@arm.com>
Change-Id: I5b8bc8fc2da57cfbc6ddea3f7e95ed7a7ae8e5a9
2023-06-09 14:35:28 +02:00
Antonio de Angelis 0361ad3d42 bootutil/crypto: SHA256 init functions should return a status
SHA-256 init functions should return the status of the init
instead of being void. This would allow the callers to implement
proper error recovery, otherwise on error the SHA-256 operation
will enter an undefined behaviour.

Signed-off-by: Antonio de Angelis <Antonio.deAngelis@arm.com>
Change-Id: I162ceb8e6dc90dc3c6b83c8a85fbd17b41c0b5d6
2023-06-09 14:35:28 +02:00
Antonio de Angelis f92a2193f4 bootutil/crypto: Fix minor typos in comments for RSA modules
A couple of typos in comments for the newly added RSA modules
need to be assessed.

Signed-off-by: Antonio de Angelis <Antonio.deAngelis@arm.com>
Change-Id: Ia06529adb81215fad796895d7b412b35717b6d65
2023-06-09 14:35:28 +02:00
Antonio de Angelis 48547008dd bootutil: Add image_index to additional logging messages
image_index should be added to additional prints as noted
during the original PR review.

Signed-off-by: Antonio de Angelis <Antonio.deAngelis@arm.com>
Change-Id: I2e456f05ee4ccb372aeab564f7f388bc2fd564e5
2023-06-09 14:35:28 +02:00