This repository has been archived by the owner on Jun 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
137 lines (114 loc) · 3.03 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
###########################################################################
#
# Copyright (c) 2013-2015, ARM Limited, All Rights Reserved
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
###########################################################################
PREFIX:=arm-none-eabi-
PROJECT:=uvisor-helloworld
ifeq ("$(ARCH)","MK64F")
CPU:=$(ARCH)N1M0XXX12
ifeq ("$(TOOL)","armcc")
YT_TARGET:=frdm-k64f-armcc
else
YT_TARGET:=frdm-k64f-gcc
endif
GDB_TARGET:=k64f
else ifeq ("$(ARCH)","EFM32")
CPU:=$(ARCH)$(FAMILY)$(DEVICE)
GDB_TARGET:=efm32
ifeq ("$(FAMILY)","GG")
YT_TARGET:=efm32gg-stk-gcc
endif
ifeq ("$(FAMILY)","LG")
YT_TARGET:=efm32lg-stk-gcc
endif
ifeq ("$(FAMILY)","WG")
YT_TARGET:=efm32wg-stk-gcc
endif
ifeq ("$(FAMILY)","PG1B")
YT_TARGET:=efm32pg-stk-gcc
endif
else
ARCH:=STM32F4
CPU:=$(ARCH)29ZI
YT_TARGET:=stm32f429i-disco-gcc
GDB_TARGET:=stm32f4
endif
#
# flash firmware image using segger JLink
# https://www.segger.com/jlink-software.html
#
JLINK:=$(SEGGER)JLinkExe
JLINK_VIEWER_MASK:=0x7
JLINK_PARAM:=-Device $(CPU) -if SWD
AUXHFRCO_FREQ:=0
#
#
# GDB configuration
GDB:=$(PREFIX)gdb
DEBUG_HOST:=localhost:2331
OBJDUMP:=$(PREFIX)objdump
#
# derived variables
#
TARGET:=./build/$(YT_TARGET)/source/$(PROJECT)
TARGET_BIN:=$(TARGET).bin
JLINK_SERVER:=$(SEGGER)JLinkGDBServer
#
# add inline files for debugging / flashing
#
include Makefile.scripts
# check if uvisor symbol file can be read - add to symbols GDB config if present
GDB_DEBUG_SYMBOLS_FILE:=$(wildcard ../uvisor*/$(GDB_TARGET)/uvisor/$(GDB_TARGET)_uvisor.elf)
ifneq ("$(GDB_DEBUG_SYMBOLS_FILE)","")
GDB_DEBUG_UVISOR:=add-symbol-file $(GDB_DEBUG_SYMBOLS_FILE) uvisor_init
endif
#
# build targets
#
.PHONY: all setup firmware relase flash erase reset gdb.script gdb gdbtui gdbserver clean
all: debug gdbtui
setup:
yotta target $(YT_TARGET)
debug: setup
yotta build -d -- -j8
$(OBJDUMP) -d $(TARGET) > $(PROJECT).asm
@$(PREFIX)size $(TARGET)
release: setup
yotta build -r -- -j8
$(OBJDUMP) -d $(TARGET) > $(PROJECT).asm
@$(PREFIX)size $(TARGET)
flash:
@echo "$$__SCRIPT_FLASH" | $(JLINK) $(JLINK_PARAM)
@$(PREFIX)size $(TARGET)
erase:
@echo "$$__SCRIPT_ERASE" | $(JLINK) $(JLINK_PARAM)
reset:
@echo "$$__SCRIPT_RESET" | $(JLINK) $(JLINK_PARAM)
jlink:
$(JLINK) $(JLINK_PARAM)
gdb.script:
@echo "$$__SCRIPT_GDB" > $@
gdb: gdb.script
$(GDB) -x $<
gdbtui: gdb.script
$(GDB) -tui -x $<
gdbserver:
$(JLINK_SERVER) $(JLINK_PARAM) $(APP_JLINK_PARAM)
$(TARGET_BIN): debug
clean: setup
rm -f gdb.script $(PROJECT).asm
yotta clean