blob: fa48dfcffa399e4b0959947a2ad8a59bac22f9c5 [file] [log] [blame]
Yann Gautierdbe63ac2022-03-16 19:03:20 +01001#
2# Copyright (c) 2023, STMicroelectronics - All Rights Reserved
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
7# Compilation rules
8.PHONY: check_dtc_version stm32image clean_stm32image check_boot_device
9.SUFFIXES:
10
11all: check_dtc_version stm32image ${STM32_TF_STM32}
12
13distclean realclean clean: clean_stm32image
14
15bl2: check_boot_device
16
17check_boot_device:
18 @if [ ${STM32MP_EMMC} != 1 ] && \
19 [ ${STM32MP_SDMMC} != 1 ] && \
20 [ ${STM32MP_RAW_NAND} != 1 ] && \
21 [ ${STM32MP_SPI_NAND} != 1 ] && \
22 [ ${STM32MP_SPI_NOR} != 1 ] && \
23 [ ${STM32MP_UART_PROGRAMMER} != 1 ] && \
24 [ ${STM32MP_USB_PROGRAMMER} != 1 ]; then \
25 echo "No boot device driver is enabled"; \
26 false; \
27 fi
28
29stm32image: ${STM32IMAGE}
30
31${STM32IMAGE}: ${STM32IMAGE_SRC}
32 ${Q}${MAKE} CPPFLAGS="" --no-print-directory -C ${STM32IMAGEPATH}
33
34clean_stm32image:
35 ${Q}${MAKE} --no-print-directory -C ${STM32IMAGEPATH} clean
36
37check_dtc_version:
Yann Gautieraa039142023-03-02 11:20:44 +010038 @if [ ${DTC_VERSION} -lt 10407 ]; then \
39 echo "dtc version too old (${DTC_V}), you need at least version 1.4.7"; \
Yann Gautierdbe63ac2022-03-16 19:03:20 +010040 false; \
41 fi
42
43# Create DTB file for BL2
44${BUILD_PLAT}/fdts/%-bl2.dts: fdts/%.dts fdts/${BL2_DTSI} | ${BUILD_PLAT} fdt_dirs
45 @echo '#include "$(patsubst fdts/%,%,$<)"' > $@
46 @echo '#include "${BL2_DTSI}"' >> $@
47
48${BUILD_PLAT}/fdts/%-bl2.dtb: ${BUILD_PLAT}/fdts/%-bl2.dts
49
50${BUILD_PLAT}/$(PLAT)-%.o: ${BUILD_PLAT}/fdts/%-bl2.dtb $(STM32_BINARY_MAPPING) bl2
51 @echo " AS $${PLAT}.S"
52 ${Q}${AS} ${ASFLAGS} ${TF_CFLAGS} \
53 -DDTB_BIN_PATH=\"$<\" \
54 -c $(word 2,$^) -o $@
55
56$(eval $(call MAKE_LD,${STM32_TF_LINKERFILE},$(STM32_LD_FILE),bl2))
57
58tf-a-%.elf: $(PLAT)-%.o ${STM32_TF_LINKERFILE}
59 @echo " LDS $<"
60 ${Q}${LD} -o $@ ${STM32_TF_ELF_LDFLAGS} -Map=$(@:.elf=.map) --script ${STM32_TF_LINKERFILE} $<
61
62tf-a-%.bin: tf-a-%.elf
63 ${Q}${OC} -O binary $< $@
64 @echo
65 @echo "Built $@ successfully"
66 @echo
67
68tf-a-%.stm32: tf-a-%.bin ${STM32_DEPS}
69 @echo
70 @echo "Generate $@"
71 $(eval LOADADDR = $(shell cat $(@:.stm32=.map) | grep RAM | awk '{print $$2}'))
72 $(eval ENTRY = $(shell cat $(@:.stm32=.map) | grep "__BL2_IMAGE_START" | awk '{print $$1}'))
73 ${Q}${STM32IMAGE} -s $< -d $@ \
74 -l $(LOADADDR) -e ${ENTRY} \
75 -v ${STM32_TF_VERSION} \
76 -m ${STM32_HEADER_VERSION_MAJOR} \
77 -n ${STM32_HEADER_VERSION_MINOR} \
78 -b ${STM32_HEADER_BL2_BINARY_TYPE}
79 @echo