blob: 8c3dbfa7e6ccc39e426d92f4e609abda157808f2 [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
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +020037ifneq ($(COMPILER), GCC_ARM)
38$(error Only GCC ARM is supported at this moment)
39endif
40
41CUR_APP_PATH = $(CURDIR)/$(APP_NAME)
42
43include $(CUR_APP_PATH)/platforms.mk
44include $(CUR_APP_PATH)/libs.mk
45include $(CUR_APP_PATH)/toolchains.mk
46
47# Application-specific DEFINES
48ifeq ($(IMG_TYPE), BOOT)
49 DEFINES_APP := -DBOOT_IMG
50else
51 DEFINES_APP := -DUPGRADE_IMG
52endif
53
54# Define start of application, RAM start and size, slot size
55ifeq ($(PLATFORM), PSOC_062_2M)
56 DEFINES_APP += -DRAM_START=0x08000000
57 DEFINES_APP += -DRAM_SIZE=0x20000
58 DEFINES_APP += -DUSER_APP_START=0x10018000
59 SLOT_SIZE ?= 0x10000
60endif
61
62# Collect Test Application sources
63SOURCES_APP_SRC := $(wildcard $(CUR_APP_PATH)/*.c)
64# Collect all the sources
65SOURCES_APP += $(SOURCES_APP_SRC)
66
67# Collect includes for BlinkyApp
68INCLUDE_DIRS_APP := $(addprefix -I, $(CURDIR))
69INCLUDE_DIRS_APP += $(addprefix -I, $(CUR_APP_PATH))
70
71# Overwite path to linker script if custom is required, otherwise default from BSP is used
72ifeq ($(COMPILER), GCC_ARM)
73LINKER_SCRIPT := $(subst /cygdrive/c,c:,$(CUR_APP_PATH)/linker/$(APP_NAME).ld)
74else
75$(error Only GCC ARM is supported at this moment)
76endif
77
78ASM_FILES_APP :=
79
80# We still need this for MCUBoot apps signing
81IMGTOOL_PATH ?= ../../scripts/imgtool.py
82
83SIGN_ARGS := sign --header-size 1024 --pad-header --align 8 -v "2.0" -S $(SLOT_SIZE) -M 512 --overwrite-only -R 0 -k keys/$(SIGN_KEY_FILE).pem
84
85# Output folder
86OUT := $(APP_NAME)/out
87# Output folder to contain build artifacts
88OUT_TARGET := $(OUT)/$(PLATFORM)
89
90OUT_CFG := $(OUT_TARGET)/$(BUILDCFG)
91
92# Set build directory for BOOT and UPGRADE images
93ifeq ($(IMG_TYPE), UPGRADE)
94 SIGN_ARGS += --pad
95 UPGRADE_SUFFIX :=_upgrade
96 OUT_CFG := $(OUT_CFG)/upgrade
97else
98 OUT_CFG := $(OUT_CFG)/boot
99endif
100
101pre_build:
102 $(info [PRE_BUILD] - Generating linker script for application $(CUR_APP_PATH)/linker/$(APP_NAME).ld)
103 @$(CC) -E -x c $(CFLAGS) $(INCLUDE_DIRS) $(CUR_APP_PATH)/linker/$(APP_NAME)_template.ld | grep -v '^#' >$(CUR_APP_PATH)/linker/$(APP_NAME).ld
104
105# Post build action to execute after main build job
106post_build: $(OUT_CFG)/$(APP_NAME).hex
107 $(info [POST_BUILD] - Executing post build script for $(APP_NAME))
108 mv -f $(OUT_CFG)/$(APP_NAME).hex $(OUT_CFG)/$(APP_NAME)_unsigned.hex
109 $(PYTHON_PATH) $(IMGTOOL_PATH) $(SIGN_ARGS) $(OUT_CFG)/$(APP_NAME)_unsigned.hex $(OUT_CFG)/$(APP_NAME)$(UPGRADE_SUFFIX).hex