Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 1 | ################################################################################ |
| 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 | |
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 defaults to: |
| 30 | # - compiler GCC |
| 31 | # - build configuration to Debug |
| 32 | # - image type to BOOT |
| 33 | COMPILER ?= GCC_ARM |
| 34 | IMG_TYPE ?= BOOT |
| 35 | |
Roman Okhrimenko | 4bc2810 | 2021-02-01 19:31:41 +0200 | [diff] [blame] | 36 | # For which core this application is built |
| 37 | CORE ?= CM4 |
| 38 | |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 39 | # image type can be BOOT or UPGRADE |
| 40 | IMG_TYPES = BOOT UPGRADE |
| 41 | |
Bohdan Kovalchuk | 0324f1b | 2020-05-26 08:04:24 -0500 | [diff] [blame] | 42 | # possible values are 0 and 0xff |
| 43 | # internal Flash by default |
| 44 | ERASED_VALUE ?= 0 |
| 45 | |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 46 | ifneq ($(COMPILER), GCC_ARM) |
| 47 | $(error Only GCC ARM is supported at this moment) |
| 48 | endif |
| 49 | |
Roman Okhrimenko | 4bc2810 | 2021-02-01 19:31:41 +0200 | [diff] [blame] | 50 | CUR_APP_PATH = $(PRJ_DIR)/$(APP_NAME) |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 51 | |
Roman Okhrimenko | 4bc2810 | 2021-02-01 19:31:41 +0200 | [diff] [blame] | 52 | include $(PRJ_DIR)/platforms.mk |
| 53 | include $(PRJ_DIR)/common_libs.mk |
| 54 | include $(PRJ_DIR)/toolchains.mk |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 55 | |
| 56 | # Application-specific DEFINES |
| 57 | ifeq ($(IMG_TYPE), BOOT) |
| 58 | DEFINES_APP := -DBOOT_IMG |
| 59 | else |
| 60 | DEFINES_APP := -DUPGRADE_IMG |
| 61 | endif |
| 62 | |
| 63 | # Define start of application, RAM start and size, slot size |
| 64 | ifeq ($(PLATFORM), PSOC_062_2M) |
Bohdan Kovalchuk | 0324f1b | 2020-05-26 08:04:24 -0500 | [diff] [blame] | 65 | DEFINES_APP += -DRAM_START=0x08040000 |
| 66 | DEFINES_APP += -DRAM_SIZE=0x10000 |
Roman Okhrimenko | 4bc2810 | 2021-02-01 19:31:41 +0200 | [diff] [blame] | 67 | else ifeq ($(PLATFORM), PSOC_062_1M) |
| 68 | DEFINES_APP += -DRAM_START=0x08020000 |
| 69 | DEFINES_APP += -DRAM_SIZE=0x10000 |
| 70 | else ifeq ($(PLATFORM), PSOC_062_512K) |
| 71 | DEFINES_APP += -DRAM_START=0x08020000 |
| 72 | DEFINES_APP += -DRAM_SIZE=0x10000 |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 73 | endif |
| 74 | |
Roman Okhrimenko | 4bc2810 | 2021-02-01 19:31:41 +0200 | [diff] [blame] | 75 | |
| 76 | DEFINES_APP += -DRAM_SIZE=0x10000 |
| 77 | DEFINES_APP += -DUSER_APP_START=0x10018000 |
| 78 | SLOT_SIZE ?= 0x10000 |
| 79 | |
| 80 | |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 81 | # Collect Test Application sources |
| 82 | SOURCES_APP_SRC := $(wildcard $(CUR_APP_PATH)/*.c) |
| 83 | # Collect all the sources |
| 84 | SOURCES_APP += $(SOURCES_APP_SRC) |
| 85 | |
| 86 | # Collect includes for BlinkyApp |
| 87 | INCLUDE_DIRS_APP := $(addprefix -I, $(CURDIR)) |
| 88 | INCLUDE_DIRS_APP += $(addprefix -I, $(CUR_APP_PATH)) |
| 89 | |
| 90 | # Overwite path to linker script if custom is required, otherwise default from BSP is used |
| 91 | ifeq ($(COMPILER), GCC_ARM) |
| 92 | LINKER_SCRIPT := $(subst /cygdrive/c,c:,$(CUR_APP_PATH)/linker/$(APP_NAME).ld) |
| 93 | else |
| 94 | $(error Only GCC ARM is supported at this moment) |
| 95 | endif |
| 96 | |
| 97 | ASM_FILES_APP := |
Roman Okhrimenko | 4bc2810 | 2021-02-01 19:31:41 +0200 | [diff] [blame] | 98 | ASM_FILES_APP += $(ASM_FILES_STARTUP) |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 99 | |
| 100 | # We still need this for MCUBoot apps signing |
| 101 | IMGTOOL_PATH ?= ../../scripts/imgtool.py |
| 102 | |
Bohdan Kovalchuk | 0324f1b | 2020-05-26 08:04:24 -0500 | [diff] [blame] | 103 | SIGN_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 Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 104 | |
| 105 | # Output folder |
| 106 | OUT := $(APP_NAME)/out |
| 107 | # Output folder to contain build artifacts |
| 108 | OUT_TARGET := $(OUT)/$(PLATFORM) |
| 109 | |
| 110 | OUT_CFG := $(OUT_TARGET)/$(BUILDCFG) |
| 111 | |
| 112 | # Set build directory for BOOT and UPGRADE images |
| 113 | ifeq ($(IMG_TYPE), UPGRADE) |
Bohdan Kovalchuk | de51807 | 2020-11-30 22:10:48 +0200 | [diff] [blame] | 114 | ifeq ($(ENC_IMG), 1) |
| 115 | SIGN_ARGS += --encrypt ../../$(ENC_KEY_FILE).pem |
| 116 | endif |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 117 | SIGN_ARGS += --pad |
| 118 | UPGRADE_SUFFIX :=_upgrade |
| 119 | OUT_CFG := $(OUT_CFG)/upgrade |
| 120 | else |
| 121 | OUT_CFG := $(OUT_CFG)/boot |
| 122 | endif |
| 123 | |
| 124 | pre_build: |
| 125 | $(info [PRE_BUILD] - Generating linker script for application $(CUR_APP_PATH)/linker/$(APP_NAME).ld) |
| 126 | @$(CC) -E -x c $(CFLAGS) $(INCLUDE_DIRS) $(CUR_APP_PATH)/linker/$(APP_NAME)_template.ld | grep -v '^#' >$(CUR_APP_PATH)/linker/$(APP_NAME).ld |
| 127 | |
| 128 | # Post build action to execute after main build job |
| 129 | post_build: $(OUT_CFG)/$(APP_NAME).hex |
| 130 | $(info [POST_BUILD] - Executing post build script for $(APP_NAME)) |
| 131 | mv -f $(OUT_CFG)/$(APP_NAME).hex $(OUT_CFG)/$(APP_NAME)_unsigned.hex |
| 132 | $(PYTHON_PATH) $(IMGTOOL_PATH) $(SIGN_ARGS) $(OUT_CFG)/$(APP_NAME)_unsigned.hex $(OUT_CFG)/$(APP_NAME)$(UPGRADE_SUFFIX).hex |