forked from renesas-rz/rzg2_flash_writer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile.linaro
514 lines (456 loc) · 11.7 KB
/
makefile.linaro
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
#
# Copyright (c) 2021, Renesas Electronics Corporation. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
ifeq ("$(BOARD)", "")
BOARD = RZG2L_SMARC
endif
ifeq ("$(BOARD)", "RZG2L_SMARC")
#--------------------------------------
# RZ/G2L Smarc board
#--------------------------------------
FILENAME_ADD = _RZG2L_SMARC
DEVICE = RZG2L
DDR_TYPE = DDR4
DDR_SIZE = 2GB
SWIZZLE = T1C
else ifeq ("$(BOARD)", "RZG2L_SMARC_PMIC")
#--------------------------------------
# RZ/G2L Smarc PMIC Edition board
#--------------------------------------
FILENAME_ADD = _RZG2L_SMARC_PMIC
DEVICE = RZG2L
DDR_TYPE = DDR4
DDR_SIZE = 2GB_1PCS
SWIZZLE = T1BC
else ifeq ("$(BOARD)", "RZG2L_15MMSQ_DEV")
#--------------------------------------
# RZ/G2L 15MMSQ Dev board
#--------------------------------------
FILENAME_ADD = _RZG2L_15MMSQ_DEV
DEVICE = RZG2L
DDR_TYPE = DDR4
DDR_SIZE = 4GB
SWIZZLE = T1C
else ifeq ("$(BOARD)", "RZG2L_21MMSQ_DEV")
#--------------------------------------
# RZ/G2L 21MMSQ Dev board
#--------------------------------------
FILENAME_ADD = _RZG2L_21MMSQ_DEV
DEVICE = RZG2L
DDR_TYPE = DDR4
DDR_SIZE = 4GB
SWIZZLE = T2C
else ifeq ("$(BOARD)", "RZG2LC_SMARC")
#--------------------------------------
# RZ/G2LC Smarc board
#--------------------------------------
FILENAME_ADD = _RZG2LC_SMARC
DEVICE = RZG2LC
DDR_TYPE = DDR4
DDR_SIZE = 1GB_1PCS
SWIZZLE = T3BC
else ifeq ("$(BOARD)", "RZG2LC_DEV")
#--------------------------------------
# RZ/G2LC Dev board
#--------------------------------------
FILENAME_ADD = _RZG2LC_DEV
DEVICE = RZG2LC
DDR_TYPE = DDR3L
DDR_SIZE = 1GB
SWIZZLE = T3CL
else ifeq ("$(BOARD)", "RZG2UL_TYPE1_DEV")
#--------------------------------------
# RZ/G2UL Type1 DDR4 Dev board
#--------------------------------------
FILENAME_ADD = _RZG2UL_TYPE1_DEV
DEVICE = RZG2UL
DDR_TYPE = DDR4
DDR_SIZE = 1GB_1PCS
SWIZZLE = T3BCUD
DEVICE_TYPE = 1
else ifeq ("$(BOARD)", "RZG2UL_TYPE1_DDR3L_DEV")
#--------------------------------------
# RZ/G2UL Type1 DDR3L Dev board
#--------------------------------------
FILENAME_ADD = _RZG2UL_TYPE1_DEV
DEVICE = RZG2UL
DDR_TYPE = DDR3L
DDR_SIZE = 512MB_1PCS
SWIZZLE = T3BCUL
DEVICE_TYPE = 1
else ifeq ("$(BOARD)", "RZG2UL_SMARC")
#--------------------------------------
# RZ/G2UL Smarc board
#--------------------------------------
FILENAME_ADD = _RZG2UL_SMARC
DEVICE = RZG2UL
DDR_TYPE = DDR4
DDR_SIZE = 1GB_1PCS
SWIZZLE = T3BCUD2
DEVICE_TYPE = 1
else ifeq ("$(BOARD)", "RZG2UL_TYPE2_SMARC")
#--------------------------------------
# RZ/G2UL Type2 Smarc board
#--------------------------------------
FILENAME_ADD = _RZG2UL_TYPE2_SMARC
DEVICE = RZG2UL
DDR_TYPE = DDR4
DDR_SIZE = 1GB_1PCS
SWIZZLE = T3BC
DEVICE_TYPE = 2
else ifeq ("$(BOARD)", "RZG2UL_TYPE2_DEV")
#--------------------------------------
# RZ/G2UL Type2 Dev board
#--------------------------------------
FILENAME_ADD = _RZG2UL_TYPE2_DEV
DEVICE = RZG2UL
DDR_TYPE = DDR3L
DDR_SIZE = 1GB
SWIZZLE = T3CL
DEVICE_TYPE = 2
else ifeq ("$(BOARD)", "RZV2L_SMARC")
#--------------------------------------
# RZ/V2L Smarc board
#--------------------------------------
FILENAME_ADD = _RZV2L_SMARC
DEVICE = RZV2L
DDR_TYPE = DDR4
DDR_SIZE = 4GB
SWIZZLE = T1C
else ifeq ("$(BOARD)", "RZV2L_SMARC_PMIC")
#--------------------------------------
# RZ/V2L Smarc PMIC Edition board
#--------------------------------------
FILENAME_ADD = _RZV2L_SMARC_PMIC
DEVICE = RZV2L
DDR_TYPE = DDR4
DDR_SIZE = 2GB_1PCS
SWIZZLE = T1BC
else ifeq ("$(BOARD)", "RZV2L_15MMSQ_DEV")
#--------------------------------------
# RZ/V2L 15MMSQ Dev board
#--------------------------------------
FILENAME_ADD = _RZV2L_15MMSQ_DEV
DEVICE = RZV2L
DDR_TYPE = DDR4
DDR_SIZE = 4GB
SWIZZLE = T1C
else ifeq ("$(BOARD)", "RZV2L_21MMSQ_DEV")
#--------------------------------------
# RZ/V2L 21MMSQ Dev board
#--------------------------------------
FILENAME_ADD = _RZV2L_21MMSQ_DEV
DEVICE = RZV2L
DDR_TYPE = DDR4
DDR_SIZE = 4GB
SWIZZLE = T2C
else ifeq ("$(BOARD)", "RZA3UL_DEV")
#--------------------------------------
# RZ/A3UL DDR4 Dev board
#--------------------------------------
FILENAME_ADD = _RZA3UL_DEV
DEVICE = RZA3UL
DDR_TYPE = DDR4
DDR_SIZE = 1GB_1PCS
SWIZZLE = T3BCUD
DEVICE_TYPE = 1
else ifeq ("$(BOARD)", "RZA3UL_DDR3L_DEV")
#--------------------------------------
# RZ/A3UL DDR3L Dev board
#--------------------------------------
FILENAME_ADD = _RZA3UL_DEV
DEVICE = RZA3UL
DDR_TYPE = DDR3L
DDR_SIZE = 512MB_1PCS
SWIZZLE = T3BCUL
DEVICE_TYPE = 1
else ifeq ("$(BOARD)", "RZA3UL_SMARC")
#--------------------------------------
# RZ/A3UL Smarc board
#--------------------------------------
FILENAME_ADD = _RZA3UL_SMARC
DEVICE = RZA3UL
DDR_TYPE = DDR4
DDR_SIZE = 1GB_1PCS
SWIZZLE = T3BCUD2
DEVICE_TYPE = 1
endif
# Select SERIAL_FLASH("ENABLE"or"DISABLE" )
ifeq ("$(SERIAL_FLASH)", "")
SERIAL_FLASH = ENABLE
endif
# Select EMMC("ENABLE"or"DISABLE" )
ifeq ("$(EMMC)", "")
EMMC = ENABLE
endif
# Select QSPI IO Voltage("1_8V"or"3_3V" )
ifeq ("$(QSPI_IOV)", "")
QSPI_IOV=1_8V
endif
# Select eMMC IO Voltage("1_8V"or"3_3V" )
ifeq ("$(EMMC_IOV)", "")
EMMC_IOV=1_8V
endif
ifeq ("$(INTERNAL_MEMORY_ONLY)", "")
INTERNAL_MEMORY_ONLY = DISABLE
endif
ifeq ("$(INTERNAL_MEMORY_ONLY)", "ENABLE")
DDR_TYPE = INTERNAL
endif
#CPU
CPU =
AArch = 64
THUMB =
AS_NEON =
CC_NEON = -mgeneral-regs-only
ALIGN = -mstrict-align
AArch32_64 = AArch64
BOOTDIR = AArch64_boot
OUTPUT_DIR = AArch64_output
OBJECT_DIR = AArch64_obj
CROSS_COMPILE ?= aarch64-none-elf-
CFLAGS += -O0 -fno-stack-protector -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables
BOOT_DEF = Writer
FILE_NAME = $(OUTPUT_DIR)/Flash_Writer_SCIF$(FILENAME_ADD)_$(DDR_TYPE)_$(DDR_SIZE)
ifeq ("$(DEVICE)", "RZG2L")
CFLAGS += -DRZG2L=1
endif
ifeq ("$(DEVICE)", "RZG2LC")
CFLAGS += -DRZG2LC=1
endif
ifeq ("$(DEVICE)", "RZG2UL")
CFLAGS += -DRZG2UL=1
endif
ifeq ("$(DEVICE)", "RZV2L")
CFLAGS += -DRZV2L=1
endif
ifeq ("$(DEVICE)", "RZA3UL")
CFLAGS += -DRZA3UL=1
endif
ifeq ("$(DDR_TYPE)", "DDR4")
CFLAGS += -DDDR4=1
endif
ifeq ("$(DDR_TYPE)", "DDR3L")
CFLAGS += -DDDR3L=1
endif
ifeq ("$(DDR_SIZE)", "4GB")
CFLAGS += -DDDR_SIZE_4GB=1
endif
ifeq ("$(DDR_SIZE)", "2GB")
CFLAGS += -DDDR_SIZE_2GB=1
endif
ifeq ("$(DDR_SIZE)", "2GB_1PCS")
CFLAGS += -DDDR_SIZE_2GB_1PCS=1
endif
ifeq ("$(DDR_SIZE)", "1GB")
CFLAGS += -DDDR_SIZE_1GB=1
endif
ifeq ("$(DDR_SIZE)", "1GB_1PCS")
CFLAGS += -DDDR_SIZE_1GB_1PCS=1
endif
ifeq ("$(DDR_SIZE)", "512MB_1PCS")
CFLAGS += -DDDR_SIZE_512MB_1PCS=1
endif
ifeq ("$(SWIZZLE)", "T1C")
CFLAGS += -DSWIZZLE_T1C=1
endif
ifeq ("$(SWIZZLE)", "T1BC")
CFLAGS += -DSWIZZLE_T1BC=1
endif
ifeq ("$(SWIZZLE)", "T2C")
CFLAGS += -DSWIZZLE_T2C=1
endif
ifeq ("$(SWIZZLE)", "T3BC")
CFLAGS += -DSWIZZLE_T3BC=1
endif
ifeq ("$(SWIZZLE)", "T3CL")
CFLAGS += -DSWIZZLE_T3CL=1
endif
ifeq ("$(SWIZZLE)", "T3BCUL")
CFLAGS += -DSWIZZLE_T3BCUL=1
endif
ifeq ("$(SWIZZLE)", "T3BCUD")
CFLAGS += -DSWIZZLE_T3BCUD=1
endif
ifeq ("$(SWIZZLE)", "T3BCUD2")
CFLAGS += -DSWIZZLE_T3BCUD2=1
endif
ifeq ("$(DEVICE_TYPE)", "1")
CFLAGS += -DDEVICE_TYPE=1
endif
ifeq ("$(DEVICE_TYPE)", "2")
CFLAGS += -DDEVICE_TYPE=2
endif
ifeq ("$(SERIAL_FLASH)", "ENABLE")
CFLAGS += -DSERIAL_FLASH=1
endif
ifeq ("$(SERIAL_FLASH)", "DISABLE")
CFLAGS += -DSERIAL_FLASH=0
endif
ifeq ("$(EMMC)", "ENABLE")
CFLAGS += -DEMMC=1
endif
ifeq ("$(EMMC)", "DISABLE")
CFLAGS += -DEMMC=0
endif
ifeq ("$(QSPI_IOV)", "1_8V")
CFLAGS += -DQSPI_IO_1_8V=1
endif
ifeq ("$(EMMC_IOV)", "1_8V")
CFLAGS += -DEMMC_IO_1_8V=1
endif
ifeq ("$(INTERNAL_MEMORY_ONLY)", "DISABLE")
CFLAGS += -DINTERNAL_MEMORY_ONLY=0
LINKER_FILE = memory_writer.def.s
endif
ifeq ("$(INTERNAL_MEMORY_ONLY)", "ENABLE")
CFLAGS += -Os -DINTERNAL_MEMORY_ONLY=1
LINKER_FILE = memory_writer_internal.def.s
endif
ifeq ("$(TRUSTED_BOARD_BOOT)", "ENABLE")
CFLAGS += -DTRUSTED_BOARD_BOOT=1
endif
MEMORY_DEF := $(LINKER_FILE:%.def.s=$(OBJECT_DIR)/%.def)
DDR_DEF = ddr_qos_init_setting
LIBS = -L$(subst libc.a, ,$(shell $(CC) -print-file-name=libc.a 2> /dev/null)) -lc
LIBS += -L$(subst libgcc.a, ,$(shell $(CC) -print-libgcc-file-name 2> /dev/null)) -lgcc
INCLUDE_DIR = include
DDR_COMMON = ddr/common
ifeq ("$(DEVICE)", "RZV2L")
DDR_SOC = ddr/v2l
else ifeq ("$(DEVICE)", "RZG2UL")
DDR_SOC = ddr/g2ul
else ifeq ("$(DEVICE)", "RZA3UL")
DDR_SOC = ddr/g2ul
else
DDR_SOC = ddr/g2l
endif
TOOL_DEF = "REWRITE_TOOL"
OUTPUT_FILE = $(FILE_NAME).axf
#Object file
OBJ_FILE_BOOT = \
$(OBJECT_DIR)/boot_mon.o \
$(OBJECT_DIR)/stack.o
SRC_FILE := \
main.c \
init_scif.c \
scifdrv.c \
devdrv.c \
common.c \
dgtable.c \
dgmodul1.c \
memory_cmd.c \
Message.c \
ramckmdl.c \
cpudrv.c \
sys/syc.c \
sys/sysc.c \
sys/cpg.c \
sys/pfc.c \
sys/tzc_400.c
ifeq ("$(INTERNAL_MEMORY_ONLY)", "DISABLE")
SRC_FILE += \
ddrcheck.c \
ddr/common/ddr.c
endif
ifeq ("$(DEVICE)", "RZV2L")
SRC_FILE += \
ddr/v2l/ddr_v2l.c
else ifeq ("$(DEVICE)", "RZG2UL")
SRC_FILE += \
ddr/g2ul/ddr_g2ul.c
else ifeq ("$(DEVICE)", "RZA3UL")
SRC_FILE += \
ddr/g2ul/ddr_g2ul.c
else
SRC_FILE += \
ddr/g2l/ddr_g2l.c
endif
ifeq ("$(SERIAL_FLASH)", "ENABLE")
SRC_FILE += \
dgmodul4.c \
rpcqspidrv.c \
spiflash1drv.c
endif
ifeq ("$(EMMC)", "ENABLE")
SRC_FILE += \
dg_emmc_config.c \
dg_emmc_access.c \
emmc_cmd.c \
emmc_init.c \
emmc_interrupt.c \
emmc_mount.c \
emmc_write.c \
emmc_erase.c \
emmc_utility.c
endif
OBJ_FILE := $(addprefix $(OBJECT_DIR)/,$(patsubst %.c,%.o,$(SRC_FILE)))
#Dependency File
DEPEND_FILE = $(patsubst %.lib, ,$(OBJ_FILE:%.o=%.d)) $(LINKER_FILE:.s=.d)
###################################################
#C compiler
CC = $(CROSS_COMPILE)gcc
#C++ compiler
CPP = $(CROSS_COMPILE)cpp
#Assembler
AS = $(CROSS_COMPILE)as
#Linker
LD = $(CROSS_COMPILE)ld
#Liblary
AR = $(CROSS_COMPILE)ar
#Object dump
OBJDUMP = $(CROSS_COMPILE)objdump
#Object copy
OBJCOPY = $(CROSS_COMPILE)objcopy
#clean
CL = rm -rf
###################################################
# Suffixes
.SUFFIXES : .s .c .o
###################################################
# Command
.PHONY: all
all: $(OBJECT_DIR) $(OUTPUT_DIR) $(OBJ_FILE_BOOT) $(OBJ_FILE) $(OUTPUT_FILE) $(MEMORY_DEF)
#------------------------------------------
# Make Directory
#------------------------------------------
$(OBJECT_DIR):
-mkdir "$(OBJECT_DIR)"
$(OUTPUT_DIR):
-mkdir "$(OUTPUT_DIR)"
#------------------------------------------
# Compile
#------------------------------------------
$(OBJECT_DIR)/%.o:$(BOOTDIR)/%.s
$(AS) -g $(CPU) $(AS_NEON) --MD $(patsubst %.o,%.d,$@) -I $(BOOTDIR) -I $(INCLUDE_DIR) -I $(DDR_COMMON) -I $(DDR_SOC) $< -o $@ --defsym $(AArch32_64)=0 --defsym $(BOOT_DEF)=0 --defsym $(TOOL_DEF)=0
$(OBJECT_DIR)/%.o:%.c
@if [ ! -e `dirname $@` ]; then mkdir -p `dirname $@`; fi
$(CC) -g -Os $(ALIGN) $(CPU) $(CC_NEON) $(THUMB) -MMD -MP -c -I $(BOOTDIR) -I $(INCLUDE_DIR) -I $(DDR_COMMON) -I $(DDR_SOC) $< -o $@ -D$(AArch32_64)=0 -D$(BOOT_DEF)=0 -D$(TOOL_DEF)=0 $(CFLAGS) -D$(DDR_DEF)=0
$(OBJECT_DIR)/%.def:%.def.s
@if [ ! -e `dirname $@` ]; then mkdir -p `dirname $@`; fi
$(CPP) $(CPU) $(CFLAGS) -I $(BOOTDIR) -I $(INCLUDE_DIR) -x assembler-with-cpp -MMD -MP -P $< -o $@ -D$(AArch32_64)=0 -D$(BOOT_DEF)=0 -D$(TOOL_DEF)=0 -D$(DDR_DEF)=0
#------------------------------------------
# Linker
#------------------------------------------
$(OUTPUT_FILE): $(OBJ_FILE_BOOT) $(OBJ_FILE) $(MEMORY_DEF)
$(LD) $(OBJ_FILE_BOOT) $(OBJ_FILE) \
-T '$(MEMORY_DEF)' \
-o '$(OUTPUT_FILE)' \
-Map '$(FILE_NAME).map' \
-static \
$(LIBS)
# Make MOT file
$(OBJCOPY) -O srec --srec-forceS3 "$(OUTPUT_FILE)" "$(FILE_NAME).mot"
# Make Binary file
$(OBJCOPY) -O binary "$(OUTPUT_FILE)" "$(FILE_NAME).bin"
# Dis assemble
$(OBJDUMP) -d -S "$(OUTPUT_FILE)" > "$(FILE_NAME)_disasm.txt"
# Time Stamp
@echo ========== `date` ==========
@echo ========== !!! Compile Complete !!! ==========
.PHONY: clean
clean:
$(CL) $(OBJECT_DIR)/* $(OUTPUT_DIR)/*
-include $(DEPEND_FILE)