-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
184 lines (154 loc) · 5.66 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
################################################################################
#
# Copyright (c) 2013-2017, 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.
#
################################################################################
# Note: This file has been autogenerated. Do not modify it manually or your
# changes will be lost. */
################################################################################
# Auto-generated settings
################################################################################
APP:=mbed-os-example-uvisor-hello-world
MBED_TARGET:=K64F
MBED_TOOLCHAIN:=GCC_ARM
UVISOR_BUILD_MODE:=release
# Set the JLink CPU based on the target.
CPU:=MK64FN1M0XXX12
UVISOR_PLATFORM:=kinetis
UVISOR_CONFIGURATION:=configuration_kinetis_cortex_m4_0x1fff0000
################################################################################
# Derived settings
################################################################################
# Toolchain
PREFIX:=arm-none-eabi-
GDB:=$(PREFIX)gdb
OBJDUMP:=$(PREFIX)objdump
MBED_DEBUG_OPTIONS:=--profile mbed-os/tools/profiles/debug.json
# JLink settings
JLINK:=$(SEGGER)JLinkExe
JLINK_CFG:=-Device $(CPU) -if SWD
JLINK_SERVER:=$(SEGGER)JLinkGDBServer
DEBUG_HOST:=localhost:2331
# Paths
TARGET:=BUILD/$(MBED_TARGET)/$(MBED_TOOLCHAIN)/$(APP)
TARGET_ELF:=$(TARGET).elf
TARGET_BIN:=$(TARGET).bin
TARGET_ASM:=$(TARGET).asm
DEBUG_ELF:=debug.elf
# Detect SEGGER JLINK mass storage devices.
SEGGER_DET:=Segger.html
FW_DIR:=$(wildcard /Volumes/JLINK/$(FW_DET))
ifeq ("$(wildcard $(SEGGER_DIR))","")
FW_DIR:=$(wildcard /run/media/$(USER)/JLINK/$(FW_DET))
endif
ifeq ("$(wildcard $(FW_DIR))","")
FW_DIR:=$(wildcard /var/run/media/$(USER)/JLINK/$(FW_DET))
endif
# Detect mbed DAPLINK mass storage devices.
MBED_DET:=MBED.HTM
ifeq ("$(wildcard $(FW_DIR))","")
FW_DIR:=$(wildcard /Volumes/*/$(MBED_DET))
endif
ifeq ("$(wildcard $(FW_DIR))","")
FW_DIR:=$(wildcard /run/media/$(USER)/*/$(MBED_DET))
endif
ifeq ("$(wildcard $(FW_DIR))","")
FW_DIR:=$(wildcard /var/run/media/$(USER)/*/$(MBED_DET))
endif
ifeq ("$(wildcard $(FW_DIR))","")
FW_DIR:=./
else
FW_DIR:=$(dir $(firstword $(FW_DIR)))
endif
# Read uVisor symbols.
UVISOR_LIB:=mbed-os/features/FEATURE_UVISOR
UVISOR_CFG_D=$(UVISOR_LIB)/importer/TARGET_IGNORE/uvisor/platform/$(UVISOR_PLATFORM)/debug/$(UVISOR_CONFIGURATION).elf
UVISOR_CFG_R=$(UVISOR_LIB)/importer/TARGET_IGNORE/uvisor/platform/$(UVISOR_PLATFORM)/release/$(UVISOR_CONFIGURATION).elf
GDB_DEBUG_UVISOR=add-symbol-file $(DEBUG_ELF) &__uvisor_main_start
# GDB scripts
include Makefile.scripts
################################################################################
# Targets
################################################################################
.PHONY: all clean uvisor_clean ci local regen debug release install uvisor objdump gdbserver gdb help
all: ci
clean:
rm -rf BUILD gdb.script $(DEBUG_ELF) .debug .release
install: $(TARGET_BIN)
-cp $^ $(FW_DIR)firmware.bin
sync
uvisor_clean:
make -C $(UVISOR_LIB)/importer clean
ci:
bash build.cmd
bash run.cmd
local: release install
python ../../tools/run_now.py
regen:
python ../../test.py -g $(APP)
debug:
if [ -f .release ] ; \
then \
rm .release ; \
rm -rf BUILD ; \
fi;
touch .debug
-cp $(UVISOR_CFG_D) $(DEBUG_ELF)
mbed compile -t $(MBED_TOOLCHAIN) -m $(MBED_TARGET) $(MBED_DEBUG_OPTIONS)
release:
if [ -f .debug ] ; \
then \
rm .debug ; \
rm -rf BUILD ; \
fi;
touch .release
-cp $(UVISOR_CFG_R) $(DEBUG_ELF)
mbed compile -t $(MBED_TOOLCHAIN) -m $(MBED_TARGET)
uvisor:
make -C $(UVISOR_LIB)/importer
objdump: $(TARGET_ASM)
$(TARGET_ASM): $(TARGET_ELF)
$(OBJDUMP) -D $^ > $@
gdbserver:
$(JLINK_SERVER) $(JLINK_CFG)
gdb:
rm -f gdb.script
@echo "$$__SCRIPT_GDB" > gdb.script
$(GDB) -x gdb.script
help:
@echo ""
@echo "##############################################################################"
@echo "# uVisor developers' Makefile"
@echo "##############################################################################"
@echo " clean Clean the current directory."
@echo " uvisor_clean Clean the uVisor build files (in the mbed OS importer path)."
@echo " ci Run the same scripts that the CI would run."
@echo " local Build and run the tests in local mode."
@echo " regen Regenerate the current test job code."
@echo " Note: This does not the test job base folder."
@echo " debug Compile the mbed OS app in debug mode."
@echo " release Compile the mbed OS app in release mode."
@echo " install Install the .bin file to an mbed device."
@echo " uvisor Compile uVisor from its source code."
@echo " objdump Generate the app objdump in the BUILD folder."
@echo " gdbserver Start a GDB server in the current shell."
@echo " Note: This currently does not support daemon mode."
@echo " gdb Start a GDB session to connect to the device."
@echo " Note: It uses the script in Makefile.scripts"
@echo " Note: It requires the GDB server to be running in another shell."
@echo " all Same as ci."
@echo " help Print this message."
@echo ""