summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaewon Lee <jaewon.lee@xilinx.com>2021-06-21 14:46:05 -0700
committerSai Hari Chandana Kalluri <chandana.kalluri@xilinx.com>2021-09-27 21:34:01 -0700
commite0718bdb5b141438b6f21911a48f00f6e470736f (patch)
tree51fda0477b8ebbc5b6445c11fc010417d081c01e
parentfd4359c8b1604745b1dbf28376fad13666e53d7d (diff)
downloadmeta-xilinx-e0718bdb5b141438b6f21911a48f00f6e470736f.tar.gz
Adding bootbin as is from xilinx-tools
Signed-off-by: Jaewon Lee <jaewon.lee@xilinx.com>
-rw-r--r--meta-xilinx-bsp/recipes-bsp/bootbin/machine-xilinx-versal.inc46
-rw-r--r--meta-xilinx-bsp/recipes-bsp/bootbin/machine-xilinx-zynq.inc17
-rw-r--r--meta-xilinx-bsp/recipes-bsp/bootbin/machine-xilinx-zynqmp.inc40
-rw-r--r--meta-xilinx-bsp/recipes-bsp/bootbin/xilinx-bootbin_1.0.bb190
-rw-r--r--meta-xilinx-bsp/recipes-bsp/bootbin/xilinx-mcs_1.0.bb70
5 files changed, 363 insertions, 0 deletions
diff --git a/meta-xilinx-bsp/recipes-bsp/bootbin/machine-xilinx-versal.inc b/meta-xilinx-bsp/recipes-bsp/bootbin/machine-xilinx-versal.inc
new file mode 100644
index 00000000..e10339dd
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-bsp/bootbin/machine-xilinx-versal.inc
@@ -0,0 +1,46 @@
1#Extra args for versal
2BOOTGEN_EXTRA_ARGS += "-dump bh"
3
4#Add pdi dependency for versal
5DEPENDS += "virtual/base-pdi"
6
7# specify BIF common attribute for FSBL
8BIF_COMMON_ATTR ?= ""
9
10# specify BIF partition attributes required for BOOT.bin
11BIF_PARTITION_ATTR ?= "pdi plm psm dtb atf u-boot"
12
13# specify BIF partition attributes for pdi
14BIF_PARTITION_ATTR[pdi] ?= "type=bootimage"
15BIF_PARTITION_IMAGE[pdi] ?= "${RECIPE_SYSROOT}/boot/base-design.pdi"
16BIF_PARTITION_DEPENDS[pdi] ?= "virtual/base-pdi:do_populate_sysroot"
17
18# specify BIF partition attributes for plm
19PLM_IMAGE_NAME ??= "plm-${MACHINE}"
20BIF_PARTITION_ATTR[plm] ?= "type=bootloader"
21BIF_PARTITION_IMAGE[plm] ?= "${DEPLOY_DIR_IMAGE}/${PLM_IMAGE_NAME}.elf"
22BIF_PARTITION_DEPENDS[plm] ?= "virtual/plm:do_deploy"
23
24# specify BIF partition attributes for psm
25PSM_FIRMWARE_IMAGE_NAME ??= "psm-firmware-${MACHINE}"
26BIF_PARTITION_ATTR[psm] ?= "core=psm"
27BIF_PARTITION_IMAGE[psm] ?= "${DEPLOY_DIR_IMAGE}/${PSM_FIRMWARE_IMAGE_NAME}.elf"
28BIF_PARTITION_DEPENDS[psm] ?= "virtual/psm-firmware:do_deploy"
29
30# specify BIF partition attributes for dtb
31BIF_PARTITION_ATTR[dtb] ?= "type=raw, load=0x1000"
32BIF_PARTITION_IMAGE[dtb] ?= "${DEPLOY_DIR_IMAGE}/system.dtb"
33BIF_PARTITION_DEPENDS[dtb] ?= "virtual/dtb:do_deploy"
34BIF_PARTITION_ID[dtb] ?= "0x1c000000"
35
36# specify BIF partition attributes for u-boot
37BIF_PARTITION_ATTR[u-boot] ?= "core=a72-0, exception_level = el-2"
38BIF_PARTITION_IMAGE[u-boot] ?= "${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.elf"
39BIF_PARTITION_DEPENDS[u-boot] ?= "virtual/bootloader:do_deploy u-boot-zynq-scr:do_deploy"
40BIF_PARTITION_ID[u-boot] ?= "0x1c000000"
41
42# specify BIF partition attributes for atf
43BIF_PARTITION_ATTR[atf] ?= "core=a72-0, exception_level = el-3, trustzone"
44BIF_PARTITION_IMAGE[atf] ?= "${DEPLOY_DIR_IMAGE}/arm-trusted-firmware.elf"
45BIF_PARTITION_DEPENDS[atf] ?= "virtual/arm-trusted-firmware:do_deploy"
46BIF_PARTITION_ID[atf] ?= "0x1c000000"
diff --git a/meta-xilinx-bsp/recipes-bsp/bootbin/machine-xilinx-zynq.inc b/meta-xilinx-bsp/recipes-bsp/bootbin/machine-xilinx-zynq.inc
new file mode 100644
index 00000000..b8d75c4f
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-bsp/bootbin/machine-xilinx-zynq.inc
@@ -0,0 +1,17 @@
1#specify BIF partition attributes required for BOOT.bin
2BIF_PARTITION_ATTR ?= "fsbl bitstream u-boot"
3
4#specify BIF partition attributes for FSBL
5#bootloader is FSBL. Location where FSBL binary is present and dependency to build FSBL
6BIF_PARTITION_ATTR[fsbl] ?= "bootloader"
7BIF_PARTITION_IMAGE[fsbl] ?= "${DEPLOY_DIR_IMAGE}/fsbl-${MACHINE}.elf"
8BIF_PARTITION_DEPENDS[fsbl] ?= "virtual/fsbl:do_deploy"
9
10#specify BIF partition attributes for u-boot
11#Location where u-boot binary is present
12BIF_PARTITION_IMAGE[u-boot] ?= "${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.elf"
13BIF_PARTITION_DEPENDS[u-boot] ?= "virtual/bootloader:do_deploy"
14
15# enable bitstream-Note this is not enabled by default (missing in BIF_PARTITION_ATTR)
16BIF_PARTITION_IMAGE[bitstream] ?= "${DEPLOY_DIR_IMAGE}/download-${MACHINE}.bit"
17BIF_PARTITION_DEPENDS[bitstream] ?= "virtual/bitstream:do_deploy"
diff --git a/meta-xilinx-bsp/recipes-bsp/bootbin/machine-xilinx-zynqmp.inc b/meta-xilinx-bsp/recipes-bsp/bootbin/machine-xilinx-zynqmp.inc
new file mode 100644
index 00000000..cd2026ad
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-bsp/bootbin/machine-xilinx-zynqmp.inc
@@ -0,0 +1,40 @@
1# specify BIF common attribute for FSBL
2BIF_COMMON_ATTR ?= ""
3
4# specify BIF partition attributes required for BOOT.bin
5BIF_PARTITION_ATTR ?= "fsbl pmu atf u-boot"
6
7# specify BIF partition attributes for FSBL
8# bootloader is FSBL. Location where FSBL binary is present and dependency to build FSBL
9BIF_PARTITION_ATTR[fsbl] ?= "bootloader, destination_cpu=a53-0"
10BIF_PARTITION_IMAGE[fsbl] ?= "${DEPLOY_DIR_IMAGE}/fsbl-${MACHINE}.elf"
11BIF_PARTITION_DEPENDS[fsbl] ?= "virtual/fsbl:do_deploy"
12
13# specify BIF partition attributes for PMU Firmware
14# destination cpu for PMU. Location where PMU binary is present and dependency to build PMU Firmware
15PMU_FIRMWARE_IMAGE_NAME ??= "pmu-firmware-${MACHINE}"
16BIF_PARTITION_ATTR[pmu] ?= "destination_cpu=pmu"
17BIF_PARTITION_IMAGE[pmu] ?= "${DEPLOY_DIR_IMAGE}/${PMU_FIRMWARE_IMAGE_NAME}.elf"
18BIF_PARTITION_DEPENDS[pmu] ?= "virtual/pmu-firmware:do_deploy"
19
20# specify BIF partition attributes for ATF
21# destination cpu for ATF, security levels. Location where ATF binary is present (dependency is not required as ATF is always built for ZU+, see zcu102-zynqmp.conf)
22BIF_PARTITION_ATTR[atf] ?= "destination_cpu=a53-0,exception_level=el-3,trustzone"
23BIF_PARTITION_IMAGE[atf] ?= "${DEPLOY_DIR_IMAGE}/arm-trusted-firmware.elf"
24BIF_PARTITION_DEPENDS[atf] ?= "arm-trusted-firmware:do_deploy"
25
26# specify BIF partition attributes for u-boot
27# destination cpu for u-boot, security levels. Location where u-boot binary is present (dependency is not required as u-boot is always built for ZU+, see zcu102-zynqmp.conf)
28BIF_PARTITION_ATTR[u-boot] ?= "destination_cpu=a53-0,exception_level=el-2"
29BIF_PARTITION_IMAGE[u-boot] ?= "${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.elf"
30BIF_PARTITION_DEPENDS[u-boot] ?= "virtual/bootloader:do_deploy"
31
32# specify BIF partition attributes for dtb
33BIF_PARTITION_ATTR[dtb] ?= "load=0x100000"
34BIF_PARTITION_IMAGE[dtb] ?= "${DEPLOY_DIR_IMAGE}/system.dtb"
35BIF_PARTITION_DEPENDS[dtb] ?= "virtual/dtb:do_deploy"
36
37# enable bitstream-Note this is not enabled by default (missing in BIF_PARTITION_ATTR)
38BIF_PARTITION_ATTR[bitstream] ?= "destination_device=pl"
39BIF_PARTITION_IMAGE[bitstream] ?= "${DEPLOY_DIR_IMAGE}/download-${MACHINE}.bit"
40BIF_PARTITION_DEPENDS[bitstream] ?= "virtual/bitstream:do_deploy"
diff --git a/meta-xilinx-bsp/recipes-bsp/bootbin/xilinx-bootbin_1.0.bb b/meta-xilinx-bsp/recipes-bsp/bootbin/xilinx-bootbin_1.0.bb
new file mode 100644
index 00000000..3a0535b7
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-bsp/bootbin/xilinx-bootbin_1.0.bb
@@ -0,0 +1,190 @@
1SUMMARY = "Generates boot.bin using bootgen tool"
2DESCRIPTION = "Manages task dependencies and creation of boot.bin. Use the \
3BIF_PARTITION_xyz global variables and flags to determine what makes it into \
4the image."
5
6LICENSE = "BSD"
7
8include machine-xilinx-${SOC_FAMILY}.inc
9
10inherit deploy
11
12PROVIDES = "virtual/boot-bin"
13
14DEPENDS += "bootgen-native"
15
16do_configure[depends] += "${@get_bootbin_depends(d)}"
17
18PACKAGE_ARCH = "${MACHINE_ARCH}"
19
20BIF_FILE_PATH ?= "${B}/bootgen.bif"
21
22LICENSE = "MIT"
23LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
24
25SRC_URI += "${@('file://' + d.getVar("BIF_FILE_PATH")) if d.getVar("BIF_FILE_PATH") != (d.getVar('B') + '/bootgen.bif') else ''}"
26
27BOOTGEN_EXTRA_ARGS ?= ""
28
29BIF_PARTITION_ATTR_zynqmp = "${@'fsbl pmu atf dtb u-boot' if d.getVar('FPGA_MNGR_RECONFIG_ENABLE') == '1' else 'fsbl bitstream pmu atf dtb u-boot'}"
30
31do_patch[noexec] = "1"
32
33def get_bootbin_depends(d):
34 bootbindeps = ""
35 bifpartition = (d.getVar("BIF_PARTITION_ATTR") or "").split()
36 attrdepends = d.getVarFlags("BIF_PARTITION_DEPENDS") or {}
37 for cfg in bifpartition:
38 if cfg in attrdepends:
39 bootbindeps = bootbindeps + " " + attrdepends[cfg]
40
41 return bootbindeps
42
43def create_bif(config, attrflags, attrimage, ids, common_attr, biffd, d):
44 import re, os
45 for cfg in config:
46 if cfg not in attrflags and common_attr:
47 error_msg = "%s: invalid ATTRIBUTE" % (cfg)
48 bb.error("BIF attribute Error: %s " % (error_msg))
49 else:
50 if common_attr:
51 cfgval = d.expand(attrflags[cfg]).split(',')
52 cfgstr = "\t [%s] %s\n" % (cfg,', '.join(cfgval))
53 else:
54 if cfg not in attrimage:
55 error_msg = "%s: invalid or missing elf or image" % (cfg)
56 bb.error("BIF atrribute Error: %s " % (error_msg))
57 imagestr = d.expand(attrimage[cfg])
58 if os.stat(imagestr).st_size == 0:
59 bb.warn("Empty file %s, excluding from bif file" %(imagestr))
60 continue
61 if cfg in attrflags:
62 cfgval = d.expand(attrflags[cfg]).split(',')
63 cfgstr = "\t [%s] %s\n" % (', '.join(cfgval), imagestr)
64 else:
65 cfgstr = "\t %s\n" % (imagestr)
66 biffd.write(cfgstr)
67
68 return
69
70def create_versal_bif(config, attrflags, attrimage, ids, common_attr, biffd, d):
71 import re, os
72 id_dict = {}
73 for cfg in config:
74 if cfg not in attrflags and common_attr:
75 error_msg = "%s: invalid ATTRIBUTE" % (cfg)
76 bb.error("BIF attribute Error: %s " % (error_msg))
77 else:
78 if common_attr:
79 cfgval = d.expand(attrflags[cfg]).split(',')
80 #TODO: Does common attribute syntax change in similar way for versal?
81 cfgstr = "\t { %s %s }\n" % (cfg,', '.join(cfgval))
82 biffd.write(cfgstr)
83 else:
84 if cfg not in attrimage:
85 error_msg = "%s: invalid or missing elf or image" % (cfg)
86 bb.error("BIF atrribute Error: %s " % (error_msg))
87 imagestr = d.expand(attrimage[cfg])
88 if os.stat(imagestr).st_size == 0:
89 bb.warn("Empty file %s, excluding from bif file" %(imagestr))
90 continue
91 if cfg in attrflags:
92 cfgval = d.expand(attrflags[cfg]).split(',')
93 try:
94 id = d.expand(ids[cfg])
95 except:
96 id = '0'
97 cfgstr = "\t { %s, file=%s }\n" % (', '.join(cfgval), imagestr)
98 try:
99 id_dict[id] += cfgstr
100 except:
101 id_dict[id] = cfgstr
102 else:
103 cfgstr = "\t %s\n" % (imagestr)
104 for id, string in id_dict.items():
105 biffd.write("\timage {\n")
106 if id != '0':
107 biffd.write("\t id = " + id + "\n")
108 biffd.write(string)
109 biffd.write("\t}\n")
110 return
111
112python do_configure() {
113 fp = d.getVar("BIF_FILE_PATH")
114 if fp == (d.getVar('B') + '/bootgen.bif'):
115 arch = d.getVar("SOC_FAMILY")
116 biffunc = {'versal':create_versal_bif, 'zynq':create_bif, 'zynqmp':create_bif}
117 biffd = open(fp, 'w')
118 biffd.write("the_ROM_image:\n")
119 biffd.write("{\n")
120
121 bifattr = (d.getVar("BIF_COMMON_ATTR") or "").split()
122 if bifattr:
123 attrflags = d.getVarFlags("BIF_COMMON_ATTR") or {}
124 biffunc[arch](bifattr, attrflags,'','', 1, biffd, d)
125
126 bifpartition = (d.getVar("BIF_PARTITION_ATTR") or "").split()
127 if bifpartition:
128 attrflags = d.getVarFlags("BIF_PARTITION_ATTR") or {}
129 attrimage = d.getVarFlags("BIF_PARTITION_IMAGE") or {}
130 ids = d.getVarFlags("BIF_PARTITION_ID") or {}
131 biffunc[arch](bifpartition, attrflags, attrimage, ids, 0, biffd, d)
132
133 biffd.write("}")
134 biffd.close()
135 else:
136 print("Using custom BIF file: " + d.getVar("BIF_FILE_PATH") )
137}
138
139do_configure[vardeps] += "BIF_PARTITION_ATTR BIF_PARTITION_IMAGE BIF_COMMON_ATTR"
140
141do_compile() {
142 cd ${WORKDIR}
143 rm -f ${B}/BOOT.bin
144 if [ "${BIF_FILE_PATH}" != "${B}/bootgen.bif" ];then
145 BIF_FILE_PATH="${WORKDIR}${BIF_FILE_PATH}"
146 fi
147 bootgen -image ${BIF_FILE_PATH} -arch ${SOC_FAMILY} ${BOOTGEN_EXTRA_ARGS} -w -o ${B}/BOOT.bin
148 if [ ! -e ${B}/BOOT.bin ]; then
149 bbfatal "bootgen failed. See log"
150 fi
151}
152
153do_compile_append_versal() {
154 dd if=/dev/zero bs=256M count=1 > ${B}/QEMU_qspi.bin
155 dd if=${B}/BOOT.bin of=${B}/QEMU_qspi.bin bs=1 seek=0 conv=notrunc
156 dd if=${DEPLOY_DIR_IMAGE}/boot.scr of=${B}/QEMU_qspi.bin bs=1 seek=66584576 conv=notrunc
157}
158
159do_install() {
160 install -d ${D}/boot
161 install -m 0644 ${B}/BOOT.bin ${D}/boot/BOOT.bin
162}
163
164inherit image-artifact-names
165
166QEMUQSPI_BASE_NAME ?= "QEMU_qspi-${MACHINE}${IMAGE_VERSION_SUFFIX}"
167
168BOOTBIN_BASE_NAME ?= "BOOT-${MACHINE}${IMAGE_VERSION_SUFFIX}"
169
170do_deploy() {
171 install -d ${DEPLOYDIR}
172 install -m 0644 ${B}/BOOT.bin ${DEPLOYDIR}/${BOOTBIN_BASE_NAME}.bin
173 ln -sf ${BOOTBIN_BASE_NAME}.bin ${DEPLOYDIR}/BOOT-${MACHINE}.bin
174 ln -sf ${BOOTBIN_BASE_NAME}.bin ${DEPLOYDIR}/boot.bin
175}
176
177do_deploy_append_versal () {
178
179 install -m 0644 ${B}/BOOT_bh.bin ${DEPLOYDIR}/${BOOTBIN_BASE_NAME}_bh.bin
180 ln -sf ${BOOTBIN_BASE_NAME}_bh.bin ${DEPLOYDIR}/BOOT-${MACHINE}_bh.bin
181
182 install -m 0644 ${B}/QEMU_qspi.bin ${DEPLOYDIR}/${QEMUQSPI_BASE_NAME}.bin
183 ln -sf ${QEMUQSPI_BASE_NAME}.bin ${DEPLOYDIR}/QEMU_qspi-${MACHINE}.bin
184}
185
186FILES_${PN} += "/boot/BOOT.bin"
187SYSROOT_DIRS += "/boot"
188
189addtask do_deploy before do_build after do_compile
190
diff --git a/meta-xilinx-bsp/recipes-bsp/bootbin/xilinx-mcs_1.0.bb b/meta-xilinx-bsp/recipes-bsp/bootbin/xilinx-mcs_1.0.bb
new file mode 100644
index 00000000..4e3b11db
--- /dev/null
+++ b/meta-xilinx-bsp/recipes-bsp/bootbin/xilinx-mcs_1.0.bb
@@ -0,0 +1,70 @@
1SUMMARY = "Generates boot.mcs using vivado"
2DESCRIPTION = "Manages task dependencies and creation of boot.mcs for microblaze"
3
4LICENSE = "BSD"
5
6PROVIDES = "virtual/boot-bin"
7
8DEPENDS = "bitstream-microblaze"
9
10PACKAGE_ARCH = "${MACHINE_ARCH}"
11
12COMPATIBLE_MACHINE ?= "^$"
13COMPATIBLE_MACHINE_microblaze = ".*"
14
15inherit deploy image-artifact-names
16
17do_fetch[noexec] = "1"
18do_unpack[noexec] = "1"
19do_patch[noexec] = "1"
20
21PROC ??= "kc705_i/microblaze_0"
22PROC_kc705 = "kc705_i/microblaze_0"
23
24FLASH_SIZE ??= "0x80"
25FLASH_INTERFACE ??= "BPIx16"
26MB_OUT_FORMAT ??= "mcs"
27BOOT_EXT = "${@d.getVar('MB_OUT_FORMAT').lower()}"
28
29BITSTREAM_FILE ?= "${RECIPE_SYSROOT}/boot/bitstream/download.bit"
30B = "${WORKDIR}/build"
31WR_CFGMEM_MISC ?= "-loadbit \" up 0 ${BITSTREAM_FILE}\""
32
33do_check_for_vivado() {
34 bbnote "Checking Vivado install path"
35 which "vivado" 2>/dev/null || {
36 bbfatal "Vivado not found! Please add \"INHERIT += \"vivado\"\" to your local.conf"
37 }
38}
39
40addtask do_check_for_vivado before do_configure
41
42do_configure() {
43 echo " write_cfgmem -force -format ${MB_OUT_FORMAT} -size ${FLASH_SIZE} -interface ${FLASH_INTERFACE} ${WR_CFGMEM_MISC} ${B}/BOOT.${BOOT_EXT} " > ${B}/write_cfgmem_boot_mcs.tcl
44 if [ ! -e ${B}/write_cfgmem_boot_mcs.tcl ]; then
45 bbfatal "write_cfgmem_boot_mcs.tcl creation failed. See log for details"
46 fi
47}
48
49
50do_compile() {
51 vivado -log "${B}/cfgmem_mcs.log" -jou "${B}/cfgmem_mcs.jou" -mode batch -s ${B}/write_cfgmem_boot_mcs.tcl
52 if [ ! -e ${B}/BOOT.${BOOT_EXT} ]; then
53 bbfatal "BOOT.${BOOT_EXT} failed. See log"
54 fi
55}
56
57do_install() {
58 :
59}
60
61BOOT_BASE_NAME ?= "BOOT-${MACHINE}${IMAGE_VERSION_SUFFIX}"
62
63do_deploy() {
64 #install BOOT.mcs
65 if [ -e ${B}/BOOT.${BOOT_EXT} ]; then
66 install -Dm 0644 ${B}/BOOT.${BOOT_EXT} ${DEPLOYDIR}/${BOOT_BASE_NAME}.${BOOT_EXT}
67 ln -sf ${BOOT_BASE_NAME}.${BOOT_EXT} ${DEPLOYDIR}/BOOT-${MACHINE}.${BOOT_EXT}
68 fi
69}
70addtask do_deploy before do_build after do_compile