blob: 562ce73eeca2ab420853d676392fe3480460f686 [file] [log] [blame]
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +02001################################################################################
2# \file toolchains.mk
3# \version 1.0
4#
5# \brief
6# Makefile to describe supported toolchains 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# Compilers
27GCC_ARM := 1
28IAR := 2
29ARM := 3
30OTHER := 4
31
32ifeq ($(MAKEINFO), 1)
33$(info $(COMPILER))
34endif
35# Detect host OS to make resolving compiler pathes easier
36UNAME_S := $(shell uname -s)
37ifeq ($(UNAME_S), Darwin)
38 HOST_OS = osx
39else
40 ifeq ($(UNAME_S), Linux)
41 HOST_OS = linux
42 else
43 HOST_OS = win
44 endif
45endif
46
47# Path to the compiler installation
48# NOTE: Absolute pathes for now for the sake of development
49ifeq ($(HOST_OS), win)
50 ifeq ($(COMPILER), GCC_ARM)
Bohdan Kovalchuk0324f1b2020-05-26 08:04:24 -050051 TOOLCHAIN_PATH ?= c:/Users/$(USERNAME)/ModusToolbox/tools_2.1/gcc-7.2.1
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +020052 MY_TOOLCHAIN_PATH:=$(subst \,/,$(TOOLCHAIN_PATH))
53 TOOLCHAIN_PATH := $(MY_TOOLCHAIN_PATH)
54 GCC_PATH := $(TOOLCHAIN_PATH)
55 # executables
56 CC := "$(GCC_PATH)/bin/arm-none-eabi-gcc"
57 LD := $(CC)
58
59 else ifeq ($(COMPILER), IAR)
60 IAR_PATH := C:/Program Files (x86)/IAR Systems/Embedded Workbench 8.0/arm
61 # executables
62 CC := "$(IAR_PATH)/bin/iccarm.exe"
63 AS := "$(IAR_PATH)/bin/iasmarm.exe"
64 LD := "$(IAR_PATH)/bin/ilinkarm.exe"
65 endif
66
67else ifeq ($(HOST_OS), osx)
68 TOOLCHAIN_PATH ?= /opt/gcc-arm-none-eabi
69 GCC_PATH := $(TOOLCHAIN_PATH)
70
71 CC := "$(GCC_PATH)/bin/arm-none-eabi-gcc"
72 LD := $(CC)
73
74else ifeq ($(HOST_OS), linux)
75 TOOLCHAIN_PATH ?= /usr/bin/gcc-arm-none-eabi/bin/arm-none-eabi-gcc
76 GCC_PATH := $(TOOLCHAIN_PATH)
77 # executables
78 CC := "$(GCC_PATH)/bin/arm-none-eabi-gcc"
79 LD := $(CC)
80endif
81
82PDL_ELFTOOL := "hal/tools/$(HOST_OS)/elf/cymcuelftool"
83
84# Set executable names for compilers
85ifeq ($(COMPILER), GCC_ARM)
86 CC := "$(GCC_PATH)/bin/arm-none-eabi-gcc"
87 LD := $(CC)
88else
89 CC := "$(IAR_PATH)/bin/iccarm.exe"
90 AS := "$(IAR_PATH)/bin/iasmarm.exe"
91 LD := "$(IAR_PATH)/bin/ilinkarm.exe"
92endif
93
94OBJDUMP := "$(GCC_PATH)/bin/arm-none-eabi-objdump"
95OBJCOPY := "$(GCC_PATH)/bin/arm-none-eabi-objcopy"
96
97# Set flags for toolchain executables
98
99ifeq ($(COMPILER), GCC_ARM)
100 # set build-in compiler flags
101 CFLAGS_COMMON := -mcpu=cortex-m0plus -mthumb -mfloat-abi=soft -fno-stack-protector -ffunction-sections -fdata-sections -ffat-lto-objects -fstrict-aliasing -g -Wall -Wextra
102 ifeq ($(BUILDCFG), Debug)
103 CFLAGS_COMMON += -Og -g3
104 else ifeq ($(BUILDCFG), Release)
105 CFLAGS_COMMON += -Os -g
106 else
107$(error BUILDCFG : '$(BUILDCFG)' is not supported)
108 endif
109 # add defines and includes
110 CFLAGS := $(CFLAGS_COMMON) $(INCLUDES)
111 CC_DEPEND = -MD -MP -MF
112
113 LDFLAGS_COMMON := -mcpu=cortex-m0plus -mthumb -specs=nano.specs -ffunction-sections -fdata-sections -Wl,--gc-sections -L "$(GCC_PATH)/lib/gcc/arm-none-eabi/7.2.1/thumb/v6-m" -ffat-lto-objects -g --enable-objc-gc
114 ifeq ($(BUILDCFG), Debug)
115 LDFLAGS_COMMON += -Og
116 else ifeq ($(BUILDCFG), Release)
117 LDFLAGS_COMMON += -Os
118 else
119$(error BUILDCFG : '$(BUILDCFG)' is not supported)
120 endif
121 LDFLAGS_NANO := -L "$(GCC_PATH)/arm-none-eabi/lib/thumb/v6-m"
122 # TODO: check .map name
123 LDFLAGS := $(LDFLAGS_COMMON) $(LDFLAGS_NANO)
124
125else ifeq ($(COMPILER), IAR)
126
127 CFLAGS := --debug --endian=little --cpu=Cortex-M0+ -e --fpu=None --dlib_config "$(IAR_PATH)\INC\c\DLib_Config_Normal.h"
128 CFLAGS += -Ohz --silent
129# CFLAGS += $(DEFINES) $(INCLUDES)
130 CFLAGS += $(INCLUDES)
131 CC_DEPEND = --dependencies
132
133 AS_FLAGS := -s+ "-M<>" -w+ -r --cpu Cortex-M0+ --fpu None -S
134
135 LINKER_SCRIPT := $(CHIP_SERIES).icf
136
137 #options to extend stack analize: --log call_graph --log_file $(OUT)/stack_usage_$(SUFFIX).txt
138 LDFLAGS_STACK_USAGE := --stack_usage_control $(STACK_CONTROL_FILE) --diag_suppress=Ls015 --diag_suppress=Ls016
139 LDFLAGS_COMMON := --vfe --text_out locale --silent --inline --merge_duplicate_sections
140 LDFLAGS := $(LDFLAGS_COMMON) $(LDFLAGS_STACK_USAGE) --config $(LINKER_SCRIPT) --map $(OUT_APP)/$(APP_NAME).map --entry Cy_FB_ResetHandler --no_exceptions
141endif