Yann Gautier | dbe63ac | 2022-03-16 19:03:20 +0100 | [diff] [blame] | 1 | # |
laurenw-arm | b3b6de7 | 2024-03-05 14:55:18 -0600 | [diff] [blame] | 2 | # Copyright (c) 2023-2024, STMicroelectronics - All Rights Reserved |
Yann Gautier | dbe63ac | 2022-03-16 19:03:20 +0100 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | |
| 7 | RESET_TO_BL2 := 1 |
| 8 | |
| 9 | STM32MP_EARLY_CONSOLE ?= 0 |
| 10 | STM32MP_RECONFIGURE_CONSOLE ?= 0 |
| 11 | STM32MP_UART_BAUDRATE ?= 115200 |
| 12 | |
| 13 | TRUSTED_BOARD_BOOT ?= 0 |
| 14 | STM32MP_USE_EXTERNAL_HEAP ?= 0 |
| 15 | |
| 16 | # Use secure library from the ROM code for authentication |
| 17 | STM32MP_CRYPTO_ROM_LIB ?= 0 |
| 18 | |
| 19 | # Please don't increment this value without good understanding of |
| 20 | # the monotonic counter |
| 21 | STM32_TF_VERSION ?= 0 |
| 22 | |
| 23 | # Enable dynamic memory mapping |
| 24 | PLAT_XLAT_TABLES_DYNAMIC := 1 |
| 25 | |
| 26 | # STM32 image header binary type for BL2 |
| 27 | STM32_HEADER_BL2_BINARY_TYPE := 0x10 |
| 28 | |
| 29 | TF_CFLAGS += -Wsign-compare |
| 30 | TF_CFLAGS += -Wformat-signedness |
| 31 | |
| 32 | # Boot devices |
| 33 | STM32MP_EMMC ?= 0 |
| 34 | STM32MP_SDMMC ?= 0 |
| 35 | STM32MP_RAW_NAND ?= 0 |
| 36 | STM32MP_SPI_NAND ?= 0 |
| 37 | STM32MP_SPI_NOR ?= 0 |
| 38 | |
| 39 | # Put both BL2 and FIP in eMMC boot partition |
| 40 | STM32MP_EMMC_BOOT ?= 0 |
| 41 | |
| 42 | # Serial boot devices |
| 43 | STM32MP_UART_PROGRAMMER ?= 0 |
| 44 | STM32MP_USB_PROGRAMMER ?= 0 |
| 45 | |
Chris Kay | 523e864 | 2023-12-04 12:03:51 +0000 | [diff] [blame] | 46 | $(eval DTC_V = $(shell $($(ARCH)-dtc) -v | awk '{print $$NF}')) |
Yann Gautier | dbe63ac | 2022-03-16 19:03:20 +0100 | [diff] [blame] | 47 | $(eval DTC_VERSION = $(shell printf "%d" $(shell echo ${DTC_V} | cut -d- -f1 | sed "s/\./0/g" | grep -o "[0-9]*"))) |
| 48 | DTC_CPPFLAGS += ${INCLUDES} |
| 49 | DTC_FLAGS += -Wno-unit_address_vs_reg |
| 50 | ifeq ($(shell test $(DTC_VERSION) -ge 10601; echo $$?),0) |
| 51 | DTC_FLAGS += -Wno-interrupt_provider |
| 52 | endif |
| 53 | |
| 54 | # Macros and rules to build TF binary |
| 55 | STM32_TF_ELF_LDFLAGS := --hash-style=gnu --as-needed |
| 56 | STM32_TF_LINKERFILE := ${BUILD_PLAT}/${PLAT}.ld |
| 57 | |
| 58 | ASFLAGS += -DBL2_BIN_PATH=\"${BUILD_PLAT}/bl2.bin\" |
| 59 | |
| 60 | # Variables for use with stm32image |
| 61 | STM32IMAGEPATH ?= tools/stm32image |
| 62 | STM32IMAGE ?= ${STM32IMAGEPATH}/stm32image${BIN_EXT} |
| 63 | STM32IMAGE_SRC := ${STM32IMAGEPATH}/stm32image.c |
| 64 | STM32_DEPS += ${STM32IMAGE} |
| 65 | |
| 66 | FIP_DEPS += dtbs |
| 67 | STM32MP_HW_CONFIG := ${BL33_CFG} |
| 68 | |
| 69 | # Add the HW_CONFIG to FIP and specify the same to certtool |
| 70 | $(eval $(call TOOL_ADD_PAYLOAD,${STM32MP_HW_CONFIG},--hw-config)) |
| 71 | |
| 72 | # Add the build options to pack Trusted OS Extra1 and Trusted OS Extra2 images |
| 73 | # in the FIP if the platform requires. |
| 74 | ifneq ($(BL32_EXTRA1),) |
| 75 | $(eval $(call TOOL_ADD_IMG,BL32_EXTRA1,--tos-fw-extra1,,$(ENCRYPT_BL32))) |
| 76 | endif |
| 77 | ifneq ($(BL32_EXTRA2),) |
| 78 | $(eval $(call TOOL_ADD_IMG,BL32_EXTRA2,--tos-fw-extra2,,$(ENCRYPT_BL32))) |
| 79 | endif |
| 80 | |
| 81 | # Enable flags for C files |
| 82 | $(eval $(call assert_booleans,\ |
| 83 | $(sort \ |
| 84 | PLAT_XLAT_TABLES_DYNAMIC \ |
| 85 | STM32MP_EARLY_CONSOLE \ |
| 86 | STM32MP_EMMC \ |
| 87 | STM32MP_EMMC_BOOT \ |
| 88 | STM32MP_RAW_NAND \ |
| 89 | STM32MP_RECONFIGURE_CONSOLE \ |
| 90 | STM32MP_SDMMC \ |
| 91 | STM32MP_SPI_NAND \ |
| 92 | STM32MP_SPI_NOR \ |
| 93 | STM32MP_UART_PROGRAMMER \ |
| 94 | STM32MP_USB_PROGRAMMER \ |
| 95 | ))) |
| 96 | |
| 97 | $(eval $(call assert_numerics,\ |
| 98 | $(sort \ |
| 99 | STM32_TF_VERSION \ |
| 100 | STM32MP_UART_BAUDRATE \ |
| 101 | ))) |
| 102 | |
| 103 | $(eval $(call add_defines,\ |
| 104 | $(sort \ |
| 105 | PLAT_XLAT_TABLES_DYNAMIC \ |
| 106 | STM32_TF_VERSION \ |
| 107 | STM32MP_EARLY_CONSOLE \ |
| 108 | STM32MP_EMMC \ |
| 109 | STM32MP_EMMC_BOOT \ |
| 110 | STM32MP_RAW_NAND \ |
| 111 | STM32MP_RECONFIGURE_CONSOLE \ |
| 112 | STM32MP_SDMMC \ |
| 113 | STM32MP_SPI_NAND \ |
| 114 | STM32MP_SPI_NOR \ |
| 115 | STM32MP_UART_BAUDRATE \ |
| 116 | STM32MP_UART_PROGRAMMER \ |
| 117 | STM32MP_USB_PROGRAMMER \ |
| 118 | ))) |
| 119 | |
| 120 | # Include paths and source files |
| 121 | PLAT_INCLUDES += -Iplat/st/common/include/ |
| 122 | |
| 123 | include lib/fconf/fconf.mk |
| 124 | include lib/libfdt/libfdt.mk |
| 125 | include lib/zlib/zlib.mk |
| 126 | |
| 127 | PLAT_BL_COMMON_SOURCES += common/uuid.c \ |
| 128 | plat/st/common/stm32mp_common.c |
| 129 | |
| 130 | |
| 131 | include lib/xlat_tables_v2/xlat_tables.mk |
| 132 | PLAT_BL_COMMON_SOURCES += ${XLAT_TABLES_LIB_SRCS} |
| 133 | |
| 134 | PLAT_BL_COMMON_SOURCES += drivers/clk/clk.c \ |
| 135 | drivers/delay_timer/delay_timer.c \ |
| 136 | drivers/delay_timer/generic_delay_timer.c \ |
| 137 | drivers/st/clk/stm32mp_clkfunc.c \ |
| 138 | drivers/st/ddr/stm32mp_ddr.c \ |
| 139 | drivers/st/gpio/stm32_gpio.c \ |
| 140 | drivers/st/regulator/regulator_core.c \ |
| 141 | drivers/st/regulator/regulator_fixed.c \ |
| 142 | plat/st/common/stm32mp_dt.c |
| 143 | |
| 144 | BL2_SOURCES += ${FCONF_SOURCES} ${FCONF_DYN_SOURCES} |
| 145 | BL2_SOURCES += $(ZLIB_SOURCES) |
| 146 | |
| 147 | BL2_SOURCES += drivers/io/io_fip.c \ |
| 148 | plat/st/common/bl2_io_storage.c \ |
Yann Gautier | ea1a3c6 | 2023-06-14 14:38:15 +0200 | [diff] [blame] | 149 | plat/st/common/plat_image_load.c \ |
Yann Gautier | dbe63ac | 2022-03-16 19:03:20 +0100 | [diff] [blame] | 150 | plat/st/common/stm32mp_fconf_io.c |
| 151 | |
| 152 | BL2_SOURCES += drivers/io/io_block.c \ |
| 153 | drivers/io/io_mtd.c \ |
| 154 | drivers/io/io_storage.c |
| 155 | |
| 156 | ifneq (${DECRYPTION_SUPPORT},none) |
| 157 | BL2_SOURCES += drivers/io/io_encrypted.c |
| 158 | endif |
| 159 | |
| 160 | ifeq (${TRUSTED_BOARD_BOOT},1) |
| 161 | AUTH_SOURCES := drivers/auth/auth_mod.c \ |
| 162 | drivers/auth/crypto_mod.c \ |
| 163 | drivers/auth/img_parser_mod.c |
| 164 | |
| 165 | ifeq (${GENERATE_COT},1) |
| 166 | TFW_NVCTR_VAL := 0 |
| 167 | NTFW_NVCTR_VAL := 0 |
Yann Gautier | dbe63ac | 2022-03-16 19:03:20 +0100 | [diff] [blame] | 168 | KEY_ALG := ecdsa |
| 169 | HASH_ALG := sha256 |
| 170 | |
| 171 | ifeq (${SAVE_KEYS},1) |
| 172 | TRUSTED_WORLD_KEY ?= ${BUILD_PLAT}/trusted.pem |
| 173 | NON_TRUSTED_WORLD_KEY ?= ${BUILD_PLAT}/non-trusted.pem |
| 174 | BL32_KEY ?= ${BUILD_PLAT}/trusted_os.pem |
| 175 | BL33_KEY ?= ${BUILD_PLAT}/non-trusted_os.pem |
| 176 | endif |
| 177 | |
| 178 | endif |
| 179 | TF_MBEDTLS_KEY_ALG := ecdsa |
laurenw-arm | b4ab90b | 2023-10-12 13:34:21 -0500 | [diff] [blame] | 180 | KEY_SIZE := 256 |
Yann Gautier | dbe63ac | 2022-03-16 19:03:20 +0100 | [diff] [blame] | 181 | |
| 182 | ifneq (${MBEDTLS_DIR},) |
| 183 | MBEDTLS_MAJOR=$(shell grep -hP "define MBEDTLS_VERSION_MAJOR" \ |
| 184 | ${MBEDTLS_DIR}/include/mbedtls/*.h | grep -oe '\([0-9.]*\)') |
| 185 | |
Yann Gautier | dbe63ac | 2022-03-16 19:03:20 +0100 | [diff] [blame] | 186 | ifeq (${MBEDTLS_MAJOR}, 3) |
Yann Gautier | d8c1a3b | 2023-03-06 13:01:10 +0100 | [diff] [blame] | 187 | MBEDTLS_CONFIG_FILE ?= "<stm32mp_mbedtls_config-3.h>" |
laurenw-arm | b3b6de7 | 2024-03-05 14:55:18 -0600 | [diff] [blame] | 188 | else |
| 189 | $(error Error: TF-A only supports MbedTLS versions > 3.x) |
Yann Gautier | dbe63ac | 2022-03-16 19:03:20 +0100 | [diff] [blame] | 190 | endif |
| 191 | endif |
| 192 | |
| 193 | include drivers/auth/mbedtls/mbedtls_x509.mk |
| 194 | |
| 195 | COT_DESC_IN_DTB := 1 |
| 196 | AUTH_SOURCES += lib/fconf/fconf_cot_getter.c \ |
| 197 | lib/fconf/fconf_tbbr_getter.c \ |
| 198 | plat/st/common/stm32mp_crypto_lib.c |
| 199 | |
| 200 | BL2_SOURCES += $(AUTH_SOURCES) \ |
| 201 | plat/st/common/stm32mp_trusted_boot.c |
| 202 | endif |
| 203 | |
| 204 | ifneq ($(filter 1,${STM32MP_EMMC} ${STM32MP_SDMMC}),) |
| 205 | BL2_SOURCES += drivers/mmc/mmc.c \ |
| 206 | drivers/partition/gpt.c \ |
| 207 | drivers/partition/partition.c |
| 208 | endif |
| 209 | |
| 210 | ifneq ($(filter 1,${STM32MP_SPI_NAND} ${STM32MP_SPI_NOR}),) |
| 211 | BL2_SOURCES += drivers/mtd/spi-mem/spi_mem.c |
| 212 | endif |
| 213 | |
| 214 | ifeq (${STM32MP_RAW_NAND},1) |
| 215 | $(eval $(call add_define_val,NAND_ONFI_DETECT,1)) |
| 216 | BL2_SOURCES += drivers/mtd/nand/raw_nand.c |
| 217 | endif |
| 218 | |
| 219 | ifeq (${STM32MP_SPI_NAND},1) |
| 220 | BL2_SOURCES += drivers/mtd/nand/spi_nand.c |
| 221 | endif |
| 222 | |
| 223 | ifeq (${STM32MP_SPI_NOR},1) |
| 224 | ifneq (${STM32MP_FORCE_MTD_START_OFFSET},) |
| 225 | $(eval $(call add_define_val,STM32MP_NOR_FIP_OFFSET,${STM32MP_FORCE_MTD_START_OFFSET})) |
| 226 | endif |
| 227 | BL2_SOURCES += drivers/mtd/nor/spi_nor.c |
| 228 | endif |
| 229 | |
| 230 | ifneq ($(filter 1,${STM32MP_RAW_NAND} ${STM32MP_SPI_NAND}),) |
| 231 | ifneq (${STM32MP_FORCE_MTD_START_OFFSET},) |
| 232 | $(eval $(call add_define_val,STM32MP_NAND_FIP_OFFSET,${STM32MP_FORCE_MTD_START_OFFSET})) |
| 233 | endif |
| 234 | BL2_SOURCES += drivers/mtd/nand/core.c |
| 235 | endif |
| 236 | |
| 237 | ifneq ($(filter 1,${STM32MP_UART_PROGRAMMER} ${STM32MP_USB_PROGRAMMER}),) |
| 238 | BL2_SOURCES += drivers/io/io_memmap.c |
| 239 | endif |
| 240 | |
| 241 | ifeq (${STM32MP_UART_PROGRAMMER},1) |
| 242 | BL2_SOURCES += plat/st/common/stm32cubeprogrammer_uart.c |
| 243 | endif |
| 244 | |
| 245 | ifeq (${STM32MP_USB_PROGRAMMER},1) |
| 246 | BL2_SOURCES += drivers/usb/usb_device.c \ |
| 247 | plat/st/common/stm32cubeprogrammer_usb.c \ |
| 248 | plat/st/common/usb_dfu.c |
| 249 | endif |
| 250 | |
| 251 | BL2_SOURCES += drivers/st/ddr/stm32mp_ddr_test.c \ |
| 252 | drivers/st/ddr/stm32mp_ram.c |
| 253 | |
| 254 | BL2_SOURCES += common/desc_image_load.c |
| 255 | |
| 256 | BL2_SOURCES += lib/optee/optee_utils.c |