xref: /OK3568_Linux_fs/buildroot/boot/uboot/uboot.mk (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1################################################################################
2#
3# uboot
4#
5################################################################################
6
7UBOOT_VERSION = $(call qstrip,$(BR2_TARGET_UBOOT_VERSION))
8UBOOT_BOARD_NAME = $(call qstrip,$(BR2_TARGET_UBOOT_BOARDNAME))
9
10UBOOT_LICENSE = GPL-2.0+
11ifeq ($(BR2_TARGET_UBOOT_LATEST_VERSION),y)
12UBOOT_LICENSE_FILES = Licenses/gpl-2.0.txt
13endif
14UBOOT_CPE_ID_VENDOR = denx
15UBOOT_CPE_ID_PRODUCT = u-boot
16
17UBOOT_INSTALL_IMAGES = YES
18
19# u-boot 2020.01+ needs make 4.0+
20UBOOT_DEPENDENCIES = host-pkgconf $(BR2_MAKE_HOST_DEPENDENCY)
21UBOOT_MAKE = $(BR2_MAKE)
22
23ifeq ($(UBOOT_VERSION),custom)
24# Handle custom U-Boot tarballs as specified by the configuration
25UBOOT_TARBALL = $(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_TARBALL_LOCATION))
26UBOOT_SITE = $(patsubst %/,%,$(dir $(UBOOT_TARBALL)))
27UBOOT_SOURCE = $(notdir $(UBOOT_TARBALL))
28else ifeq ($(BR2_TARGET_UBOOT_CUSTOM_GIT),y)
29UBOOT_SITE = $(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_REPO_URL))
30UBOOT_SITE_METHOD = git
31else ifeq ($(BR2_TARGET_UBOOT_CUSTOM_HG),y)
32UBOOT_SITE = $(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_REPO_URL))
33UBOOT_SITE_METHOD = hg
34else ifeq ($(BR2_TARGET_UBOOT_CUSTOM_SVN),y)
35UBOOT_SITE = $(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_REPO_URL))
36UBOOT_SITE_METHOD = svn
37else
38# Handle stable official U-Boot versions
39UBOOT_SITE = https://ftp.denx.de/pub/u-boot
40UBOOT_SOURCE = u-boot-$(UBOOT_VERSION).tar.bz2
41endif
42
43ifeq ($(BR2_TARGET_UBOOT)$(BR2_TARGET_UBOOT_LATEST_VERSION),y)
44BR_NO_CHECK_HASH_FOR += $(UBOOT_SOURCE)
45endif
46
47ifeq ($(BR2_TARGET_UBOOT_FORMAT_BIN),y)
48UBOOT_BINS += u-boot.bin
49endif
50
51ifeq ($(BR2_TARGET_UBOOT_FORMAT_DTB),y)
52UBOOT_BINS += u-boot.dtb
53endif
54
55ifeq ($(BR2_TARGET_UBOOT_FORMAT_ELF),y)
56UBOOT_BINS += u-boot
57# To make elf usable for debuging on ARC use special target
58ifeq ($(BR2_arc),y)
59UBOOT_MAKE_TARGET += mdbtrick
60endif
61endif
62
63# Call 'make all' unconditionally
64UBOOT_MAKE_TARGET += all
65
66ifeq ($(BR2_TARGET_UBOOT_FORMAT_KWB),y)
67UBOOT_BINS += u-boot.kwb
68UBOOT_MAKE_TARGET += u-boot.kwb
69endif
70
71ifeq ($(BR2_TARGET_UBOOT_FORMAT_AIS),y)
72UBOOT_BINS += u-boot.ais
73UBOOT_MAKE_TARGET += u-boot.ais
74endif
75
76ifeq ($(BR2_TARGET_UBOOT_FORMAT_NAND_BIN),y)
77UBOOT_BINS += u-boot-nand.bin
78endif
79
80ifeq ($(BR2_TARGET_UBOOT_FORMAT_DTB_IMG),y)
81UBOOT_BINS += u-boot-dtb.img
82UBOOT_MAKE_TARGET += u-boot-dtb.img
83endif
84
85ifeq ($(BR2_TARGET_UBOOT_FORMAT_DTB_IMX),y)
86UBOOT_BINS += u-boot-dtb.imx
87UBOOT_MAKE_TARGET += u-boot-dtb.imx
88endif
89
90ifeq ($(BR2_TARGET_UBOOT_FORMAT_DTB_BIN),y)
91UBOOT_BINS += u-boot-dtb.bin
92UBOOT_MAKE_TARGET += u-boot-dtb.bin
93endif
94
95ifeq ($(BR2_TARGET_UBOOT_FORMAT_IMG),y)
96UBOOT_BINS += u-boot.img
97UBOOT_MAKE_TARGET += u-boot.img
98endif
99
100ifeq ($(BR2_TARGET_UBOOT_FORMAT_ITB),y)
101UBOOT_BINS += u-boot.itb
102UBOOT_MAKE_TARGET += u-boot.itb
103endif
104
105ifeq ($(BR2_TARGET_UBOOT_FORMAT_IMX),y)
106UBOOT_BINS += u-boot.imx
107UBOOT_MAKE_TARGET += u-boot.imx
108endif
109
110ifeq ($(BR2_TARGET_UBOOT_FORMAT_SB),y)
111UBOOT_BINS += u-boot.sb
112UBOOT_MAKE_TARGET += u-boot.sb
113# mxsimage needs OpenSSL
114UBOOT_DEPENDENCIES += host-elftosb host-openssl
115endif
116
117ifeq ($(BR2_TARGET_UBOOT_FORMAT_SD),y)
118# BootStream (.sb) is generated by U-Boot, we convert it to SD format
119UBOOT_BINS += u-boot.sd
120UBOOT_MAKE_TARGET += u-boot.sb
121UBOOT_DEPENDENCIES += host-elftosb host-openssl
122endif
123
124ifeq ($(BR2_TARGET_UBOOT_FORMAT_NAND),y)
125UBOOT_BINS += u-boot.nand
126UBOOT_MAKE_TARGET += u-boot.sb
127UBOOT_DEPENDENCIES += host-elftosb host-openssl
128endif
129
130ifeq ($(BR2_TARGET_UBOOT_FORMAT_STM32),y)
131UBOOT_BINS += u-boot.stm32
132UBOOT_MAKE_TARGET += u-boot.stm32
133endif
134
135ifeq ($(BR2_TARGET_UBOOT_FORMAT_CUSTOM),y)
136UBOOT_BINS += $(call qstrip,$(BR2_TARGET_UBOOT_FORMAT_CUSTOM_NAME))
137endif
138
139ifeq ($(BR2_TARGET_UBOOT_OMAP_IFT),y)
140UBOOT_BINS += u-boot.bin
141UBOOT_BIN_IFT = u-boot.bin.ift
142endif
143
144# The kernel calls AArch64 'arm64', but U-Boot calls it just 'arm', so
145# we have to special case it. Similar for i386/x86_64 -> x86
146ifeq ($(NORMALIZED_ARCH),arm64)
147UBOOT_ARCH = arm
148else ifneq ($(filter $(NORMALIZED_ARCH),i386 x86_64),)
149UBOOT_ARCH = x86
150else
151UBOOT_ARCH = $(NORMALIZED_ARCH)
152endif
153
154UBOOT_MAKE_OPTS += \
155	CROSS_COMPILE="$(TARGET_CROSS)" \
156	ARCH=$(UBOOT_ARCH) \
157	HOSTCC="$(HOSTCC) $(subst -I/,-isystem /,$(subst -I /,-isystem /,$(HOST_CFLAGS)))" \
158	HOSTLDFLAGS="$(HOST_LDFLAGS)" \
159	$(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_MAKEOPTS))
160
161ifeq ($(BR2_TARGET_UBOOT_NEEDS_ATF_BL31),y)
162UBOOT_DEPENDENCIES += arm-trusted-firmware
163ifeq ($(BR2_TARGET_UBOOT_NEEDS_ATF_BL31_ELF),y)
164UBOOT_MAKE_OPTS += BL31=$(BINARIES_DIR)/bl31.elf
165define UBOOT_COPY_ATF_FIRMWARE
166	cp $(BINARIES_DIR)/bl31.elf $(@D)/
167endef
168UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_ATF_FIRMWARE
169else
170UBOOT_MAKE_OPTS += BL31=$(BINARIES_DIR)/bl31.bin
171define UBOOT_COPY_ATF_FIRMWARE
172	cp $(BINARIES_DIR)/bl31.bin $(@D)/
173endef
174UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_ATF_FIRMWARE
175endif
176endif
177
178ifeq ($(BR2_TARGET_UBOOT_NEEDS_OPENSBI),y)
179UBOOT_DEPENDENCIES += opensbi
180UBOOT_MAKE_OPTS += OPENSBI=$(BINARIES_DIR)/fw_dynamic.bin
181endif
182
183# Mainline U-Boot versions can create the i.MX specific boot images
184# and need some NXP firmware blobs.
185ifeq ($(BR2_TARGET_UBOOT_NEEDS_IMX_FIRMWARE),y)
186UBOOT_DEPENDENCIES += firmware-imx
187UBOOT_IMX_FW_FILES = \
188	$(if $(BR2_PACKAGE_FIRMWARE_IMX_NEEDS_HDMI_FW),signed_hdmi_imx8m.bin) \
189	$(if $(BR2_PACKAGE_FIRMWARE_IMX_LPDDR4),lpddr4*.bin) \
190	$(if $(BR2_PACKAGE_FIRMWARE_IMX_DDR4),ddr4*.bin)
191
192define UBOOT_COPY_IMX_FW_FILES
193	$(foreach fw,$(UBOOT_IMX_FW_FILES),\
194		cp $(BINARIES_DIR)/$(fw) $(@D)/
195	)
196endef
197UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_IMX_FW_FILES
198endif
199
200ifeq ($(BR2_TARGET_UBOOT_NEEDS_DTC),y)
201UBOOT_DEPENDENCIES += host-dtc
202endif
203
204ifeq ($(BR2_TARGET_UBOOT_NEEDS_PYTHON2),y)
205UBOOT_DEPENDENCIES += host-python host-python-setuptools
206else ifeq ($(BR2_TARGET_UBOOT_NEEDS_PYTHON3),y)
207UBOOT_DEPENDENCIES += host-python3 host-python3-setuptools
208endif
209
210ifeq ($(BR2_TARGET_UBOOT_NEEDS_PYLIBFDT),y)
211UBOOT_DEPENDENCIES += host-swig
212endif
213
214ifeq ($(BR2_TARGET_UBOOT_NEEDS_PYELFTOOLS),y)
215ifeq ($(BR2_TARGET_UBOOT_NEEDS_PYTHON2),y)
216UBOOT_DEPENDENCIES += host-python-pyelftools
217else ifeq ($(BR2_TARGET_UBOOT_NEEDS_PYTHON3),y)
218UBOOT_DEPENDENCIES += host-python3-pyelftools
219endif
220endif
221
222ifeq ($(BR2_TARGET_UBOOT_NEEDS_OPENSSL),y)
223UBOOT_DEPENDENCIES += host-openssl
224endif
225
226ifeq ($(BR2_TARGET_UBOOT_NEEDS_LZOP),y)
227UBOOT_DEPENDENCIES += host-lzop
228endif
229
230# prior to u-boot 2013.10 the license info was in COPYING. Copy it so
231# legal-info finds it
232define UBOOT_COPY_OLD_LICENSE_FILE
233	if [ -f $(@D)/COPYING ]; then \
234		$(INSTALL) -m 0644 -D $(@D)/COPYING $(@D)/Licenses/gpl-2.0.txt; \
235	fi
236endef
237
238UBOOT_POST_EXTRACT_HOOKS += UBOOT_COPY_OLD_LICENSE_FILE
239UBOOT_POST_RSYNC_HOOKS += UBOOT_COPY_OLD_LICENSE_FILE
240
241ifneq ($(ARCH_XTENSA_OVERLAY_FILE),)
242define UBOOT_XTENSA_OVERLAY_EXTRACT
243	$(call arch-xtensa-overlay-extract,$(@D),u-boot)
244endef
245UBOOT_POST_EXTRACT_HOOKS += UBOOT_XTENSA_OVERLAY_EXTRACT
246UBOOT_EXTRA_DOWNLOADS += $(ARCH_XTENSA_OVERLAY_URL)
247endif
248
249# Analogous code exists in linux/linux.mk. Basically, the generic
250# package infrastructure handles downloading and applying remote
251# patches. Local patches are handled depending on whether they are
252# directories or files.
253UBOOT_PATCHES = $(call qstrip,$(BR2_TARGET_UBOOT_PATCH))
254UBOOT_PATCH = $(filter ftp://% http://% https://%,$(UBOOT_PATCHES))
255
256define UBOOT_APPLY_LOCAL_PATCHES
257	for p in $(filter-out ftp://% http://% https://%,$(UBOOT_PATCHES)) ; do \
258		if test -d $$p ; then \
259			$(APPLY_PATCHES) $(@D) $$p \*.patch || exit 1 ; \
260		else \
261			$(APPLY_PATCHES) $(@D) `dirname $$p` `basename $$p` || exit 1; \
262		fi \
263	done
264endef
265UBOOT_POST_PATCH_HOOKS += UBOOT_APPLY_LOCAL_PATCHES
266
267# Fixup inclusion of libfdt headers, which can fail in older u-boot versions
268# when libfdt-devel is installed system-wide.
269# The core change is equivalent to upstream commit
270# e0d20dc1521e74b82dbd69be53a048847798a90a (first in v2018.03). However, the fixup
271# is complicated by the fact that the underlying u-boot code changed multiple
272# times in history:
273# - The directory scripts/dtc/libfdt only exists since upstream commit
274#   c0e032e0090d6541549b19cc47e06ccd1f302893 (first in v2017.11). For earlier
275#   versions, create a dummy scripts/dtc/libfdt directory with symlinks for the
276#   fdt-related files. This allows to use the same -I<path> option for both
277#   cases.
278# - The variable 'srctree' used to be called 'SRCTREE' before upstream commit
279#   01286329b27b27eaeda045b469d41b1d9fce545a (first in v2014.04).
280# - The original location for libfdt, 'lib/libfdt/', used to be simply
281#   'libfdt' before upstream commit 0de71d507157c4bd4fddcd3a419140d2b986eed2
282#   (first in v2010.06). Make the 'lib' part optional in the substitution to
283#   handle this.
284define UBOOT_FIXUP_LIBFDT_INCLUDE
285	$(Q)if [ ! -d $(@D)/scripts/dtc/libfdt ]; then \
286		mkdir -p $(@D)/scripts/dtc/libfdt; \
287		cd $(@D)/scripts/dtc/libfdt; \
288		ln -s ../../../include/fdt.h .; \
289		ln -s ../../../include/libfdt*.h .; \
290		ln -s ../../../lib/libfdt/libfdt_internal.h .; \
291	fi
292	$(Q)$(SED) \
293		's%-I\ *\$$(srctree)/lib/libfdt%-I$$(srctree)/scripts/dtc/libfdt%; \
294		s%-I\ *\$$(SRCTREE)\(/lib\)\?/libfdt%-I$$(SRCTREE)/scripts/dtc/libfdt%' \
295		$(@D)/tools/Makefile
296endef
297UBOOT_POST_PATCH_HOOKS += UBOOT_FIXUP_LIBFDT_INCLUDE
298
299ifeq ($(BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY),y)
300define UBOOT_CONFIGURE_CMDS
301	$(TARGET_CONFIGURE_OPTS) \
302		$(UBOOT_MAKE) -C $(@D) $(UBOOT_MAKE_OPTS) \
303		$(UBOOT_BOARD_NAME)_config
304endef
305else ifeq ($(BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG),y)
306ifeq ($(BR2_TARGET_UBOOT_USE_DEFCONFIG),y)
307UBOOT_KCONFIG_DEFCONFIG = $(call qstrip,$(BR2_TARGET_UBOOT_BOARD_DEFCONFIG))_defconfig
308else ifeq ($(BR2_TARGET_UBOOT_USE_CUSTOM_CONFIG),y)
309UBOOT_KCONFIG_FILE = $(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE))
310endif # BR2_TARGET_UBOOT_USE_DEFCONFIG
311
312UBOOT_KCONFIG_FRAGMENT_FILES = $(call qstrip,$(BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES))
313UBOOT_KCONFIG_EDITORS = menuconfig xconfig gconfig nconfig
314
315# UBOOT_MAKE_OPTS overrides HOSTCC / HOSTLDFLAGS to allow the build to
316# find our host-openssl. However, this triggers a bug in the kconfig
317# build script that causes it to build with /usr/include/ncurses.h
318# (which is typically wchar) but link with
319# $(HOST_DIR)/lib/libncurses.so (which is not).  We don't actually
320# need any host-package for kconfig, so remove the HOSTCC/HOSTLDFLAGS
321# override again. In addition, host-ccache is not ready at kconfig
322# time, so use HOSTCC_NOCCACHE.
323UBOOT_KCONFIG_OPTS = $(UBOOT_MAKE_OPTS) HOSTCC="$(HOSTCC_NOCCACHE)" HOSTLDFLAGS=""
324endif # BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY
325
326UBOOT_CUSTOM_DTS_PATH = $(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_DTS_PATH))
327
328define UBOOT_BUILD_CMDS
329	$(if $(UBOOT_CUSTOM_DTS_PATH),
330		cp -f $(UBOOT_CUSTOM_DTS_PATH) $(@D)/arch/$(UBOOT_ARCH)/dts/
331	)
332	$(TARGET_CONFIGURE_OPTS) \
333		PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
334		PKG_CONFIG_SYSROOT_DIR="/" \
335		PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
336		PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 \
337		PKG_CONFIG_LIBDIR="$(HOST_DIR)/lib/pkgconfig:$(HOST_DIR)/share/pkgconfig" \
338		$(UBOOT_MAKE) -C $(@D) $(UBOOT_MAKE_OPTS) \
339		$(UBOOT_MAKE_TARGET)
340	$(if $(BR2_TARGET_UBOOT_FORMAT_SD),
341		$(@D)/tools/mxsboot sd $(@D)/u-boot.sb $(@D)/u-boot.sd)
342	$(if $(BR2_TARGET_UBOOT_FORMAT_NAND),
343		$(@D)/tools/mxsboot \
344			-w $(BR2_TARGET_UBOOT_FORMAT_NAND_PAGE_SIZE) \
345			-o $(BR2_TARGET_UBOOT_FORMAT_NAND_OOB_SIZE) \
346			-e $(BR2_TARGET_UBOOT_FORMAT_NAND_ERASE_SIZE) \
347			nand $(@D)/u-boot.sb $(@D)/u-boot.nand)
348endef
349
350define UBOOT_BUILD_OMAP_IFT
351	$(HOST_DIR)/bin/gpsign -f $(@D)/u-boot.bin \
352		-c $(call qstrip,$(BR2_TARGET_UBOOT_OMAP_IFT_CONFIG))
353endef
354
355define UBOOT_INSTALL_IMAGES_CMDS
356	$(foreach f,$(UBOOT_BINS), \
357			cp -dpf $(@D)/$(f) $(BINARIES_DIR)/
358	)
359	$(if $(BR2_TARGET_UBOOT_FORMAT_NAND),
360		cp -dpf $(@D)/u-boot.sb $(BINARIES_DIR))
361	$(if $(BR2_TARGET_UBOOT_SPL),
362		$(foreach f,$(call qstrip,$(BR2_TARGET_UBOOT_SPL_NAME)), \
363			cp -dpf $(@D)/$(f) $(BINARIES_DIR)/
364		)
365	)
366endef
367
368ifeq ($(BR2_TARGET_UBOOT_ZYNQMP),y)
369
370UBOOT_ZYNQMP_PMUFW = $(call qstrip,$(BR2_TARGET_UBOOT_ZYNQMP_PMUFW))
371
372ifneq ($(findstring ://,$(UBOOT_ZYNQMP_PMUFW)),)
373UBOOT_EXTRA_DOWNLOADS += $(UBOOT_ZYNQMP_PMUFW)
374BR_NO_CHECK_HASH_FOR += $(notdir $(UBOOT_ZYNQMP_PMUFW))
375UBOOT_ZYNQMP_PMUFW_PATH = $(UBOOT_DL_DIR)/$(notdir $(UBOOT_ZYNQMP_PMUFW))
376else ifneq ($(UBOOT_ZYNQMP_PMUFW),)
377UBOOT_ZYNQMP_PMUFW_PATH = $(shell readlink -f $(UBOOT_ZYNQMP_PMUFW))
378endif
379
380define UBOOT_ZYNQMP_KCONFIG_PMUFW
381	$(call KCONFIG_SET_OPT,CONFIG_PMUFW_INIT_FILE,"$(UBOOT_ZYNQMP_PMUFW_PATH)")
382endef
383
384UBOOT_ZYNQMP_PM_CFG = $(call qstrip,$(BR2_TARGET_UBOOT_ZYNQMP_PM_CFG))
385ifneq ($(UBOOT_ZYNQMP_PM_CFG),)
386UBOOT_ZYNQMP_PM_CFG_BIN = $(UBOOT_DIR)/pm_cfg_obj.bin
387define UBOOT_ZYNQMP_KCONFIG_PM_CFG
388	$(call KCONFIG_SET_OPT,CONFIG_ZYNQMP_SPL_PM_CFG_OBJ_FILE,"$(UBOOT_ZYNQMP_PM_CFG_BIN)", \
389		$(@D)/.config)
390endef
391
392define UBOOT_ZYNQMP_PM_CFG_CONVERT
393	$(UBOOT_DIR)/tools/zynqmp_pm_cfg_obj_convert.py \
394		"$(UBOOT_ZYNQMP_PM_CFG)" \
395		"$(UBOOT_ZYNQMP_PM_CFG_BIN)"
396endef
397UBOOT_PRE_BUILD_HOOKS += UBOOT_ZYNQMP_PM_CFG_CONVERT
398endif
399
400UBOOT_ZYNQMP_PSU_INIT = $(call qstrip,$(BR2_TARGET_UBOOT_ZYNQMP_PSU_INIT_FILE))
401UBOOT_ZYNQMP_PSU_INIT_PATH = $(shell readlink -f $(UBOOT_ZYNQMP_PSU_INIT))
402
403ifneq ($(UBOOT_ZYNQMP_PSU_INIT),)
404define UBOOT_ZYNQMP_KCONFIG_PSU_INIT
405	$(call KCONFIG_SET_OPT,CONFIG_XILINX_PS_INIT_FILE,"$(UBOOT_ZYNQMP_PSU_INIT_PATH)")
406endef
407endif
408
409endif # BR2_TARGET_UBOOT_ZYNQMP
410
411define UBOOT_INSTALL_OMAP_IFT_IMAGE
412	cp -dpf $(@D)/$(UBOOT_BIN_IFT) $(BINARIES_DIR)/
413endef
414
415ifeq ($(BR2_TARGET_UBOOT_OMAP_IFT),y)
416ifeq ($(BR_BUILDING),y)
417ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_OMAP_IFT_CONFIG)),)
418$(error No gpsign config file. Check your BR2_TARGET_UBOOT_OMAP_IFT_CONFIG setting)
419endif
420ifeq ($(wildcard $(call qstrip,$(BR2_TARGET_UBOOT_OMAP_IFT_CONFIG))),)
421$(error gpsign config file $(BR2_TARGET_UBOOT_OMAP_IFT_CONFIG) not found. Check your BR2_TARGET_UBOOT_OMAP_IFT_CONFIG setting)
422endif
423endif
424UBOOT_DEPENDENCIES += host-omap-u-boot-utils
425UBOOT_POST_BUILD_HOOKS += UBOOT_BUILD_OMAP_IFT
426UBOOT_POST_INSTALL_IMAGES_HOOKS += UBOOT_INSTALL_OMAP_IFT_IMAGE
427endif
428
429ifeq ($(BR2_TARGET_UBOOT_ZYNQ_IMAGE),y)
430define UBOOT_GENERATE_ZYNQ_IMAGE
431	$(HOST_DIR)/bin/python2 \
432		$(HOST_DIR)/bin/zynq-boot-bin.py \
433		-u $(@D)/$(firstword $(call qstrip,$(BR2_TARGET_UBOOT_SPL_NAME))) \
434		-o $(BINARIES_DIR)/BOOT.BIN
435endef
436UBOOT_DEPENDENCIES += host-zynq-boot-bin
437UBOOT_POST_INSTALL_IMAGES_HOOKS += UBOOT_GENERATE_ZYNQ_IMAGE
438endif
439
440ifeq ($(BR2_TARGET_UBOOT_ALTERA_SOCFPGA_IMAGE_CRC),y)
441ifeq ($(BR2_TARGET_UBOOT_SPL),y)
442UBOOT_CRC_ALTERA_SOCFPGA_INPUT_IMAGES = $(call qstrip,$(BR2_TARGET_UBOOT_SPL_NAME))
443UBOOT_CRC_ALTERA_SOCFPGA_HEADER_VERSION = 0
444else
445UBOOT_CRC_ALTERA_SOCFPGA_INPUT_IMAGES = u-boot-dtb.bin
446UBOOT_CRC_ALTERA_SOCFPGA_HEADER_VERSION = 1
447endif
448define UBOOT_CRC_ALTERA_SOCFPGA_IMAGE
449	$(foreach f,$(UBOOT_CRC_ALTERA_SOCFPGA_INPUT_IMAGES), \
450		$(HOST_DIR)/bin/mkpimage \
451			-v $(UBOOT_CRC_ALTERA_SOCFPGA_HEADER_VERSION) \
452			-o $(BINARIES_DIR)/$(notdir $(call qstrip,$(f))).crc \
453			$(@D)/$(call qstrip,$(f))
454	)
455endef
456UBOOT_DEPENDENCIES += host-mkpimage
457UBOOT_POST_INSTALL_IMAGES_HOOKS += UBOOT_CRC_ALTERA_SOCFPGA_IMAGE
458endif
459
460define UBOOT_KCONFIG_FIXUP_CMDS
461	$(UBOOT_ZYNQMP_KCONFIG_PMUFW)
462	$(UBOOT_ZYNQMP_KCONFIG_PM_CFG)
463	$(UBOOT_ZYNQMP_KCONFIG_PSU_INIT)
464endef
465
466ifeq ($(BR2_TARGET_UBOOT)$(BR_BUILDING),yy)
467
468#
469# Check U-Boot board name (for legacy) or the defconfig/custom config
470# file options (for kconfig)
471#
472ifeq ($(BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY),y)
473ifeq ($(UBOOT_BOARD_NAME),)
474$(error No U-Boot board name set. Check your BR2_TARGET_UBOOT_BOARDNAME setting)
475endif # UBOOT_BOARD_NAME
476else ifeq ($(BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG),y)
477ifeq ($(BR2_TARGET_UBOOT_USE_DEFCONFIG),y)
478ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_BOARD_DEFCONFIG)),)
479$(error No board defconfig name specified, check your BR2_TARGET_UBOOT_BOARD_DEFCONFIG setting)
480endif # qstrip BR2_TARGET_UBOOT_BOARD_DEFCONFIG
481endif # BR2_TARGET_UBOOT_USE_DEFCONFIG
482ifeq ($(BR2_TARGET_UBOOT_USE_CUSTOM_CONFIG),y)
483ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE)),)
484$(error No board configuration file specified, check your BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE setting)
485endif # qstrip BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE
486endif # BR2_TARGET_UBOOT_USE_CUSTOM_CONFIG
487endif # BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY
488
489#
490# Check custom version option
491#
492ifeq ($(BR2_TARGET_UBOOT_CUSTOM_VERSION),y)
493ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE)),)
494$(error No custom U-Boot version specified. Check your BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE setting)
495endif # qstrip BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE
496endif # BR2_TARGET_UBOOT_CUSTOM_VERSION
497
498#
499# Check custom tarball option
500#
501ifeq ($(BR2_TARGET_UBOOT_CUSTOM_TARBALL),y)
502ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_TARBALL_LOCATION)),)
503$(error No custom U-Boot tarball specified. Check your BR2_TARGET_UBOOT_CUSTOM_TARBALL_LOCATION setting)
504endif # qstrip BR2_TARGET_UBOOT_CUSTOM_TARBALL_LOCATION
505endif # BR2_TARGET_UBOOT_CUSTOM_TARBALL
506
507#
508# Check Git/Mercurial repo options
509#
510ifeq ($(BR2_TARGET_UBOOT_CUSTOM_GIT)$(BR2_TARGET_UBOOT_CUSTOM_HG),y)
511ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_REPO_URL)),)
512$(error No custom U-Boot repository URL specified. Check your BR2_TARGET_UBOOT_CUSTOM_REPO_URL setting)
513endif # qstrip BR2_TARGET_UBOOT_CUSTOM_CUSTOM_REPO_URL
514ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_REPO_VERSION)),)
515$(error No custom U-Boot repository version specified. Check your BR2_TARGET_UBOOT_CUSTOM_REPO_VERSION setting)
516endif # qstrip BR2_TARGET_UBOOT_CUSTOM_CUSTOM_REPO_VERSION
517endif # BR2_TARGET_UBOOT_CUSTOM_GIT || BR2_TARGET_UBOOT_CUSTOM_HG
518
519endif # BR2_TARGET_UBOOT && BR_BUILDING
520
521ifeq ($(BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY),y)
522UBOOT_DEPENDENCIES += \
523	$(BR2_BISON_HOST_DEPENDENCY) \
524	$(BR2_FLEX_HOST_DEPENDENCY)
525$(eval $(generic-package))
526else ifeq ($(BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG),y)
527UBOOT_MAKE_ENV = $(TARGET_MAKE_ENV)
528# Starting with 2021.10, the kconfig in uboot calls the cross-compiler
529# to check its capabilities. So we need the toolchain before we can
530# call the configurators.
531UBOOT_KCONFIG_DEPENDENCIES += \
532	toolchain \
533	$(BR2_MAKE_HOST_DEPENDENCY) \
534	$(BR2_BISON_HOST_DEPENDENCY) \
535	$(BR2_FLEX_HOST_DEPENDENCY)
536$(eval $(kconfig-package))
537endif # BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY
538