blob: 1e8f7ff713b634e69ccac21865caff962a3dbddf [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 Kay1870c722024-05-02 17:52:37 +000010include ../../../make_helpers/common.mk
Chris Kayc8a47ba2023-10-20 09:17:33 +000011include ../../../make_helpers/toolchain.mk
12
Biju Dasfb0e5502020-12-07 13:25:07 +000013###################################################
14# makefile
15###################################################
16
17#output file name
18FILE_NAME_SA0 = bootparam_sa0
19FILE_NAME_SA6 = cert_header_sa6
20
21OUTPUT_FILE_SA0 = $(FILE_NAME_SA0).elf
22OUTPUT_FILE_SA6 = $(FILE_NAME_SA6).elf
23
24#object file name
25OBJ_FILE_SA0 = sa0.o
26OBJ_FILE_SA6 = sa6.o
27
28#linker script name
29MEMORY_DEF_SA0 = sa0.ld.S
30MEMORY_DEF_SA6 = sa6.ld.S
31
32###################################################
33# Convenience function for adding build definitions
34# $(eval $(call add_define,FOO)) will have:
35# -DFOO if $(FOO) is empty; -DFOO=$(FOO) otherwise
36define add_define
37DEFINES += -D$(1)$(if $(value $(1)),=$(value $(1)),)
38endef
39
40# Process RCAR_SA0_SIZE flag
41ifndef RCAR_SA0_SIZE
42RCAR_SA0_SIZE := 1
43else
44ifeq (${RCAR_SA0_SIZE},0)
45RCAR_SA0_SIZE := 0
46else
47RCAR_SA0_SIZE := 1
48endif
49endif
50$(eval $(call add_define,RCAR_SA0_SIZE))
51
52# Process RCAR_SA6_TYPE flag
53ifndef RCAR_SA6_TYPE
54RCAR_SA6_TYPE := 0
55else
56ifeq (${RCAR_SA6_TYPE},0)
57RCAR_SA6_TYPE := 0
58else
59RCAR_SA6_TYPE := 1
60endif
61endif
62$(eval $(call add_define,RCAR_SA6_TYPE))
63
64RCAR_VMA_ADJUST_ADDR := 0xE6320000
65$(eval $(call add_define,RCAR_VMA_ADJUST_ADDR))
66
67
68###################################################
69
70#c compiler
Biju Dasfb0e5502020-12-07 13:25:07 +000071CFLAGS += ${DEFINES}
72CFLAGS += -nostdinc \
73 -I../../../include/lib/libc \
74 -I../../../include/lib/libc/aarch64
75
Biju Dasfb0e5502020-12-07 13:25:07 +000076#clean
77CL = rm -f
78
79###################################################
80.SUFFIXES : .s .c .o
81
82###################################################
83# command
84
85.PHONY: all
Chris Kay51a20b72024-06-04 11:31:06 +000086
87all: $(FILE_NAME_SA0).srec $(FILE_NAME_SA0).bin
88all: $(FILE_NAME_SA6).srec $(FILE_NAME_SA6).bin
89
Biju Dasfb0e5502020-12-07 13:25:07 +000090###################################################
91# Linker
92###################################################
Chris Kay51a20b72024-06-04 11:31:06 +000093
94$(FILE_NAME_SA0).srec: $(OUTPUT_FILE_SA0)
95 $(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 +000096
Chris Kay51a20b72024-06-04 11:31:06 +000097$(FILE_NAME_SA0).bin: $(OUTPUT_FILE_SA0)
98 $(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 +000099
Chris Kay51a20b72024-06-04 11:31:06 +0000100$(OUTPUT_FILE_SA0): $(MEMORY_DEF_SA0) $(OBJ_FILE_SA0)
101 $(aarch64-ld) $(OBJ_FILE_SA0) -nostdlib -T $(MEMORY_DEF_SA0) -o $(OUTPUT_FILE_SA0) -Wl,-Map $(FILE_NAME_SA0).map
102
103$(FILE_NAME_SA6).srec: $(OUTPUT_FILE_SA6)
104 $(aarch64-oc) -O srec --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA6) $(FILE_NAME_SA6).srec
105
106$(FILE_NAME_SA6).bin: $(OUTPUT_FILE_SA6)
107 $(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 +0000108
Chris Kay51a20b72024-06-04 11:31:06 +0000109$(OUTPUT_FILE_SA6): $(MEMORY_DEF_SA6) $(OBJ_FILE_SA6)
110 $(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 +0000111
112###################################################
113# Compile
114###################################################
115
Chris Kay46d3ab32024-01-15 16:16:07 +0000116%.o: %.c
Chris Kay523e8642023-12-04 12:03:51 +0000117 $(aarch64-cc) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
Biju Dasfb0e5502020-12-07 13:25:07 +0000118
119.PHONY: clean
120clean:
121 $(CL) *.bin *.map *.srec *.elf *.o