Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 1 | # |
| 2 | # Copyright (c) 2015-2018, Renesas Electronics Corporation. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | |
Chris Kay | c8a47ba | 2023-10-20 09:17:33 +0000 | [diff] [blame] | 7 | toolchains := aarch64 |
| 8 | |
| 9 | include ../../../make_helpers/toolchain.mk |
| 10 | |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 11 | ################################################### |
| 12 | # makefile |
| 13 | ################################################### |
| 14 | |
| 15 | #output file name |
| 16 | FILE_NAME_SA0 = bootparam_sa0 |
| 17 | FILE_NAME_SA6 = cert_header_sa6 |
| 18 | |
| 19 | OUTPUT_FILE_SA0 = $(FILE_NAME_SA0).elf |
| 20 | OUTPUT_FILE_SA6 = $(FILE_NAME_SA6).elf |
| 21 | |
| 22 | #object file name |
| 23 | OBJ_FILE_SA0 = sa0.o |
| 24 | OBJ_FILE_SA6 = sa6.o |
| 25 | |
| 26 | #linker script name |
| 27 | MEMORY_DEF_SA0 = sa0.ld.S |
| 28 | MEMORY_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 |
| 34 | define add_define |
| 35 | DEFINES += -D$(1)$(if $(value $(1)),=$(value $(1)),) |
| 36 | endef |
| 37 | |
| 38 | # Process RCAR_SA0_SIZE flag |
| 39 | ifndef RCAR_SA0_SIZE |
| 40 | RCAR_SA0_SIZE := 1 |
| 41 | else |
| 42 | ifeq (${RCAR_SA0_SIZE},0) |
| 43 | RCAR_SA0_SIZE := 0 |
| 44 | else |
| 45 | RCAR_SA0_SIZE := 1 |
| 46 | endif |
| 47 | endif |
| 48 | $(eval $(call add_define,RCAR_SA0_SIZE)) |
| 49 | |
| 50 | # Process RCAR_SA6_TYPE flag |
| 51 | ifndef RCAR_SA6_TYPE |
| 52 | RCAR_SA6_TYPE := 0 |
| 53 | else |
| 54 | ifeq (${RCAR_SA6_TYPE},0) |
| 55 | RCAR_SA6_TYPE := 0 |
| 56 | else |
| 57 | RCAR_SA6_TYPE := 1 |
| 58 | endif |
| 59 | endif |
| 60 | $(eval $(call add_define,RCAR_SA6_TYPE)) |
| 61 | |
Marek Vasut | 4ae342c | 2019-01-05 13:56:03 +0100 | [diff] [blame] | 62 | # Handle different VMA adjustment on D3 |
| 63 | ifeq (${RCAR_LSI},${RCAR_D3}) |
| 64 | RCAR_VMA_ADJUST_ADDR := 0xE6320000 |
| 65 | else |
| 66 | RCAR_VMA_ADJUST_ADDR := 0xE6312000 |
| 67 | endif |
| 68 | $(eval $(call add_define,RCAR_VMA_ADJUST_ADDR)) |
| 69 | |
| 70 | |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 71 | ################################################### |
| 72 | |
| 73 | #c compiler |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 74 | CFLAGS += ${DEFINES} |
| 75 | CFLAGS += -I../../include/lib/stdlib |
| 76 | |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 77 | #clean |
| 78 | CL = rm -f |
| 79 | |
| 80 | ################################################### |
| 81 | .SUFFIXES : .s .c .o |
| 82 | |
| 83 | ################################################### |
| 84 | # command |
| 85 | |
| 86 | .PHONY: all |
| 87 | all: $(OUTPUT_FILE_SA0) $(OUTPUT_FILE_SA6) |
| 88 | ################################################### |
| 89 | # Linker |
| 90 | ################################################### |
| 91 | $(OUTPUT_FILE_SA0) : $(MEMORY_DEF_SA0) $(OBJ_FILE_SA0) |
Chris Kay | 255a409 | 2024-02-21 12:52:46 +0000 | [diff] [blame] | 92 | $(aarch64-ld) $(OBJ_FILE_SA0) -nostdlib \ |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 93 | -T $(MEMORY_DEF_SA0) \ |
| 94 | -o $(OUTPUT_FILE_SA0) \ |
Chris Kay | 255a409 | 2024-02-21 12:52:46 +0000 | [diff] [blame] | 95 | -Wl,-Map $(FILE_NAME_SA0).map \ |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 96 | |
Chris Kay | 523e864 | 2023-12-04 12:03:51 +0000 | [diff] [blame] | 97 | $(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-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 99 | |
| 100 | $(OUTPUT_FILE_SA6) : $(MEMORY_DEF_SA6) $(OBJ_FILE_SA6) |
Chris Kay | 255a409 | 2024-02-21 12:52:46 +0000 | [diff] [blame] | 101 | $(aarch64-ld) $(OBJ_FILE_SA6) -nostdlib \ |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 102 | -T $(MEMORY_DEF_SA6) \ |
| 103 | -o $(OUTPUT_FILE_SA6) \ |
Chris Kay | 255a409 | 2024-02-21 12:52:46 +0000 | [diff] [blame] | 104 | -Wl,-Map $(FILE_NAME_SA6).map \ |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 105 | |
Chris Kay | 523e864 | 2023-12-04 12:03:51 +0000 | [diff] [blame] | 106 | $(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-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 108 | |
| 109 | ################################################### |
| 110 | # Compile |
| 111 | ################################################### |
| 112 | |
Chris Kay | 46d3ab3 | 2024-01-15 16:16:07 +0000 | [diff] [blame] | 113 | %.o: %.c |
Chris Kay | 523e864 | 2023-12-04 12:03:51 +0000 | [diff] [blame] | 114 | $(aarch64-cc) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< |
Jorge Ramirez-Ortiz | bf084dc | 2018-09-23 09:36:13 +0200 | [diff] [blame] | 115 | |
| 116 | .PHONY: clean |
| 117 | clean: |
| 118 | $(CL) *.bin *.map *.srec *.elf *.o |