blob: 936420dbc398b47f553d68aeecac9ed6e2caf5dc [file] [log] [blame]
Biju Dasfb0e5502020-12-07 13:25:07 +00001#
Chris Kay51a20b72024-06-04 11:31:06 +00002# Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.
Biju Dasfb0e5502020-12-07 13:25:07 +00003# Copyright (c) 2020, Renesas Electronics Corporation. All rights reserved.
4#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7
Chris Kayc8a47ba2023-10-20 09:17:33 +00008toolchains := aarch64
9
Chris Kay1559f642024-06-04 00:04:48 +000010include ../../../make_helpers/build-rules.mk
Chris Kay1870c722024-05-02 17:52:37 +000011include ../../../make_helpers/common.mk
Chris Kayc8a47ba2023-10-20 09:17:33 +000012include ../../../make_helpers/toolchain.mk
13
Biju Dasfb0e5502020-12-07 13:25:07 +000014###################################################
15# makefile
16###################################################
17
18#output file name
19FILE_NAME_SA0 = bootparam_sa0
20FILE_NAME_SA6 = cert_header_sa6
21
22OUTPUT_FILE_SA0 = $(FILE_NAME_SA0).elf
23OUTPUT_FILE_SA6 = $(FILE_NAME_SA6).elf
24
25#object file name
26OBJ_FILE_SA0 = sa0.o
27OBJ_FILE_SA6 = sa6.o
28
29#linker script name
30MEMORY_DEF_SA0 = sa0.ld.S
31MEMORY_DEF_SA6 = sa6.ld.S
32
33###################################################
34# Convenience function for adding build definitions
35# $(eval $(call add_define,FOO)) will have:
36# -DFOO if $(FOO) is empty; -DFOO=$(FOO) otherwise
37define add_define
38DEFINES += -D$(1)$(if $(value $(1)),=$(value $(1)),)
39endef
40
41# Process RCAR_SA0_SIZE flag
42ifndef RCAR_SA0_SIZE
43RCAR_SA0_SIZE := 1
44else
45ifeq (${RCAR_SA0_SIZE},0)
46RCAR_SA0_SIZE := 0
47else
48RCAR_SA0_SIZE := 1
49endif
50endif
51$(eval $(call add_define,RCAR_SA0_SIZE))
52
53# Process RCAR_SA6_TYPE flag
54ifndef RCAR_SA6_TYPE
55RCAR_SA6_TYPE := 0
56else
57ifeq (${RCAR_SA6_TYPE},0)
58RCAR_SA6_TYPE := 0
59else
60RCAR_SA6_TYPE := 1
61endif
62endif
63$(eval $(call add_define,RCAR_SA6_TYPE))
64
65RCAR_VMA_ADJUST_ADDR := 0xE6320000
66$(eval $(call add_define,RCAR_VMA_ADJUST_ADDR))
67
68
69###################################################
70
71#c compiler
Biju Dasfb0e5502020-12-07 13:25:07 +000072CFLAGS += ${DEFINES}
73CFLAGS += -nostdinc \
74 -I../../../include/lib/libc \
75 -I../../../include/lib/libc/aarch64
76
Biju Dasfb0e5502020-12-07 13:25:07 +000077#clean
78CL = rm -f
79
80###################################################
81.SUFFIXES : .s .c .o
82
83###################################################
84# command
85
86.PHONY: all
Chris Kay51a20b72024-06-04 11:31:06 +000087
88all: $(FILE_NAME_SA0).srec $(FILE_NAME_SA0).bin
89all: $(FILE_NAME_SA6).srec $(FILE_NAME_SA6).bin
90
Biju Dasfb0e5502020-12-07 13:25:07 +000091###################################################
92# Linker
93###################################################
Chris Kay51a20b72024-06-04 11:31:06 +000094
Chris Kay1559f642024-06-04 00:04:48 +000095$(FILE_NAME_SA0).srec: $(OUTPUT_FILE_SA0) | $$(@D)/
Chris Kay51a20b72024-06-04 11:31:06 +000096 $(aarch64-oc) -O srec --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA0) $(FILE_NAME_SA0).srec
Biju Dasfb0e5502020-12-07 13:25:07 +000097
Chris Kay1559f642024-06-04 00:04:48 +000098$(FILE_NAME_SA0).bin: $(OUTPUT_FILE_SA0) | $$(@D)/
Chris Kay51a20b72024-06-04 11:31:06 +000099 $(aarch64-oc) -O binary --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA0) $(FILE_NAME_SA0).bin
Biju Dasfb0e5502020-12-07 13:25:07 +0000100
Chris Kay1559f642024-06-04 00:04:48 +0000101$(OUTPUT_FILE_SA0): $(MEMORY_DEF_SA0) $(OBJ_FILE_SA0) | $$(@D)/
Chris Kay51a20b72024-06-04 11:31:06 +0000102 $(aarch64-ld) $(OBJ_FILE_SA0) -nostdlib -T $(MEMORY_DEF_SA0) -o $(OUTPUT_FILE_SA0) -Wl,-Map $(FILE_NAME_SA0).map
103
Chris Kay1559f642024-06-04 00:04:48 +0000104$(FILE_NAME_SA6).srec: $(OUTPUT_FILE_SA6) | $$(@D)/
Chris Kay51a20b72024-06-04 11:31:06 +0000105 $(aarch64-oc) -O srec --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA6) $(FILE_NAME_SA6).srec
106
Chris Kay1559f642024-06-04 00:04:48 +0000107$(FILE_NAME_SA6).bin: $(OUTPUT_FILE_SA6) | $$(@D)/
Chris Kay51a20b72024-06-04 11:31:06 +0000108 $(aarch64-oc) -O binary --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA6) $(FILE_NAME_SA6).bin
Biju Dasfb0e5502020-12-07 13:25:07 +0000109
Chris Kay1559f642024-06-04 00:04:48 +0000110$(OUTPUT_FILE_SA6): $(MEMORY_DEF_SA6) $(OBJ_FILE_SA6) | $$(@D)/
Chris Kay51a20b72024-06-04 11:31:06 +0000111 $(aarch64-ld) $(OBJ_FILE_SA6) -nostdlib -T $(MEMORY_DEF_SA6) -o $(OUTPUT_FILE_SA6) -Wl,-Map $(FILE_NAME_SA6).map
Biju Dasfb0e5502020-12-07 13:25:07 +0000112
113###################################################
114# Compile
115###################################################
116
Chris Kay1559f642024-06-04 00:04:48 +0000117%.o: %.c | $$(@D)/
Chris Kay523e8642023-12-04 12:03:51 +0000118 $(aarch64-cc) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
Biju Dasfb0e5502020-12-07 13:25:07 +0000119
120.PHONY: clean
121clean:
122 $(CL) *.bin *.map *.srec *.elf *.o