uboot.mk 18 KB

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