blob: a7608482d601b0d02fb631ba31694551ddeb72ad [file] [log] [blame]
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +02001################################################################################
Bohdan Kovalchuk77256522020-04-15 18:03:43 +03002# \file MCUBootApp.mk
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +02003# \version 1.0
4#
5# \brief
Bohdan Kovalchuk77256522020-04-15 18:03:43 +03006# Makefile for Cypress MCUBoot-based application.
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +02007#
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
26# Cypress' MCUBoot Application supports GCC ARM only at this moment
27# Set default compiler to GCC if not specified from command line
28COMPILER ?= GCC_ARM
29
Roman Okhrimenko38aa6c42020-01-31 16:10:28 +020030USE_CRYPTO_HW ?= 1
Kostiantyn Tkachov120efee2020-06-04 21:16:09 +030031USE_EXTERNAL_FLASH ?= 0
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +020032MCUBOOT_IMAGE_NUMBER ?= 1
33
34ifneq ($(COMPILER), GCC_ARM)
35$(error Only GCC ARM is supported at this moment)
36endif
37
38CUR_APP_PATH = $(CURDIR)/$(APP_NAME)
39
40include $(CUR_APP_PATH)/platforms.mk
41include $(CUR_APP_PATH)/libs.mk
42include $(CUR_APP_PATH)/toolchains.mk
43
Bohdan Kovalchuka333a452020-07-09 16:55:58 +030044# default slot size is 0x10000, 512bytes per row/sector, so 128 sectors
45MAX_IMG_SECTORS ?= 128
46
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +020047# Application-specific DEFINES
48DEFINES_APP := -DMBEDTLS_CONFIG_FILE="\"mcuboot_crypto_config.h\""
49DEFINES_APP += -DECC256_KEY_FILE="\"keys/$(SIGN_KEY_FILE).pub\""
50DEFINES_APP += -DCORE=$(CORE)
51DEFINES_APP += -DMCUBOOT_IMAGE_NUMBER=$(MCUBOOT_IMAGE_NUMBER)
Kostiantyn Tkachov120efee2020-06-04 21:16:09 +030052ifeq ($(USE_EXTERNAL_FLASH), 1)
Bohdan Kovalchuk0324f1b2020-05-26 08:04:24 -050053DEFINES_APP += -DCY_BOOT_USE_EXTERNAL_FLASH
Kostiantyn Tkachov120efee2020-06-04 21:16:09 +030054endif
Bohdan Kovalchuka333a452020-07-09 16:55:58 +030055DEFINES_APP += -DMCUBOOT_MAX_IMG_SECTORS=$(MAX_IMG_SECTORS)
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +020056
Roman Okhrimenko38aa6c42020-01-31 16:10:28 +020057ifeq ($(USE_CRYPTO_HW), 1)
58DEFINES_APP += -DMBEDTLS_USER_CONFIG_FILE="\"mcuboot_crypto_acc_config.h\""
Kostiantyn Tkachov120efee2020-06-04 21:16:09 +030059DEFINES_APP += -DCY_CRYPTO_HAL_DISABLE
Roman Okhrimenko38aa6c42020-01-31 16:10:28 +020060endif
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +020061# Collect MCUBoot sourses
62SOURCES_MCUBOOT := $(wildcard $(CURDIR)/../bootutil/src/*.c)
63# Collect MCUBoot Application sources
64SOURCES_APP_SRC := $(wildcard $(CUR_APP_PATH)/*.c)
Bohdan Kovalchuk0324f1b2020-05-26 08:04:24 -050065
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +020066# Collect Flash Layer port sources
67SOURCES_FLASH_PORT := $(wildcard $(CURDIR)/cy_flash_pal/*.c)
Bohdan Kovalchuk0324f1b2020-05-26 08:04:24 -050068SOURCES_FLASH_PORT += $(wildcard $(CURDIR)/cy_flash_pal/flash_qspi/*.c)
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +020069# Collect all the sources
70SOURCES_APP := $(SOURCES_MCUBOOT)
71SOURCES_APP += $(SOURCES_APP_SRC)
72SOURCES_APP += $(SOURCES_FLASH_PORT)
73
Bohdan Kovalchuk77256522020-04-15 18:03:43 +030074INCLUDE_DIRS_MCUBOOT := $(addprefix -I, $(CURDIR)/../bootutil/include)
75INCLUDE_DIRS_MCUBOOT += $(addprefix -I, $(CURDIR)/../bootutil/src)
76INCLUDE_DIRS_MCUBOOT += $(addprefix -I, $(CURDIR)/..)
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +020077
78INCLUDE_DIRS_APP := $(addprefix -I, $(CURDIR))
Bohdan Kovalchuk0324f1b2020-05-26 08:04:24 -050079INCLUDE_DIRS_APP += $(addprefix -I, $(CURDIR)/cy_flash_pal/flash_qspi)
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +020080INCLUDE_DIRS_APP += $(addprefix -I, $(CURDIR)/cy_flash_pal/include)
81INCLUDE_DIRS_APP += $(addprefix -I, $(CURDIR)/cy_flash_pal/include/flash_map_backend)
82INCLUDE_DIRS_APP += $(addprefix -I, $(CUR_APP_PATH))
83INCLUDE_DIRS_APP += $(addprefix -I, $(CUR_APP_PATH)/config)
84INCLUDE_DIRS_APP += $(addprefix -I, $(CUR_APP_PATH)/os)
85
86ASM_FILES_APP :=
87
88# Output folder
89OUT := $(APP_NAME)/out
90# Output folder to contain build artifacts
91OUT_TARGET := $(OUT)/$(PLATFORM)
92
93OUT_CFG := $(OUT_TARGET)/$(BUILDCFG)
94
Bohdan Kovalchuk77256522020-04-15 18:03:43 +030095# Overwite path to linker script if custom is required
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +020096ifeq ($(COMPILER), GCC_ARM)
97LINKER_SCRIPT := $(subst /cygdrive/c,c:,$(CUR_APP_PATH)/$(APP_NAME).ld)
98else
99$(error Only GCC ARM is supported at this moment)
100endif