1#-------------------------------------------------------------------------------
2# Copyright (c) 2021-2022, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8if (NOT TFM_PARTITION_FIRMWARE_UPDATE)
9    return()
10endif()
11
12cmake_minimum_required(VERSION 3.21)
13
14add_library(tfm_psa_rot_partition_fwu STATIC)
15
16add_dependencies(tfm_psa_rot_partition_fwu manifest_tool)
17
18target_include_directories(tfm_psa_rot_partition_fwu
19    INTERFACE
20        ${CMAKE_SOURCE_DIR}/secure_fw/include
21    PRIVATE
22        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
23        ${CMAKE_BINARY_DIR}/generated/secure_fw/partitions/firmware_update
24)
25target_include_directories(tfm_partitions
26    INTERFACE
27        ${CMAKE_BINARY_DIR}/generated/secure_fw/partitions/firmware_update
28)
29
30target_sources(tfm_psa_rot_partition_fwu
31    PRIVATE
32        tfm_fwu_req_mngr.c
33        ${CMAKE_BINARY_DIR}/generated/secure_fw/partitions/firmware_update/auto_generated/intermedia_tfm_firmware_update.c
34)
35target_sources(tfm_partitions
36    INTERFACE
37        ${CMAKE_BINARY_DIR}/generated/secure_fw/partitions/firmware_update/auto_generated/load_info_tfm_firmware_update.c
38)
39
40# The bootloader specific configuration.
41if ((NOT TFM_FWU_BOOTLOADER_LIB) OR (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/bootloader/${TFM_FWU_BOOTLOADER_LIB}))
42    message(FATAL_ERROR "TFM_FWU_BOOTLOADER_LIB invalid")
43endif()
44add_subdirectory(bootloader/${TFM_FWU_BOOTLOADER_LIB})
45
46target_link_libraries(tfm_psa_rot_partition_fwu
47    PRIVATE
48        platform_s
49        tfm_config
50        tfm_sprt
51)
52
53
54# Generate firmware update feature if FWU_DEVICE_CONFIG_FILE is not provided
55if (NOT FWU_DEVICE_CONFIG_FILE)
56    configure_file(${CMAKE_SOURCE_DIR}/interface/include/psa/fwu_config.h.in
57                   ${CMAKE_BINARY_DIR}/generated/interface/include/psa/fwu_config.h
58                   @ONLY)
59    set(FWU_DEVICE_CONFIG_FILE "${CMAKE_BINARY_DIR}/generated/interface/include/psa/fwu_config.h")
60endif()
61
62
63target_compile_definitions(tfm_psa_rot_partition_fwu
64    PRIVATE
65        $<$<BOOL:${DEFAULT_MCUBOOT_FLASH_MAP}>:DEFAULT_MCUBOOT_FLASH_MAP>
66        FWU_DEVICE_CONFIG_FILE="${FWU_DEVICE_CONFIG_FILE}"
67)
68
69############################ Partition Defs ####################################
70
71target_link_libraries(tfm_partitions
72    INTERFACE
73        tfm_psa_rot_partition_fwu
74)
75
76target_compile_definitions(tfm_config
77    INTERFACE
78    TFM_PARTITION_FIRMWARE_UPDATE
79)
80
81################ Display the configuration being applied #######################
82
83include(utils)
84dump_options("Firmware Update Partition config"
85"
86    TFM_FWU_BOOTLOADER_LIB;
87    FWU_DEVICE_CONFIG_FILE
88"
89)
90