Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 1 | ################################################################################ |
Bohdan Kovalchuk | 7725652 | 2020-04-15 18:03:43 +0300 | [diff] [blame] | 2 | # \file MCUBootApp.mk |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 3 | # \version 1.0 |
| 4 | # |
| 5 | # \brief |
Bohdan Kovalchuk | 7725652 | 2020-04-15 18:03:43 +0300 | [diff] [blame] | 6 | # Makefile for Cypress MCUBoot-based application. |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 7 | # |
| 8 | ################################################################################ |
| 9 | # \copyright |
| 10 | # Copyright 2018-2019 Cypress Semiconductor Corporation |
| 11 | # SPDX-License-Identifier: Apache-2.0 |
| 12 | # |
| 13 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 14 | # you may not use this file except in compliance with the License. |
| 15 | # You may obtain a copy of the License at |
| 16 | # |
| 17 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 18 | # |
| 19 | # Unless required by applicable law or agreed to in writing, software |
| 20 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 21 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 22 | # See the License for the specific language governing permissions and |
| 23 | # limitations under the License. |
| 24 | ################################################################################ |
| 25 | |
Roman Okhrimenko | 4bc2810 | 2021-02-01 19:31:41 +0200 | [diff] [blame] | 26 | include host.mk |
| 27 | |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 28 | # Cypress' MCUBoot Application supports GCC ARM only at this moment |
| 29 | # Set default compiler to GCC if not specified from command line |
| 30 | COMPILER ?= GCC_ARM |
| 31 | |
Roman Okhrimenko | a41a850 | 2021-08-26 09:40:54 +0300 | [diff] [blame] | 32 | USE_CRYPTO_HW ?= 0 |
Kostiantyn Tkachov | 120efee | 2020-06-04 21:16:09 +0300 | [diff] [blame] | 33 | USE_EXTERNAL_FLASH ?= 0 |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 34 | MCUBOOT_IMAGE_NUMBER ?= 1 |
Bohdan Kovalchuk | de51807 | 2020-11-30 22:10:48 +0200 | [diff] [blame] | 35 | ENC_IMG ?= 0 |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 36 | |
Roman Okhrimenko | 4bc2810 | 2021-02-01 19:31:41 +0200 | [diff] [blame] | 37 | # For which core this application is built |
| 38 | CORE ?= CM0P |
| 39 | |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 40 | ifneq ($(COMPILER), GCC_ARM) |
| 41 | $(error Only GCC ARM is supported at this moment) |
| 42 | endif |
| 43 | |
Roman Okhrimenko | 4bc2810 | 2021-02-01 19:31:41 +0200 | [diff] [blame] | 44 | CUR_APP_PATH = $(PRJ_DIR)/$(APP_NAME) |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 45 | |
Roman Okhrimenko | 4bc2810 | 2021-02-01 19:31:41 +0200 | [diff] [blame] | 46 | include $(PRJ_DIR)/platforms.mk |
| 47 | include $(PRJ_DIR)/common_libs.mk |
| 48 | include $(PRJ_DIR)/toolchains.mk |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 49 | |
Bohdan Kovalchuk | a333a45 | 2020-07-09 16:55:58 +0300 | [diff] [blame] | 50 | # default slot size is 0x10000, 512bytes per row/sector, so 128 sectors |
| 51 | MAX_IMG_SECTORS ?= 128 |
| 52 | |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 53 | # Application-specific DEFINES |
| 54 | DEFINES_APP := -DMBEDTLS_CONFIG_FILE="\"mcuboot_crypto_config.h\"" |
| 55 | DEFINES_APP += -DECC256_KEY_FILE="\"keys/$(SIGN_KEY_FILE).pub\"" |
| 56 | DEFINES_APP += -DCORE=$(CORE) |
| 57 | DEFINES_APP += -DMCUBOOT_IMAGE_NUMBER=$(MCUBOOT_IMAGE_NUMBER) |
Kostiantyn Tkachov | 120efee | 2020-06-04 21:16:09 +0300 | [diff] [blame] | 58 | ifeq ($(USE_EXTERNAL_FLASH), 1) |
Bohdan Kovalchuk | 0324f1b | 2020-05-26 08:04:24 -0500 | [diff] [blame] | 59 | DEFINES_APP += -DCY_BOOT_USE_EXTERNAL_FLASH |
Kostiantyn Tkachov | 120efee | 2020-06-04 21:16:09 +0300 | [diff] [blame] | 60 | endif |
Bohdan Kovalchuk | a333a45 | 2020-07-09 16:55:58 +0300 | [diff] [blame] | 61 | DEFINES_APP += -DMCUBOOT_MAX_IMG_SECTORS=$(MAX_IMG_SECTORS) |
Bohdan Kovalchuk | de51807 | 2020-11-30 22:10:48 +0200 | [diff] [blame] | 62 | # Hardrware acceleration support |
Roman Okhrimenko | 38aa6c4 | 2020-01-31 16:10:28 +0200 | [diff] [blame] | 63 | ifeq ($(USE_CRYPTO_HW), 1) |
| 64 | DEFINES_APP += -DMBEDTLS_USER_CONFIG_FILE="\"mcuboot_crypto_acc_config.h\"" |
Kostiantyn Tkachov | 120efee | 2020-06-04 21:16:09 +0300 | [diff] [blame] | 65 | DEFINES_APP += -DCY_CRYPTO_HAL_DISABLE |
Roman Okhrimenko | 8953001 | 2021-03-05 14:07:18 +0200 | [diff] [blame] | 66 | DEFINES_APP += -DCY_MBEDTLS_HW_ACCELERATION |
Roman Okhrimenko | 38aa6c4 | 2020-01-31 16:10:28 +0200 | [diff] [blame] | 67 | endif |
Bohdan Kovalchuk | de51807 | 2020-11-30 22:10:48 +0200 | [diff] [blame] | 68 | # Encrypted image support |
| 69 | ifeq ($(ENC_IMG), 1) |
| 70 | DEFINES_APP += -DENC_IMG=1 |
| 71 | endif |
| 72 | |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 73 | # Collect MCUBoot sourses |
| 74 | SOURCES_MCUBOOT := $(wildcard $(CURDIR)/../bootutil/src/*.c) |
| 75 | # Collect MCUBoot Application sources |
| 76 | SOURCES_APP_SRC := $(wildcard $(CUR_APP_PATH)/*.c) |
Bohdan Kovalchuk | 0324f1b | 2020-05-26 08:04:24 -0500 | [diff] [blame] | 77 | |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 78 | # Collect Flash Layer port sources |
| 79 | SOURCES_FLASH_PORT := $(wildcard $(CURDIR)/cy_flash_pal/*.c) |
Bohdan Kovalchuk | 0324f1b | 2020-05-26 08:04:24 -0500 | [diff] [blame] | 80 | SOURCES_FLASH_PORT += $(wildcard $(CURDIR)/cy_flash_pal/flash_qspi/*.c) |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 81 | # Collect all the sources |
| 82 | SOURCES_APP := $(SOURCES_MCUBOOT) |
| 83 | SOURCES_APP += $(SOURCES_APP_SRC) |
| 84 | SOURCES_APP += $(SOURCES_FLASH_PORT) |
| 85 | |
Bohdan Kovalchuk | 7725652 | 2020-04-15 18:03:43 +0300 | [diff] [blame] | 86 | INCLUDE_DIRS_MCUBOOT := $(addprefix -I, $(CURDIR)/../bootutil/include) |
| 87 | INCLUDE_DIRS_MCUBOOT += $(addprefix -I, $(CURDIR)/../bootutil/src) |
| 88 | INCLUDE_DIRS_MCUBOOT += $(addprefix -I, $(CURDIR)/..) |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 89 | |
| 90 | INCLUDE_DIRS_APP := $(addprefix -I, $(CURDIR)) |
Bohdan Kovalchuk | 0324f1b | 2020-05-26 08:04:24 -0500 | [diff] [blame] | 91 | INCLUDE_DIRS_APP += $(addprefix -I, $(CURDIR)/cy_flash_pal/flash_qspi) |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 92 | INCLUDE_DIRS_APP += $(addprefix -I, $(CURDIR)/cy_flash_pal/include) |
| 93 | INCLUDE_DIRS_APP += $(addprefix -I, $(CURDIR)/cy_flash_pal/include/flash_map_backend) |
| 94 | INCLUDE_DIRS_APP += $(addprefix -I, $(CUR_APP_PATH)) |
| 95 | INCLUDE_DIRS_APP += $(addprefix -I, $(CUR_APP_PATH)/config) |
| 96 | INCLUDE_DIRS_APP += $(addprefix -I, $(CUR_APP_PATH)/os) |
| 97 | |
| 98 | ASM_FILES_APP := |
Roman Okhrimenko | 4bc2810 | 2021-02-01 19:31:41 +0200 | [diff] [blame] | 99 | ASM_FILES_APP += $(ASM_FILES_STARTUP) |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 100 | |
| 101 | # Output folder |
| 102 | OUT := $(APP_NAME)/out |
| 103 | # Output folder to contain build artifacts |
| 104 | OUT_TARGET := $(OUT)/$(PLATFORM) |
| 105 | |
| 106 | OUT_CFG := $(OUT_TARGET)/$(BUILDCFG) |
| 107 | |
Bohdan Kovalchuk | 7725652 | 2020-04-15 18:03:43 +0300 | [diff] [blame] | 108 | # Overwite path to linker script if custom is required |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 109 | ifeq ($(COMPILER), GCC_ARM) |
| 110 | LINKER_SCRIPT := $(subst /cygdrive/c,c:,$(CUR_APP_PATH)/$(APP_NAME).ld) |
| 111 | else |
| 112 | $(error Only GCC ARM is supported at this moment) |
| 113 | endif |