blob: 919c1de7057ebf56ed3ac7729c3579c63522bbc3 [file] [log] [blame]
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +02001#
2# Copyright (c) 2015-2018, Renesas Electronics Corporation. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
Chris Kayc8a47ba2023-10-20 09:17:33 +00007toolchains := aarch64
8
9include ../../../make_helpers/toolchain.mk
10
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020011###################################################
12# makefile
13###################################################
14
15#output file name
16FILE_NAME_SA0 = bootparam_sa0
17FILE_NAME_SA6 = cert_header_sa6
18
19OUTPUT_FILE_SA0 = $(FILE_NAME_SA0).elf
20OUTPUT_FILE_SA6 = $(FILE_NAME_SA6).elf
21
22#object file name
23OBJ_FILE_SA0 = sa0.o
24OBJ_FILE_SA6 = sa6.o
25
26#linker script name
27MEMORY_DEF_SA0 = sa0.ld.S
28MEMORY_DEF_SA6 = sa6.ld.S
29
30###################################################
31# Convenience function for adding build definitions
32# $(eval $(call add_define,FOO)) will have:
33# -DFOO if $(FOO) is empty; -DFOO=$(FOO) otherwise
34define add_define
35DEFINES += -D$(1)$(if $(value $(1)),=$(value $(1)),)
36endef
37
38# Process RCAR_SA0_SIZE flag
39ifndef RCAR_SA0_SIZE
40RCAR_SA0_SIZE := 1
41else
42ifeq (${RCAR_SA0_SIZE},0)
43RCAR_SA0_SIZE := 0
44else
45RCAR_SA0_SIZE := 1
46endif
47endif
48$(eval $(call add_define,RCAR_SA0_SIZE))
49
50# Process RCAR_SA6_TYPE flag
51ifndef RCAR_SA6_TYPE
52RCAR_SA6_TYPE := 0
53else
54ifeq (${RCAR_SA6_TYPE},0)
55RCAR_SA6_TYPE := 0
56else
57RCAR_SA6_TYPE := 1
58endif
59endif
60$(eval $(call add_define,RCAR_SA6_TYPE))
61
Marek Vasut4ae342c2019-01-05 13:56:03 +010062# Handle different VMA adjustment on D3
63ifeq (${RCAR_LSI},${RCAR_D3})
64RCAR_VMA_ADJUST_ADDR := 0xE6320000
65else
66RCAR_VMA_ADJUST_ADDR := 0xE6312000
67endif
68$(eval $(call add_define,RCAR_VMA_ADJUST_ADDR))
69
70
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020071###################################################
72
73#c compiler
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020074CFLAGS += ${DEFINES}
75CFLAGS += -I../../include/lib/stdlib
76
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020077#clean
78CL = rm -f
79
80###################################################
81.SUFFIXES : .s .c .o
82
83###################################################
84# command
85
86.PHONY: all
87all: $(OUTPUT_FILE_SA0) $(OUTPUT_FILE_SA6)
88###################################################
89# Linker
90###################################################
91$(OUTPUT_FILE_SA0) : $(MEMORY_DEF_SA0) $(OBJ_FILE_SA0)
Chris Kay255a4092024-02-21 12:52:46 +000092 $(aarch64-ld) $(OBJ_FILE_SA0) -nostdlib \
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020093 -T $(MEMORY_DEF_SA0) \
94 -o $(OUTPUT_FILE_SA0) \
Chris Kay255a4092024-02-21 12:52:46 +000095 -Wl,-Map $(FILE_NAME_SA0).map \
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020096
Chris Kay523e8642023-12-04 12:03:51 +000097 $(aarch64-oc) -O srec --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA0) $(FILE_NAME_SA0).srec
98 $(aarch64-oc) -O binary --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA0) $(FILE_NAME_SA0).bin
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020099
100$(OUTPUT_FILE_SA6) : $(MEMORY_DEF_SA6) $(OBJ_FILE_SA6)
Chris Kay255a4092024-02-21 12:52:46 +0000101 $(aarch64-ld) $(OBJ_FILE_SA6) -nostdlib \
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +0200102 -T $(MEMORY_DEF_SA6) \
103 -o $(OUTPUT_FILE_SA6) \
Chris Kay255a4092024-02-21 12:52:46 +0000104 -Wl,-Map $(FILE_NAME_SA6).map \
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +0200105
Chris Kay523e8642023-12-04 12:03:51 +0000106 $(aarch64-oc) -O srec --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA6) $(FILE_NAME_SA6).srec
107 $(aarch64-oc) -O binary --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA6) $(FILE_NAME_SA6).bin
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +0200108
109###################################################
110# Compile
111###################################################
112
Chris Kay46d3ab32024-01-15 16:16:07 +0000113%.o: %.c
Chris Kay523e8642023-12-04 12:03:51 +0000114 $(aarch64-cc) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +0200115
116.PHONY: clean
117clean:
118 $(CL) *.bin *.map *.srec *.elf *.o