diff options
Diffstat (limited to 'meta-xilinx-core/recipes-bsp/bootbin/xilinx-bootbin_1.0.bb')
| -rw-r--r-- | meta-xilinx-core/recipes-bsp/bootbin/xilinx-bootbin_1.0.bb | 171 |
1 files changed, 171 insertions, 0 deletions
diff --git a/meta-xilinx-core/recipes-bsp/bootbin/xilinx-bootbin_1.0.bb b/meta-xilinx-core/recipes-bsp/bootbin/xilinx-bootbin_1.0.bb new file mode 100644 index 00000000..532da106 --- /dev/null +++ b/meta-xilinx-core/recipes-bsp/bootbin/xilinx-bootbin_1.0.bb | |||
| @@ -0,0 +1,171 @@ | |||
| 1 | SUMMARY = "Generates boot.bin using bootgen tool" | ||
| 2 | DESCRIPTION = "Manages task dependencies and creation of boot.bin. Use the \ | ||
| 3 | BIF_PARTITION_xyz global variables and flags to determine what makes it into \ | ||
| 4 | the image." | ||
| 5 | |||
| 6 | LICENSE = "BSD" | ||
| 7 | |||
| 8 | include machine-xilinx-${SOC_FAMILY}.inc | ||
| 9 | |||
| 10 | inherit deploy | ||
| 11 | |||
| 12 | PROVIDES = "virtual/boot-bin" | ||
| 13 | |||
| 14 | DEPENDS += "bootgen-native" | ||
| 15 | |||
| 16 | # There is no bitstream recipe, so really depend on virtual/bitstream | ||
| 17 | DEPENDS += "${@(d.getVar('BIF_PARTITION_ATTR') or "").replace('bitstream', 'virtual/bitstream')}" | ||
| 18 | |||
| 19 | # Specify a default in case boardvariant isn't available | ||
| 20 | BOARDVARIANT_ARCH ??= "${MACHINE_ARCH}" | ||
| 21 | PACKAGE_ARCH = "${BOARDVARIANT_ARCH}" | ||
| 22 | |||
| 23 | BIF_FILE_PATH ?= "${B}/bootgen.bif" | ||
| 24 | |||
| 25 | LICENSE = "MIT" | ||
| 26 | LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" | ||
| 27 | |||
| 28 | SRC_URI += "${@('file://' + d.getVar("BIF_FILE_PATH")) if d.getVar("BIF_FILE_PATH") != (d.getVar('B') + '/bootgen.bif') else ''}" | ||
| 29 | |||
| 30 | BOOTGEN_EXTRA_ARGS ?= "" | ||
| 31 | |||
| 32 | do_patch[noexec] = "1" | ||
| 33 | |||
| 34 | def create_bif(config, attrflags, attrimage, ids, common_attr, biffd, d): | ||
| 35 | import re, os | ||
| 36 | for cfg in config: | ||
| 37 | if cfg not in attrflags and common_attr: | ||
| 38 | error_msg = "%s: invalid ATTRIBUTE" % (cfg) | ||
| 39 | bb.error("BIF attribute Error: %s " % (error_msg)) | ||
| 40 | else: | ||
| 41 | if common_attr: | ||
| 42 | cfgval = d.expand(attrflags[cfg]).split(',') | ||
| 43 | cfgstr = "\t [%s] %s\n" % (cfg,', '.join(cfgval)) | ||
| 44 | else: | ||
| 45 | if cfg not in attrimage: | ||
| 46 | error_msg = "%s: invalid or missing elf or image" % (cfg) | ||
| 47 | bb.error("BIF atrribute Error: %s " % (error_msg)) | ||
| 48 | imagestr = d.expand(attrimage[cfg]) | ||
| 49 | if os.stat(imagestr).st_size == 0: | ||
| 50 | bb.warn("Empty file %s, excluding from bif file" %(imagestr)) | ||
| 51 | continue | ||
| 52 | if cfg in attrflags: | ||
| 53 | cfgval = d.expand(attrflags[cfg]).split(',') | ||
| 54 | cfgstr = "\t [%s] %s\n" % (', '.join(cfgval), imagestr) | ||
| 55 | else: | ||
| 56 | cfgstr = "\t %s\n" % (imagestr) | ||
| 57 | biffd.write(cfgstr) | ||
| 58 | |||
| 59 | return | ||
| 60 | |||
| 61 | def create_versal_bif(config, attrflags, attrimage, ids, common_attr, biffd, d): | ||
| 62 | import re, os | ||
| 63 | id_dict = {} | ||
| 64 | for cfg in config: | ||
| 65 | if cfg not in attrflags and common_attr: | ||
| 66 | error_msg = "%s: invalid ATTRIBUTE" % (cfg) | ||
| 67 | bb.error("BIF attribute Error: %s " % (error_msg)) | ||
| 68 | else: | ||
| 69 | if common_attr: | ||
| 70 | cfgval = d.expand(attrflags[cfg]).split(',') | ||
| 71 | #TODO: Does common attribute syntax change in similar way for versal? | ||
| 72 | cfgstr = "\t { %s %s }\n" % (cfg,', '.join(cfgval)) | ||
| 73 | biffd.write(cfgstr) | ||
| 74 | else: | ||
| 75 | if cfg not in attrimage: | ||
| 76 | error_msg = "%s: invalid or missing elf or image" % (cfg) | ||
| 77 | bb.error("BIF atrribute Error: %s " % (error_msg)) | ||
| 78 | imagestr = d.expand(attrimage[cfg]) | ||
| 79 | if os.stat(imagestr).st_size == 0: | ||
| 80 | bb.warn("Empty file %s, excluding from bif file" %(imagestr)) | ||
| 81 | continue | ||
| 82 | if cfg in attrflags: | ||
| 83 | cfgval = d.expand(attrflags[cfg]).split(',') | ||
| 84 | try: | ||
| 85 | id = d.expand(ids[cfg]) | ||
| 86 | except: | ||
| 87 | id = '0' | ||
| 88 | cfgstr = "\t { %s, file=%s }\n" % (', '.join(cfgval), imagestr) | ||
| 89 | try: | ||
| 90 | id_dict[id] += cfgstr | ||
| 91 | except: | ||
| 92 | id_dict[id] = cfgstr | ||
| 93 | else: | ||
| 94 | cfgstr = "\t %s\n" % (imagestr) | ||
| 95 | for id, string in id_dict.items(): | ||
| 96 | biffd.write("\timage {\n") | ||
| 97 | if id != '0': | ||
| 98 | biffd.write("\t id = " + id + "\n") | ||
| 99 | biffd.write(string) | ||
| 100 | biffd.write("\t}\n") | ||
| 101 | return | ||
| 102 | |||
| 103 | python do_configure() { | ||
| 104 | fp = d.getVar("BIF_FILE_PATH") | ||
| 105 | if fp == (d.getVar('B') + '/bootgen.bif'): | ||
| 106 | arch = d.getVar("SOC_FAMILY") | ||
| 107 | biffunc = {'versal':create_versal_bif, 'zynq':create_bif, 'zynqmp':create_bif} | ||
| 108 | biffd = open(fp, 'w') | ||
| 109 | biffd.write("the_ROM_image:\n") | ||
| 110 | biffd.write("{\n") | ||
| 111 | |||
| 112 | bifattr = (d.getVar("BIF_COMMON_ATTR") or "").split() | ||
| 113 | if bifattr: | ||
| 114 | attrflags = d.getVarFlags("BIF_COMMON_ATTR") or {} | ||
| 115 | biffunc[arch](bifattr, attrflags,'','', 1, biffd, d) | ||
| 116 | |||
| 117 | bifpartition = (d.getVar("BIF_PARTITION_ATTR") or "").split() | ||
| 118 | if bifpartition: | ||
| 119 | attrflags = d.getVarFlags("BIF_PARTITION_ATTR") or {} | ||
| 120 | attrimage = d.getVarFlags("BIF_PARTITION_IMAGE") or {} | ||
| 121 | ids = d.getVarFlags("BIF_PARTITION_ID") or {} | ||
| 122 | biffunc[arch](bifpartition, attrflags, attrimage, ids, 0, biffd, d) | ||
| 123 | |||
| 124 | biffd.write("}") | ||
| 125 | biffd.close() | ||
| 126 | else: | ||
| 127 | print("Using custom BIF file: " + d.getVar("BIF_FILE_PATH") ) | ||
| 128 | } | ||
| 129 | |||
| 130 | do_configure[vardeps] += "BIF_PARTITION_ATTR BIF_PARTITION_IMAGE BIF_COMMON_ATTR" | ||
| 131 | |||
| 132 | do_compile() { | ||
| 133 | cd ${WORKDIR} | ||
| 134 | rm -f ${B}/BOOT.bin | ||
| 135 | if [ "${BIF_FILE_PATH}" != "${B}/bootgen.bif" ];then | ||
| 136 | BIF_FILE_PATH="${WORKDIR}${BIF_FILE_PATH}" | ||
| 137 | fi | ||
| 138 | bootgen -image ${BIF_FILE_PATH} -arch ${SOC_FAMILY} ${BOOTGEN_EXTRA_ARGS} -w -o ${B}/BOOT.bin | ||
| 139 | if [ ! -e ${B}/BOOT.bin ]; then | ||
| 140 | bbfatal "bootgen failed. See log" | ||
| 141 | fi | ||
| 142 | } | ||
| 143 | |||
| 144 | do_install() { | ||
| 145 | install -d ${D}/boot | ||
| 146 | install -m 0644 ${B}/BOOT.bin ${D}/boot/BOOT.bin | ||
| 147 | } | ||
| 148 | |||
| 149 | inherit image-artifact-names | ||
| 150 | |||
| 151 | QEMUQSPI_BASE_NAME ?= "QEMU_qspi-${MACHINE}${IMAGE_VERSION_SUFFIX}" | ||
| 152 | |||
| 153 | BOOTBIN_BASE_NAME ?= "BOOT-${MACHINE}${IMAGE_VERSION_SUFFIX}" | ||
| 154 | |||
| 155 | do_deploy() { | ||
| 156 | install -d ${DEPLOYDIR} | ||
| 157 | install -m 0644 ${B}/BOOT.bin ${DEPLOYDIR}/${BOOTBIN_BASE_NAME}.bin | ||
| 158 | ln -sf ${BOOTBIN_BASE_NAME}.bin ${DEPLOYDIR}/BOOT-${MACHINE}.bin | ||
| 159 | ln -sf ${BOOTBIN_BASE_NAME}.bin ${DEPLOYDIR}/boot.bin | ||
| 160 | } | ||
| 161 | |||
| 162 | do_deploy:append:versal () { | ||
| 163 | |||
| 164 | install -m 0644 ${B}/BOOT_bh.bin ${DEPLOYDIR}/${BOOTBIN_BASE_NAME}_bh.bin | ||
| 165 | ln -sf ${BOOTBIN_BASE_NAME}_bh.bin ${DEPLOYDIR}/BOOT-${MACHINE}_bh.bin | ||
| 166 | } | ||
| 167 | |||
| 168 | FILES:${PN} += "/boot/BOOT.bin" | ||
| 169 | SYSROOT_DIRS += "/boot" | ||
| 170 | |||
| 171 | addtask do_deploy before do_build after do_compile | ||
