-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathMakefile
186 lines (146 loc) · 5.68 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
185
186
##
# Copyright (c) 2015 Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from this
# software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
TOPDIR := ${shell pwd}
OUTROOT := build
# VERBOSE==1: Echo commands
# VERBOSE!=1: Do not echo commands
ifeq ($(VERBOSE),1)
export Q :=
else
export Q := @
endif
ifeq ($(APPLICATION),)
APPLICATION=bootrom
endif
include $(TOPDIR)/apps/$(APPLICATION)/Make.def
#
# "ES3 Bridge ASIC Boot ROM High Level Design" specifies 2 compile-time
# switches:
# Production/Development: Assign UART to debug if Development
# Normal/Simulation: If Simulation, bypass crypto and memory clearing so
# that chip-level simulations run quicker.
#
XFLAGS =
# _PRODUCTION==1: Shipping version - prevent debug from using UART
# _PRODUCTION!=1: Development version - debug uses UART
ifeq ($(_PRODUCTION),1)
XCFLAGS += -D_PRODUCTION
XAFLAGS += -D_PRODUCTION
else
# Non-production builds: testing switches allowed
include $(TOPDIR)/testing.mk
endif
# no need to include a .config for these rules
no-dot-config-targets := clean distclean
dot-config :=1
ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
dot-config := 0
endif
endif
ifeq ($(dot-config),1)
include $(TOPDIR)/.config
CONFIG_ARCH_CHIP := $(patsubst "%",%,$(strip $(CONFIG_ARCH_CHIP)))
CHIP_DIR := $(TOPDIR)/chips/$(CONFIG_ARCH_CHIP)
ifdef CONFIG_ARCH_EXTRA
ARCH_EXTRA_DIR = $(TOPDIR)/chips/$(CONFIG_ARCH_EXTRA)
endif
include $(CHIP_DIR)/Make.defs
CFLAGS += $(XCFLAGS)
AFLAGS += $(XAFLAGS)
_dummy := $(shell [ -d $(OUTROOT) ] || mkdir -p $(OUTROOT))
include $(TOPDIR)/Sources.mk
_dummy := $(foreach d,$(SRCDIRS), \
$(shell [ -d $(OUTROOT)/$(d) ] || mkdir -p $(OUTROOT)/$(d)))
endif
ELF = $(OUTROOT)/bootrom
BIN = $(ELF).bin
HEXAP = $(OUTROOT)/bromcAP.dat
HEXGP = $(OUTROOT)/bromcGP.dat
MANIFEST_OUTDIR = $(OUTROOT)/$(MANIFEST_SRCDIR)
CFLAGS += -DMANIFEST=$(MANIFEST) -DMANIFEST_HEADER="<$(MANIFEST).h>"
CFLAGS += -I$(MANIFEST_OUTDIR)
CFLAGS += -DBOOT_STAGE=$(BOOT_STAGE)
AFLAGS += -DBOOT_STAGE=$(BOOT_STAGE)
CFLAGS += $(APP_CFLAGS)
AFLAGS += $(APP_AFLAGS)
COBJS += $(MANIFEST_OUTDIR)/manifest.o $(MANIFEST_OUTDIR)/public_keys.o
all: $(HEXAP) $(HEXGP)
$(MANIFEST_OUTDIR)/%.o: $(MANIFEST_OUTDIR)/%.c
$(Q) $(CC) $(CFLAGS) -o $@ -c $<
$(MANIFEST_OUTDIR)/public_keys.c: $(PUBLIC_KEYS_FILE)
@ echo "Use "$<" as the public keys file"
$(Q) cp $< $@
$(MANIFEST_OUTDIR)/manifest.c: $(MANIFEST_OUTDIR)/manifest.mnfb
@echo "Generating manifest data..."
$(Q) cd $(MANIFEST_OUTDIR) && xxd -i $(notdir $<) > $(notdir $@)
$(MANIFEST_OUTDIR)/manifest.mnfb: $(MANIFEST_OUTDIR)/manifest
$(Q) manifesto $<
$(MANIFEST_OUTDIR)/manifest: $(MANIFEST_SRCDIR)/$(MANIFEST)
$(Q) cp $< $@
$(ELF): $(AOBJS) $(COBJS) $(APP_LIBS)
@ echo Linking $@
$(Q) $(LD) -T $(LDSCRIPT) $(LINKFLAGS) -o $@ $(AOBJS) $(COBJS) $(APP_LIBS) $(EXTRALIBS)
$(BIN): $(ELF)
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O binary $< $@
# TBD: figure out the "version"
HEXVER=0
$(HEXGP): $(BIN)
$(Q) tools/bin2verilog --input $< --out $@ \
--version $(HEXVER) --gpb --size 0x4000
$(HEXAP): $(BIN)
$(Q) tools/bin2verilog --input $< --out $@ \
--version $(HEXVER) --apb --size 0x4000
-include $(COBJS:.o=.d) $(AOBJS:.o=.d)
$(OUTROOT)/%.o: %.c
@ echo Compiling $<
$(Q) $(CC) $(CFLAGS) -MM -MT $@ -MF $(patsubst %.o,%.d,$@) -c $<
$(Q) $(CC) $(CFLAGS) -o $@ -c $<
$(OUTROOT)/%.o: %.S
@ echo Assembling $<
$(Q) $(CC) $(AFLAGS) -MM -MT $@ -MF $(patsubst %.o,%.d,$@) -c $<
$(Q) $(CC) $(AFLAGS) -o $@ -c $<
clean:
$(Q) -rm -rf $(OUTROOT)
distclean: clean
$(Q) -rm -rf .config
second_stage:
@ echo "Building for second stage boot loader"
$(Q) VERBOSE=$(VERBOSE) APPLICATION=secondstage make $(ELF) --no-print-directory
third_stage:
@ echo "Building for third stage boot firmware"
$(Q) VERBOSE=$(VERBOSE) APPLICATION=test3rdstage make --no-print-directory
es3_boot_verify:
@ echo "Building special sign-verify image"
$(Q) VERBOSE=$(VERBOSE) APPLICATION=es3_boot_verify make --no-print-directory
es3_boot_verify_restricted:
@ echo "Building special sign-verify image c/w IMS/CMS hash calculation"
$(Q) VERBOSE=$(VERBOSE) APPLICATION=es3_boot_verify_restricted make --no-print-directory
gbboot_server:
@ echo "Building server for downloading FW over UniPro"
$(Q) VERBOSE=$(VERBOSE) APPLICATION=gbboot_server make --no-print-directory