Commit a9101667 authored by Artur Tynecki's avatar Artur Tynecki Committed by David Brown
Browse files

mbed: Add CMake support and fix files paths



The mbed port should be compatible with a new command-line tool
mbed-tools (Mbed CLI 2) which use cmake build system. This allows build
cmake-base applications.
Fix mbed files paths - it's required for the new version of mbed-os
(v6.15)

Signed-off-by: default avatarArtur Tynecki <artur.tynecki@mobica.com>
parent 4c0f6c17
Loading
Loading
Loading
Loading
+61 −0
Original line number Diff line number Diff line
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

# Mbed-MCUboot Port

cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR)

get_filename_component(BOOT_UTIL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../bootutil REALPATH)

set(LIB_TARGET mbed-mcuboot)
set(LIB_BOOTUTIL bootutil)

add_library(${LIB_TARGET} STATIC)

target_include_directories(${LIB_TARGET}
    PUBLIC
        include
        ${BOOT_UTIL_DIR}/include
        ${BOOT_UTIL_DIR}/src
)

target_sources(${LIB_TARGET}
    PRIVATE
        mcuboot_main.cpp
        app_enc_keys.c
        src/flash_map_backend.cpp
        src/secondary_bd.cpp
)

target_link_libraries(${LIB_TARGET}
    PUBLIC
        bootutil  # Cross-dependency
        mbed-mbedtls
        mbed-storage-flashiap
        mbed-storage-blockdevice
)

if("_RTE_" IN_LIST MBED_CONFIG_DEFINITIONS)
    target_link_libraries(${LIB_TARGET}
    PUBLIC
        mbed-os
    )
else()
    target_link_libraries(${LIB_TARGET}
    PUBLIC
        mbed-baremetal
    )
endif()

# The cross-dependency requires that bootutil have access to the mbed port's
# include directory and is linked with the appropriate mbed-specific libraries.
target_include_directories(${LIB_BOOTUTIL}
    PUBLIC
        include
)

target_link_libraries(${LIB_BOOTUTIL}
    PUBLIC
        mbed-mcuboot
        mbed-mbedtls
)
+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@
#endif

#define TRACE_GROUP "MCUb"
#include "mbed_trace.h"
#include "mbed-trace/mbed_trace.h"
#include "bootutil/ignore.h"

#define MCUBOOT_LOG_MODULE_DECLARE(domain)  /* ignore */
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@
#include "bootutil/bootutil.h"
#include "bootutil/image.h"
#include "hal/serial_api.h"
#include "mbed_application.h"
#include "platform/mbed_application.h"

#if (MCUBOOT_CRYPTO_BACKEND == MBEDTLS)
#include "mbedtls/platform.h"
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@

#include "flash_map_backend/secondary_bd.h"
#include "platform/mbed_toolchain.h"
#include "FlashIAPBlockDevice.h"
#include "FlashIAP/FlashIAPBlockDevice.h"

/**
 * For an XIP build, the secondary BD is provided by mcuboot by default.