blob: 4cab5fba91cf68b134716266996d5ab246eb74b3 [file] [log] [blame]
Biju Dasfb0e5502020-12-07 13:25:07 +00001#
2# Copyright (c) 2020, 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
Biju Dasfb0e5502020-12-07 13:25:07 +000011###################################################
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
62RCAR_VMA_ADJUST_ADDR := 0xE6320000
63$(eval $(call add_define,RCAR_VMA_ADJUST_ADDR))
64
65
66###################################################
67
68#c compiler
Biju Dasfb0e5502020-12-07 13:25:07 +000069CFLAGS += ${DEFINES}
70CFLAGS += -nostdinc \
71 -I../../../include/lib/libc \
72 -I../../../include/lib/libc/aarch64
73
Biju Dasfb0e5502020-12-07 13:25:07 +000074#clean
75CL = rm -f
76
77###################################################
78.SUFFIXES : .s .c .o
79
80###################################################
81# command
82
83.PHONY: all
84all: $(OUTPUT_FILE_SA0) $(OUTPUT_FILE_SA6)
85###################################################
86# Linker
87###################################################
88$(OUTPUT_FILE_SA0) : $(MEMORY_DEF_SA0) $(OBJ_FILE_SA0)
Chris Kay523e8642023-12-04 12:03:51 +000089 $(aarch64-ld) $(OBJ_FILE_SA0) \
Biju Dasfb0e5502020-12-07 13:25:07 +000090 -T $(MEMORY_DEF_SA0) \
91 -o $(OUTPUT_FILE_SA0) \
92 -Map $(FILE_NAME_SA0).map \
93
Chris Kay523e8642023-12-04 12:03:51 +000094 $(aarch64-oc) -O srec --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA0) $(FILE_NAME_SA0).srec
95 $(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 +000096
97$(OUTPUT_FILE_SA6) : $(MEMORY_DEF_SA6) $(OBJ_FILE_SA6)
Chris Kay523e8642023-12-04 12:03:51 +000098 $(aarch64-ld) $(OBJ_FILE_SA6) \
Biju Dasfb0e5502020-12-07 13:25:07 +000099 -T $(MEMORY_DEF_SA6) \
100 -o $(OUTPUT_FILE_SA6) \
101 -Map $(FILE_NAME_SA6).map \
102
Chris Kay523e8642023-12-04 12:03:51 +0000103 $(aarch64-oc) -O srec --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA6) $(FILE_NAME_SA6).srec
104 $(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 +0000105
106###################################################
107# Compile
108###################################################
109
Chris Kay46d3ab32024-01-15 16:16:07 +0000110%.o: %.c
Chris Kay523e8642023-12-04 12:03:51 +0000111 $(aarch64-cc) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
Biju Dasfb0e5502020-12-07 13:25:07 +0000112
113.PHONY: clean
114clean:
115 $(CL) *.bin *.map *.srec *.elf *.o