blob: a4ae9525989286c8dea2a637eb209f846feac997 [file] [log] [blame]
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +02001################################################################################
2# \file BlinkyApp.mk
3# \version 1.0
4#
5# \brief
6# Makefile to describe demo application BlinkyApp for Cypress MCUBoot based applications.
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
26# Cypress' MCUBoot Application supports GCC ARM only at this moment
27# Set defaults to:
28# - compiler GCC
29# - build configuration to Debug
30# - image type to BOOT
31COMPILER ?= GCC_ARM
32IMG_TYPE ?= BOOT
33
34# image type can be BOOT or UPGRADE
35IMG_TYPES = BOOT UPGRADE
36
Bohdan Kovalchuk0324f1b2020-05-26 08:04:24 -050037# possible values are 0 and 0xff
38# internal Flash by default
39ERASED_VALUE ?= 0
40
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +020041ifneq ($(COMPILER), GCC_ARM)
42$(error Only GCC ARM is supported at this moment)
43endif
44
45CUR_APP_PATH = $(CURDIR)/$(APP_NAME)
46
47include $(CUR_APP_PATH)/platforms.mk
48include $(CUR_APP_PATH)/libs.mk
49include $(CUR_APP_PATH)/toolchains.mk
50
51# Application-specific DEFINES
52ifeq ($(IMG_TYPE), BOOT)
53 DEFINES_APP := -DBOOT_IMG
54else
55 DEFINES_APP := -DUPGRADE_IMG
56endif
57
58# Define start of application, RAM start and size, slot size
59ifeq ($(PLATFORM), PSOC_062_2M)
Bohdan Kovalchuk0324f1b2020-05-26 08:04:24 -050060 DEFINES_APP += -DRAM_START=0x08040000
61 DEFINES_APP += -DRAM_SIZE=0x10000
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +020062 DEFINES_APP += -DUSER_APP_START=0x10018000
63 SLOT_SIZE ?= 0x10000
64endif
65
66# Collect Test Application sources
67SOURCES_APP_SRC := $(wildcard $(CUR_APP_PATH)/*.c)
68# Collect all the sources
69SOURCES_APP += $(SOURCES_APP_SRC)
70
71# Collect includes for BlinkyApp
72INCLUDE_DIRS_APP := $(addprefix -I, $(CURDIR))
73INCLUDE_DIRS_APP += $(addprefix -I, $(CUR_APP_PATH))
74
75# Overwite path to linker script if custom is required, otherwise default from BSP is used
76ifeq ($(COMPILER), GCC_ARM)
77LINKER_SCRIPT := $(subst /cygdrive/c,c:,$(CUR_APP_PATH)/linker/$(APP_NAME).ld)
78else
79$(error Only GCC ARM is supported at this moment)
80endif
81
82ASM_FILES_APP :=
83
84# We still need this for MCUBoot apps signing
85IMGTOOL_PATH ?= ../../scripts/imgtool.py
86
Bohdan Kovalchuk0324f1b2020-05-26 08:04:24 -050087SIGN_ARGS := sign --header-size 1024 --pad-header --align 8 -v "2.0" -S $(SLOT_SIZE) -M 512 --overwrite-only -R $(ERASED_VALUE) -k keys/$(SIGN_KEY_FILE).pem
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +020088
89# Output folder
90OUT := $(APP_NAME)/out
91# Output folder to contain build artifacts
92OUT_TARGET := $(OUT)/$(PLATFORM)
93
94OUT_CFG := $(OUT_TARGET)/$(BUILDCFG)
95
96# Set build directory for BOOT and UPGRADE images
97ifeq ($(IMG_TYPE), UPGRADE)
98 SIGN_ARGS += --pad
99 UPGRADE_SUFFIX :=_upgrade
100 OUT_CFG := $(OUT_CFG)/upgrade
101else
102 OUT_CFG := $(OUT_CFG)/boot
103endif
104
105pre_build:
106 $(info [PRE_BUILD] - Generating linker script for application $(CUR_APP_PATH)/linker/$(APP_NAME).ld)
107 @$(CC) -E -x c $(CFLAGS) $(INCLUDE_DIRS) $(CUR_APP_PATH)/linker/$(APP_NAME)_template.ld | grep -v '^#' >$(CUR_APP_PATH)/linker/$(APP_NAME).ld
108
109# Post build action to execute after main build job
110post_build: $(OUT_CFG)/$(APP_NAME).hex
111 $(info [POST_BUILD] - Executing post build script for $(APP_NAME))
112 mv -f $(OUT_CFG)/$(APP_NAME).hex $(OUT_CFG)/$(APP_NAME)_unsigned.hex
113 $(PYTHON_PATH) $(IMGTOOL_PATH) $(SIGN_ARGS) $(OUT_CFG)/$(APP_NAME)_unsigned.hex $(OUT_CFG)/$(APP_NAME)$(UPGRADE_SUFFIX).hex