Yann Gautier | dbe63ac | 2022-03-16 19:03:20 +0100 | [diff] [blame] | 1 | # |
| 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 | |
| 11 | all: check_dtc_version stm32image ${STM32_TF_STM32} |
| 12 | |
| 13 | distclean realclean clean: clean_stm32image |
| 14 | |
| 15 | bl2: check_boot_device |
| 16 | |
| 17 | check_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 | |
| 29 | stm32image: ${STM32IMAGE} |
| 30 | |
| 31 | ${STM32IMAGE}: ${STM32IMAGE_SRC} |
| 32 | ${Q}${MAKE} CPPFLAGS="" --no-print-directory -C ${STM32IMAGEPATH} |
| 33 | |
| 34 | clean_stm32image: |
| 35 | ${Q}${MAKE} --no-print-directory -C ${STM32IMAGEPATH} clean |
| 36 | |
| 37 | check_dtc_version: |
Yann Gautier | aa03914 | 2023-03-02 11:20:44 +0100 | [diff] [blame] | 38 | @if [ ${DTC_VERSION} -lt 10407 ]; then \ |
| 39 | echo "dtc version too old (${DTC_V}), you need at least version 1.4.7"; \ |
Yann Gautier | dbe63ac | 2022-03-16 19:03:20 +0100 | [diff] [blame] | 40 | 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 | |
| 58 | tf-a-%.elf: $(PLAT)-%.o ${STM32_TF_LINKERFILE} |
| 59 | @echo " LDS $<" |
Yann Gautier | 6c6e6d0 | 2023-03-09 13:45:24 +0100 | [diff] [blame] | 60 | ifneq ($(findstring gcc,$(notdir $(LD))),) |
| 61 | ${Q}${LD} -o $@ $(subst --,-Wl$(comma)--,${STM32_TF_ELF_LDFLAGS}) -nostartfiles -Wl,-Map=$(@:.elf=.map) -Wl,-dT ${STM32_TF_LINKERFILE} $< |
| 62 | else |
Yann Gautier | dbe63ac | 2022-03-16 19:03:20 +0100 | [diff] [blame] | 63 | ${Q}${LD} -o $@ ${STM32_TF_ELF_LDFLAGS} -Map=$(@:.elf=.map) --script ${STM32_TF_LINKERFILE} $< |
Yann Gautier | 6c6e6d0 | 2023-03-09 13:45:24 +0100 | [diff] [blame] | 64 | endif |
Yann Gautier | dbe63ac | 2022-03-16 19:03:20 +0100 | [diff] [blame] | 65 | |
| 66 | tf-a-%.bin: tf-a-%.elf |
| 67 | ${Q}${OC} -O binary $< $@ |
| 68 | @echo |
| 69 | @echo "Built $@ successfully" |
| 70 | @echo |
| 71 | |
| 72 | tf-a-%.stm32: tf-a-%.bin ${STM32_DEPS} |
| 73 | @echo |
| 74 | @echo "Generate $@" |
Yann Gautier | 760a2d3 | 2023-09-20 15:12:26 +0200 | [diff] [blame] | 75 | $(eval LOADADDR = $(shell cat $(@:.stm32=.map) | grep '^RAM' | awk '{print $$2}')) |
Yann Gautier | dbe63ac | 2022-03-16 19:03:20 +0100 | [diff] [blame] | 76 | $(eval ENTRY = $(shell cat $(@:.stm32=.map) | grep "__BL2_IMAGE_START" | awk '{print $$1}')) |
| 77 | ${Q}${STM32IMAGE} -s $< -d $@ \ |
| 78 | -l $(LOADADDR) -e ${ENTRY} \ |
| 79 | -v ${STM32_TF_VERSION} \ |
| 80 | -m ${STM32_HEADER_VERSION_MAJOR} \ |
| 81 | -n ${STM32_HEADER_VERSION_MINOR} \ |
| 82 | -b ${STM32_HEADER_BL2_BINARY_TYPE} |
| 83 | @echo |