diff options
Diffstat (limited to 'meta-xilinx-core/classes-recipe')
| -rw-r--r-- | meta-xilinx-core/classes-recipe/dfx_user_dts.bbclass | 129 |
1 files changed, 81 insertions, 48 deletions
diff --git a/meta-xilinx-core/classes-recipe/dfx_user_dts.bbclass b/meta-xilinx-core/classes-recipe/dfx_user_dts.bbclass index bde5be5d..c20cd8f7 100644 --- a/meta-xilinx-core/classes-recipe/dfx_user_dts.bbclass +++ b/meta-xilinx-core/classes-recipe/dfx_user_dts.bbclass | |||
| @@ -50,37 +50,46 @@ python() { | |||
| 50 | pdi_found = False | 50 | pdi_found = False |
| 51 | 51 | ||
| 52 | # Required Inputs | 52 | # Required Inputs |
| 53 | if '.dtsi' in d.getVar("SRC_URI") or '.dts' in d.getVar("SRC_URI"): | 53 | if '.dtsi ' in d.getVar("SRC_URI") or '.dts ' in d.getVar("SRC_URI"): |
| 54 | dtsi_found = True | 54 | dtsi_found = True |
| 55 | d.setVar("DTSI_PATH",os.path.dirname([a for a in d.getVar('SRC_URI').split() if '.dtsi' in a or '.dts' in a][0].lstrip('file://'))) | 55 | d.setVar("DTSI_PATH",os.path.dirname([a for a in d.getVar('SRC_URI').split() if '.dtsi' in a or '.dts' in a][0].lstrip('file://'))) |
| 56 | 56 | ||
| 57 | if '.dtbo' in d.getVar("SRC_URI"): | 57 | if '.dtbo ' in d.getVar("SRC_URI"): |
| 58 | dtbo_found = True | 58 | dtbo_found = True |
| 59 | d.setVar("DTBO_PATH",os.path.dirname([a for a in d.getVar('SRC_URI').split() if '.dtbo' in a][0].lstrip('file://'))) | 59 | d.setVar("DTBO_PATH",os.path.dirname([a for a in d.getVar('SRC_URI').split() if '.dtbo' in a][0].lstrip('file://'))) |
| 60 | 60 | ||
| 61 | if '.bit' in d.getVar("SRC_URI") and soc_family != "versal": | 61 | if soc_family == "zynq" or soc_family == "zynqmp": |
| 62 | bit_found = True | 62 | if '.bit ' in d.getVar("SRC_URI"): |
| 63 | d.setVar("BIT_PATH",os.path.dirname([a for a in d.getVar('SRC_URI').split() if '.bit' in a][0].lstrip('file://'))) | 63 | bit_found = True |
| 64 | d.setVar("BIT_PATH",os.path.dirname([a for a in d.getVar('SRC_URI').split() if '.bit' in a][0].lstrip('file://'))) | ||
| 64 | 65 | ||
| 65 | if '.bin' in d.getVar("SRC_URI") and soc_family != "versal": | 66 | if '.bin ' in d.getVar("SRC_URI"): |
| 66 | bin_found = True | 67 | bin_found = True |
| 67 | d.setVar("BIN_PATH",os.path.dirname([a for a in d.getVar('SRC_URI').split() if '.bin' in a][0].lstrip('file://'))) | 68 | d.setVar("BIN_PATH",os.path.dirname([a for a in d.getVar('SRC_URI').split() if '.bin' in a][0].lstrip('file://'))) |
| 68 | 69 | else: | |
| 69 | if '.pdi' in d.getVar("SRC_URI") and soc_family == "versal": | 70 | if '.pdi ' in d.getVar("SRC_URI"): |
| 70 | pdi_found = True | 71 | pdi_found = True |
| 71 | d.setVar("PDI_PATH",os.path.dirname([a for a in d.getVar('SRC_URI').split() if '.pdi' in a][0].lstrip('file://'))) | 72 | d.setVar("PDI_PATH",os.path.dirname([a for a in d.getVar('SRC_URI').split() if '.pdi' in a][0].lstrip('file://'))) |
| 72 | 73 | ||
| 73 | # Check for valid combination of input files in SRC_URI | 74 | # Check for valid combination of input files in SRC_URI |
| 74 | if dtsi_found or dtbo_found: | 75 | # Skip recipe if any of the below conditions are not satisfied. |
| 75 | bb.debug(2, "dtsi or dtbo found in SRC_URI") | 76 | # 1. At least one bit or bin or pdi or dts or dtsi or dtbo should exists. |
| 76 | if bit_found or pdi_found or bin_found: | 77 | # 2. More than one dtbo. |
| 77 | bb.debug(2, "bitstream or pdi found in SRC_URI") | 78 | # 3. More than one bit or bin or pdi. |
| 78 | elif bit_found and bin_found: | 79 | # 4. More than one dts and zero dtsi. |
| 80 | # 5. More than one dtsi and zero dts. | ||
| 81 | if dtsi_found or dtbo_found or bit_found or bin_found or pdi_found: | ||
| 82 | bb.debug(2, "dtsi or dtbo or bitstream or pdi found in SRC_URI") | ||
| 83 | if bit_found and pdi_found : | ||
| 84 | raise bb.parse.SkipRecipe("Both '.bit' and '.pdi' file found in SRC_URI, this is invalid use case.") | ||
| 85 | |||
| 86 | if bin_found and pdi_found : | ||
| 87 | raise bb.parse.SkipRecipe("Both '.bin' and '.pdi' file found in SRC_URI, this is invalid use case.") | ||
| 88 | |||
| 89 | if bit_found and bin_found: | ||
| 79 | raise bb.parse.SkipRecipe("Both '.bit' and '.bin' file found in SRC_URI, either .bit or .bin file is supported but not both.") | 90 | raise bb.parse.SkipRecipe("Both '.bit' and '.bin' file found in SRC_URI, either .bit or .bin file is supported but not both.") |
| 80 | else: | ||
| 81 | raise bb.parse.SkipRecipe("Need one '.bit' or one '.pdi' file added to SRC_URI ") | ||
| 82 | else: | 91 | else: |
| 83 | raise bb.parse.SkipRecipe("Need one '.dtsi' or one '.dtbo' file added to SRC_URI ") | 92 | raise bb.parse.SkipRecipe("Need one '.dtsi' or '.dtbo' or '.bit' or '.bin' or '.pdi' file added to SRC_URI ") |
| 84 | 93 | ||
| 85 | # Check for valid combination of dtsi and dts files in SRC_URI | 94 | # Check for valid combination of dtsi and dts files in SRC_URI |
| 86 | # Following file combinations are not supported use case. | 95 | # Following file combinations are not supported use case. |
| @@ -97,10 +106,10 @@ python() { | |||
| 97 | raise bb.parse.SkipRecipe("Recipe has more than one '.dts' and zero or more than one '.dtsi' found, this is an unsupported use case") | 106 | raise bb.parse.SkipRecipe("Recipe has more than one '.dts' and zero or more than one '.dtsi' found, this is an unsupported use case") |
| 98 | 107 | ||
| 99 | # Optional input | 108 | # Optional input |
| 100 | if '.json' in d.getVar("SRC_URI"): | 109 | if '.json ' in d.getVar("SRC_URI"): |
| 101 | d.setVar("JSON_PATH",os.path.dirname([a for a in d.getVar('SRC_URI').split() if '.json' in a][0].lstrip('file://'))) | 110 | d.setVar("JSON_PATH",os.path.dirname([a for a in d.getVar('SRC_URI').split() if '.json' in a][0].lstrip('file://'))) |
| 102 | 111 | ||
| 103 | if '.xclbin' in d.getVar("SRC_URI"): | 112 | if '.xclbin ' in d.getVar("SRC_URI"): |
| 104 | d.setVar("XCL_PATH",os.path.dirname([a for a in d.getVar('SRC_URI').split() if '.xclbin' in a][0].lstrip('file://'))) | 113 | d.setVar("XCL_PATH",os.path.dirname([a for a in d.getVar('SRC_URI').split() if '.xclbin' in a][0].lstrip('file://'))) |
| 105 | } | 114 | } |
| 106 | 115 | ||
| @@ -144,10 +153,10 @@ python do_configure() { | |||
| 144 | with open(new_dtsi, 'w') as newdtsi: | 153 | with open(new_dtsi, 'w') as newdtsi: |
| 145 | with open(orig_dtsi) as olddtsi: | 154 | with open(orig_dtsi) as olddtsi: |
| 146 | for line in olddtsi: | 155 | for line in olddtsi: |
| 147 | if soc_family == 'versal': | 156 | if soc_family == 'zynq' or soc_family == 'zynqmp': |
| 148 | newdtsi.write(re.sub('firmware-name.*\".*\"','firmware-name = \"'+d.getVar('PN')+'.pdi\"',line)) | ||
| 149 | else: | ||
| 150 | newdtsi.write(re.sub('firmware-name.*\".*\"','firmware-name = \"'+d.getVar('PN')+'.bin\"',line)) | 157 | newdtsi.write(re.sub('firmware-name.*\".*\"','firmware-name = \"'+d.getVar('PN')+'.bin\"',line)) |
| 158 | else: | ||
| 159 | newdtsi.write(re.sub('firmware-name.*\".*\"','firmware-name = \"'+d.getVar('PN')+'.pdi\"',line)) | ||
| 151 | shutil.move(new_dtsi,orig_dtsi) | 160 | shutil.move(new_dtsi,orig_dtsi) |
| 152 | } | 161 | } |
| 153 | 162 | ||
| @@ -166,7 +175,7 @@ python devicetree_do_compile:append() { | |||
| 166 | # In case of dtbo as input, bbclass doesn't know if firmware-name is .bit | 175 | # In case of dtbo as input, bbclass doesn't know if firmware-name is .bit |
| 167 | # or .bin format and corresponding file name. Hence we are not doing .bin | 176 | # or .bin format and corresponding file name. Hence we are not doing .bin |
| 168 | # conversion. | 177 | # conversion. |
| 169 | if soc_family != 'versal' and glob.glob(d.getVar('S') + '/' + d.getVar('FIRMWARE_NAME_DT_FILE')): | 178 | if soc_family == 'zynq' or soc_family == 'zynqmp' and glob.glob(d.getVar('S') + '/' + d.getVar('FIRMWARE_NAME_DT_FILE')): |
| 170 | pn = d.getVar('PN') | 179 | pn = d.getVar('PN') |
| 171 | biffile = pn + '.bif' | 180 | biffile = pn + '.bif' |
| 172 | 181 | ||
| @@ -199,16 +208,24 @@ python devicetree_do_compile:append() { | |||
| 199 | python find_user_dts_overlay_file() { | 208 | python find_user_dts_overlay_file() { |
| 200 | import glob | 209 | import glob |
| 201 | dtbo_count = sum(1 for f in glob.iglob((d.getVar('S') + '/*.dtbo'),recursive=True) if os.path.isfile(f)) | 210 | dtbo_count = sum(1 for f in glob.iglob((d.getVar('S') + '/*.dtbo'),recursive=True) if os.path.isfile(f)) |
| 202 | # Skip if input file is dtbo in SRC_URI | 211 | dts_count = sum(1 for f in glob.iglob((d.getVar('S') + '/*.dts'),recursive=True) if os.path.isfile(f)) |
| 203 | if not dtbo_count: | 212 | dtsi_count = sum(1 for f in glob.iglob((d.getVar('S') + '/*.dtsi'),recursive=True) if os.path.isfile(f)) |
| 213 | # Set USER_DTS_FILE if input file is dts/dtsi in SRC_URI else skip operation. | ||
| 214 | if not dtbo_count and dts_count or dtsi_count: | ||
| 204 | dts_count = get_dt_count(d, 'dts') | 215 | dts_count = get_dt_count(d, 'dts') |
| 205 | dtsi_count = get_dt_count(d, 'dtsi') | 216 | dtsi_count = get_dt_count(d, 'dtsi') |
| 206 | if dtsi_count == 1 and dts_count == 0: | 217 | if dtsi_count == 1 and dts_count == 0: |
| 207 | dts_file =glob.glob(d.getVar('S')+ (d.getVar('DTSI_PATH') or '') + '/*.dtsi')[0] | 218 | dts_file = glob.glob(d.getVar('S')+ (d.getVar('DTSI_PATH') or '') + '/*.dtsi')[0] |
| 208 | elif dtsi_count >=0 and dts_count == 1: | 219 | elif dtsi_count >=0 and dts_count == 1: |
| 209 | dts_file = glob.glob(d.getVar('S')+ (d.getVar('DTSI_PATH') or '') + '/*.dts')[0] | 220 | dts_file = glob.glob(d.getVar('S')+ (d.getVar('DTSI_PATH') or '') + '/*.dts')[0] |
| 221 | else: | ||
| 222 | dts_file = '' | ||
| 210 | 223 | ||
| 211 | d.setVar('USER_DTS_FILE', os.path.splitext(os.path.basename(dts_file))[0]) | 224 | d.setVar('USER_DTS_FILE', os.path.splitext(os.path.basename(dts_file))[0]) |
| 225 | elif dtbo_count: | ||
| 226 | bb.debug(2, "Firmware recipe input file is dtbo in SRC_URI") | ||
| 227 | else: | ||
| 228 | bb.debug(2, "Firmware recipe input file is bit/bin/pdi in SRC_URI") | ||
| 212 | } | 229 | } |
| 213 | 230 | ||
| 214 | do_install[prefuncs] += "find_user_dts_overlay_file" | 231 | do_install[prefuncs] += "find_user_dts_overlay_file" |
| @@ -216,8 +233,12 @@ do_install[prefuncs] += "find_user_dts_overlay_file" | |||
| 216 | do_install() { | 233 | do_install() { |
| 217 | install -d ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/ | 234 | install -d ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/ |
| 218 | 235 | ||
| 236 | # Install dtbo | ||
| 219 | # In case of dtbo as input, dtbo will be copied from directly from ${S} | 237 | # In case of dtbo as input, dtbo will be copied from directly from ${S} |
| 220 | # In case of dtsi as input, dtbo will be copied from directly from ${B} | 238 | # In case of dtsi as input, dtbo will be copied from directly from ${B} |
| 239 | # If more than one dtbo file is found then fatal the task. | ||
| 240 | # If no dtbo file is found add warning message as in some use case if IP | ||
| 241 | # doesn't have any driver then user can load pdi/bit/bin file. | ||
| 221 | if [ `ls ${S}/*.dtbo | wc -l` -eq 1 ]; then | 242 | if [ `ls ${S}/*.dtbo | wc -l` -eq 1 ]; then |
| 222 | install -Dm 0644 ${S}/*.dtbo ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/ | 243 | install -Dm 0644 ${S}/*.dtbo ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/ |
| 223 | elif [ `ls ${S}/*.dtbo | wc -l` -gt 1 ]; then | 244 | elif [ `ls ${S}/*.dtbo | wc -l` -gt 1 ]; then |
| @@ -225,32 +246,23 @@ do_install() { | |||
| 225 | elif [ -f ${B}/${USER_DTS_FILE}.dtbo ]; then | 246 | elif [ -f ${B}/${USER_DTS_FILE}.dtbo ]; then |
| 226 | install -Dm 0644 ${B}/${USER_DTS_FILE}.dtbo ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/${PN}.dtbo | 247 | install -Dm 0644 ${B}/${USER_DTS_FILE}.dtbo ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/${PN}.dtbo |
| 227 | else | 248 | else |
| 228 | bbfatal "A dtbo ending '.dtbo' expected but not found" | 249 | bbnote "A dtbo ending '.dtbo' expected but not found in ${S} or ${B}, This means firmware can be loaded without dtbo dependency." |
| 229 | fi | 250 | fi |
| 230 | 251 | ||
| 231 | if [ "${SOC_FAMILY}" == "versal" ]; then | 252 | # Install bit or bin if soc family is zynq-7000 or zynqmp. |
| 232 | # In case of dtbo as input, pdi will be copied from directly from ${S} | 253 | # In case of dtbo as input or no dtbo exists in ${B}, then .bit or .bin will |
| 233 | # without renaming the pdi name to ${PN}.pdi | 254 | # be copied from directly from ${S} without renaming the .bit/.bin name to |
| 234 | if [ `ls ${S}/*.pdi | wc -l` -eq 1 ] && [ `ls ${S}/*.dtbo | wc -l` -eq 1 ]; then | 255 | # ${PN}.bit/${PN}.bin. |
| 235 | install -Dm 0644 ${S}/*.pdi ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/ | 256 | # if more than one .bit/.bin file is found then fatal the task. |
| 236 | elif [ `ls ${S}/*.pdi | wc -l` -gt 1 ]; then | 257 | # if no .bit/.bin file is found then fatal the task. |
| 237 | bbfatal "Multiple PDI found, use the right PDI in SRC_URI from the following:\n$(basename -a ${S}/*.pdi)" | 258 | if [ "${SOC_FAMILY}" = "zynq" ] || [ "${SOC_FAMILY}" = "zynqmp" ]; then |
| 238 | elif [ `ls ${S}/*.pdi | wc -l` -eq 1 ] && [ -f ${B}/${USER_DTS_FILE}.dtbo ]; then | ||
| 239 | install -Dm 0644 ${S}/*.pdi ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/${PN}.pdi | ||
| 240 | else | ||
| 241 | bbfatal "A PDI file with '.pdi' expected but not found" | ||
| 242 | fi | ||
| 243 | else | ||
| 244 | # In case of dtbo as input, .bit or .bin will be copied from directly | ||
| 245 | # from ${S} without renaming the .bit/.bin name to ${PN}.bit/${PN}.bin | ||
| 246 | # if more than one .bit/.bin file is found then fail the task. | ||
| 247 | if [ `ls ${S}/*.bit | wc -l` -gt 1 ]; then | 259 | if [ `ls ${S}/*.bit | wc -l` -gt 1 ]; then |
| 248 | bbfatal "Multiple .bit found, use the right .bit in SRC_URI from the following:\n$(basename -a ${S}/*.bit)" | 260 | bbfatal "Multiple .bit found, use the right .bit in SRC_URI from the following:\n$(basename -a ${S}/*.bit)" |
| 249 | elif [ `ls ${S}/*.bin | wc -l` -gt 1 ]; then | 261 | elif [ `ls ${S}/*.bin | wc -l` -gt 1 ]; then |
| 250 | bbfatal "Multiple .bin found, use the right .bin in SRC_URI from the following:\n$(basename -a ${S}/*.bin)" | 262 | bbfatal "Multiple .bin found, use the right .bin in SRC_URI from the following:\n$(basename -a ${S}/*.bin)" |
| 251 | elif [ `ls ${S}/*.bit | wc -l` -eq 1 ] && [ `ls ${S}/*.dtbo | wc -l` -eq 1 ]; then | 263 | elif [ `ls ${S}/*.bit | wc -l` -eq 1 ] && [ ! -f ${B}/${USER_DTS_FILE}.dtbo ]; then |
| 252 | install -Dm 0644 ${S}/*.bit ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/ | 264 | install -Dm 0644 ${S}/*.bit ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/ |
| 253 | elif [ `ls ${S}/*.bin | wc -l` -eq 1 ] && [ `ls ${S}/*.dtbo | wc -l` -eq 1 ]; then | 265 | elif [ `ls ${S}/*.bin | wc -l` -eq 1 ] && [ ! -f ${B}/${USER_DTS_FILE}.dtbo ]; then |
| 254 | install -Dm 0644 ${S}/*.bin ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/ | 266 | install -Dm 0644 ${S}/*.bin ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/ |
| 255 | elif [ -f ${B}/${PN}.bin ] && [ -f ${B}/${USER_DTS_FILE}.dtbo ]; then | 267 | elif [ -f ${B}/${PN}.bin ] && [ -f ${B}/${USER_DTS_FILE}.dtbo ]; then |
| 256 | install -Dm 0644 ${B}/${PN}.bin ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/${PN}.bin | 268 | install -Dm 0644 ${B}/${PN}.bin ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/${PN}.bin |
| @@ -259,10 +271,31 @@ do_install() { | |||
| 259 | fi | 271 | fi |
| 260 | fi | 272 | fi |
| 261 | 273 | ||
| 274 | # Install pdi if soc family is versal or new silicon. | ||
| 275 | # In case of dtbo as input or no dtbo exists in ${B}, then .pdi will be copied | ||
| 276 | # from directly from ${S} without renaming the pdi name to ${PN}.pdi | ||
| 277 | # if more than one .pdi file is found then fail the task. | ||
| 278 | # In case of Versal DFx Static, only static dtbo can be loaded as BOOT.bin | ||
| 279 | # already contains static pdi. bbclass is not smart enough to determine | ||
| 280 | # whether it is static pdi or not, hence change fatal to warn if no PDI is found. | ||
| 281 | if [ "${SOC_FAMILY}" != "zynq" ] && [ "${SOC_FAMILY}" != "zynqmp" ]; then | ||
| 282 | if [ `ls ${S}/*.pdi | wc -l` -eq 1 ] && [ ! -f ${B}/${USER_DTS_FILE}.dtbo ]; then | ||
| 283 | install -Dm 0644 ${S}/*.pdi ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/ | ||
| 284 | elif [ `ls ${S}/*.pdi | wc -l` -gt 1 ]; then | ||
| 285 | bbfatal "Multiple PDI found, use the right PDI in SRC_URI from the following:\n$(basename -a ${S}/*.pdi)" | ||
| 286 | elif [ `ls ${S}/*.pdi | wc -l` -eq 1 ] && [ -f ${B}/${USER_DTS_FILE}.dtbo ]; then | ||
| 287 | install -Dm 0644 ${S}/*.pdi ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/${PN}.pdi | ||
| 288 | else | ||
| 289 | bbwarn "A PDI file with '.pdi' expected but not found" | ||
| 290 | fi | ||
| 291 | fi | ||
| 292 | |||
| 293 | # Install xclbin | ||
| 262 | if ls ${S}/${XCL_PATH}/*.xclbin >/dev/null 2>&1; then | 294 | if ls ${S}/${XCL_PATH}/*.xclbin >/dev/null 2>&1; then |
| 263 | install -Dm 0644 ${S}/${XCL_PATH}/*.xclbin ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/${PN}.xclbin | 295 | install -Dm 0644 ${S}/${XCL_PATH}/*.xclbin ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/${PN}.xclbin |
| 264 | fi | 296 | fi |
| 265 | 297 | ||
| 298 | # Install shell.json or accel.json | ||
| 266 | if [ -f ${S}/${JSON_PATH}/shell.json ] || [ -f ${S}/${JSON_PATH}/accel.json ]; then | 299 | if [ -f ${S}/${JSON_PATH}/shell.json ] || [ -f ${S}/${JSON_PATH}/accel.json ]; then |
| 267 | install -Dm 0644 ${S}/${JSON_PATH}/*.json ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/ | 300 | install -Dm 0644 ${S}/${JSON_PATH}/*.json ${D}/${nonarch_base_libdir}/firmware/xilinx/${PN}/ |
| 268 | fi | 301 | fi |
