Initial commit

Initial commit.
This commit is contained in:
kntran1
2026-03-23 14:40:39 -05:00
parent e84b2b4166
commit 4e2a5258a5
872 changed files with 165227 additions and 0 deletions

View File

@@ -0,0 +1,635 @@
# CMakeLists.txt for building mcuboot as a Zephyr project
#
# Copyright (c) 2017 Open Source Foundries Limited
# Copyright (c) 2023 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.13.1)
# find_package(Zephyr) in order to load application boilerplate:
# http://docs.zephyrproject.org/application/application.html
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(NONE)
# Path to "boot" subdirectory of repository root.
get_filename_component(BOOT_DIR ${APPLICATION_SOURCE_DIR} DIRECTORY)
# Path to top-level repository root directory.
get_filename_component(MCUBOOT_DIR ${BOOT_DIR} DIRECTORY)
# Path to tinycrypt library source subdirectory of MCUBOOT_DIR.
set(TINYCRYPT_DIR "${MCUBOOT_DIR}/ext/tinycrypt/lib")
assert_exists(TINYCRYPT_DIR)
set(TINYCRYPT_SHA512_DIR "${MCUBOOT_DIR}/ext/tinycrypt-sha512/lib")
assert_exists(TINYCRYPT_SHA512_DIR)
# Path to crypto-fiat
set(FIAT_DIR "${MCUBOOT_DIR}/ext/fiat")
assert_exists(FIAT_DIR)
# Path to mbed-tls' asn1 parser library.
set(MBEDTLS_ASN1_DIR "${MCUBOOT_DIR}/ext/mbedtls-asn1")
assert_exists(MBEDTLS_ASN1_DIR)
set(MCUBOOT_NRF_EXT_DIR "${MCUBOOT_DIR}/ext/nrf")
if(CONFIG_BOOT_USE_NRF_CC310_BL)
if(NOT EXISTS ${ZEPHYR_NRFXLIB_MODULE_DIR})
message(FATAL_ERROR "
------------------------------------------------------------------------
No such file or directory: ${ZEPHYR_NRFXLIB_MODULE_DIR}
The current configuration enables nRF CC310 crypto accelerator hardware
with the `CONFIG_BOOT_USE_NRF_CC310_BL` option. Please follow
`ext/nrf/README.md` guide to fix your setup or use tinycrypt instead of
the HW accelerator.
To use the tinycrypt set `CONFIG_BOOT_ECDSA_TINYCRYPT` to y.
------------------------------------------------------------------------")
endif()
endif()
zephyr_library_include_directories(
include
targets
)
if(EXISTS targets/${BOARD}.h)
zephyr_library_compile_definitions(MCUBOOT_TARGET_CONFIG="${BOARD}.h")
endif()
if(DEFINED CONFIG_MBEDTLS)
zephyr_library_include_directories(
${ZEPHYR_MBEDTLS_MODULE_DIR}/include
)
endif()
# Zephyr port-specific sources.
zephyr_library_sources(
main.c
io.c
flash_map_extended.c
os.c
keys.c
)
if(DEFINED CONFIG_ENABLE_MGMT_PERUSER)
zephyr_library_sources(
boot_serial_extensions.c
)
zephyr_linker_sources_ifdef(
CONFIG_ENABLE_MGMT_PERUSER
SECTIONS include/boot_serial/boot_serial.ld
)
if(DEFINED CONFIG_BOOT_MGMT_CUSTOM_STORAGE_ERASE OR DEFINED CONFIG_BOOT_MGMT_CUSTOM_IMG_LIST)
zephyr_library_sources(
boot_serial_extension_zephyr_basic.c
)
endif()
endif()
if(NOT DEFINED CONFIG_FLASH_PAGE_LAYOUT)
zephyr_library_sources(
flash_map_legacy.c
)
endif()
if(DEFINED CONFIG_BOOT_SHARE_BACKEND_RETENTION)
zephyr_library_sources(
shared_data.c
)
endif()
# Generic bootutil sources and includes.
zephyr_library_include_directories(${BOOT_DIR}/bootutil/include)
zephyr_library_sources(
${BOOT_DIR}/bootutil/src/image_validate.c
${BOOT_DIR}/bootutil/src/tlv.c
${BOOT_DIR}/bootutil/src/encrypted.c
${BOOT_DIR}/bootutil/src/image_rsa.c
${BOOT_DIR}/bootutil/src/image_ecdsa.c
${BOOT_DIR}/bootutil/src/image_ed25519.c
${BOOT_DIR}/bootutil/src/bootutil_misc.c
${BOOT_DIR}/bootutil/src/fault_injection_hardening.c
)
if(DEFINED CONFIG_BOOT_ENCRYPT_X25519 AND DEFINED CONFIG_BOOT_ED25519_PSA)
zephyr_library_sources(${BOOT_DIR}/bootutil/src/encrypted_psa.c)
endif()
if(DEFINED CONFIG_MEASURED_BOOT OR DEFINED CONFIG_BOOT_SHARE_DATA)
zephyr_library_sources(
${BOOT_DIR}/bootutil/src/boot_record.c
)
# Set a define for this file which will allow inclusion of the Zephyr version
# include file
set_source_files_properties(
${BOOT_DIR}/bootutil/src/boot_record.c
PROPERTIES COMPILE_FLAGS -DZEPHYR_VER_INCLUDE=1
)
endif()
# library which might be common source code for MCUBoot and an application
zephyr_link_libraries(MCUBOOT_BOOTUTIL)
if(CONFIG_BOOT_FIH_PROFILE_HIGH)
zephyr_library_sources(
${BOOT_DIR}/bootutil/src/fault_injection_hardening_delay_rng_mbedtls.c
)
endif()
if(CONFIG_SINGLE_APPLICATION_SLOT)
zephyr_library_sources(
${BOOT_DIR}/zephyr/single_loader.c
)
zephyr_library_include_directories(${BOOT_DIR}/bootutil/src)
elseif(CONFIG_BOOT_FIRMWARE_LOADER)
zephyr_library_sources(
${BOOT_DIR}/zephyr/firmware_loader.c
)
zephyr_library_include_directories(${BOOT_DIR}/bootutil/src)
else()
if(NOT CONFIG_MCUBOOT_APPLICATION_IMAGE_NUMBER EQUAL "-1")
# Sysbuild
zephyr_library_sources(
${BOOT_DIR}/bootutil/src/loader.c
)
else()
# Legacy child/parent image
zephyr_library_sources(
${BOOT_DIR}/bootutil/src/loader_legacy_child_parent.c
)
endif()
zephyr_library_sources(
${BOOT_DIR}/bootutil/src/swap_misc.c
${BOOT_DIR}/bootutil/src/swap_scratch.c
${BOOT_DIR}/bootutil/src/swap_move.c
${BOOT_DIR}/bootutil/src/caps.c
)
if(NOT CONFIG_MCUBOOT_MCUBOOT_IMAGE_NUMBER EQUAL "-1" AND NOT CONFIG_BOOT_UPGRADE_ONLY)
zephyr_library_sources(
${BOOT_DIR}/bootutil/src/swap_nsib.c
)
endif()
endif()
if(CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256 OR CONFIG_BOOT_ENCRYPT_EC256)
zephyr_library_include_directories(
${MBEDTLS_ASN1_DIR}/include
)
zephyr_library_sources(
# Additionally pull in just the ASN.1 parser from mbedTLS.
${MBEDTLS_ASN1_DIR}/src/asn1parse.c
${MBEDTLS_ASN1_DIR}/src/platform_util.c
)
if(CONFIG_BOOT_USE_TINYCRYPT)
# When using ECDSA signatures, pull in our copy of the tinycrypt library.
zephyr_library_include_directories(
${BOOT_DIR}/zephyr/include
${TINYCRYPT_DIR}/include
)
zephyr_include_directories(${TINYCRYPT_DIR}/include)
zephyr_library_sources(
${TINYCRYPT_DIR}/source/ecc.c
${TINYCRYPT_DIR}/source/ecc_dsa.c
${TINYCRYPT_DIR}/source/sha256.c
${TINYCRYPT_DIR}/source/utils.c
)
elseif(CONFIG_BOOT_USE_NRF_CC310_BL)
zephyr_library_sources(${MCUBOOT_NRF_EXT_DIR}/cc310_glue.c)
zephyr_library_include_directories(${MCUBOOT_NRF_EXT_DIR})
zephyr_link_libraries(nrfxlib_crypto)
elseif(CONFIG_BOOT_USE_NRF_EXTERNAL_CRYPTO)
zephyr_include_directories(${BL_CRYPTO_DIR}/../include)
endif()
# Since here we are not using Zephyr's mbedTLS but rather our own, we need
# to set MBEDTLS_CONFIG_FILE ourselves. When using Zephyr's copy, this
# variable is set by its Kconfig in the Zephyr codebase.
zephyr_library_compile_definitions(
MBEDTLS_CONFIG_FILE="${CMAKE_CURRENT_LIST_DIR}/include/mcuboot-mbedtls-cfg.h"
)
elseif(CONFIG_BOOT_SIGNATURE_TYPE_NONE)
zephyr_library_include_directories(
${BOOT_DIR}/zephyr/include
${TINYCRYPT_DIR}/include
)
zephyr_library_sources(
${TINYCRYPT_DIR}/source/sha256.c
${TINYCRYPT_DIR}/source/utils.c
)
elseif(CONFIG_BOOT_SIGNATURE_TYPE_RSA)
# Use mbedTLS provided by Zephyr for RSA signatures. (Its config file
# is set using Kconfig.)
zephyr_include_directories(include)
if(CONFIG_BOOT_ENCRYPT_RSA)
set_source_files_properties(
${BOOT_DIR}/bootutil/src/encrypted.c
PROPERTIES
INCLUDE_DIRECTORIES ${ZEPHYR_MBEDTLS_MODULE_DIR}/library
)
endif()
elseif(CONFIG_BOOT_SIGNATURE_TYPE_ED25519 OR CONFIG_BOOT_ENCRYPT_X25519)
if(CONFIG_BOOT_USE_TINYCRYPT)
zephyr_library_include_directories(
${MBEDTLS_ASN1_DIR}/include
${BOOT_DIR}/zephyr/include
${TINYCRYPT_DIR}/include
${TINYCRYPT_SHA512_DIR}/include
)
zephyr_library_sources(
${TINYCRYPT_DIR}/source/sha256.c
${TINYCRYPT_DIR}/source/utils.c
${TINYCRYPT_SHA512_DIR}/source/sha512.c
# Additionally pull in just the ASN.1 parser from mbedTLS.
${MBEDTLS_ASN1_DIR}/src/asn1parse.c
${MBEDTLS_ASN1_DIR}/src/platform_util.c
)
zephyr_library_compile_definitions(
MBEDTLS_CONFIG_FILE="${CMAKE_CURRENT_LIST_DIR}/include/mcuboot-mbedtls-cfg.h"
)
else()
zephyr_include_directories(include)
endif()
zephyr_library_include_directories(
${BOOT_DIR}/zephyr/include
${FIAT_DIR}/include/
)
if(NOT CONFIG_BOOT_ED25519_PSA)
zephyr_library_sources(
${FIAT_DIR}/src/curve25519.c
)
else()
zephyr_library_sources(
${MBEDTLS_ASN1_DIR}/src/asn1parse.c
${BOOT_DIR}/bootutil/src/ed25519_psa.c
)
endif()
endif()
if(NOT CONFIG_BOOT_ED25519_PSA)
if(CONFIG_BOOT_ENCRYPT_EC256 OR CONFIG_BOOT_ENCRYPT_X25519)
zephyr_library_sources(
${TINYCRYPT_DIR}/source/aes_encrypt.c
${TINYCRYPT_DIR}/source/aes_decrypt.c
${TINYCRYPT_DIR}/source/ctr_mode.c
${TINYCRYPT_DIR}/source/hmac.c
${TINYCRYPT_DIR}/source/ecc_dh.c
)
endif()
endif()
if(CONFIG_BOOT_ENCRYPT_EC256)
zephyr_library_sources(
${TINYCRYPT_DIR}/source/ecc_dh.c
)
endif()
if(CONFIG_BOOT_DECOMPRESSION)
zephyr_library_sources(
decompression.c
)
endif()
if(CONFIG_MCUBOOT_SERIAL)
zephyr_sources(${BOOT_DIR}/zephyr/serial_adapter.c)
zephyr_sources(${BOOT_DIR}/boot_serial/src/boot_serial.c)
zephyr_sources(${BOOT_DIR}/boot_serial/src/zcbor_bulk.c)
zephyr_include_directories(${BOOT_DIR}/bootutil/include)
zephyr_include_directories(${BOOT_DIR}/boot_serial/include)
zephyr_include_directories(include)
zephyr_include_directories_ifdef(
CONFIG_BOOT_ERASE_PROGRESSIVELY
${BOOT_DIR}/bootutil/src
)
if(CONFIG_BOOT_ENCRYPT_IMAGE)
zephyr_library_sources(
${BOOT_DIR}/boot_serial/src/boot_serial_encryption.c
)
endif()
endif()
if(NOT CONFIG_BOOT_SIGNATURE_USING_KMU AND NOT CONFIG_BOOT_SIGNATURE_KEY_FILE STREQUAL "")
# CONF_FILE points to the KConfig configuration files of the bootloader.
foreach (filepath ${CONF_FILE})
file(READ ${filepath} temp_text)
string(FIND "${temp_text}" ${CONFIG_BOOT_SIGNATURE_KEY_FILE} match)
if (${match} GREATER_EQUAL 0)
if (NOT DEFINED CONF_DIR)
get_filename_component(CONF_DIR ${filepath} DIRECTORY)
else()
message(FATAL_ERROR "Signature key file defined in multiple conf files")
endif()
endif()
endforeach()
if(IS_ABSOLUTE ${CONFIG_BOOT_SIGNATURE_KEY_FILE})
set(KEY_FILE ${CONFIG_BOOT_SIGNATURE_KEY_FILE})
elseif((DEFINED CONF_DIR) AND
(EXISTS ${CONF_DIR}/${CONFIG_BOOT_SIGNATURE_KEY_FILE}))
set(KEY_FILE ${CONF_DIR}/${CONFIG_BOOT_SIGNATURE_KEY_FILE})
else()
set(KEY_FILE ${MCUBOOT_DIR}/${CONFIG_BOOT_SIGNATURE_KEY_FILE})
endif()
message("MCUBoot bootloader key file: ${KEY_FILE}")
set_property(
GLOBAL
PROPERTY
KEY_FILE
${KEY_FILE}
)
set(GENERATED_PUBKEY ${ZEPHYR_BINARY_DIR}/autogen-pubkey.c)
add_custom_command(
OUTPUT ${GENERATED_PUBKEY}
COMMAND
${PYTHON_EXECUTABLE}
${MCUBOOT_DIR}/scripts/imgtool.py
getpub
-k
${KEY_FILE}
> ${GENERATED_PUBKEY}
DEPENDS ${KEY_FILE}
)
zephyr_library_sources(${GENERATED_PUBKEY})
endif()
if(CONFIG_BOOT_ENCRYPTION_KEY_FILE AND NOT CONFIG_BOOT_ENCRYPTION_KEY_FILE STREQUAL "")
# CONF_FILE points to the KConfig configuration files of the bootloader.
unset(CONF_DIR)
foreach(filepath ${CONF_FILE})
file(READ ${filepath} temp_text)
string(FIND "${temp_text}" ${CONFIG_BOOT_ENCRYPTION_KEY_FILE} match)
if(${match} GREATER_EQUAL 0)
if(NOT DEFINED CONF_DIR)
get_filename_component(CONF_DIR ${filepath} DIRECTORY)
else()
message(FATAL_ERROR "Encryption key file defined in multiple conf files")
endif()
endif()
endforeach()
if(IS_ABSOLUTE ${CONFIG_BOOT_ENCRYPTION_KEY_FILE})
set(KEY_FILE ${CONFIG_BOOT_ENCRYPTION_KEY_FILE})
elseif((DEFINED CONF_DIR) AND
(EXISTS ${CONF_DIR}/${CONFIG_BOOT_ENCRYPTION_KEY_FILE}))
set(KEY_FILE ${CONF_DIR}/${CONFIG_BOOT_ENCRYPTION_KEY_FILE})
else()
set(KEY_FILE ${MCUBOOT_DIR}/${CONFIG_BOOT_ENCRYPTION_KEY_FILE})
endif()
message("MCUBoot bootloader encryption key file: ${KEY_FILE}")
set(GENERATED_ENCKEY ${ZEPHYR_BINARY_DIR}/autogen-enckey.c)
add_custom_command(
OUTPUT ${GENERATED_ENCKEY}
COMMAND
${PYTHON_EXECUTABLE}
${MCUBOOT_DIR}/scripts/imgtool.py
getpriv
-k
${KEY_FILE}
> ${GENERATED_ENCKEY}
DEPENDS ${KEY_FILE}
)
zephyr_library_sources(${GENERATED_ENCKEY})
endif()
if(CONFIG_MCUBOOT_CLEANUP_ARM_CORE)
zephyr_library_sources(
${BOOT_DIR}/zephyr/arm_cleanup.c
)
endif()
if(CONFIG_MCUBOOT_BOOT_BANNER)
# Replace Zephyr's boot banner with the MCUboot one
zephyr_sources(kernel/banner.c)
endif()
function(align_up num align result)
math(EXPR out "(((${num}) + ((${align}) - 1)) & ~((${align}) - 1))")
set(${result} "${out}" PARENT_SCOPE)
endfunction()
function(dt_get_parent node)
string(FIND "${${node}}" "/" pos REVERSE)
if(pos EQUAL -1)
message(ERROR "Unable to get parent of node: ${${node}}")
endif()
string(SUBSTRING "${${node}}" 0 ${pos} ${node})
set(${node} "${${node}}" PARENT_SCOPE)
endfunction()
if(CONFIG_BOOT_MAX_IMG_SECTORS_AUTO)
dt_nodelabel(slot0_flash NODELABEL "slot0_partition")
dt_prop(slot0_size PATH "${slot0_flash}" PROPERTY "reg" INDEX 1)
dt_get_parent(slot0_flash)
dt_get_parent(slot0_flash)
dt_prop(erase_size_slot0 PATH "${slot0_flash}" PROPERTY "erase-block-size")
if(NOT DEFINED slot0_size)
message(WARNING "Unable to determine size of slot0 partition, cannot calculate minimum sector usage")
elseif(NOT DEFINED erase_size_slot0)
message(WARNING "Unable to determine erase size of slot0 partition, cannot calculate minimum sector usage")
else()
math(EXPR slot_min_sectors "${slot0_size} / ${erase_size_slot0}")
endif()
if(NOT CONFIG_SINGLE_APPLICATION_SLOT)
dt_nodelabel(slot1_flash NODELABEL "slot1_partition")
dt_prop(slot1_size PATH "${slot1_flash}" PROPERTY "reg" INDEX 1)
dt_get_parent(slot1_flash)
dt_get_parent(slot1_flash)
dt_prop(erase_size_slot1 PATH "${slot1_flash}" PROPERTY "erase-block-size")
if(NOT DEFINED slot1_size)
message(WARNING "Unable to determine size of slot1 partition, cannot calculate minimum sector usage")
elseif(NOT DEFINED erase_size_slot1)
message(WARNING "Unable to determine erase size of slot1 partition, cannot calculate minimum sector usage")
else()
math(EXPR slot1_min_sectors "${slot1_size} / ${erase_size_slot1}")
if("${slot1_min_sectors}" GREATER "${slot_min_sectors}")
set(slot_min_sectors ${slot1_min_sectors})
endif()
endif()
endif()
if(DEFINED slot_min_sectors AND "${slot_min_sectors}" GREATER "0")
zephyr_compile_definitions("MIN_SECTOR_COUNT=${slot_min_sectors}")
message("Calculated maximum number of sectors: ${slot_min_sectors}")
else()
message(WARNING "Unable to calculate minimum number of sector sizes, falling back to 128 sector default. Please disable CONFIG_BOOT_MAX_IMG_SECTORS_AUTO and set CONFIG_BOOT_MAX_IMG_SECTORS to the required value")
endif()
endif()
if(SYSBUILD)
if(CONFIG_SINGLE_APPLICATION_SLOT OR CONFIG_BOOT_FIRMWARE_LOADER OR CONFIG_BOOT_SWAP_USING_SCRATCH OR CONFIG_BOOT_SWAP_USING_MOVE OR CONFIG_BOOT_UPGRADE_ONLY OR CONFIG_BOOT_DIRECT_XIP OR CONFIG_BOOT_RAM_LOAD)
# TODO: RAM LOAD support
dt_nodelabel(slot0_flash NODELABEL "slot0_partition")
dt_get_parent(slot0_flash)
dt_get_parent(slot0_flash)
if(NOT CONFIG_SINGLE_APPLICATION_SLOT)
dt_nodelabel(slot1_flash NODELABEL "slot1_partition")
dt_get_parent(slot1_flash)
dt_get_parent(slot1_flash)
if(NOT "${slot0_flash}" STREQUAL "${slot1_flash}")
# Check both slots for the one with the largest write/erase block size
dt_prop(erase_size_slot0 PATH "${slot0_flash}" PROPERTY "erase-block-size")
dt_prop(write_size_slot0 PATH "${slot0_flash}" PROPERTY "write-block-size")
dt_prop(erase_size_slot1 PATH "${slot1_flash}" PROPERTY "erase-block-size")
dt_prop(write_size_slot1 PATH "${slot1_flash}" PROPERTY "write-block-size")
if(DEFINED erase_size_slot0 AND DEFINED erase_size_slot1)
if(${erase_size_slot0} GREATER ${erase_size_slot1})
set(erase_size ${erase_size_slot0})
else()
set(erase_size ${erase_size_slot1})
endif()
elseif(DEFINED erase_size_slot0)
set(erase_size ${erase_size_slot0})
elseif(DEFINED erase_size_slot1)
set(erase_size ${erase_size_slot1})
endif()
if(DEFINED write_size_slot0 AND DEFINED write_size_slot1)
if(${write_size_slot0} GREATER ${write_size_slot1})
set(write_size ${write_size_slot0})
else()
set(write_size ${write_size_slot1})
endif()
elseif(DEFINED write_size_slot0)
set(write_size ${write_size_slot0})
elseif(DEFINED write_size_slot1)
set(write_size ${write_size_slot1})
endif()
else()
dt_prop(erase_size PATH "${slot0_flash}" PROPERTY "erase-block-size")
dt_prop(write_size PATH "${slot0_flash}" PROPERTY "write-block-size")
endif()
else()
dt_prop(erase_size PATH "${slot0_flash}" PROPERTY "erase-block-size")
dt_prop(write_size PATH "${slot0_flash}" PROPERTY "write-block-size")
endif()
if(NOT DEFINED erase_size)
message(WARNING "Unable to determine erase size of slot0 or slot1 partition, setting to 1 (this is probably wrong)")
set(erase_size 1)
endif()
if(NOT DEFINED write_size)
message(WARNING "Unable to determine write size of slot0 or slot1 partition, setting to 8 (this is probably wrong)")
set(write_size 8)
endif()
if(${write_size} LESS 8)
set(max_align_size 8)
else()
set(max_align_size ${write_size})
endif()
set(key_size 0)
# Boot trailer magic size
set(boot_magic_size 16)
# Estimates for trailer TLV data size, this was taken from hello world builds for nrf52840dk
if(CONFIG_BOOT_SIGNATURE_TYPE_RSA)
if(CONFIG_BOOT_SIGNATURE_TYPE_RSA_LEN EQUAL 3072)
set(boot_tlv_estimate 464)
else()
set(boot_tlv_estimate 336)
endif()
elseif(CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256)
set(boot_tlv_estimate 150)
elseif(CONFIG_BOOT_SIGNATURE_TYPE_ED25519)
set(boot_tlv_estimate 144)
else()
set(boot_tlv_estimate 40)
endif()
if(CONFIG_BOOT_ENCRYPT_RSA OR CONFIG_BOOT_ENCRYPT_EC256 OR CONFIG_BOOT_ENCRYPT_X25519)
# 128-bit AES key size
set(boot_enc_key_size 16)
if(CONFIG_BOOT_SWAP_SAVE_ENCTLV)
if(CONFIG_BOOT_ENCRYPT_RSA)
set(key_size 256)
elseif(CONFIG_BOOT_ENCRYPT_EC256)
math(EXPR key_size "65 + 32 + ${boot_enc_key_size}")
elseif(CONFIG_BOOT_ENCRYPT_X25519)
math(EXPR key_size "32 + 32 + ${boot_enc_key_size}")
endif()
else()
set(key_size "${boot_enc_key_size}")
endif()
align_up(${key_size} ${max_align_size} key_size)
math(EXPR key_size "${key_size} * 2")
endif()
align_up(${boot_magic_size} ${write_size} boot_magic_size)
if(CONFIG_SINGLE_APPLICATION_SLOT OR CONFIG_BOOT_FIRMWARE_LOADER)
set(boot_swap_data_size 0)
else()
math(EXPR boot_swap_data_size "${max_align_size} * 4")
endif()
if(CONFIG_BOOT_SWAP_USING_SCRATCH OR CONFIG_BOOT_SWAP_USING_MOVE)
if(CONFIG_BOOT_MAX_IMG_SECTORS_AUTO AND DEFINED slot_min_sectors AND "${slot_min_sectors}" GREATER "0")
math(EXPR boot_status_data_size "${slot_min_sectors} * (3 * ${write_size})")
else()
math(EXPR boot_status_data_size "${CONFIG_BOOT_MAX_IMG_SECTORS} * (3 * ${write_size})")
endif()
else()
set(boot_status_data_size 0)
endif()
math(EXPR required_size "${key_size} + ${boot_magic_size} + ${boot_swap_data_size} + ${boot_status_data_size} + ${boot_tlv_estimate}")
align_up(${required_size} ${erase_size} required_size)
if(CONFIG_SINGLE_APPLICATION_SLOT OR CONFIG_BOOT_FIRMWARE_LOADER)
set(required_upgrade_size "0")
else()
math(EXPR required_upgrade_size "${boot_magic_size} + ${boot_swap_data_size} + ${boot_status_data_size}")
align_up(${required_upgrade_size} ${erase_size} required_upgrade_size)
endif()
if(CONFIG_BOOT_SWAP_USING_MOVE)
math(EXPR required_size "${required_size} + ${erase_size}")
math(EXPR required_upgrade_size "${required_upgrade_size} + ${erase_size}")
endif()
else()
set(required_size 0)
set(required_upgrade_size 0)
endif()
set(mcuboot_image_footer_size ${required_size} CACHE INTERNAL "Estimated MCUboot image trailer size" FORCE)
set(mcuboot_image_upgrade_footer_size ${required_upgrade_size} CACHE INTERNAL "Estimated MCUboot update image trailer size" FORCE)
endif()
if(CONFIG_MCUBOOT_NRF_CLEANUP_PERIPHERAL OR CONFIG_MCUBOOT_CLEANUP_NONSECURE_RAM)
zephyr_library_sources(
${BOOT_DIR}/zephyr/nrf_cleanup.c
)
endif()
if(SYSBUILD AND CONFIG_PCD_APP)
# Sysbuild requires details of the RAM flash device are stored to the cache of MCUboot so
# that they can be read when running partition manager
dt_nodelabel(ram_flash_dev NODELABEL flash_sim0)
dt_reg_addr(ram_flash_addr PATH ${ram_flash_dev})
dt_reg_size(ram_flash_size PATH ${ram_flash_dev})
set(RAM_FLASH_ADDR "${ram_flash_addr}" CACHE STRING "" FORCE)
set(RAM_FLASH_SIZE "${ram_flash_size}" CACHE STRING "" FORCE)
endif()

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,47 @@
# Copyright (c) 2023 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0
if BOOT_FIRMWARE_LOADER
menu "Firmware loader entrance methods"
menuconfig BOOT_FIRMWARE_LOADER_ENTRANCE_GPIO
bool "GPIO"
depends on GPIO
help
Use a GPIO to enter firmware loader mode.
config BOOT_FIRMWARE_LOADER_DETECT_DELAY
int "Serial detect pin detection delay time [ms]"
default 0
depends on BOOT_FIRMWARE_LOADER_ENTRANCE_GPIO
help
Used to prevent the bootloader from loading on button press.
Useful for powering on when using the same button as
the one used to place the device in bootloader mode.
config BOOT_FIRMWARE_LOADER_BOOT_MODE
bool "Check boot mode via retention subsystem"
depends on RETENTION_BOOT_MODE
help
Allows for entering firmware loader mode by using Zephyr's boot mode
retention system (i.e. an application must set the boot mode to stay
in firmware loader mode and reboot the module).
config BOOT_FIRMWARE_LOADER_NO_APPLICATION
bool "Stay in bootloader if no application"
help
Allows for entering firmware loader mode if there is no bootable
application that the bootloader can jump to.
config BOOT_FIRMWARE_LOADER_PIN_RESET
bool "Check for device reset by pin"
select HWINFO
help
Checks if the module reset was caused by the reset pin and will
remain in bootloader firmware loader mode if it was.
endmenu
endif

View File

@@ -0,0 +1,212 @@
# Copyright (c) 2017-2020 Linaro Limited
# Copyright (c) 2020 Arm Limited
# Copyright (c) 2017-2023 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0
menuconfig MCUBOOT_SERIAL
bool "MCUboot serial recovery"
default n
select REBOOT
select SERIAL
select UART_INTERRUPT_DRIVEN
select BASE64
select CRC
select ZCBOR
depends on !BOOT_FIRMWARE_LOADER
help
If y, enables a serial-port based update mode. This allows
MCUboot itself to load update images into flash over a UART.
If unsure, leave at the default value.
if MCUBOOT_SERIAL
choice BOOT_SERIAL_DEVICE
prompt "Serial device"
default BOOT_SERIAL_UART if !BOARD_NRF52840DONGLE_NRF52840
default BOOT_SERIAL_CDC_ACM if BOARD_NRF52840DONGLE_NRF52840
config BOOT_SERIAL_UART
bool "UART"
# SERIAL and UART_INTERRUPT_DRIVEN already selected
help
The serial device to use will be fist selected via chosen
node "zephyr,uart-mcumgr", when such node does not exist
the "zephyr,console" is used. In case when
the "zephyr,uart-mcumgr" points to the same device as
the "zephyr,console" compilation error will be triggered.
config BOOT_SERIAL_CDC_ACM
bool "CDC ACM"
select USB_DEVICE_STACK
help
This setting will choose CDC ACM for serial recovery unless chosen
"zephyr,uart-mcumgr" is present, in which case the chosen takes
precedence and redirects serial recovery to uart pointed by
the chosen, leaving console on CDC ACM.
endchoice
config MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD
bool "Allow to select image number for DFU"
depends on !SINGLE_APPLICATION_SLOT
help
With the option enabled, the mcuboot serial recovery will
respect the "image" field in mcumgr image update frame
header.
The mapping of image number to partition is as follows:
0 -> default behaviour, same as 1;
1 -> image-0 (primary slot of the first image);
2 -> image-1 (secondary slot of the first image);
3 -> image-2;
4 -> image-3.
Note that 0 is default upload target when no explicit
selection is done.
config BOOT_SERIAL_UNALIGNED_BUFFER_SIZE
int "Stack buffer for unaligned memory writes"
default 64
range 0 128
help
Specifies the stack usage for a buffer which is used for unaligned
memory access when data is written to a device with memory alignment
requirements. Set to 0 to disable.
config BOOT_MAX_LINE_INPUT_LEN
int "Maximum input line length"
default 128
help
Maximum length of input serial port buffer (SMP serial transport uses
fragments of 128-bytes, this should not need to be changed unless a
different value is used for the transport).
config BOOT_LINE_BUFS
int "Number of receive buffers"
range 2 128
default 8
help
Number of receive buffers for data received via the serial port.
config BOOT_SERIAL_MAX_RECEIVE_SIZE
int "Maximum command line length"
default 1024
help
Maximum length of received commands via the serial port (this should
be equal to the maximum line length, BOOT_MAX_LINE_INPUT_LEN times
by the number of receive buffers, BOOT_LINE_BUFS to allow for
optimal data transfer speeds).
config BOOT_ERASE_PROGRESSIVELY
bool "Erase flash progressively when receiving new firmware"
default y if SOC_FAMILY_NORDIC_NRF
help
If enabled, flash is erased as necessary when receiving new firmware,
instead of erasing the whole image slot at once. This is necessary
on some hardware that has long erase times, to prevent long wait
times at the beginning of the DFU process.
config BOOT_MGMT_ECHO
bool "Enable echo command"
help
if enabled, support for the mcumgr echo command is being added.
menuconfig ENABLE_MGMT_PERUSER
bool "Enable system specific mcumgr commands"
help
The option enables processing of system specific mcumgr commands;
system specific commands are within group MGMT_GROUP_ID_PERUSER (64)
and above, as defined within mcumgr library.
These are system specific command and system specific implementation
function is required to process these commands.
if ENABLE_MGMT_PERUSER
config BOOT_MGMT_CUSTOM_STORAGE_ERASE
bool "Enable storage erase command"
help
The option enables mcumgr command that allows to erase storage
partition.
Note that the storage partition needs to be defined, in DTS, otherwise
enabling the option will cause a compilation to fail.
endif # ENABLE_MGMT_PERUSER
menu "Entrance methods"
menuconfig BOOT_SERIAL_ENTRANCE_GPIO
bool "GPIO"
default y
depends on GPIO
help
Use a GPIO to enter serial recovery mode.
config BOOT_SERIAL_DETECT_DELAY
int "Serial detect pin detection delay time [ms]"
default 0
depends on BOOT_SERIAL_ENTRANCE_GPIO
help
Used to prevent the bootloader from loading on button press.
Useful for powering on when using the same button as
the one used to place the device in bootloader mode.
menuconfig BOOT_SERIAL_WAIT_FOR_DFU
bool "Wait a prescribed duration to see if DFU is invoked by receiving a MCUmgr comand"
depends on BOOT_SERIAL_UART || BOOT_SERIAL_CDC_ACM
help
If y, MCUboot waits for a prescribed duration of time to allow
for DFU to be invoked. The serial recovery can be entered by receiving any
mcumgr command.
config BOOT_SERIAL_WAIT_FOR_DFU_TIMEOUT
int "Duration to wait for the serial DFU timeout in ms"
default 500
depends on BOOT_SERIAL_WAIT_FOR_DFU
help
Timeout in ms for MCUboot to wait to allow for DFU to be invoked.
config BOOT_SERIAL_BOOT_MODE
bool "Check boot mode via retention subsystem"
depends on RETENTION_BOOT_MODE
help
Allows for entering serial recovery mode by using Zephyr's boot mode
retention system (i.e. an application must set the boot mode to stay
in serial recovery mode and reboot the module).
config BOOT_SERIAL_NO_APPLICATION
bool "Stay in bootloader if no application"
help
Allows for entering serial recovery mode if there is no bootable
application that the bootloader can jump to.
config BOOT_SERIAL_PIN_RESET
bool "Check for device reset by pin"
select HWINFO
help
Checks if the module reset was caused by the reset pin and will
remain in bootloader serial recovery mode if it was.
endmenu
config BOOT_SERIAL_IMG_GRP_HASH
bool "Image list hash support"
default y
help
If y, image list responses will include the image hash (adds ~100
bytes of flash).
config BOOT_SERIAL_IMG_GRP_IMAGE_STATE
bool "Image state support"
depends on !SINGLE_APPLICATION_SLOT
select BOOT_SERIAL_IMG_GRP_HASH if UPDATEABLE_IMAGE_NUMBER > 1
help
If y, image states will be included with image lists and the set
state command can be used to mark an image as test/confirmed.
config BOOT_SERIAL_IMG_GRP_SLOT_INFO
bool "Slot info"
default y if UPDATEABLE_IMAGE_NUMBER > 1
help
If y, will include the slot info command which lists what available
slots there are in the system.
endif # MCUBOOT_SERIAL

View File

@@ -0,0 +1,5 @@
VERSION_MAJOR = 2
VERSION_MINOR = 1
PATCHLEVEL = 0
VERSION_TWEAK = 0
EXTRAVERSION = dev

View File

@@ -0,0 +1,5 @@
/ {
chosen {
zephyr,code-partition = &boot_partition;
};
};

View File

@@ -0,0 +1,55 @@
/*
* Copyright (c) 2020 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/toolchain.h>
#include <cmsis_core.h>
#if CONFIG_CPU_HAS_NXP_MPU
#include <fsl_sysmpu.h>
#endif
void cleanup_arm_nvic(void) {
/* Allow any pending interrupts to be recognized */
__ISB();
__disable_irq();
/* Disable NVIC interrupts */
for (uint8_t i = 0; i < ARRAY_SIZE(NVIC->ICER); i++) {
NVIC->ICER[i] = 0xFFFFFFFF;
}
/* Clear pending NVIC interrupts */
for (uint8_t i = 0; i < ARRAY_SIZE(NVIC->ICPR); i++) {
NVIC->ICPR[i] = 0xFFFFFFFF;
}
}
#if CONFIG_CPU_HAS_ARM_MPU
__weak void z_arm_clear_arm_mpu_config(void)
{
int i;
int num_regions =
((MPU->TYPE & MPU_TYPE_DREGION_Msk) >> MPU_TYPE_DREGION_Pos);
for (i = 0; i < num_regions; i++) {
ARM_MPU_ClrRegion(i);
}
}
#elif CONFIG_CPU_HAS_NXP_MPU
__weak void z_arm_clear_arm_mpu_config(void)
{
int i;
int num_regions = FSL_FEATURE_SYSMPU_DESCRIPTOR_COUNT;
SYSMPU_Enable(SYSMPU, false);
/* NXP MPU region 0 is reserved for the debugger */
for (i = 1; i < num_regions; i++) {
SYSMPU_RegionEnable(SYSMPU, i, false);
}
}
#endif

View File

@@ -0,0 +1,10 @@
# Disable Zephyr console
CONFIG_CONSOLE=n
# MCUBoot settings
CONFIG_BOOT_MAX_IMG_SECTORS=256
# MCUboot serial recovery
CONFIG_MCUBOOT_SERIAL=y
CONFIG_MULTITHREADING=y

View File

@@ -0,0 +1,10 @@
# Disable Zephyr console
CONFIG_CONSOLE=n
# MCUBoot settings
CONFIG_BOOT_MAX_IMG_SECTORS=256
# MCUboot serial recovery
CONFIG_MCUBOOT_SERIAL=y
CONFIG_MULTITHREADING=y

View File

@@ -0,0 +1,10 @@
# Disable Zephyr console
CONFIG_CONSOLE=n
# MCUBoot settings
CONFIG_BOOT_MAX_IMG_SECTORS=256
# MCUboot serial recovery
CONFIG_MCUBOOT_SERIAL=y
CONFIG_MULTITHREADING=y

View File

@@ -0,0 +1,10 @@
# Disable Zephyr console
CONFIG_CONSOLE=n
# MCUBoot settings
CONFIG_BOOT_MAX_IMG_SECTORS=256
# MCUboot serial recovery
CONFIG_MCUBOOT_SERIAL=y
CONFIG_MULTITHREADING=y

View File

@@ -0,0 +1,6 @@
CONFIG_MULTITHREADING=y
# Enable QSPI (MX25R64) - Slot 1 in QSPI
CONFIG_NORDIC_QSPI_NOR=y
CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=4
CONFIG_BOOT_MAX_IMG_SECTORS=256

View File

@@ -0,0 +1,13 @@
# Disable Zephyr console
CONFIG_CONSOLE=n
# Multithreading
CONFIG_MULTITHREADING=y
# MCUBoot settings
CONFIG_BOOT_MAX_IMG_SECTORS=256
# MCUboot serial recovery
CONFIG_MCUBOOT_SERIAL=y
CONFIG_BOOT_SERIAL_DETECT_DELAY=450
CONFIG_MCUBOOT_INDICATION_LED=y

View File

@@ -0,0 +1,15 @@
# Disable Zephyr console
CONFIG_CONSOLE=n
CONFIG_CONSOLE_HANDLER=n
CONFIG_UART_CONSOLE=n
# Multithreading
CONFIG_MULTITHREADING=y
# MCUBoot settings
CONFIG_BOOT_MAX_IMG_SECTORS=256
# MCUboot serial recovery
CONFIG_MCUBOOT_SERIAL=y
CONFIG_BOOT_SERIAL_DETECT_DELAY=450
CONFIG_MCUBOOT_INDICATION_LED=y

View File

@@ -0,0 +1,2 @@
CONFIG_BOOT_MAX_IMG_SECTORS=256
CONFIG_WATCHDOG=y

View File

@@ -0,0 +1,2 @@
CONFIG_FLASH_SIMULATOR=y
CONFIG_FLASH_SIMULATOR_UNALIGNED_READ=y

View File

@@ -0,0 +1 @@
CONFIG_WATCHDOG=y

View File

@@ -0,0 +1,5 @@
# Copyright 2024 NXP
# SPDX-License-Identifier: Apache-2.0
#MCXN94x does not support the MCUBoot swap mode.
CONFIG_BOOT_UPGRADE_ONLY=y

View File

@@ -0,0 +1,5 @@
# Copyright 2023 NXP
# SPDX-License-Identifier: Apache-2.0
CONFIG_BOOT_MAX_IMG_SECTORS=1024
CONFIG_BOOT_UPGRADE_ONLY=y

View File

@@ -0,0 +1,12 @@
/*
* Copyright 2023 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/
/ {
chosen {
zephyr,flash = &flash;
};
};

View File

@@ -0,0 +1,6 @@
# Copyright 2023 NXP
# SPDX-License-Identifier: Apache-2.0
#LPC does not support the MCUBoot swap mode.
CONFIG_BOOT_UPGRADE_ONLY=y
CONFIG_BOOT_MAX_IMG_SECTORS=256

View File

@@ -0,0 +1,6 @@
# Copyright 2023 NXP
# SPDX-License-Identifier: Apache-2.0
#LPC does not support the MCUBoot swap mode.
CONFIG_BOOT_UPGRADE_ONLY=y
CONFIG_BOOT_MAX_IMG_SECTORS=256

View File

@@ -0,0 +1,6 @@
# Copyright 2023 NXP
# SPDX-License-Identifier: Apache-2.0
#LPC does not support the MCUBoot swap mode.
CONFIG_BOOT_UPGRADE_ONLY=y
CONFIG_BOOT_MAX_IMG_SECTORS=512

View File

@@ -0,0 +1,6 @@
# Copyright 2023 NXP
# SPDX-License-Identifier: Apache-2.0
#LPC does not support the MCUBoot swap mode.
CONFIG_BOOT_UPGRADE_ONLY=y
CONFIG_BOOT_MAX_IMG_SECTORS=256

View File

@@ -0,0 +1,6 @@
# Copyright 2023 NXP
# SPDX-License-Identifier: Apache-2.0
#LPC does not support the MCUBoot swap mode.
CONFIG_BOOT_UPGRADE_ONLY=y
CONFIG_BOOT_MAX_IMG_SECTORS=512

View File

@@ -0,0 +1,4 @@
# Copyright 2023 NXP
# SPDX-License-Identifier: Apache-2.0
CONFIG_BOOT_MAX_IMG_SECTORS=2048

View File

@@ -0,0 +1,4 @@
# Copyright 2023 NXP
# SPDX-License-Identifier: Apache-2.0
CONFIG_BOOT_MAX_IMG_SECTORS=2048

View File

@@ -0,0 +1,4 @@
# Copyright 2021 NXP
# SPDX-License-Identifier: Apache-2.0
CONFIG_BOOT_MAX_IMG_SECTORS=1024

View File

@@ -0,0 +1,4 @@
# Copyright (c) 2021 Prevas A/S
# SPDX-License-Identifier: Apache-2.0
CONFIG_BOOT_MAX_IMG_SECTORS=512

View File

@@ -0,0 +1,4 @@
# Copyright 2023 NXP
# SPDX-License-Identifier: Apache-2.0
CONFIG_BOOT_MAX_IMG_SECTORS=1024

View File

@@ -0,0 +1,5 @@
# Copyright 2021-2024 NXP
# SPDX-License-Identifier: Apache-2.0
CONFIG_BOOT_MAX_IMG_SECTORS=1024
CONFIG_BOOT_ERASE_PROGRESSIVELY=y

View File

@@ -0,0 +1,5 @@
# Copyright 2021-2022 NXP
# SPDX-License-Identifier: Apache-2.0
CONFIG_BOOT_MAX_IMG_SECTORS=1024
CONFIG_BOOT_ERASE_PROGRESSIVELY=y

View File

@@ -0,0 +1,7 @@
# Copyright 2022 NXP
# SPDX-License-Identifier: Apache-2.0
CONFIG_BOOT_MAX_IMG_SECTORS=1024
CONFIG_BOOT_ERASE_PROGRESSIVELY=y
# Move swap provides better wear levelling, so use it by default
CONFIG_BOOT_SWAP_USING_MOVE=y

View File

@@ -0,0 +1,5 @@
# Copyright 2021-2022 NXP
# SPDX-License-Identifier: Apache-2.0
CONFIG_BOOT_MAX_IMG_SECTORS=1024
CONFIG_BOOT_ERASE_PROGRESSIVELY=y

View File

@@ -0,0 +1,5 @@
# Copyright 2024 NXP
# SPDX-License-Identifier: Apache-2.0
CONFIG_BOOT_MAX_IMG_SECTORS=1024
CONFIG_BOOT_ERASE_PROGRESSIVELY=y

View File

@@ -0,0 +1,4 @@
# Copyright 2021 NXP
# SPDX-License-Identifier: Apache-2.0
CONFIG_BOOT_MAX_IMG_SECTORS=512

View File

@@ -0,0 +1,5 @@
# Copyright 2024 NXP
# SPDX-License-Identifier: Apache-2.0
CONFIG_BOOT_MAX_IMG_SECTORS=2048
CONFIG_BOOT_ERASE_PROGRESSIVELY=y

View File

@@ -0,0 +1,6 @@
# Copyright 2022-2024 NXP
# SPDX-License-Identifier: Apache-2.0
CONFIG_BOOT_MAX_IMG_SECTORS=2048
CONFIG_BOOT_ERASE_PROGRESSIVELY=y

View File

@@ -0,0 +1,3 @@
# Copyright 2023 NXP
# SPDX-License-Identifier: Apache-2.0
CONFIG_BOOT_MAX_IMG_SECTORS=8192

View File

@@ -0,0 +1,4 @@
# Copyright 2021 NXP
# SPDX-License-Identifier: Apache-2.0
CONFIG_BOOT_MAX_IMG_SECTORS=8192

View File

@@ -0,0 +1,5 @@
# Due the small boot partition, we can't enable logging or the debug
# optimization level out off the box. You need to increase the boot
# partition size with a zephyr DTS overlay to make MCUboot's debug
# builds fit.
CONFIG_LOG=n

View File

@@ -0,0 +1,36 @@
/*
* Copyright (c) 2020 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
/delete-node/ &boot_partition;
/delete-node/ &slot0_partition;
/delete-node/ &slot1_partition;
&flash0 {
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
boot_partition: partition@0 {
label = "mcuboot";
reg = <0x000000000 0x00010000>;
};
slot0_partition: partition@10000 {
label = "image-0";
reg = <0x000010000 0x000074000>;
};
slot1_partition: partition@75000 {
label = "image-1";
reg = <0x00084000 0x000074000>;
};
};
};
&zephyr_udc0 {
cdc_acm_uart0 {
compatible = "zephyr,cdc-acm-uart";
};
};

View File

@@ -0,0 +1,26 @@
/*
* Copyright (c) 2020 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
/delete-node/ &boot_partition;
/delete-node/ &slot0_partition;
/delete-node/ &slot1_partition;
&flash0 {
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
boot_partition: partition@0 {
label = "mcuboot";
reg = <0x000000000 0x00010000>;
};
slot0_partition: partition@10000 {
label = "image-0";
reg = <0x000010000 0x0000E8000>;
};
};
};

View File

@@ -0,0 +1,6 @@
CONFIG_UPDATEABLE_IMAGE_NUMBER=2
CONFIG_FLASH_SIMULATOR=y
CONFIG_FLASH_SIMULATOR_UNALIGNED_READ=y
CONFIG_BOOT_IMAGE_ACCESS_HOOKS=y

View File

@@ -0,0 +1,2 @@
# Ensure that the qspi driver is disabled by default
CONFIG_NORDIC_QSPI_NOR=n

View File

@@ -0,0 +1,3 @@
&uicr {
/delete-property/ gpio-as-nreset;
};

View File

@@ -0,0 +1,3 @@
CONFIG_NORDIC_QSPI_NOR=y
CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16

View File

@@ -0,0 +1,35 @@
/*
* Copyright (c) 2020 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
/delete-node/ &boot_partition;
/delete-node/ &slot0_partition;
/delete-node/ &slot1_partition;
&flash0 {
partitions {
boot_partition: partition@0 {
label = "mcuboot";
reg = <0x000000000 0x00010000>;
};
slot0_partition: partition@10000 {
label = "image-0";
reg = <0x000010000 0x0000e8000>;
};
};
};
&mx25r64 {
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
slot1_partition: partition@0 {
label = "image-1";
reg = <0x000000000 0x0000e8000>;
};
};
};

View File

@@ -0,0 +1,2 @@
CONFIG_MULTITHREADING=y
CONFIG_BOOT_MAX_IMG_SECTORS=256

View File

@@ -0,0 +1,54 @@
/*
* Copyright (c) 2021 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
/delete-node/ &slot1_partition;
/delete-node/ &slot0_partition;
/delete-node/ &boot_partition;
&flash0 {
partitions {
boot_partition: partition@0 {
label = "mcuboot";
reg = <0x000000000 0x00010000>;
};
slot0_partition: partition@10000 {
label = "image-0";
reg = <0x000010000 0x00000A000>;
};
};
};
/ {
soc {
flash_controller2: flash-controller@2 {
compatible = "zephyr,sim-flash";
reg = <0x00000000 DT_SIZE_K(40)>;
#address-cells = <1>;
#size-cells = <1>;
erase-value = <0xff>;
flash_sim0: flash_sim@0 {
status = "okay";
compatible = "soc-nv-flash";
erase-block-size = <4096>;
write-block-size = <1>;
reg = <0x00000000 DT_SIZE_K(40)>;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
slot1_partition: partition@0 {
label = "image-1";
reg = <0x00000000 0x00000A000>;
};
};
};
};
};
};

View File

@@ -0,0 +1,62 @@
/*
* Copyright (c) 2021 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
/delete-node/ &slot1_partition;
/delete-node/ &slot0_partition;
/delete-node/ &boot_partition;
&flash0 {
partitions {
boot_partition: partition@0 {
label = "mcuboot";
reg = <0x000000000 0x00010000>;
};
slot0_partition: partition@10000 {
label = "image-0";
reg = <0x000010000 0x00000A000>;
};
slot1_partition: partition@1A000 {
label = "image-1";
reg = <0x00001A000 0x00000A000>;
};
slot3_partition: partition@24000 {
label = "image-3";
reg = <0x000024000 0x00000A000>;
};
};
};
/ {
soc {
flash_controller2: flash-controller@2 {
compatible = "zephyr,sim-flash";
reg = <0x00000000 DT_SIZE_K(40)>;
#address-cells = <1>;
#size-cells = <1>;
erase-value = <0xff>;
flash_sim0: flash_sim@0 {
status = "okay";
compatible = "soc-nv-flash";
erase-block-size = <4096>;
write-block-size = <1>;
reg = <0x00000000 DT_SIZE_K(40)>;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
slot2_partition: partition@0 {
label = "image-2";
reg = <0x00000000 0x00000A000>;
};
};
};
};
};
};

View File

@@ -0,0 +1,26 @@
# The UART is used for Serial Recovery, so logging requires
# an RTT console, which is not available out of the box on this board.
# Disable logging.
CONFIG_LOG=n
# Serial
CONFIG_CONSOLE=n
CONFIG_SERIAL=y
CONFIG_UART_NRFX=n
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_LINE_CTRL=y
# MCUBoot serial
CONFIG_GPIO=y
CONFIG_MCUBOOT_SERIAL=y
CONFIG_BOOT_SERIAL_CDC_ACM=y
# Required by USB
CONFIG_MULTITHREADING=y
# USB
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_REMOTE_WAKEUP=n
CONFIG_USB_DEVICE_PRODUCT="MCUBOOT"
CONFIG_NORDIC_QSPI_NOR=n

View File

@@ -0,0 +1,61 @@
# Minimal MCUBoot flash footprint configuration
# for nRF52832 SoC targets
# This is not recomendet configuration because of security and reliability
# reasons.
# Generated by Kconfiglib (https://github.com/ulfalizer/Kconfiglib)
CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256=y
CONFIG_BOOT_SIGNATURE_KEY_FILE="root-ec-p256.pem"
# In any real project CONFIG_BOOT_VALIDATE_SLOT0 enabling is recommended
# by security reason.
# CONFIG_BOOT_VALIDATE_SLOT0 is not set
# In most of projects CONFIG_BOOT_UPGRADE_ONLY disabling is recommended
# by reliability reason.
CONFIG_BOOT_UPGRADE_ONLY=y
# CONFIG_BOARD_ENABLE_DCDC is not set
CONFIG_SOC_SERIES_NRF52X=y
CONFIG_SOC_NRF52832_QFAA=y
CONFIG_ARM=y
CONFIG_ARM_MPU=n
CONFIG_MAIN_STACK_SIZE=10240
CONFIG_THREAD_STACK_INFO=n
# CONFIG_TICKLESS_KERNEL is not set
CONFIG_FLASH=y
CONFIG_CONSOLE=n
CONFIG_DEBUG=n
CONFIG_EARLY_CONSOLE=n
CONFIG_PRINTK=n
CONFIG_SYS_CLOCK_EXISTS=n
# Drivers and peripherals
CONFIG_I2C=n
CONFIG_WATCHDOG=n
CONFIG_GPIO=n
CONFIG_PINMUX=n
CONFIG_SPI=n
CONFIG_SERIAL=n
# Power management
CONFIG_PM=n
# Interrupts
CONFIG_DYNAMIC_INTERRUPTS=n
CONFIG_IRQ_OFFLOAD=n
# Memory protection
CONFIG_MEMORY_PROTECTION=n
CONFIG_THREAD_CUSTOM_DATA=n
CONFIG_FPU=n
# Boot
CONFIG_BOOT_BANNER=n
CONFIG_BOOT_DELAY=0
# Console
CONFIG_STDOUT_CONSOLE=n

View File

@@ -0,0 +1,13 @@
#
# Copyright (c) 2021 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
# CC3xx is currently not used for nrf53
CONFIG_HW_CC3XX=n
CONFIG_NRF_CC3XX_PLATFORM=n
# Required for kernel operation
CONFIG_CLOCK_CONTROL=y
CONFIG_SYS_CLOCK_EXISTS=y

View File

@@ -0,0 +1,13 @@
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0
#
CONFIG_BOOT_MAX_IMG_SECTORS=256
# Ensure that the SPI NOR driver is disabled by default
CONFIG_SPI_NOR=n
# TODO: below are not yet supported and need fixing
CONFIG_FPROTECT=n
CONFIG_BOOT_WATCHDOG_FEED=n

View File

@@ -0,0 +1,15 @@
CONFIG_MULTITHREADING=y
CONFIG_SPI=y
CONFIG_SPI_NOR=y
CONFIG_FLASH=y
CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x14000
CONFIG_MAIN_STACK_SIZE=20480
CONFIG_BOOT_MAX_IMG_SECTORS=512
CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
# Ensure that the qspi driver is disabled by default
CONFIG_NORDIC_QSPI_NOR=n
# TODO: below are not yet supported and need fixing
CONFIG_FPROTECT=n
CONFIG_BOOT_WATCHDOG_FEED=n

View File

@@ -0,0 +1,47 @@
/ {
chosen {
nordic,pm-ext-flash = &mx25r64;
zephyr,code-partition = &boot_partition;
};
};
/delete-node/ &boot_partition;
/delete-node/ &slot0_partition;
/delete-node/ &slot1_partition;
/delete-node/ &slot0_ns_partition;
/delete-node/ &slot1_ns_partition;
/delete-node/ &storage_partition;
&cpuapp_rram {
reg = < 0x0 DT_SIZE_K(1524) >;
partitions {
boot_partition: partition@0 {
label = "mcuboot";
reg = <0x000000000 0x00014000>;
};
slot0_partition: partition@14000 {
label = "image-0";
reg = <0x000014000 0x0015A000>;
};
storage_partition: partition@16E000 {
label = "storage";
reg = < 0x16E000 0x9000 >;
};
};
};
&mx25r64 {
status = "okay";
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
slot1_partition: partition@0 {
label = "image-1";
reg = <0x000000000 0x0015A000>;
};
};
};

View File

@@ -0,0 +1,13 @@
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0
#
CONFIG_BOOT_MAX_IMG_SECTORS=256
# Ensure that the SPI NOR driver is disabled by default
CONFIG_SPI_NOR=n
# TODO: below are not yet supported and need fixing
CONFIG_FPROTECT=n
CONFIG_BOOT_WATCHDOG_FEED=n

View File

@@ -0,0 +1,15 @@
CONFIG_MULTITHREADING=y
CONFIG_SPI=y
CONFIG_SPI_NOR=y
CONFIG_FLASH=y
CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x14000
CONFIG_MAIN_STACK_SIZE=20480
CONFIG_BOOT_MAX_IMG_SECTORS=512
CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
# Ensure that the qspi driver is disabled by default
CONFIG_NORDIC_QSPI_NOR=n
# TODO: below are not yet supported and need fixing
CONFIG_FPROTECT=n
CONFIG_BOOT_WATCHDOG_FEED=n

View File

@@ -0,0 +1,47 @@
/ {
chosen {
nordic,pm-ext-flash = &mx25r64;
zephyr,code-partition = &boot_partition;
};
};
/delete-node/ &boot_partition;
/delete-node/ &slot0_partition;
/delete-node/ &slot1_partition;
/delete-node/ &slot0_ns_partition;
/delete-node/ &slot1_ns_partition;
/delete-node/ &storage_partition;
&cpuapp_rram {
reg = < 0x0 DT_SIZE_K(1524) >;
partitions {
boot_partition: partition@0 {
label = "mcuboot";
reg = <0x000000000 0x00014000>;
};
slot0_partition: partition@14000 {
label = "image-0";
reg = <0x000014000 0x0015A000>;
};
storage_partition: partition@16E000 {
label = "storage";
reg = < 0x16E000 0x9000 >;
};
};
};
&mx25r64 {
status = "okay";
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
slot1_partition: partition@0 {
label = "image-1";
reg = <0x000000000 0x0015A000>;
};
};
};

View File

@@ -0,0 +1 @@
CONFIG_SPI_NOR=n

View File

@@ -0,0 +1,4 @@
# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
CONFIG_REGULATOR=n

View File

@@ -0,0 +1,6 @@
CONFIG_MULTITHREADING=y
# Enable QSPI (MX25R64) - Slot 1 in QSPI
CONFIG_NORDIC_QSPI_NOR=y
CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=4
CONFIG_BOOT_MAX_IMG_SECTORS=256

View File

@@ -0,0 +1,4 @@
# Copyright 2024 NXP
# SPDX-License-Identifier: Apache-2.0
CONFIG_BOOT_MAX_IMG_SECTORS=1024

View File

@@ -0,0 +1,13 @@
# Disable Zephyr console
CONFIG_CONSOLE=n
# Multithreading
CONFIG_MULTITHREADING=y
# MCUBoot settings
CONFIG_BOOT_MAX_IMG_SECTORS=256
# MCUboot serial recovery
CONFIG_MCUBOOT_SERIAL=y
CONFIG_BOOT_SERIAL_DETECT_DELAY=450
CONFIG_MCUBOOT_INDICATION_LED=y

View File

@@ -0,0 +1 @@
CONFIG_GPIO_SX1509B=n

View File

@@ -0,0 +1,74 @@
CONFIG_SIZE_OPTIMIZATIONS=y
CONFIG_SYSTEM_CLOCK_NO_WAIT=y
CONFIG_PM=n
CONFIG_MAIN_STACK_SIZE=10240
CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h"
CONFIG_BOOT_MAX_IMG_SECTORS=2048
CONFIG_BOOT_SIGNATURE_TYPE_RSA=y
# Flash
CONFIG_FLASH=y
CONFIG_BOOT_ERASE_PROGRESSIVELY=y
CONFIG_SOC_FLASH_NRF_EMULATE_ONE_BYTE_WRITE_ACCESS=y
CONFIG_FPROTECT=y
# Serial
CONFIG_SERIAL=y
CONFIG_UART_LINE_CTRL=y
# MCUBoot serial
CONFIG_GPIO=y
CONFIG_GPIO_NRFX_INTERRUPT=n
CONFIG_MCUBOOT_SERIAL=y
CONFIG_MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD=y
CONFIG_BOOT_SERIAL_CDC_ACM=y
# Required by QSPI
CONFIG_NORDIC_QSPI_NOR=y
CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16
# Required by USB and QSPI
CONFIG_MULTITHREADING=y
# USB
CONFIG_BOARD_SERIAL_BACKEND_CDC_ACM=n
CONFIG_USB_DEVICE_REMOTE_WAKEUP=n
CONFIG_USB_DEVICE_MANUFACTURER="Nordic Semiconductor ASA"
CONFIG_USB_DEVICE_PRODUCT="Bootloader Thingy:53"
CONFIG_USB_DEVICE_VID=0x1915
CONFIG_USB_DEVICE_PID=0x5300
CONFIG_USB_CDC_ACM=y
# Decrease memory footprint
CONFIG_CBPRINTF_NANO=y
CONFIG_TIMESLICING=n
CONFIG_BOOT_BANNER=n
CONFIG_CONSOLE=n
CONFIG_CONSOLE_HANDLER=n
CONFIG_UART_CONSOLE=n
CONFIG_USE_SEGGER_RTT=n
CONFIG_LOG=n
CONFIG_ERRNO=n
CONFIG_PRINTK=n
CONFIG_RESET_ON_FATAL_ERROR=n
CONFIG_SPI=n
CONFIG_I2C=n
CONFIG_UART_NRFX=n
# The following configurations are required to support simultaneous multi image update
CONFIG_PCD_APP=y
CONFIG_UPDATEABLE_IMAGE_NUMBER=2
CONFIG_BOOT_UPGRADE_ONLY=y
# The network core cannot access external flash directly. The flash simulator must be used to
# provide a memory region that is used to forward the new firmware to the network core.
CONFIG_FLASH_SIMULATOR=y
CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y
CONFIG_FLASH_SIMULATOR_STATS=n
# Enable custom command to erase settings partition.
CONFIG_ENABLE_MGMT_PERUSER=y
CONFIG_BOOT_MGMT_CUSTOM_STORAGE_ERASE=y

View File

@@ -0,0 +1,34 @@
# Disable Zephyr console
CONFIG_LOG=n
CONFIG_CONSOLE=n
CONFIG_CONSOLE_HANDLER=n
CONFIG_UART_CONSOLE=n
# The build won't fit on the partition allocated for it without size
# optimizations.
CONFIG_SIZE_OPTIMIZATIONS=y
CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x12000
# Serial
CONFIG_SERIAL=y
CONFIG_UART_NRFX=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_LINE_CTRL=y
# MCUboot serial recovery
CONFIG_GPIO=y
CONFIG_MCUBOOT_SERIAL=y
CONFIG_BOOT_SERIAL_CDC_ACM=y
# Required by USB
CONFIG_MULTITHREADING=y
# USB
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_PRODUCT="MCUBOOT"
CONFIG_USB_CDC_ACM=y
CONFIG_USB_COMPOSITE_DEVICE=y
CONFIG_USB_MASS_STORAGE=n
CONFIG_USB_DEVICE_MANUFACTURER="Nordic Semiconductor"
CONFIG_USB_DEVICE_VID=0x1915
CONFIG_USB_DEVICE_PID=0x520F

View File

@@ -0,0 +1,13 @@
# Disable Zephyr console
CONFIG_CONSOLE=n
CONFIG_CONSOLE_HANDLER=n
CONFIG_UART_CONSOLE=n
# Disable Flash protection
CONFIG_FPROTECT=n
# MCUBoot settings
CONFIG_BOOT_MAX_IMG_SECTORS=256
# MCUboot serial recovery
CONFIG_MCUBOOT_SERIAL=y

View File

@@ -0,0 +1,63 @@
# MCUBoot settings
CONFIG_BOOT_MAX_IMG_SECTORS=110
# MCUboot serial recovery
CONFIG_MCUBOOT_SERIAL=y
# Disable Zephyr console
CONFIG_LOG=n
CONFIG_CONSOLE=n
CONFIG_CONSOLE_HANDLER=n
CONFIG_UART_CONSOLE=n
# Serial
CONFIG_SERIAL=y
CONFIG_UART_NRFX=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_LINE_CTRL=y
# MCUboot serial recovery
CONFIG_GPIO=y
CONFIG_MCUBOOT_SERIAL=y
CONFIG_BOOT_SERIAL_CDC_ACM=y
# Required by USB
CONFIG_MULTITHREADING=y
# USB
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_PRODUCT="MCUBOOT"
CONFIG_USB_CDC_ACM=y
CONFIG_USB_COMPOSITE_DEVICE=y
CONFIG_USB_MASS_STORAGE=n
CONFIG_USB_DEVICE_MANUFACTURER="Nordic Semiconductor"
CONFIG_USB_DEVICE_VID=0x1915
CONFIG_USB_DEVICE_PID=0x910A
CONFIG_BOOT_SERIAL_BOOT_MODE=y
CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x13E00
# The following configurations are required to support simultaneous multi image update
CONFIG_PCD_APP=y
CONFIG_UPDATEABLE_IMAGE_NUMBER=2
CONFIG_BOOT_UPGRADE_ONLY=y
# The network core cannot access external flash directly. The flash simulator must be used to
# provide a memory region that is used to forward the new firmware to the network core.
CONFIG_FLASH_SIMULATOR=y
CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y
CONFIG_FLASH_SIMULATOR_STATS=n
CONFIG_BOOT_IMAGE_ACCESS_HOOKS=y
# Makes it possible to update the network core using the flash simulator
CONFIG_NRF53_RECOVERY_NETWORK_CORE=y
CONFIG_MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD=y
CONFIG_BOOT_SERIAL_IMG_GRP_IMAGE_STATE=y
# Skip checks on the secondary image to make it possible to update MCUBoot on S1/S0
CONFIG_MCUBOOT_VERIFY_IMG_ADDRESS=n
CONFIG_BOOT_SERIAL_NO_APPLICATION=y
CONFIG_FW_INFO_FIRMWARE_VERSION=2

View File

@@ -0,0 +1,21 @@
# MCUBoot settings
CONFIG_BOOT_MAX_IMG_SECTORS=512
CONFIG_SPI=y
CONFIG_SPI_NOR=y
CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
CONFIG_SPI_NOR_SFDP_DEVICETREE=y
CONFIG_MULTITHREADING=y
# Disable Zephyr console and use UART for MCUboot serial recovery instead
CONFIG_CONSOLE=n
CONFIG_CONSOLE_HANDLER=n
CONFIG_UART_CONSOLE=n
CONFIG_MCUBOOT_SERIAL=y
CONFIG_MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD=y
CONFIG_BOOT_SERIAL_IMG_GRP_IMAGE_STATE=y
CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y
CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y
CONFIG_FW_INFO_FIRMWARE_VERSION=2

View File

@@ -0,0 +1,4 @@
&uart0 {
status = "okay";
current-speed = < 1000000 >;
};

View File

@@ -0,0 +1,4 @@
# Copyright 2022 Telink Semiconductor
# SPDX-License-Identifier: Apache-2.0
CONFIG_BOOT_MAX_IMG_SECTORS=4096

View File

@@ -0,0 +1,5 @@
# Copyright 2024 NXP
# SPDX-License-Identifier: Apache-2.0
CONFIG_BOOT_MAX_IMG_SECTORS=1024
CONFIG_BOOT_ERASE_PROGRESSIVELY=y

View File

@@ -0,0 +1,71 @@
/*
* Copyright (c) 2021-2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdio.h>
#include <zephyr/kernel.h>
#include <zephyr/drivers/flash.h>
#include <zephyr/mgmt/mcumgr/mgmt/mgmt_defines.h>
#include <zephyr/mgmt/mcumgr/grp/zephyr/zephyr_basic.h>
#include <../subsys/mgmt/mcumgr/transport/include/mgmt/mcumgr/transport/smp_internal.h>
#include <flash_map_backend/flash_map_backend.h>
#include <sysflash/sysflash.h>
#include "bootutil/bootutil_log.h"
#include "../boot_serial/src/boot_serial_priv.h"
#include <zcbor_encode.h>
#include "bootutil/image.h"
#include "bootutil/bootutil_public.h"
#include "bootutil/boot_hooks.h"
#include <boot_serial/boot_serial_extensions.h>
BOOT_LOG_MODULE_DECLARE(mcuboot);
#ifdef CONFIG_BOOT_MGMT_CUSTOM_STORAGE_ERASE
static int bs_custom_storage_erase(const struct nmgr_hdr *hdr,
const char *buffer, int len,
zcbor_state_t *cs)
{
int rc;
const struct flash_area *fa;
(void)buffer;
(void)len;
if (hdr->nh_group != ZEPHYR_MGMT_GRP_BASIC || hdr->nh_op != NMGR_OP_WRITE ||
hdr->nh_id != ZEPHYR_MGMT_GRP_BASIC_CMD_ERASE_STORAGE) {
return MGMT_ERR_ENOTSUP;
}
rc = flash_area_open(FIXED_PARTITION_ID(storage_partition), &fa);
if (rc < 0) {
BOOT_LOG_ERR("failed to open flash area");
} else {
rc = flash_area_erase(fa, 0, flash_area_get_size(fa));
if (rc < 0) {
BOOT_LOG_ERR("failed to erase flash area");
}
flash_area_close(fa);
}
if (rc == 0) {
rc = MGMT_ERR_OK;
} else {
rc = MGMT_ERR_EUNKNOWN;
}
zcbor_map_start_encode(cs, 10);
zcbor_tstr_put_lit(cs, "rc");
zcbor_uint32_put(cs, rc);
zcbor_map_end_encode(cs, 10);
return rc;
}
MCUMGR_HANDLER_DEFINE(storage_erase, bs_custom_storage_erase);
#endif

View File

@@ -0,0 +1,39 @@
/*
* Copyright (c) 2021-2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/kernel.h>
#include "bootutil/bootutil_log.h"
#include "../boot_serial/src/boot_serial_priv.h"
#include <zcbor_encode.h>
#include <boot_serial/boot_serial_extensions.h>
BOOT_LOG_MODULE_DECLARE(mcuboot);
int bs_peruser_system_specific(const struct nmgr_hdr *hdr, const char *buffer,
int len, zcbor_state_t *cs)
{
int mgmt_rc = MGMT_ERR_ENOTSUP;
STRUCT_SECTION_FOREACH(mcuboot_bs_custom_handlers, function) {
if (function->handler) {
mgmt_rc = function->handler(hdr, buffer, len, cs);
if (mgmt_rc != MGMT_ERR_ENOTSUP) {
break;
}
}
}
if (mgmt_rc == MGMT_ERR_ENOTSUP) {
zcbor_map_start_encode(cs, 10);
zcbor_tstr_put_lit(cs, "rc");
zcbor_uint32_put(cs, mgmt_rc);
zcbor_map_end_encode(cs, 10);
}
return MGMT_ERR_OK;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,20 @@
#
# Copyright (c) 2021 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
# These configurations should be used when using nrf/samples/bootloader
# as the immutable bootloader (B0), and MCUBoot as the second stage updateable
# bootloader.
# Set ECDSA as signing mechanism
CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256=y
# Use crypto backend from B0
CONFIG_BOOT_NRF_EXTERNAL_CRYPTO=y
CONFIG_SECURE_BOOT_CRYPTO=y
CONFIG_SB_CRYPTO_CLIENT_ECDSA_SECP256R1=y
CONFIG_SB_CRYPTO_CLIENT_SHA256=y
CONFIG_BL_SHA256_EXT_API_REQUIRED=y
CONFIG_BL_SECP256R1_EXT_API_REQUIRED=y

View File

@@ -0,0 +1,196 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2020 Arm Limited
* Copyright (c) 2020-2023 Nordic Semiconductor ASA
*/
#include <assert.h>
#include <zephyr/kernel.h>
#include <zephyr/devicetree.h>
#include <zephyr/drivers/gpio.h>
#include "bootutil/image.h"
#include "bootutil_priv.h"
#include "bootutil/bootutil_log.h"
#include "bootutil/bootutil_public.h"
#include "bootutil/fault_injection_hardening.h"
#include "io/io.h"
#include "mcuboot_config/mcuboot_config.h"
BOOT_LOG_MODULE_DECLARE(mcuboot);
/* Variables passed outside of unit via poiters. */
static const struct flash_area *_fa_p;
static struct image_header _hdr = { 0 };
#if defined(MCUBOOT_VALIDATE_PRIMARY_SLOT) || defined(MCUBOOT_VALIDATE_PRIMARY_SLOT_ONCE)
/**
* Validate hash of a primary boot image.
*
* @param[in] fa_p flash area pointer
* @param[in] hdr boot image header pointer
*
* @return FIH_SUCCESS on success, error code otherwise
*/
fih_ret
boot_image_validate(const struct flash_area *fa_p,
struct image_header *hdr)
{
static uint8_t tmpbuf[BOOT_TMPBUF_SZ];
FIH_DECLARE(fih_rc, FIH_FAILURE);
/* NOTE: The first argument to boot_image_validate, for enc_state pointer,
* is allowed to be NULL only because the single image loader compiles
* with BOOT_IMAGE_NUMBER == 1, which excludes the code that uses
* the pointer from compilation.
*/
/* Validate hash */
if (IS_ENCRYPTED(hdr))
{
/* Clear the encrypted flag we didn't supply a key
* This flag could be set if there was a decryption in place
* was performed. We will try to validate the image, and if still
* encrypted the validation will fail, and go in panic mode
*/
hdr->ih_flags &= ~(ENCRYPTIONFLAGS);
}
FIH_CALL(bootutil_img_validate, fih_rc, NULL, 0, hdr, fa_p, tmpbuf,
BOOT_TMPBUF_SZ, NULL, 0, NULL);
FIH_RET(fih_rc);
}
#endif /* MCUBOOT_VALIDATE_PRIMARY_SLOT || MCUBOOT_VALIDATE_PRIMARY_SLOT_ONCE*/
#if defined(MCUBOOT_VALIDATE_PRIMARY_SLOT_ONCE)
inline static fih_ret
boot_image_validate_once(const struct flash_area *fa_p,
struct image_header *hdr)
{
static struct boot_swap_state state;
int rc;
FIH_DECLARE(fih_rc, FIH_FAILURE);
memset(&state, 0, sizeof(struct boot_swap_state));
rc = boot_read_swap_state(fa_p, &state);
if (rc != 0)
FIH_RET(FIH_FAILURE);
if (state.magic != BOOT_MAGIC_GOOD
|| state.image_ok != BOOT_FLAG_SET) {
/* At least validate the image once */
FIH_CALL(boot_image_validate, fih_rc, fa_p, hdr);
if (FIH_NOT_EQ(fih_rc, FIH_SUCCESS)) {
FIH_RET(FIH_FAILURE);
}
if (state.magic != BOOT_MAGIC_GOOD) {
rc = boot_write_magic(fa_p);
if (rc != 0)
FIH_RET(FIH_FAILURE);
}
rc = boot_write_image_ok(fa_p);
if (rc != 0)
FIH_RET(FIH_FAILURE);
}
FIH_RET(FIH_SUCCESS);
}
#endif
/**
* Validates that an image in a slot is OK to boot.
*
* @param[in] slot Slot number to check
* @param[out] rsp Parameters for booting image, on success
*
* @return FIH_SUCCESS on success; non-zero on failure.
*/
static fih_ret validate_image_slot(int slot, struct boot_rsp *rsp)
{
int rc = -1;
FIH_DECLARE(fih_rc, FIH_FAILURE);
rc = flash_area_open(slot, &_fa_p);
assert(rc == 0);
rc = boot_image_load_header(_fa_p, &_hdr);
if (rc != 0) {
goto other;
}
#ifdef MCUBOOT_VALIDATE_PRIMARY_SLOT
FIH_CALL(boot_image_validate, fih_rc, _fa_p, &_hdr);
if (FIH_NOT_EQ(fih_rc, FIH_SUCCESS)) {
goto other;
}
#elif defined(MCUBOOT_VALIDATE_PRIMARY_SLOT_ONCE)
FIH_CALL(boot_image_validate_once, fih_rc, _fa_p, &_hdr);
if (FIH_NOT_EQ(fih_rc, FIH_SUCCESS)) {
goto other;
}
#else
fih_rc = FIH_SUCCESS;
#endif /* MCUBOOT_VALIDATE_PRIMARY_SLOT */
rsp->br_flash_dev_id = flash_area_get_device_id(_fa_p);
rsp->br_image_off = flash_area_get_off(_fa_p);
rsp->br_hdr = &_hdr;
other:
flash_area_close(_fa_p);
FIH_RET(fih_rc);
}
/**
* Gather information on image and prepare for booting. Will boot from main
* image if none of the enabled entrance modes for the firmware loader are set,
* otherwise will boot the firmware loader. Note: firmware loader must be a
* valid signed image with the same signing key as the application image.
*
* @param[out] rsp Parameters for booting image, on success
*
* @return FIH_SUCCESS on success; non-zero on failure.
*/
fih_ret
boot_go(struct boot_rsp *rsp)
{
bool boot_firmware_loader = false;
FIH_DECLARE(fih_rc, FIH_FAILURE);
#ifdef CONFIG_BOOT_FIRMWARE_LOADER_ENTRANCE_GPIO
if (io_detect_pin() &&
!io_boot_skip_serial_recovery()) {
boot_firmware_loader = true;
}
#endif
#ifdef CONFIG_BOOT_FIRMWARE_LOADER_PIN_RESET
if (io_detect_pin_reset()) {
boot_firmware_loader = true;
}
#endif
#ifdef CONFIG_BOOT_FIRMWARE_LOADER_BOOT_MODE
if (io_detect_boot_mode()) {
boot_firmware_loader = true;
}
#endif
/* Check if firmware loader button is pressed. TODO: check all entrance methods */
if (boot_firmware_loader == true) {
FIH_CALL(validate_image_slot, fih_rc, FLASH_AREA_IMAGE_SECONDARY(0), rsp);
if (FIH_EQ(fih_rc, FIH_SUCCESS)) {
FIH_RET(fih_rc);
}
}
FIH_CALL(validate_image_slot, fih_rc, FLASH_AREA_IMAGE_PRIMARY(0), rsp);
#ifdef CONFIG_BOOT_FIRMWARE_LOADER_NO_APPLICATION
if (FIH_NOT_EQ(fih_rc, FIH_SUCCESS)) {
FIH_CALL(validate_image_slot, fih_rc, FLASH_AREA_IMAGE_SECONDARY(0), rsp);
}
#endif
FIH_RET(fih_rc);
}

View File

@@ -0,0 +1,174 @@
/*
* Copyright (c) 2018 Nordic Semiconductor ASA
* Copyright (c) 2015 Runtime Inc
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/kernel.h>
#include <zephyr/devicetree.h>
#include <zephyr/drivers/flash.h>
#include "target.h"
#include <flash_map_backend/flash_map_backend.h>
#include <sysflash/sysflash.h>
#include "bootutil/bootutil_log.h"
BOOT_LOG_MODULE_DECLARE(mcuboot);
#if (!defined(CONFIG_XTENSA) && DT_HAS_CHOSEN(zephyr_flash_controller))
#define FLASH_DEVICE_ID SOC_FLASH_0_ID
#define FLASH_DEVICE_BASE CONFIG_FLASH_BASE_ADDRESS
#define FLASH_DEVICE_NODE DT_CHOSEN(zephyr_flash_controller)
#elif (defined(CONFIG_XTENSA) && DT_NODE_EXISTS(DT_INST(0, jedec_spi_nor)))
#define FLASH_DEVICE_ID SPI_FLASH_0_ID
#define FLASH_DEVICE_BASE 0
#define FLASH_DEVICE_NODE DT_INST(0, jedec_spi_nor)
#elif defined(CONFIG_SOC_FAMILY_ESPRESSIF_ESP32)
#define FLASH_DEVICE_ID SPI_FLASH_0_ID
#define FLASH_DEVICE_BASE 0
#define FLASH_DEVICE_NODE DT_CHOSEN(zephyr_flash_controller)
#else
#error "FLASH_DEVICE_ID could not be determined"
#endif
static const struct device *flash_dev = DEVICE_DT_GET(FLASH_DEVICE_NODE);
int flash_device_base(uint8_t fd_id, uintptr_t *ret)
{
if (fd_id != FLASH_DEVICE_ID) {
BOOT_LOG_ERR("invalid flash ID %d; expected %d",
fd_id, FLASH_DEVICE_ID);
return -EINVAL;
}
*ret = FLASH_DEVICE_BASE;
return 0;
}
/*
* This depends on the mappings defined in sysflash.h.
* MCUBoot uses continuous numbering for the primary slot, the secondary slot,
* and the scratch while zephyr might number it differently.
*/
int flash_area_id_from_multi_image_slot(int image_index, int slot)
{
switch (slot) {
case 0: return FLASH_AREA_IMAGE_PRIMARY(image_index);
#if !defined(CONFIG_SINGLE_APPLICATION_SLOT)
case 1: return FLASH_AREA_IMAGE_SECONDARY(image_index);
#endif
#if defined(CONFIG_BOOT_SWAP_USING_SCRATCH)
case 2: return FLASH_AREA_IMAGE_SCRATCH;
#endif
}
return -EINVAL; /* flash_area_open will fail on that */
}
int flash_area_id_from_image_slot(int slot)
{
return flash_area_id_from_multi_image_slot(0, slot);
}
int flash_area_id_to_multi_image_slot(int image_index, int area_id)
{
if (area_id == FLASH_AREA_IMAGE_PRIMARY(image_index)) {
return 0;
}
#if !defined(CONFIG_SINGLE_APPLICATION_SLOT)
if (area_id == FLASH_AREA_IMAGE_SECONDARY(image_index)) {
return 1;
}
#endif
BOOT_LOG_ERR("invalid flash area ID");
return -1;
}
#if defined(CONFIG_MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD)
int flash_area_id_from_direct_image(int image_id)
{
switch (image_id) {
case 0:
case 1:
return FIXED_PARTITION_ID(slot0_partition);
#if FIXED_PARTITION_EXISTS(slot1_partition)
case 2:
return FIXED_PARTITION_ID(slot1_partition);
#endif
#if FIXED_PARTITION_EXISTS(slot2_partition)
case 3:
return FIXED_PARTITION_ID(slot2_partition);
#endif
#if FIXED_PARTITION_EXISTS(slot3_partition)
case 4:
return FIXED_PARTITION_ID(slot3_partition);
#endif
#if FIXED_PARTITION_EXISTS(slot4_partition)
case 5:
return FIXED_PARTITION_ID(slot4_partition);
#endif
#if FIXED_PARTITION_EXISTS(slot5_partition)
case 6:
return FIXED_PARTITION_ID(slot5_partition);
#endif
}
return -EINVAL;
}
#endif
int flash_area_sector_from_off(off_t off, struct flash_sector *sector)
{
int rc;
struct flash_pages_info page;
rc = flash_get_page_info_by_offs(flash_dev, off, &page);
if (rc) {
return rc;
}
sector->fs_off = page.start_offset;
sector->fs_size = page.size;
return rc;
}
uint8_t flash_area_get_device_id(const struct flash_area *fa)
{
(void)fa;
return FLASH_DEVICE_ID;
}
#define ERASED_VAL 0xff
__weak uint8_t flash_area_erased_val(const struct flash_area *fap)
{
(void)fap;
return ERASED_VAL;
}
int flash_area_get_sector(const struct flash_area *fap, off_t off,
struct flash_sector *fsp)
{
struct flash_pages_info fpi;
int rc;
if (off >= fap->fa_size) {
return -ERANGE;
}
rc = flash_get_page_info_by_offs(fap->fa_dev, fap->fa_off + off,
&fpi);
if (rc == 0) {
fsp->fs_off = fpi.start_offset - fap->fa_off;
fsp->fs_size = fpi.size;
}
return rc;
}

View File

@@ -0,0 +1,104 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* @file
* @brief Legacy flash fallbacks
*
* This file contains hacks for flash drivers without page layout
* support. They're hacks because they guess a page layout that may be
* incorrect, but is likely to "work". Needless to say, such guesswork
* is undesirable in trusted bootloader code.
*
* The behavior is:
*
* - If FLASH_AREA_IMAGE_SECTOR_SIZE is defined (this was used by
* older Zephyr ports), the image sectors have uniform sector sizes.
* We also assume that's the size of the scratch sectors.
*
* - Otherwise, we assume that the size of the entire scratch area is
* a least common multiple of all sector sizes, and use that as
* FLASH_AREA_IMAGE_SECTOR_SIZE.
*/
#include "bootutil/bootutil_log.h"
#include <flash_map_backend/flash_map_backend.h>
#include <inttypes.h>
#include <target.h>
#warning "The flash driver lacks page layout support; falling back on hacks."
#if !defined(FLASH_AREA_IMAGE_SECTOR_SIZE)
#define FLASH_AREA_IMAGE_SECTOR_SIZE FLASH_AREA_IMAGE_SCRATCH_SIZE
#endif
BOOT_LOG_MODULE_DECLARE(mcuboot);
/*
* Lookup the sector map for a given flash area. This should fill in
* `ret` with all of the sectors in the area. `*cnt` will be set to
* the storage at `ret` and should be set to the final number of
* sectors in this area.
*/
int flash_area_get_sectors(int idx, uint32_t *cnt, struct flash_sector *ret)
{
const struct flash_area *fa;
uint32_t max_cnt = *cnt;
uint32_t rem_len;
int rc = -1;
if (flash_area_open(idx, &fa)) {
goto out;
}
BOOT_LOG_DBG("area %d: offset=0x%x, length=0x%x", idx, fa->fa_off,
fa->fa_size);
if (*cnt < 1) {
goto fa_close_out;
}
rem_len = fa->fa_size;
*cnt = 0;
while (rem_len > 0 && *cnt < max_cnt) {
if (rem_len < FLASH_AREA_IMAGE_SECTOR_SIZE) {
BOOT_LOG_ERR("area %d size 0x%x not divisible by sector size 0x%x",
idx, fa->fa_size, FLASH_AREA_IMAGE_SECTOR_SIZE);
goto fa_close_out;
}
ret[*cnt].fs_off = FLASH_AREA_IMAGE_SECTOR_SIZE * (*cnt);
ret[*cnt].fs_size = FLASH_AREA_IMAGE_SECTOR_SIZE;
*cnt = *cnt + 1;
rem_len -= FLASH_AREA_IMAGE_SECTOR_SIZE;
}
if (*cnt >= max_cnt) {
BOOT_LOG_ERR("flash area %d sector count overflow", idx);
goto fa_close_out;
}
rc = 0;
fa_close_out:
flash_area_close(fa);
out:
return rc;
}

View File

@@ -0,0 +1,95 @@
/*
* Copyright (c) 2021 Nordic Semiconductor ASA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <assert.h>
#include <zephyr/kernel.h>
#include "bootutil/image.h"
#include "bootutil/bootutil.h"
#include "bootutil/fault_injection_hardening.h"
#include "flash_map_backend/flash_map_backend.h"
/* @retval 0: header was read/populated
* FIH_FAILURE: image is invalid,
* BOOT_HOOK_REGULAR if hook not implemented for the image-slot,
* othervise an error-code value.
*/
int boot_read_image_header_hook(int img_index, int slot,
struct image_header *img_hed)
{
if (img_index == 1 && slot == 0) {
img_hed->ih_magic = IMAGE_MAGIC;
return 0;
}
return BOOT_HOOK_REGULAR;
}
/* @retval FIH_SUCCESS: image is valid,
* FIH_FAILURE: image is invalid,
* fih encoded BOOT_HOOK_REGULAR if hook not implemented for
* the image-slot.
*/
fih_ret boot_image_check_hook(int img_index, int slot)
{
if (img_index == 1 && slot == 0) {
FIH_RET(FIH_SUCCESS);
}
FIH_RET(FIH_BOOT_HOOK_REGULAR);
}
int boot_perform_update_hook(int img_index, struct image_header *img_head,
const struct flash_area *area)
{
if (img_index == 1) {
return 0;
}
return BOOT_HOOK_REGULAR;
}
int boot_read_swap_state_primary_slot_hook(int image_index,
struct boot_swap_state *state)
{
if (image_index == 1) {
state->magic = BOOT_MAGIC_UNSET;
state->swap_type = BOOT_SWAP_TYPE_NONE;
state->image_num = image_index ; // ?
state->copy_done = BOOT_FLAG_UNSET;
state->image_ok = BOOT_FLAG_UNSET;
return 0;
}
return BOOT_HOOK_REGULAR;
}
int boot_copy_region_post_hook(int img_index, const struct flash_area *area,
size_t size)
{
return 0;
}
int boot_serial_uploaded_hook(int img_index, const struct flash_area *area,
size_t size)
{
return 0;
}
int boot_img_install_stat_hook(int image_index, int slot, int *img_install_stat)
{
return BOOT_HOOK_REGULAR;
}

View File

@@ -0,0 +1,23 @@
/*
* Copyright (c) 2020 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef H_ARM_CLEANUP_
#define H_ARM_CLEANUP_
/**
* Cleanup interrupt priority and interupt enable registers.
*/
void cleanup_arm_nvic(void);
#if defined(CONFIG_CPU_HAS_ARM_MPU) || defined(CONFIG_CPU_HAS_NXP_MPU)
/**
* Cleanup all ARM MPU region configuration
*/
void z_arm_clear_arm_mpu_config(void);
#endif
#endif

View File

@@ -0,0 +1,9 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/linker/iterable_sections.h>
ITERABLE_SECTION_ROM(mcuboot_bs_custom_handlers, 4)

View File

@@ -0,0 +1,41 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef H_BOOT_SERIAL_EXTENTIONS_
#define H_BOOT_SERIAL_EXTENTIONS_
#include <zephyr/kernel.h>
#include <zephyr/sys/util_macro.h>
#include <zephyr/sys/iterable_sections.h>
/**
* Callback handler prototype for boot serial extensions.
*
* @param[in] hdr MCUmgr header
* @param[in] buffer Buffer with first MCUmgr message
* @param[in] len Length of data in buffer
* @param[out] cs Response
*
* @return MGMT_ERR_ENOTSUP to run other handlers, other MGMT_ERR_* value
* when expected handler has ran.
*/
typedef int (*bs_custom_handler_cb)(const struct nmgr_hdr *hdr,
const char *buffer, int len,
zcbor_state_t *cs);
struct mcuboot_bs_custom_handlers {
const bs_custom_handler_cb handler;
};
/* Used to create an iterable section containing a boot serial handler
* function
*/
#define MCUMGR_HANDLER_DEFINE(name, _handler) \
STRUCT_SECTION_ITERABLE(mcuboot_bs_custom_handlers, name) = { \
.handler = _handler, \
}
#endif /* H_BOOT_SERIAL_EXTENTIONS_ */

View File

@@ -0,0 +1,104 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/
#ifndef H_DECOMPRESSION_
#define H_DECOMPRESSION_
#include <stdint.h>
#include <stdbool.h>
#include <inttypes.h>
#include "bootutil/bootutil.h"
#include "bootutil/bootutil_public.h"
#include "bootutil/image.h"
#include "../src/bootutil_priv.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Checks if a compressed image header is valid.
*
* @param hdr Image header.
* @param fap Flash area of the slot.
* @param state Bootloader state object.
*
* @return true if valid; false if invalid.
*/
bool boot_is_compressed_header_valid(const struct image_header *hdr, const struct flash_area *fap,
struct boot_loader_state *state);
/**
* Reads in compressed image data from a slot, decompresses it and writes it out to a destination
* slot, including corresponding image headers and TLVs.
*
* @param state Bootloader state object.
* @param fap_src Flash area of the source slot.
* @param fap_dst Flash area of the destination slot.
* @param off_src Offset of the source slot to read from (should be 0).
* @param off_dst Offset of the destination slot to write to (should be 0).
* @param sz Size of the source slot data.
* @param buf Temporary buffer for reading data from.
* @param buf_size Size of temporary buffer.
*
* @return 0 on success; nonzero on failure.
*/
int boot_copy_region_decompress(struct boot_loader_state *state, const struct flash_area *fap_src,
const struct flash_area *fap_dst, uint32_t off_src,
uint32_t off_dst, uint32_t sz, uint8_t *buf, size_t buf_size);
/**
* Gets the total data size (excluding headers and TLVs) of a compressed image when it is
* decompressed.
*
* @param hdr Image header.
* @param fap Flash area of the slot.
* @param img_decomp_size Pointer to variable that will be updated with the decompressed image
* size.
*
* @return 0 on success; nonzero on failure.
*/
int bootutil_get_img_decomp_size(const struct image_header *hdr, const struct flash_area *fap,
uint32_t *img_decomp_size);
/**
* Calculate MCUboot-compatible image hash of compressed image slot.
*
* @param enc_state Not currently used, set to NULL.
* @param image_index Image number.
* @param hdr Image header.
* @param fap Flash area of the slot.
* @param tmp_buf Temporary buffer for reading data from.
* @param tmp_buf_sz Size of temporary buffer.
* @param hash_result Pointer to a variable that will be updated with the image hash.
* @param seed Not currently used, set to NULL.
* @param seed_len Not currently used, set to 0.
*
* @return 0 on success; nonzero on failure.
*/
int bootutil_img_hash_decompress(struct enc_key_data *enc_state, int image_index,
struct image_header *hdr, const struct flash_area *fap,
uint8_t *tmp_buf, uint32_t tmp_buf_sz, uint8_t *hash_result,
uint8_t *seed, int seed_len);
/**
* Calculates the size that the compressed image protected TLV section will occupy once the image
* has been decompressed.
*
* @param hdr Image header.
* @param fap Flash area of the slot.
* @param sz Pointer to variable that will be updated with the protected TLV size.
*
* @return 0 on success; nonzero on failure.
*/
int boot_size_protected_tlvs(const struct image_header *hdr, const struct flash_area *fap_src,
uint32_t *sz);
#ifdef __cplusplus
}
#endif
#endif /* H_DECOMPRESSION_ */

View File

@@ -0,0 +1,44 @@
/*
* Configuration of mbedTLS containing only the ASN.1 parser.
*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* Copyright (C) 2016, Linaro Ltd
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of mbed TLS (https://tls.mbed.org)
*/
/*
* Minimal configuration for using TLS in the bootloader
*
* - RSA or ECDSA signature verification
*/
#ifndef MBEDTLS_CONFIG_ASN1_H
#define MBEDTLS_CONFIG_ASN1_H
#define MBEDTLS_PLATFORM_C
#define MBEDTLS_PLATFORM_MEMORY
#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
/* mbed TLS modules */
#define MBEDTLS_ASN1_PARSE_C
// #define MBEDTLS_ASN1_WRITE_C
// #define MBEDTLS_BIGNUM_C
// #define MBEDTLS_MD_C
// #define MBEDTLS_OID_C
// #define MBEDTLS_SHA256_C
#endif /* MBEDTLS_CONFIG_ASN1_H */

View File

@@ -0,0 +1,94 @@
/*
* Minimal configuration for using TLS in the bootloader
*
* Copyright (C) 2006-2021, ARM Limited, All Rights Reserved
* Copyright (C) 2016, Linaro Ltd
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of mbed TLS (https://tls.mbed.org)
*/
/*
* Minimal configuration for using TLS in the bootloader
*
* - RSA or ECDSA signature verification
*/
#ifndef MCUBOOT_MBEDTLS_CONFIG_ECDSA
#define MCUBOOT_MBEDTLS_CONFIG_ECDSA
#ifdef CONFIG_MCUBOOT_SERIAL
/* Mcuboot uses mbedts-base64 for serial protocol encoding. */
#define MBEDTLS_BASE64_C
#endif
/* System support */
#define MBEDTLS_PLATFORM_C
#define MBEDTLS_PLATFORM_MEMORY
#define MBEDTLS_MEMORY_BUFFER_ALLOC_C
#define MBEDTLS_NO_PLATFORM_ENTROPY
#define MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
/* STD functions */
#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
#define MBEDTLS_PLATFORM_EXIT_ALT
#define MBEDTLS_PLATFORM_PRINTF_ALT
#define MBEDTLS_PLATFORM_SNPRINTF_ALT
#if !defined(CONFIG_ARM)
#define MBEDTLS_HAVE_ASM
#endif
#define MBEDTLS_ECDSA_C
#define MBEDTLS_ECDH_C
/* mbed TLS modules */
#define MBEDTLS_ASN1_PARSE_C
#define MBEDTLS_ASN1_WRITE_C
#define MBEDTLS_ECP_C
#define MBEDTLS_ECP_DP_SECP256R1_ENABLED
#define MBEDTLS_ECP_NIST_OPTIM
#define MBEDTLS_BIGNUM_C
#define MBEDTLS_MD_C
#define MBEDTLS_OID_C
#define MBEDTLS_SHA256_C
#define MBEDTLS_SHA256_SMALLER
#define MBEDTLS_SHA224_C
#define MBEDTLS_AES_C
/* Bring in support for x509. */
#define MBEDTLS_X509_USE_C
#define MBEDTLS_PK_C
#define MBEDTLS_PK_PARSE_C
#define MBEDTLS_X509_CRT_PARSE_C
/* Save RAM by adjusting to our exact needs */
#define MBEDTLS_MPI_MAX_SIZE 32
#define MBEDTLS_SSL_MAX_CONTENT_LEN 1024
/* Save ROM and a few bytes of RAM by specifying our own ciphersuite list */
#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8
/* If encryption is being used, also enable the features needed for
* that. */
#if defined(MCUBOOT_ENC_IMAGES)
#define MBEDTLS_CIPHER_MODE_CTR
#define MBEDTLS_CIPHER_C
#define MBEDTLS_NIST_KW_C
#endif /* MCUBOOT_ENC_IMAGES */
#endif /* MCUBOOT_MBEDTLS_CONFIG_ECDSA */

View File

@@ -0,0 +1,76 @@
/*
* Configuration of mbedTLS containing only the ASN.1 parser.
*
* Copyright (C) 2006-2021, ARM Limited, All Rights Reserved
* Copyright (C) 2016, Linaro Ltd
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of mbed TLS (https://tls.mbed.org)
*/
/*
* Minimal configuration for using TLS in the bootloader
*
* - ed25519 signature verification
*/
#ifndef MCUBOOT_MBEDTLS_CONFIG_ED25519
#define MCUBOOT_MBEDTLS_CONFIG_ED25519
#ifdef CONFIG_MCUBOOT_SERIAL
/* Mcuboot uses mbedts-base64 for serial protocol encoding. */
#define MBEDTLS_BASE64_C
#endif
/* System support */
#define MBEDTLS_PLATFORM_C
#define MBEDTLS_PLATFORM_MEMORY
#define MBEDTLS_MEMORY_BUFFER_ALLOC_C
#define MBEDTLS_NO_PLATFORM_ENTROPY
#define MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
/* STD functions */
#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
#define MBEDTLS_PLATFORM_EXIT_ALT
#define MBEDTLS_PLATFORM_PRINTF_ALT
#define MBEDTLS_PLATFORM_SNPRINTF_ALT
#if !defined(CONFIG_ARM)
#define MBEDTLS_HAVE_ASM
#endif
#define MBEDTLS_CIPHER_MODE_CTR
/* mbed TLS modules */
#define MBEDTLS_ASN1_PARSE_C
#define MBEDTLS_BIGNUM_C
#define MBEDTLS_MD_C
#define MBEDTLS_OID_C
#define MBEDTLS_SHA256_C
#define MBEDTLS_SHA256_SMALLER
#define MBEDTLS_SHA224_C
#define MBEDTLS_SHA512_C
#define MBEDTLS_AES_C
/* Save RAM by adjusting to our exact needs */
#define MBEDTLS_MPI_MAX_SIZE 64
//#define MBEDTLS_SSL_MAX_CONTENT_LEN 1024
/* Save ROM and a few bytes of RAM by specifying our own ciphersuite list */
#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8
#endif /* MCUBOOT_MBEDTLS_CONFIG_RSA */

View File

@@ -0,0 +1,66 @@
/*
* Minimal configuration for using TLS in the bootloader
*
* Copyright (C) 2006-2021, ARM Limited, All Rights Reserved
* Copyright (C) 2016, Linaro Ltd
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of mbed TLS (https://tls.mbed.org)
*/
/*
* Minimal configuration for using TLS in the bootloader
*
* - RSA or ECDSA signature verification
*/
#ifndef MCUBOOT_MBEDTLS_CONFIG_KW
#define MCUBOOT_MBEDTLS_CONFIG_KW
#ifdef CONFIG_MCUBOOT_SERIAL
/* Mcuboot uses mbedts-base64 for serial protocol encoding. */
#define MBEDTLS_BASE64_C
#endif
/* System support */
#define MBEDTLS_PLATFORM_C
#define MBEDTLS_PLATFORM_MEMORY
#define MBEDTLS_MEMORY_BUFFER_ALLOC_C
#define MBEDTLS_NO_PLATFORM_ENTROPY
#define MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
/* STD functions */
#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
#define MBEDTLS_PLATFORM_EXIT_ALT
#define MBEDTLS_PLATFORM_PRINTF_ALT
#define MBEDTLS_PLATFORM_SNPRINTF_ALT
#define MBEDTLS_ASN1_PARSE_C
#if !defined(CONFIG_ARM)
#define MBEDTLS_HAVE_ASM
#endif
#define MBEDTLS_CIPHER_MODE_CTR
#define MBEDTLS_SHA256_C
#define MBEDTLS_SHA256_SMALLER
#define MBEDTLS_SHA224_C
#define MBEDTLS_AES_C
#define MBEDTLS_CIPHER_C
#define MBEDTLS_NIST_KW_C
#endif /* MCUBOOT_MBEDTLS_CONFIG_KW */

View File

@@ -0,0 +1,80 @@
/*
* Minimal configuration for using TLS in the bootloader
*
* Copyright (C) 2006-2021, ARM Limited, All Rights Reserved
* Copyright (C) 2016, Linaro Ltd
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of mbed TLS (https://tls.mbed.org)
*/
/*
* Minimal configuration for using TLS in the bootloader
*
* - RSA signature verification + NIST Keywrapping support
*/
#ifndef MCUBOOT_MBEDTLS_CONFIG_RSA_KW
#define MCUBOOT_MBEDTLS_CONFIG_RSA_KW
#ifdef CONFIG_MCUBOOT_SERIAL
/* Mcuboot uses mbedts-base64 for serial protocol encoding. */
#define MBEDTLS_BASE64_C
#endif
/* System support */
#define MBEDTLS_PLATFORM_C
#define MBEDTLS_PLATFORM_MEMORY
#define MBEDTLS_MEMORY_BUFFER_ALLOC_C
#define MBEDTLS_NO_PLATFORM_ENTROPY
#define MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
/* STD functions */
#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
#define MBEDTLS_PLATFORM_EXIT_ALT
#define MBEDTLS_PLATFORM_PRINTF_ALT
#define MBEDTLS_PLATFORM_SNPRINTF_ALT
#if !defined(CONFIG_ARM)
#define MBEDTLS_HAVE_ASM
#endif
#define MBEDTLS_RSA_C
#define MBEDTLS_PKCS1_V21
#define MBEDTLS_CIPHER_MODE_CTR
/* mbed TLS modules */
#define MBEDTLS_ASN1_PARSE_C
#define MBEDTLS_BIGNUM_C
#define MBEDTLS_MD_C
#define MBEDTLS_OID_C
#define MBEDTLS_SHA256_C
#define MBEDTLS_SHA256_SMALLER
#define MBEDTLS_SHA224_C
#define MBEDTLS_AES_C
#define MBEDTLS_CIPHER_C
#define MBEDTLS_NIST_KW_C
/* Save RAM by adjusting to our exact needs */
#define MBEDTLS_MPI_MAX_SIZE 256
#define MBEDTLS_SSL_MAX_CONTENT_LEN 1024
/* Save ROM and a few bytes of RAM by specifying our own ciphersuite list */
#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8
#endif /* MCUBOOT_MBEDTLS_CONFIG_RSA_KW */

View File

@@ -0,0 +1,83 @@
/*
* Minimal configuration for using TLS in the bootloader
*
* Copyright (C) 2006-2021, ARM Limited, All Rights Reserved
* Copyright (C) 2016, Linaro Ltd
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of mbed TLS (https://tls.mbed.org)
*/
/*
* Minimal configuration for using TLS in the bootloader
*
* - RSA or ECDSA signature verification
*/
#ifndef MCUBOOT_MBEDTLS_CONFIG_RSA
#define MCUBOOT_MBEDTLS_CONFIG_RSA
#ifdef CONFIG_MCUBOOT_SERIAL
/* Mcuboot uses mbedts-base64 for serial protocol encoding. */
#define MBEDTLS_BASE64_C
#endif
/* System support */
#define MBEDTLS_PLATFORM_C
#define MBEDTLS_PLATFORM_MEMORY
#define MBEDTLS_MEMORY_BUFFER_ALLOC_C
#define MBEDTLS_NO_PLATFORM_ENTROPY
#define MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
/* STD functions */
#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
#define MBEDTLS_PLATFORM_EXIT_ALT
#define MBEDTLS_PLATFORM_PRINTF_ALT
#define MBEDTLS_PLATFORM_SNPRINTF_ALT
#if !defined(CONFIG_ARM)
#define MBEDTLS_HAVE_ASM
#endif
#define MBEDTLS_RSA_C
#define MBEDTLS_PKCS1_V21
#define MBEDTLS_CIPHER_MODE_CTR
/* mbed TLS modules */
#define MBEDTLS_ASN1_PARSE_C
#define MBEDTLS_ASN1_WRITE_C
#define MBEDTLS_BIGNUM_C
#define MBEDTLS_MD_C
#define MBEDTLS_OID_C
#define MBEDTLS_SHA256_C
#define MBEDTLS_SHA256_SMALLER
#define MBEDTLS_SHA224_C
#define MBEDTLS_AES_C
/* Save RAM by adjusting to our exact needs */
#if (CONFIG_BOOT_SIGNATURE_TYPE_RSA_LEN == 3072)
#define MBEDTLS_MPI_MAX_SIZE 384
#else
#define MBEDTLS_MPI_MAX_SIZE 256
#endif
#define MBEDTLS_SSL_MAX_CONTENT_LEN 1024
/* Save ROM and a few bytes of RAM by specifying our own ciphersuite list */
#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8
#endif /* MCUBOOT_MBEDTLS_CONFIG_RSA */

View File

@@ -0,0 +1,113 @@
/*
* Copyright (c) 2018 Nordic Semiconductor ASA
* Copyright (c) 2015 Runtime Inc
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __FLASH_MAP_BACKEND_H__
#define __FLASH_MAP_BACKEND_H__
#include <zephyr/storage/flash_map.h> // the zephyr flash_map
#ifdef __cplusplus
extern "C" {
#endif
/**
*
* Provides abstraction of flash regions for type of use.
* I.e. dude where's my image?
*
* System will contain a map which contains flash areas. Every
* region will contain flash identifier, offset within flash and length.
*
* 1. This system map could be in a file within filesystem (Initializer
* must know/figure out where the filesystem is at).
* 2. Map could be at fixed location for project (compiled to code)
* 3. Map could be at specific place in flash (put in place at mfg time).
*
* Note that the map you use must be valid for BSP it's for,
* match the linker scripts when platform executes from flash,
* and match the target offset specified in download script.
*/
#include <inttypes.h>
#include <sys/types.h>
/*
* Retrieve a memory-mapped flash device's base address.
*
* On success, the address will be stored in the value pointed to by
* ret.
*
* Returns 0 on success, or an error code on failure.
*/
int flash_device_base(uint8_t fd_id, uintptr_t *ret);
int flash_area_id_from_image_slot(int slot);
int flash_area_id_from_multi_image_slot(int image_index, int slot);
/**
* Converts the specified flash area ID and image index (in multi-image setup)
* to an image slot index.
*
* Returns image slot index (0 or 1), or -1 if ID doesn't correspond to an image
* slot.
*/
int flash_area_id_to_multi_image_slot(int image_index, int area_id);
/* Retrieve the flash sector a given offset belongs to.
*
* Returns 0 on success, or an error code on failure.
*/
int flash_area_sector_from_off(off_t off, struct flash_sector *sector);
static inline uint32_t flash_area_get_off(const struct flash_area *fa)
{
return (uint32_t)fa->fa_off;
}
static inline uint32_t flash_area_get_size(const struct flash_area *fa)
{
return (uint32_t)fa->fa_size;
}
static inline uint8_t flash_area_get_id(const struct flash_area *fa)
{
return fa->fa_id;
}
uint8_t flash_area_get_device_id(const struct flash_area *fa);
/*
* Returns the value expected to be read when accessing any erased
* flash byte.
*/
uint8_t flash_area_erased_val(const struct flash_area *fap);
static inline uint32_t flash_sector_get_off(const struct flash_sector *fs)
{
return fs->fs_off;
}
static inline uint32_t flash_sector_get_size(const struct flash_sector *fs)
{
return fs->fs_size;
}
/* Retrieve the flash sector withing given flash area, at a given offset.
*
* @param fa flash area where the sector is taken from.
* @param off offset within flash area.
* @param sector structure of sector information.
* Returns 0 on success, -ERANGE if @p off is beyond flash area size,
* other negative errno code on failure.
*/
int flash_area_get_sector(const struct flash_area *fa, off_t off,
struct flash_sector *fs);
#ifdef __cplusplus
}
#endif
#endif /* __FLASH_MAP_BACKEND_H__ */

View File

@@ -0,0 +1,79 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#ifndef __HAL_BSP_H_
#define __HAL_BSP_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <inttypes.h>
/*
* Initializes BSP; registers flash_map with the system.
*/
void hal_bsp_init(void);
/*
* Return pointer to flash device structure, given BSP specific
* flash id.
*/
struct hal_flash;
const struct hal_flash *hal_bsp_flash_dev(uint8_t flash_id);
/*
* Grows heap by given amount. XXX giving space back not implemented.
*/
void *_sbrk(int incr);
/*
* Report which memory areas should be included inside a coredump.
*/
struct hal_bsp_mem_dump {
void *hbmd_start;
uint32_t hbmd_size;
};
const struct hal_bsp_mem_dump *hal_bsp_core_dump(int *area_cnt);
/*
* Get unique HW identifier/serial number for platform.
* Returns the number of bytes filled in.
*/
#define HAL_BSP_MAX_ID_LEN 32
int hal_bsp_hw_id(uint8_t *id, int max_len);
#define HAL_BSP_POWER_ON (1)
#define HAL_BSP_POWER_WFI (2)
#define HAL_BSP_POWER_SLEEP (3)
#define HAL_BSP_POWER_DEEP_SLEEP (4)
#define HAL_BSP_POWER_OFF (5)
#define HAL_BSP_POWER_PERUSER (128)
int hal_bsp_power_state(int state);
/* Returns priority of given interrupt number */
uint32_t hal_bsp_get_nvic_priority(int irq_num, uint32_t pri);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,43 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#ifndef H_HAL_FLASH_
#define H_HAL_FLASH_
#ifdef __cplusplus
extern "C" {
#endif
#include <inttypes.h>
int hal_flash_read(uint8_t flash_id, uint32_t address, void *dst,
uint32_t num_bytes);
int hal_flash_write(uint8_t flash_id, uint32_t address, const void *src,
uint32_t num_bytes);
int hal_flash_erase_sector(uint8_t flash_id, uint32_t sector_address);
int hal_flash_erase(uint8_t flash_id, uint32_t address, uint32_t num_bytes);
uint8_t hal_flash_align(uint8_t flash_id);
int hal_flash_init(void);
#ifdef __cplusplus
}
#endif
#endif /* H_HAL_FLASH_ */

View File

@@ -0,0 +1,83 @@
/*
* Copyright (c) 2012-2014 Wind River Systems, Inc.
* Copyright (c) 2020 Arm Limited
* Copyright (c) 2021-2023 Nordic Semiconductor ASA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef H_IO_
#define H_IO_
#include <stddef.h>
#ifdef CONFIG_SOC_FAMILY_NORDIC_NRF
#include <helpers/nrfx_reset_reason.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* Initialises the configured LED.
*/
void io_led_init(void);
/*
* Sets value of the configured LED.
*/
void io_led_set(int value);
/*
* Checks if GPIO is set in the required way to remain in serial recovery mode
*
* @retval false for normal boot, true for serial recovery boot
*/
bool io_detect_pin(void);
/*
* Checks if board was reset using reset pin and if device should stay in
* serial recovery mode
*
* @retval false for normal boot, true for serial recovery boot
*/
bool io_detect_pin_reset(void);
/*
* Checks board boot mode via retention subsystem and if device should stay in
* serial recovery mode
*
* @retval false for normal boot, true for serial recovery boot
*/
bool io_detect_boot_mode(void);
#ifdef CONFIG_SOC_FAMILY_NORDIC_NRF
static inline bool io_boot_skip_serial_recovery()
{
uint32_t rr = nrfx_reset_reason_get();
return !(rr == 0 || (rr & NRFX_RESET_REASON_RESETPIN_MASK));
}
#else
static inline bool io_boot_skip_serial_recovery()
{
return false;
}
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,36 @@
/*
* Copyright (C) 2018 Open Source Foundries Limited
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _MCUBOOT_MBEDTLS_CONFIG_
#define _MCUBOOT_MBEDTLS_CONFIG_
/**
* @file
*
* This is the top-level mbedTLS configuration file for MCUboot. The
* configuration depends on the signature type, so this file just
* pulls in the right header depending on that setting.
*/
/*
* IMPORTANT:
*
* If you put any "generic" definitions in here, make sure to update
* the simulator build.rs accordingly.
*/
#if defined(CONFIG_BOOT_SIGNATURE_TYPE_RSA) || defined(CONFIG_BOOT_ENCRYPT_RSA)
#include "config-rsa.h"
#elif defined(CONFIG_BOOT_USE_PSA_CRYPTO) || defined(CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256) || \
defined(CONFIG_BOOT_ENCRYPT_EC256) || \
(defined(CONFIG_BOOT_ENCRYPT_X25519) && !defined(CONFIG_BOOT_SIGNATURE_TYPE_ED25519))
#include "config-asn1.h"
#elif defined(CONFIG_BOOT_SIGNATURE_TYPE_ED25519)
#include "config-ed25519.h"
#else
#error "Cannot configure mbedTLS; signature type is unknown."
#endif
#endif

View File

@@ -0,0 +1,424 @@
/*
* Copyright (c) 2018 Open Source Foundries Limited
* Copyright (c) 2019-2020 Arm Limited
* Copyright (c) 2019-2020 Linaro Limited
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __MCUBOOT_CONFIG_H__
#define __MCUBOOT_CONFIG_H__
#include <zephyr/devicetree.h>
#ifdef CONFIG_BOOT_SIGNATURE_TYPE_RSA
#define MCUBOOT_SIGN_RSA
# if (CONFIG_BOOT_SIGNATURE_TYPE_RSA_LEN != 2048 && \
CONFIG_BOOT_SIGNATURE_TYPE_RSA_LEN != 3072)
# error "Invalid RSA key size (must be 2048 or 3072)"
# else
# define MCUBOOT_SIGN_RSA_LEN CONFIG_BOOT_SIGNATURE_TYPE_RSA_LEN
# endif
#elif defined(CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256)
#define MCUBOOT_SIGN_EC256
#elif defined(CONFIG_BOOT_SIGNATURE_TYPE_ED25519)
#define MCUBOOT_SIGN_ED25519
#endif
#if defined(CONFIG_BOOT_USE_TINYCRYPT)
# if defined(CONFIG_MBEDTLS) || defined(CONFIG_BOOT_USE_CC310)
# error "One crypto library implementation allowed at a time."
# endif
#elif defined(CONFIG_MBEDTLS) && defined(CONFIG_BOOT_USE_CC310)
# error "One crypto library implementation allowed at a time."
#endif
#ifdef CONFIG_BOOT_USE_MBEDTLS
#define MCUBOOT_USE_MBED_TLS
#elif defined(CONFIG_BOOT_USE_TINYCRYPT)
#define MCUBOOT_USE_TINYCRYPT
#elif defined(CONFIG_BOOT_USE_CC310)
#define MCUBOOT_USE_CC310
#elif defined(CONFIG_MBEDTLS_PSA_CRYPTO_CLIENT)
#define MCUBOOT_USE_PSA_CRYPTO
#elif defined(CONFIG_BOOT_USE_NRF_EXTERNAL_CRYPTO)
#define MCUBOOT_USE_NRF_EXTERNAL_CRYPTO
#endif
#ifdef CONFIG_BOOT_IMG_HASH_ALG_SHA512
#define MCUBOOT_SHA512
#endif
#ifdef CONFIG_BOOT_IMG_HASH_ALG_SHA256
#define MCUBOOT_SHA256
#endif
/* Zephyr, regardless of C library used, provides snprintf */
#define MCUBOOT_USE_SNPRINTF 1
#ifdef CONFIG_BOOT_HW_KEY
#define MCUBOOT_HW_KEY
#endif
#ifdef CONFIG_BOOT_VALIDATE_SLOT0
#define MCUBOOT_VALIDATE_PRIMARY_SLOT
#endif
#ifdef CONFIG_BOOT_VALIDATE_SLOT0_ONCE
#define MCUBOOT_VALIDATE_PRIMARY_SLOT_ONCE
#endif
#ifdef CONFIG_BOOT_UPGRADE_ONLY
#define MCUBOOT_OVERWRITE_ONLY
#define MCUBOOT_OVERWRITE_ONLY_FAST
#endif
#ifdef CONFIG_SINGLE_APPLICATION_SLOT
#define MCUBOOT_SINGLE_APPLICATION_SLOT 1
#define MCUBOOT_IMAGE_NUMBER 1
#else
#ifdef CONFIG_BOOT_SWAP_USING_MOVE
#define MCUBOOT_SWAP_USING_MOVE 1
#endif
#ifdef CONFIG_BOOT_DIRECT_XIP
#define MCUBOOT_DIRECT_XIP
#endif
#ifdef CONFIG_BOOT_DIRECT_XIP_REVERT
#define MCUBOOT_DIRECT_XIP_REVERT
#endif
#ifdef CONFIG_BOOT_RAM_LOAD
#define MCUBOOT_RAM_LOAD 1
#define IMAGE_EXECUTABLE_RAM_START CONFIG_BOOT_IMAGE_EXECUTABLE_RAM_START
#define IMAGE_EXECUTABLE_RAM_SIZE CONFIG_BOOT_IMAGE_EXECUTABLE_RAM_SIZE
#endif
#ifdef CONFIG_BOOT_FIRMWARE_LOADER
#define MCUBOOT_FIRMWARE_LOADER
#endif
#ifdef CONFIG_UPDATEABLE_IMAGE_NUMBER
#define MCUBOOT_IMAGE_NUMBER CONFIG_UPDATEABLE_IMAGE_NUMBER
#else
#define MCUBOOT_IMAGE_NUMBER 1
#endif
#ifdef CONFIG_BOOT_VERSION_CMP_USE_BUILD_NUMBER
#define MCUBOOT_VERSION_CMP_USE_BUILD_NUMBER
#endif
#ifdef CONFIG_BOOT_SWAP_SAVE_ENCTLV
#define MCUBOOT_SWAP_SAVE_ENCTLV 1
#endif
#endif /* CONFIG_SINGLE_APPLICATION_SLOT */
#ifdef CONFIG_LOG
#define MCUBOOT_HAVE_LOGGING 1
#endif
#ifdef CONFIG_BOOT_ENCRYPT_RSA
#define MCUBOOT_ENC_IMAGES
#define MCUBOOT_ENCRYPT_RSA
#endif
#ifdef CONFIG_BOOT_ENCRYPT_EC256
#define MCUBOOT_ENC_IMAGES
#define MCUBOOT_ENCRYPT_EC256
#endif
#ifdef CONFIG_BOOT_ENCRYPT_X25519
#define MCUBOOT_ENC_IMAGES
#define MCUBOOT_ENCRYPT_X25519
#endif
#ifdef CONFIG_BOOT_DECOMPRESSION
#define MCUBOOT_DECOMPRESS_IMAGES
#endif
/* Invoke hashing functions directly on storage. This requires for device
* to be able to map storage to address space or RAM.
*/
#ifdef CONFIG_BOOT_IMG_HASH_DIRECTLY_ON_STORAGE
#define MCUBOOT_HASH_STORAGE_DIRECTLY
#endif
#ifdef CONFIG_BOOT_SIGNATURE_TYPE_PURE
#define MCUBOOT_SIGN_PURE
#endif
#ifdef CONFIG_BOOT_BOOTSTRAP
#define MCUBOOT_BOOTSTRAP 1
#endif
#ifdef CONFIG_BOOT_USE_BENCH
#define MCUBOOT_USE_BENCH 1
#endif
#ifdef CONFIG_MCUBOOT_DOWNGRADE_PREVENTION
#define MCUBOOT_DOWNGRADE_PREVENTION 1
/* MCUBOOT_DOWNGRADE_PREVENTION_SECURITY_COUNTER is used later as bool value so it is
* always defined, (unlike MCUBOOT_DOWNGRADE_PREVENTION which is only used in
* preprocessor condition and my be not defined) */
# ifdef CONFIG_MCUBOOT_DOWNGRADE_PREVENTION_SECURITY_COUNTER
# define MCUBOOT_DOWNGRADE_PREVENTION_SECURITY_COUNTER 1
# else
# define MCUBOOT_DOWNGRADE_PREVENTION_SECURITY_COUNTER 0
# endif
#endif
#ifdef CONFIG_MCUBOOT_HW_DOWNGRADE_PREVENTION
#define MCUBOOT_HW_ROLLBACK_PROT
#endif
#ifdef CONFIG_MEASURED_BOOT
#define MCUBOOT_MEASURED_BOOT
#endif
#ifdef CONFIG_BOOT_SHARE_DATA
#define MCUBOOT_DATA_SHARING
#endif
#ifdef CONFIG_BOOT_SHARE_BACKEND_RETENTION
#define MCUBOOT_CUSTOM_DATA_SHARING_FUNCTION
#endif
#ifdef CONFIG_BOOT_SHARE_DATA_BOOTINFO
#define MCUBOOT_DATA_SHARING_BOOTINFO
#endif
#ifdef CONFIG_MEASURED_BOOT_MAX_CBOR_SIZE
#define MAX_BOOT_RECORD_SZ CONFIG_MEASURED_BOOT_MAX_CBOR_SIZE
#endif
#ifdef CONFIG_BOOT_FIH_PROFILE_OFF
#define MCUBOOT_FIH_PROFILE_OFF
#endif
#ifdef CONFIG_BOOT_FIH_PROFILE_LOW
#define MCUBOOT_FIH_PROFILE_LOW
#endif
#ifdef CONFIG_BOOT_FIH_PROFILE_MEDIUM
#define MCUBOOT_FIH_PROFILE_MEDIUM
#endif
#ifdef CONFIG_BOOT_FIH_PROFILE_HIGH
#define MCUBOOT_FIH_PROFILE_HIGH
#endif
#ifdef CONFIG_ENABLE_MGMT_PERUSER
#define MCUBOOT_PERUSER_MGMT_GROUP_ENABLED 1
#else
#define MCUBOOT_PERUSER_MGMT_GROUP_ENABLED 0
#endif
#ifdef CONFIG_BOOT_MGMT_CUSTOM_IMG_LIST
#define MCUBOOT_MGMT_CUSTOM_IMG_LIST
#endif
#ifdef CONFIG_BOOT_MGMT_ECHO
#define MCUBOOT_BOOT_MGMT_ECHO
#endif
#ifdef CONFIG_BOOT_IMAGE_ACCESS_HOOKS
#define MCUBOOT_IMAGE_ACCESS_HOOKS
#endif
#ifdef CONFIG_MCUBOOT_VERIFY_IMG_ADDRESS
#define MCUBOOT_VERIFY_IMG_ADDRESS
#endif
#ifdef CONFIG_MCUBOOT_SERIAL
#define MCUBOOT_SERIAL
#endif
/*
* The configuration option enables direct image upload with the
* serial recovery.
*/
#ifdef CONFIG_MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD
#define MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD
#endif
#ifdef CONFIG_BOOT_SERIAL_WAIT_FOR_DFU
#define MCUBOOT_SERIAL_WAIT_FOR_DFU
#endif
#ifdef CONFIG_BOOT_SERIAL_IMG_GRP_HASH
#define MCUBOOT_SERIAL_IMG_GRP_HASH
#endif
#ifdef CONFIG_BOOT_SERIAL_IMG_GRP_IMAGE_STATE
#define MCUBOOT_SERIAL_IMG_GRP_IMAGE_STATE
#endif
#ifdef CONFIG_BOOT_SERIAL_IMG_GRP_SLOT_INFO
#define MCUBOOT_SERIAL_IMG_GRP_SLOT_INFO
#endif
#ifdef CONFIG_MCUBOOT_SERIAL
#define MCUBOOT_SERIAL_RECOVERY
#endif
#if (defined(CONFIG_BOOT_USB_DFU_WAIT) || \
defined(CONFIG_BOOT_USB_DFU_GPIO))
#define MCUBOOT_USB_DFU
#endif
/*
* The option enables code, currently in boot_serial, that attempts
* to erase flash progressively, as update fragments are received,
* instead of erasing whole image size of flash area after receiving
* first frame.
* Enabling this options prevents stalling the beginning of transfer
* for the time needed to erase large chunk of flash.
*/
#ifdef CONFIG_BOOT_ERASE_PROGRESSIVELY
#define MCUBOOT_ERASE_PROGRESSIVELY
#endif
/*
* Enabling this option uses newer flash map APIs. This saves RAM and
* avoids deprecated API usage.
*
* (This can be deleted when flash_area_to_sectors() is removed instead
* of simply deprecated.)
*/
#define MCUBOOT_USE_FLASH_AREA_GET_SECTORS
#if (defined(CONFIG_BOOT_USB_DFU_WAIT) || \
defined(CONFIG_BOOT_USB_DFU_GPIO))
# ifndef CONFIG_MULTITHREADING
# error "USB DFU Requires MULTITHREADING"
# endif
#endif
#if defined(CONFIG_BOOT_MAX_IMG_SECTORS_AUTO) && defined(MIN_SECTOR_COUNT)
#define MCUBOOT_MAX_IMG_SECTORS MIN_SECTOR_COUNT
#elif defined(CONFIG_BOOT_MAX_IMG_SECTORS)
#define MCUBOOT_MAX_IMG_SECTORS CONFIG_BOOT_MAX_IMG_SECTORS
#else
#define MCUBOOT_MAX_IMG_SECTORS 128
#endif
#ifdef CONFIG_BOOT_SERIAL_MAX_RECEIVE_SIZE
#define MCUBOOT_SERIAL_MAX_RECEIVE_SIZE CONFIG_BOOT_SERIAL_MAX_RECEIVE_SIZE
#endif
#ifdef CONFIG_BOOT_SERIAL_UNALIGNED_BUFFER_SIZE
#define MCUBOOT_SERIAL_UNALIGNED_BUFFER_SIZE CONFIG_BOOT_SERIAL_UNALIGNED_BUFFER_SIZE
#endif
#if defined(MCUBOOT_DATA_SHARING) && defined(ZEPHYR_VER_INCLUDE)
#include <zephyr/app_version.h>
#define MCUBOOT_VERSION_AVAILABLE
#define MCUBOOT_VERSION_MAJOR APP_VERSION_MAJOR
#define MCUBOOT_VERSION_MINOR APP_VERSION_MINOR
#define MCUBOOT_VERSION_PATCHLEVEL APP_PATCHLEVEL
#endif
/* Support 32-byte aligned flash sizes */
#if DT_HAS_CHOSEN(zephyr_flash)
#if DT_PROP_OR(DT_CHOSEN(zephyr_flash), write_block_size, 0) > 8
#define MCUBOOT_BOOT_MAX_ALIGN \
DT_PROP(DT_CHOSEN(zephyr_flash), write_block_size)
#endif
#endif
#ifdef CONFIG_MCUBOOT_BOOTUTIL_LIB_FOR_DIRECT_XIP
#define MCUBOOT_BOOTUTIL_LIB_FOR_DIRECT_XIP 1
#endif
#if CONFIG_BOOT_WATCHDOG_FEED
#if CONFIG_NRFX_WDT
#include <nrfx_wdt.h>
#define FEED_WDT_INST(id) \
do { \
nrfx_wdt_t wdt_inst_##id = NRFX_WDT_INSTANCE(id); \
for (uint8_t i = 0; i < NRF_WDT_CHANNEL_NUMBER; i++) \
{ \
nrf_wdt_reload_request_set(wdt_inst_##id.p_reg, \
(nrf_wdt_rr_register_t)(NRF_WDT_RR0 + i)); \
} \
} while (0)
#if defined(CONFIG_NRFX_WDT0) && defined(CONFIG_NRFX_WDT1)
#define MCUBOOT_WATCHDOG_FEED() \
do { \
FEED_WDT_INST(0); \
FEED_WDT_INST(1); \
} while (0)
#elif defined(CONFIG_NRFX_WDT0)
#define MCUBOOT_WATCHDOG_FEED() \
FEED_WDT_INST(0);
#elif defined(CONFIG_NRFX_WDT30) && defined(CONFIG_NRFX_WDT31)
#define MCUBOOT_WATCHDOG_FEED() \
do { \
FEED_WDT_INST(30); \
FEED_WDT_INST(31); \
} while (0)
#elif defined(CONFIG_NRFX_WDT30)
#define MCUBOOT_WATCHDOG_FEED() \
FEED_WDT_INST(30);
#elif defined(CONFIG_NRFX_WDT31)
#define MCUBOOT_WATCHDOG_FEED() \
FEED_WDT_INST(31);
#else
#error "No NRFX WDT instances enabled"
#endif
#elif DT_NODE_HAS_STATUS(DT_ALIAS(watchdog0), okay) /* CONFIG_NRFX_WDT */
#include <zephyr/device.h>
#include <zephyr/drivers/watchdog.h>
#define MCUBOOT_WATCHDOG_SETUP() \
do { \
const struct device* wdt = \
DEVICE_DT_GET(DT_ALIAS(watchdog0)); \
if (device_is_ready(wdt)) { \
wdt_setup(wdt, 0); \
} \
} while (0)
#define MCUBOOT_WATCHDOG_FEED() \
do { \
const struct device* wdt = \
DEVICE_DT_GET(DT_ALIAS(watchdog0)); \
if (device_is_ready(wdt)) { \
wdt_feed(wdt, 0); \
} \
} while (0)
#else /* DT_NODE_HAS_STATUS(DT_ALIAS(watchdog0), okay) */
/* No vendor implementation, no-op for historical reasons */
#define MCUBOOT_WATCHDOG_FEED() \
do { \
} while (0)
#endif
#else /* CONFIG_BOOT_WATCHDOG_FEED */
/* Not enabled, no feed activity */
#define MCUBOOT_WATCHDOG_FEED() \
do { \
} while (0)
#endif /* CONFIG_BOOT_WATCHDOG_FEED */
#ifndef MCUBOOT_WATCHDOG_SETUP
#define MCUBOOT_WATCHDOG_SETUP()
#endif
#define MCUBOOT_CPU_IDLE() \
if (!IS_ENABLED(CONFIG_MULTITHREADING)) { \
k_cpu_idle(); \
}
#endif /* __MCUBOOT_CONFIG_H__ */

View File

@@ -0,0 +1,30 @@
/*
* Copyright (c) 2018 Runtime Inc
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __MCUBOOT_LOGGING_H__
#define __MCUBOOT_LOGGING_H__
/*
* When building for targets running Zephyr, delegate to its native
* logging subsystem.
*/
#ifdef CONFIG_MCUBOOT
#define MCUBOOT_LOG_MODULE_DECLARE(domain) LOG_MODULE_DECLARE(domain, CONFIG_MCUBOOT_LOG_LEVEL)
#define MCUBOOT_LOG_MODULE_REGISTER(domain) LOG_MODULE_REGISTER(domain, CONFIG_MCUBOOT_LOG_LEVEL)
#else
#define MCUBOOT_LOG_MODULE_DECLARE(domain) LOG_MODULE_DECLARE(domain, CONFIG_MCUBOOT_UTIL_LOG_LEVEL)
#define MCUBOOT_LOG_MODULE_REGISTER(domain) LOG_MODULE_REGISTER(domain, CONFIG_MCUBOOT_UTIL_LOG_LEVEL)
#endif
#define MCUBOOT_LOG_ERR(...) LOG_ERR(__VA_ARGS__)
#define MCUBOOT_LOG_WRN(...) LOG_WRN(__VA_ARGS__)
#define MCUBOOT_LOG_INF(...) LOG_INF(__VA_ARGS__)
#define MCUBOOT_LOG_DBG(...) LOG_DBG(__VA_ARGS__)
#define MCUBOOT_LOG_SIM(...) IGNORE(__VA_ARGS__)
#include <zephyr/logging/log.h>
#endif /* __MCUBOOT_LOGGING_H__ */

View File

@@ -0,0 +1,24 @@
/*
* Copyright (c) 2020 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/
#ifndef H_NRF_CLEANUP_
#define H_NRF_CLEANUP_
/**
* Perform cleanup on some peripheral resources used by MCUBoot prior chainload
* the application.
*
* This function disables all RTC instances and UARTE instances.
* It Disables their interrupts signals as well.
*/
void nrf_cleanup_peripheral(void);
/**
* Perform cleanup of non-secure RAM that may have been used by MCUBoot.
*/
void nrf_cleanup_ns_ram(void);
#endif

Some files were not shown because too many files have changed in this diff Show More