uboot.mk 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  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_OPENSBI),y)
  150. UBOOT_DEPENDENCIES += opensbi
  151. UBOOT_MAKE_OPTS += OPENSBI=$(BINARIES_DIR)/fw_dynamic.bin
  152. endif
  153. # Mainline U-Boot versions can create the i.MX specific boot images
  154. # and need some NXP firmware blobs.
  155. ifeq ($(BR2_TARGET_UBOOT_NEEDS_IMX_FIRMWARE),y)
  156. UBOOT_DEPENDENCIES += firmware-imx
  157. UBOOT_IMX_FW_FILES = \
  158. $(if $(BR2_PACKAGE_FIRMWARE_IMX_NEEDS_HDMI_FW),signed_hdmi_imx8m.bin) \
  159. $(if $(BR2_PACKAGE_FIRMWARE_IMX_LPDDR4),lpddr4*.bin) \
  160. $(if $(BR2_PACKAGE_FIRMWARE_IMX_DDR4),ddr4*.bin)
  161. define UBOOT_COPY_IMX_FW_FILES
  162. $(foreach fw,$(UBOOT_IMX_FW_FILES),\
  163. cp $(BINARIES_DIR)/$(fw) $(@D)/
  164. )
  165. endef
  166. UBOOT_PRE_BUILD_HOOKS += UBOOT_COPY_IMX_FW_FILES
  167. endif
  168. ifeq ($(BR2_TARGET_UBOOT_NEEDS_DTC),y)
  169. UBOOT_DEPENDENCIES += host-dtc
  170. endif
  171. ifeq ($(BR2_TARGET_UBOOT_NEEDS_PYTHON2),y)
  172. UBOOT_DEPENDENCIES += host-python host-python-setuptools
  173. else ifeq ($(BR2_TARGET_UBOOT_NEEDS_PYTHON3),y)
  174. UBOOT_DEPENDENCIES += host-python3 host-python3-setuptools
  175. endif
  176. ifeq ($(BR2_TARGET_UBOOT_NEEDS_PYLIBFDT),y)
  177. UBOOT_DEPENDENCIES += host-swig
  178. endif
  179. ifeq ($(BR2_TARGET_UBOOT_NEEDS_PYELFTOOLS),y)
  180. ifeq ($(BR2_TARGET_UBOOT_NEEDS_PYTHON2),y)
  181. UBOOT_DEPENDENCIES += host-python-pyelftools
  182. else ifeq ($(BR2_TARGET_UBOOT_NEEDS_PYTHON3),y)
  183. UBOOT_DEPENDENCIES += host-python3-pyelftools
  184. endif
  185. endif
  186. ifeq ($(BR2_TARGET_UBOOT_NEEDS_OPENSSL),y)
  187. UBOOT_DEPENDENCIES += host-openssl
  188. endif
  189. ifeq ($(BR2_TARGET_UBOOT_NEEDS_LZOP),y)
  190. UBOOT_DEPENDENCIES += host-lzop
  191. endif
  192. # prior to u-boot 2013.10 the license info was in COPYING. Copy it so
  193. # legal-info finds it
  194. define UBOOT_COPY_OLD_LICENSE_FILE
  195. if [ -f $(@D)/COPYING ]; then \
  196. $(INSTALL) -m 0644 -D $(@D)/COPYING $(@D)/Licenses/gpl-2.0.txt; \
  197. fi
  198. endef
  199. UBOOT_POST_EXTRACT_HOOKS += UBOOT_COPY_OLD_LICENSE_FILE
  200. UBOOT_POST_RSYNC_HOOKS += UBOOT_COPY_OLD_LICENSE_FILE
  201. ifneq ($(ARCH_XTENSA_OVERLAY_FILE),)
  202. define UBOOT_XTENSA_OVERLAY_EXTRACT
  203. $(call arch-xtensa-overlay-extract,$(@D),u-boot)
  204. endef
  205. UBOOT_POST_EXTRACT_HOOKS += UBOOT_XTENSA_OVERLAY_EXTRACT
  206. UBOOT_EXTRA_DOWNLOADS += $(ARCH_XTENSA_OVERLAY_URL)
  207. endif
  208. # Analogous code exists in linux/linux.mk. Basically, the generic
  209. # package infrastructure handles downloading and applying remote
  210. # patches. Local patches are handled depending on whether they are
  211. # directories or files.
  212. UBOOT_PATCHES = $(call qstrip,$(BR2_TARGET_UBOOT_PATCH))
  213. UBOOT_PATCH = $(filter ftp://% http://% https://%,$(UBOOT_PATCHES))
  214. define UBOOT_APPLY_LOCAL_PATCHES
  215. for p in $(filter-out ftp://% http://% https://%,$(UBOOT_PATCHES)) ; do \
  216. if test -d $$p ; then \
  217. $(APPLY_PATCHES) $(@D) $$p \*.patch || exit 1 ; \
  218. else \
  219. $(APPLY_PATCHES) $(@D) `dirname $$p` `basename $$p` || exit 1; \
  220. fi \
  221. done
  222. endef
  223. UBOOT_POST_PATCH_HOOKS += UBOOT_APPLY_LOCAL_PATCHES
  224. # Fixup inclusion of libfdt headers, which can fail in older u-boot versions
  225. # when libfdt-devel is installed system-wide.
  226. # The core change is equivalent to upstream commit
  227. # e0d20dc1521e74b82dbd69be53a048847798a90a (first in v2018.03). However, the fixup
  228. # is complicated by the fact that the underlying u-boot code changed multiple
  229. # times in history:
  230. # - The directory scripts/dtc/libfdt only exists since upstream commit
  231. # c0e032e0090d6541549b19cc47e06ccd1f302893 (first in v2017.11). For earlier
  232. # versions, create a dummy scripts/dtc/libfdt directory with symlinks for the
  233. # fdt-related files. This allows to use the same -I<path> option for both
  234. # cases.
  235. # - The variable 'srctree' used to be called 'SRCTREE' before upstream commit
  236. # 01286329b27b27eaeda045b469d41b1d9fce545a (first in v2014.04).
  237. # - The original location for libfdt, 'lib/libfdt/', used to be simply
  238. # 'libfdt' before upstream commit 0de71d507157c4bd4fddcd3a419140d2b986eed2
  239. # (first in v2010.06). Make the 'lib' part optional in the substitution to
  240. # handle this.
  241. define UBOOT_FIXUP_LIBFDT_INCLUDE
  242. $(Q)if [ ! -d $(@D)/scripts/dtc/libfdt ]; then \
  243. mkdir -p $(@D)/scripts/dtc/libfdt; \
  244. cd $(@D)/scripts/dtc/libfdt; \
  245. ln -s ../../../include/fdt.h .; \
  246. ln -s ../../../include/libfdt*.h .; \
  247. ln -s ../../../lib/libfdt/libfdt_internal.h .; \
  248. fi
  249. $(Q)$(SED) \
  250. 's%-I\ *\$$(srctree)/lib/libfdt%-I$$(srctree)/scripts/dtc/libfdt%; \
  251. s%-I\ *\$$(SRCTREE)\(/lib\)\?/libfdt%-I$$(SRCTREE)/scripts/dtc/libfdt%' \
  252. $(@D)/tools/Makefile
  253. endef
  254. UBOOT_POST_PATCH_HOOKS += UBOOT_FIXUP_LIBFDT_INCLUDE
  255. ifeq ($(BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY),y)
  256. define UBOOT_CONFIGURE_CMDS
  257. $(TARGET_CONFIGURE_OPTS) \
  258. $(UBOOT_MAKE) -C $(@D) $(UBOOT_MAKE_OPTS) \
  259. $(UBOOT_BOARD_NAME)_config
  260. endef
  261. else ifeq ($(BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG),y)
  262. ifeq ($(BR2_TARGET_UBOOT_USE_DEFCONFIG),y)
  263. UBOOT_KCONFIG_DEFCONFIG = $(call qstrip,$(BR2_TARGET_UBOOT_BOARD_DEFCONFIG))_defconfig
  264. else ifeq ($(BR2_TARGET_UBOOT_USE_CUSTOM_CONFIG),y)
  265. UBOOT_KCONFIG_FILE = $(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE))
  266. endif # BR2_TARGET_UBOOT_USE_DEFCONFIG
  267. UBOOT_KCONFIG_FRAGMENT_FILES = $(call qstrip,$(BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES))
  268. UBOOT_KCONFIG_EDITORS = menuconfig xconfig gconfig nconfig
  269. # UBOOT_MAKE_OPTS overrides HOSTCC / HOSTLDFLAGS to allow the build to
  270. # find our host-openssl. However, this triggers a bug in the kconfig
  271. # build script that causes it to build with /usr/include/ncurses.h
  272. # (which is typically wchar) but link with
  273. # $(HOST_DIR)/lib/libncurses.so (which is not). We don't actually
  274. # need any host-package for kconfig, so remove the HOSTCC/HOSTLDFLAGS
  275. # override again. In addition, host-ccache is not ready at kconfig
  276. # time, so use HOSTCC_NOCCACHE.
  277. UBOOT_KCONFIG_OPTS = $(UBOOT_MAKE_OPTS) HOSTCC="$(HOSTCC_NOCCACHE)" HOSTLDFLAGS=""
  278. endif # BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY
  279. UBOOT_CUSTOM_DTS_PATH = $(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_DTS_PATH))
  280. define UBOOT_BUILD_CMDS
  281. $(if $(UBOOT_CUSTOM_DTS_PATH),
  282. cp -f $(UBOOT_CUSTOM_DTS_PATH) $(@D)/arch/$(UBOOT_ARCH)/dts/
  283. )
  284. $(TARGET_CONFIGURE_OPTS) \
  285. PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
  286. PKG_CONFIG_SYSROOT_DIR="/" \
  287. PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
  288. PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 \
  289. PKG_CONFIG_LIBDIR="$(HOST_DIR)/lib/pkgconfig:$(HOST_DIR)/share/pkgconfig" \
  290. $(UBOOT_MAKE) -C $(@D) $(UBOOT_MAKE_OPTS) \
  291. $(UBOOT_MAKE_TARGET)
  292. $(if $(BR2_TARGET_UBOOT_FORMAT_SD),
  293. $(@D)/tools/mxsboot sd $(@D)/u-boot.sb $(@D)/u-boot.sd)
  294. $(if $(BR2_TARGET_UBOOT_FORMAT_NAND),
  295. $(@D)/tools/mxsboot \
  296. -w $(BR2_TARGET_UBOOT_FORMAT_NAND_PAGE_SIZE) \
  297. -o $(BR2_TARGET_UBOOT_FORMAT_NAND_OOB_SIZE) \
  298. -e $(BR2_TARGET_UBOOT_FORMAT_NAND_ERASE_SIZE) \
  299. nand $(@D)/u-boot.sb $(@D)/u-boot.nand)
  300. endef
  301. define UBOOT_BUILD_OMAP_IFT
  302. $(HOST_DIR)/bin/gpsign -f $(@D)/u-boot.bin \
  303. -c $(call qstrip,$(BR2_TARGET_UBOOT_OMAP_IFT_CONFIG))
  304. endef
  305. define UBOOT_INSTALL_IMAGES_CMDS
  306. $(foreach f,$(UBOOT_BINS), \
  307. cp -dpf $(@D)/$(f) $(BINARIES_DIR)/
  308. )
  309. $(if $(BR2_TARGET_UBOOT_FORMAT_NAND),
  310. cp -dpf $(@D)/u-boot.sb $(BINARIES_DIR))
  311. $(if $(BR2_TARGET_UBOOT_SPL),
  312. $(foreach f,$(call qstrip,$(BR2_TARGET_UBOOT_SPL_NAME)), \
  313. cp -dpf $(@D)/$(f) $(BINARIES_DIR)/
  314. )
  315. )
  316. endef
  317. ifeq ($(BR2_TARGET_UBOOT_ZYNQMP),y)
  318. UBOOT_ZYNQMP_PMUFW = $(call qstrip,$(BR2_TARGET_UBOOT_ZYNQMP_PMUFW))
  319. ifneq ($(findstring ://,$(UBOOT_ZYNQMP_PMUFW)),)
  320. UBOOT_EXTRA_DOWNLOADS += $(UBOOT_ZYNQMP_PMUFW)
  321. BR_NO_CHECK_HASH_FOR += $(notdir $(UBOOT_ZYNQMP_PMUFW))
  322. UBOOT_ZYNQMP_PMUFW_PATH = $(UBOOT_DL_DIR)/$(notdir $(UBOOT_ZYNQMP_PMUFW))
  323. else ifneq ($(UBOOT_ZYNQMP_PMUFW),)
  324. UBOOT_ZYNQMP_PMUFW_PATH = $(shell readlink -f $(UBOOT_ZYNQMP_PMUFW))
  325. endif
  326. define UBOOT_ZYNQMP_KCONFIG_PMUFW
  327. $(call KCONFIG_SET_OPT,CONFIG_PMUFW_INIT_FILE,"$(UBOOT_ZYNQMP_PMUFW_PATH)")
  328. endef
  329. UBOOT_ZYNQMP_PM_CFG = $(call qstrip,$(BR2_TARGET_UBOOT_ZYNQMP_PM_CFG))
  330. ifneq ($(UBOOT_ZYNQMP_PM_CFG),)
  331. UBOOT_ZYNQMP_PM_CFG_BIN = $(UBOOT_DIR)/pm_cfg_obj.bin
  332. define UBOOT_ZYNQMP_KCONFIG_PM_CFG
  333. $(call KCONFIG_SET_OPT,CONFIG_ZYNQMP_SPL_PM_CFG_OBJ_FILE,"$(UBOOT_ZYNQMP_PM_CFG_BIN)", \
  334. $(@D)/.config)
  335. endef
  336. define UBOOT_ZYNQMP_PM_CFG_CONVERT
  337. $(UBOOT_DIR)/tools/zynqmp_pm_cfg_obj_convert.py \
  338. "$(UBOOT_ZYNQMP_PM_CFG)" \
  339. "$(UBOOT_ZYNQMP_PM_CFG_BIN)"
  340. endef
  341. UBOOT_PRE_BUILD_HOOKS += UBOOT_ZYNQMP_PM_CFG_CONVERT
  342. endif
  343. UBOOT_ZYNQMP_PSU_INIT = $(call qstrip,$(BR2_TARGET_UBOOT_ZYNQMP_PSU_INIT_FILE))
  344. UBOOT_ZYNQMP_PSU_INIT_PATH = $(shell readlink -f $(UBOOT_ZYNQMP_PSU_INIT))
  345. ifneq ($(UBOOT_ZYNQMP_PSU_INIT),)
  346. define UBOOT_ZYNQMP_KCONFIG_PSU_INIT
  347. $(call KCONFIG_SET_OPT,CONFIG_XILINX_PS_INIT_FILE,"$(UBOOT_ZYNQMP_PSU_INIT_PATH)")
  348. endef
  349. endif
  350. endif # BR2_TARGET_UBOOT_ZYNQMP
  351. define UBOOT_INSTALL_OMAP_IFT_IMAGE
  352. cp -dpf $(@D)/$(UBOOT_BIN_IFT) $(BINARIES_DIR)/
  353. endef
  354. ifeq ($(BR2_TARGET_UBOOT_OMAP_IFT),y)
  355. ifeq ($(BR_BUILDING),y)
  356. ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_OMAP_IFT_CONFIG)),)
  357. $(error No gpsign config file. Check your BR2_TARGET_UBOOT_OMAP_IFT_CONFIG setting)
  358. endif
  359. ifeq ($(wildcard $(call qstrip,$(BR2_TARGET_UBOOT_OMAP_IFT_CONFIG))),)
  360. $(error gpsign config file $(BR2_TARGET_UBOOT_OMAP_IFT_CONFIG) not found. Check your BR2_TARGET_UBOOT_OMAP_IFT_CONFIG setting)
  361. endif
  362. endif
  363. UBOOT_DEPENDENCIES += host-omap-u-boot-utils
  364. UBOOT_POST_BUILD_HOOKS += UBOOT_BUILD_OMAP_IFT
  365. UBOOT_POST_INSTALL_IMAGES_HOOKS += UBOOT_INSTALL_OMAP_IFT_IMAGE
  366. endif
  367. ifeq ($(BR2_TARGET_UBOOT_ZYNQ_IMAGE),y)
  368. define UBOOT_GENERATE_ZYNQ_IMAGE
  369. $(HOST_DIR)/bin/python2 \
  370. $(HOST_DIR)/bin/zynq-boot-bin.py \
  371. -u $(@D)/$(firstword $(call qstrip,$(BR2_TARGET_UBOOT_SPL_NAME))) \
  372. -o $(BINARIES_DIR)/BOOT.BIN
  373. endef
  374. UBOOT_DEPENDENCIES += host-zynq-boot-bin
  375. UBOOT_POST_INSTALL_IMAGES_HOOKS += UBOOT_GENERATE_ZYNQ_IMAGE
  376. endif
  377. ifeq ($(BR2_TARGET_UBOOT_ALTERA_SOCFPGA_IMAGE_CRC),y)
  378. ifeq ($(BR2_TARGET_UBOOT_SPL),y)
  379. UBOOT_CRC_ALTERA_SOCFPGA_INPUT_IMAGES = $(call qstrip,$(BR2_TARGET_UBOOT_SPL_NAME))
  380. UBOOT_CRC_ALTERA_SOCFPGA_HEADER_VERSION = 0
  381. else
  382. UBOOT_CRC_ALTERA_SOCFPGA_INPUT_IMAGES = u-boot-dtb.bin
  383. UBOOT_CRC_ALTERA_SOCFPGA_HEADER_VERSION = 1
  384. endif
  385. define UBOOT_CRC_ALTERA_SOCFPGA_IMAGE
  386. $(foreach f,$(UBOOT_CRC_ALTERA_SOCFPGA_INPUT_IMAGES), \
  387. $(HOST_DIR)/bin/mkpimage \
  388. -v $(UBOOT_CRC_ALTERA_SOCFPGA_HEADER_VERSION) \
  389. -o $(BINARIES_DIR)/$(notdir $(call qstrip,$(f))).crc \
  390. $(@D)/$(call qstrip,$(f))
  391. )
  392. endef
  393. UBOOT_DEPENDENCIES += host-mkpimage
  394. UBOOT_POST_INSTALL_IMAGES_HOOKS += UBOOT_CRC_ALTERA_SOCFPGA_IMAGE
  395. endif
  396. define UBOOT_KCONFIG_FIXUP_CMDS
  397. $(UBOOT_ZYNQMP_KCONFIG_PMUFW)
  398. $(UBOOT_ZYNQMP_KCONFIG_PM_CFG)
  399. $(UBOOT_ZYNQMP_KCONFIG_PSU_INIT)
  400. endef
  401. ifeq ($(BR2_TARGET_UBOOT)$(BR_BUILDING),yy)
  402. #
  403. # Check U-Boot board name (for legacy) or the defconfig/custom config
  404. # file options (for kconfig)
  405. #
  406. ifeq ($(BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY),y)
  407. ifeq ($(UBOOT_BOARD_NAME),)
  408. $(error No U-Boot board name set. Check your BR2_TARGET_UBOOT_BOARDNAME setting)
  409. endif # UBOOT_BOARD_NAME
  410. else ifeq ($(BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG),y)
  411. ifeq ($(BR2_TARGET_UBOOT_USE_DEFCONFIG),y)
  412. ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_BOARD_DEFCONFIG)),)
  413. $(error No board defconfig name specified, check your BR2_TARGET_UBOOT_BOARD_DEFCONFIG setting)
  414. endif # qstrip BR2_TARGET_UBOOT_BOARD_DEFCONFIG
  415. endif # BR2_TARGET_UBOOT_USE_DEFCONFIG
  416. ifeq ($(BR2_TARGET_UBOOT_USE_CUSTOM_CONFIG),y)
  417. ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE)),)
  418. $(error No board configuration file specified, check your BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE setting)
  419. endif # qstrip BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE
  420. endif # BR2_TARGET_UBOOT_USE_CUSTOM_CONFIG
  421. endif # BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY
  422. #
  423. # Check custom version option
  424. #
  425. ifeq ($(BR2_TARGET_UBOOT_CUSTOM_VERSION),y)
  426. ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE)),)
  427. $(error No custom U-Boot version specified. Check your BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE setting)
  428. endif # qstrip BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE
  429. endif # BR2_TARGET_UBOOT_CUSTOM_VERSION
  430. #
  431. # Check custom tarball option
  432. #
  433. ifeq ($(BR2_TARGET_UBOOT_CUSTOM_TARBALL),y)
  434. ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_TARBALL_LOCATION)),)
  435. $(error No custom U-Boot tarball specified. Check your BR2_TARGET_UBOOT_CUSTOM_TARBALL_LOCATION setting)
  436. endif # qstrip BR2_TARGET_UBOOT_CUSTOM_TARBALL_LOCATION
  437. endif # BR2_TARGET_UBOOT_CUSTOM_TARBALL
  438. #
  439. # Check Git/Mercurial repo options
  440. #
  441. ifeq ($(BR2_TARGET_UBOOT_CUSTOM_GIT)$(BR2_TARGET_UBOOT_CUSTOM_HG),y)
  442. ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_REPO_URL)),)
  443. $(error No custom U-Boot repository URL specified. Check your BR2_TARGET_UBOOT_CUSTOM_REPO_URL setting)
  444. endif # qstrip BR2_TARGET_UBOOT_CUSTOM_CUSTOM_REPO_URL
  445. ifeq ($(call qstrip,$(BR2_TARGET_UBOOT_CUSTOM_REPO_VERSION)),)
  446. $(error No custom U-Boot repository version specified. Check your BR2_TARGET_UBOOT_CUSTOM_REPO_VERSION setting)
  447. endif # qstrip BR2_TARGET_UBOOT_CUSTOM_CUSTOM_REPO_VERSION
  448. endif # BR2_TARGET_UBOOT_CUSTOM_GIT || BR2_TARGET_UBOOT_CUSTOM_HG
  449. endif # BR2_TARGET_UBOOT && BR_BUILDING
  450. ifeq ($(BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY),y)
  451. UBOOT_DEPENDENCIES += \
  452. $(BR2_BISON_HOST_DEPENDENCY) \
  453. $(BR2_FLEX_HOST_DEPENDENCY)
  454. $(eval $(generic-package))
  455. else ifeq ($(BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG),y)
  456. UBOOT_MAKE_ENV = $(TARGET_MAKE_ENV)
  457. # Starting with 2021.10, the kconfig in uboot calls the cross-compiler
  458. # to check its capabilities. So we need the toolchain before we can
  459. # call the configurators.
  460. UBOOT_KCONFIG_DEPENDENCIES += \
  461. toolchain \
  462. $(BR2_MAKE_HOST_DEPENDENCY) \
  463. $(BR2_BISON_HOST_DEPENDENCY) \
  464. $(BR2_FLEX_HOST_DEPENDENCY)
  465. $(eval $(kconfig-package))
  466. endif # BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY