blob: cf8b9b7ca625e65a64a920cb0bfad23580af5c18 [file] [log] [blame]
Brad Bishop286d45c2018-10-02 15:21:57 -04001inherit xilinx-platform-init
2
3FORCE_PLATFORM_INIT[doc] = "This variable is used to force the overriding of all platform init files in u-boot source."
4
5PLATFORM_BOARD_DIR ?= ""
6PLATFORM_BOARD_DIR_zynq = "board/xilinx/zynq"
7PLATFORM_BOARD_DIR_zynqmp = "board/xilinx/zynqmp"
8
9do_zynq_platform_init() {
10 for f in ${PLATFORM_INIT_FILES}; do
11 if [ -d "${S}/${PLATFORM_BOARD_DIR}/custom_hw_platform" ]; then
12 cp ${PLATFORM_INIT_STAGE_DIR}/$f ${S}/${PLATFORM_BOARD_DIR}/custom_hw_platform/
13 else
14 cp ${PLATFORM_INIT_STAGE_DIR}/$f ${S}/${PLATFORM_BOARD_DIR}/
15 fi
16 # Newer u-boot sources use the init files in a sub directory named
17 # based on the name of the device tree. This is not straight forward to
18 # detect. Instead of detecting just overwrite all the platform init
19 # files so that the correct one is always used. This shotgun approach
20 # only works due to this recipe being machine arch specific. Do this
21 # overwrite un-conditionally as there is no guarantees that the chosen
22 # board config does not have the device tree config set.
23 for i in ${S}/${PLATFORM_BOARD_DIR}/*/; do
24 [ -d $i ] && cp ${PLATFORM_INIT_STAGE_DIR}/$f $i
25 done
26 done
27}
28
29python () {
30 # strip the tail _config/_defconfig for better comparison
31 def strip_config_name(c):
32 for i in ["_config", "_defconfig"]:
33 if c.endswith(i):
34 return c[0:len(c) - len(i)]
35 return c
36
37 if d.getVar("SOC_FAMILY") not in ["zynq", "zynqmp"]:
38 # continue on this is not a zynq/zynqmp target
39 return
40
41 # Determine if target machine needs to provide a custom platform init files
42 if d.getVar("SPL_BINARY"):
43 hasconfigs = [strip_config_name(c) for c in (d.getVar("HAS_PLATFORM_INIT") or "").split()]
44 currentconfig = strip_config_name(d.getVar("UBOOT_MACHINE"))
45
46 # only add the dependency if u-boot doesn't already provide the platform init files
47 if (currentconfig not in hasconfigs) or (d.getVar("FORCE_PLATFORM_INIT") == "1"):
48 # force the dependency on a recipe that provides the platform init files
49 d.appendVar("DEPENDS", " virtual/xilinx-platform-init")
50 # setup task to modify platform init after unpack and prepare_recipe_sysroot, and before configure
51 bb.build.addtask("do_zynq_platform_init", "do_configure", "do_unpack do_prepare_recipe_sysroot", d)
52
53 if "boot.bin" not in d.getVar("SPL_BINARY"):
54 # not deploying the boot.bin, just building SPL
55 return
56
57 # assume that U-Boot is to provide the boot.bin if no other provides are selected or U-Boot is selected
58 providesbin = not(d.getVar("PREFERRED_PROVIDER_virtual/boot-bin")) or d.getVar("PREFERRED_PROVIDER_virtual/boot-bin") == d.getVar("PN")
59 if providesbin:
60 # add provides, if U-Boot is set to provide boot.bin
61 d.appendVar("PROVIDES", " virtual/boot-bin")
62 else:
63 # prevent U-Boot from deploying the boot.bin
64 d.setVar("SPL_BINARY", "")
65
66 if providesbin and d.getVar("SOC_FAMILY") in ["zynqmp"]:
Brad Bishop286d45c2018-10-02 15:21:57 -040067 # determine the path relative to the source tree
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080068 relpath = os.path.relpath(d.expand("${PMU_FIRMWARE_DEPLOY_DIR}/${PMU_FIRMWARE_IMAGE_NAME}.bin"), d.getVar("S"))
Brad Bishop286d45c2018-10-02 15:21:57 -040069 # setup PMU Firmware path via MAKEFLAGS
70 d.appendVar("EXTRA_OEMAKE", " CONFIG_PMUFW_INIT_FILE=\"{0}\"".format(relpath))
71}
72