blob: 8c2c054d7ebffdd6f929fd8cd4c417d7c3f74926 [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
Chris Kay1870c722024-05-02 17:52:37 +00009include ../../../make_helpers/common.mk
Chris Kayc8a47ba2023-10-20 09:17:33 +000010include ../../../make_helpers/toolchain.mk
11
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020012###################################################
13# makefile
14###################################################
15
16#output file name
17FILE_NAME_SA0 = bootparam_sa0
18FILE_NAME_SA6 = cert_header_sa6
19
20OUTPUT_FILE_SA0 = $(FILE_NAME_SA0).elf
21OUTPUT_FILE_SA6 = $(FILE_NAME_SA6).elf
22
23#object file name
24OBJ_FILE_SA0 = sa0.o
25OBJ_FILE_SA6 = sa6.o
26
27#linker script name
28MEMORY_DEF_SA0 = sa0.ld.S
29MEMORY_DEF_SA6 = sa6.ld.S
30
31###################################################
32# Convenience function for adding build definitions
33# $(eval $(call add_define,FOO)) will have:
34# -DFOO if $(FOO) is empty; -DFOO=$(FOO) otherwise
35define add_define
36DEFINES += -D$(1)$(if $(value $(1)),=$(value $(1)),)
37endef
38
39# Process RCAR_SA0_SIZE flag
40ifndef RCAR_SA0_SIZE
41RCAR_SA0_SIZE := 1
42else
43ifeq (${RCAR_SA0_SIZE},0)
44RCAR_SA0_SIZE := 0
45else
46RCAR_SA0_SIZE := 1
47endif
48endif
49$(eval $(call add_define,RCAR_SA0_SIZE))
50
51# Process RCAR_SA6_TYPE flag
52ifndef RCAR_SA6_TYPE
53RCAR_SA6_TYPE := 0
54else
55ifeq (${RCAR_SA6_TYPE},0)
56RCAR_SA6_TYPE := 0
57else
58RCAR_SA6_TYPE := 1
59endif
60endif
61$(eval $(call add_define,RCAR_SA6_TYPE))
62
Marek Vasut4ae342c2019-01-05 13:56:03 +010063# Handle different VMA adjustment on D3
64ifeq (${RCAR_LSI},${RCAR_D3})
65RCAR_VMA_ADJUST_ADDR := 0xE6320000
66else
67RCAR_VMA_ADJUST_ADDR := 0xE6312000
68endif
69$(eval $(call add_define,RCAR_VMA_ADJUST_ADDR))
70
71
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020072###################################################
73
74#c compiler
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020075CFLAGS += ${DEFINES}
76CFLAGS += -I../../include/lib/stdlib
77
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020078#clean
79CL = rm -f
80
81###################################################
82.SUFFIXES : .s .c .o
83
84###################################################
85# command
86
87.PHONY: all
88all: $(OUTPUT_FILE_SA0) $(OUTPUT_FILE_SA6)
89###################################################
90# Linker
91###################################################
92$(OUTPUT_FILE_SA0) : $(MEMORY_DEF_SA0) $(OBJ_FILE_SA0)
Chris Kay255a4092024-02-21 12:52:46 +000093 $(aarch64-ld) $(OBJ_FILE_SA0) -nostdlib \
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020094 -T $(MEMORY_DEF_SA0) \
95 -o $(OUTPUT_FILE_SA0) \
Chris Kay255a4092024-02-21 12:52:46 +000096 -Wl,-Map $(FILE_NAME_SA0).map \
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020097
Chris Kay523e8642023-12-04 12:03:51 +000098 $(aarch64-oc) -O srec --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA0) $(FILE_NAME_SA0).srec
99 $(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 +0200100
101$(OUTPUT_FILE_SA6) : $(MEMORY_DEF_SA6) $(OBJ_FILE_SA6)
Chris Kay255a4092024-02-21 12:52:46 +0000102 $(aarch64-ld) $(OBJ_FILE_SA6) -nostdlib \
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +0200103 -T $(MEMORY_DEF_SA6) \
104 -o $(OUTPUT_FILE_SA6) \
Chris Kay255a4092024-02-21 12:52:46 +0000105 -Wl,-Map $(FILE_NAME_SA6).map \
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +0200106
Chris Kay523e8642023-12-04 12:03:51 +0000107 $(aarch64-oc) -O srec --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA6) $(FILE_NAME_SA6).srec
108 $(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 +0200109
110###################################################
111# Compile
112###################################################
113
Chris Kay46d3ab32024-01-15 16:16:07 +0000114%.o: %.c
Chris Kay523e8642023-12-04 12:03:51 +0000115 $(aarch64-cc) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +0200116
117.PHONY: clean
118clean:
119 $(CL) *.bin *.map *.srec *.elf *.o