Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 1 | # Image class to write .fvpconf files for use with runfvp. If this is desired |
| 2 | # then add fvpboot to IMAGE_CLASSES, and set the variables below in your machine |
| 3 | # configuration as appropriate. |
| 4 | |
| 5 | # Name of recipe providing FVP executable. If unset then the executable must be installed on the host. |
| 6 | FVP_PROVIDER ?= "" |
| 7 | # Name of FVP executable to run |
| 8 | FVP_EXE ?= "" |
| 9 | # Flags for --parameter/-C |
| 10 | FVP_CONFIG ?= "" |
| 11 | # Flags for --data |
| 12 | FVP_DATA ?= "" |
| 13 | # Flags for --application |
| 14 | FVP_APPLICATIONS ?= "" |
| 15 | # Flags to name serial terminals. Flag name is the terminal id (such as |
| 16 | # terminal_0), value is a human-readable name. If the name is not set |
| 17 | # then runfvp will hide the terminal. |
| 18 | FVP_TERMINALS ?= "" |
| 19 | # What terminal should be considered the primary console |
| 20 | FVP_CONSOLE ?= "" |
| 21 | # Flags for console names, as they appear in the FVP output. Flag name is an |
| 22 | # application-specific id for the console for use in test cases |
| 23 | FVP_CONSOLES[default] ?= "${FVP_CONSOLE}" |
| 24 | # Arbitrary extra arguments |
| 25 | FVP_EXTRA_ARGS ?= "" |
Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame] | 26 | # Bitbake variables to pass to the FVP environment |
| 27 | FVP_ENV_PASSTHROUGH ?= "" |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 28 | |
| 29 | EXTRA_IMAGEDEPENDS += "${FVP_PROVIDER}" |
| 30 | |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 31 | IMAGE_CLASSES += "image-artifact-names" |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 32 | |
| 33 | IMAGE_POSTPROCESS_COMMAND += "do_write_fvpboot_conf;" |
| 34 | python do_write_fvpboot_conf() { |
| 35 | # Note that currently this JSON file is in development and the format may |
| 36 | # change at any point, so it should always be used with a matching runfvp. |
| 37 | |
| 38 | import json, shlex |
| 39 | |
| 40 | if not d.getVar("FVP_EXE"): |
| 41 | return |
| 42 | |
| 43 | conffile = os.path.join(d.getVar("IMGDEPLOYDIR"), d.getVar("IMAGE_NAME") + ".fvpconf") |
| 44 | conffile_link = os.path.join(d.getVar("IMGDEPLOYDIR"), d.getVar("IMAGE_LINK_NAME") + ".fvpconf") |
| 45 | |
| 46 | data = {} |
| 47 | provider = d.getVar("FVP_PROVIDER") |
| 48 | if provider: |
| 49 | data["provider"] = provider |
| 50 | data["fvp-bindir"] = os.path.join(d.getVar("COMPONENTS_DIR"), |
| 51 | d.getVar("BUILD_ARCH"), |
| 52 | provider, |
| 53 | "usr", "bin") |
| 54 | |
| 55 | def getFlags(varname): |
| 56 | flags = d.getVarFlags(varname) |
| 57 | # For unexplained reasons, getVarFlags() returns None if there are no flags |
| 58 | if flags is None: |
| 59 | return {} |
| 60 | # For other reasons, you can't pass expand=True |
| 61 | return {key: d.expand(value) for key, value in flags.items()} |
| 62 | |
| 63 | data["exe"] = d.getVar("FVP_EXE") |
| 64 | data["parameters"] = getFlags("FVP_CONFIG") |
| 65 | data["data"] = shlex.split(d.getVar("FVP_DATA") or "") |
| 66 | data["applications"] = getFlags("FVP_APPLICATIONS") |
| 67 | data["consoles"] = getFlags("FVP_CONSOLES") |
| 68 | data["terminals"] = getFlags("FVP_TERMINALS") |
| 69 | data["args"] = shlex.split(d.getVar("FVP_EXTRA_ARGS") or "") |
| 70 | |
Patrick Williams | 8dd6848 | 2022-10-04 07:57:18 -0500 | [diff] [blame] | 71 | data["env"] = {} |
| 72 | for var in d.getVar("FVP_ENV_PASSTHROUGH").split(): |
| 73 | data["env"][var] = d.getVar(var) |
| 74 | |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 75 | os.makedirs(os.path.dirname(conffile), exist_ok=True) |
| 76 | with open(conffile, "wt") as f: |
| 77 | json.dump(data, f) |
| 78 | |
| 79 | if conffile_link != conffile: |
| 80 | if os.path.lexists(conffile_link): |
| 81 | os.remove(conffile_link) |
| 82 | os.symlink(os.path.basename(conffile), conffile_link) |
| 83 | } |
| 84 | |
| 85 | def fvpboot_vars(d): |
| 86 | vars = ['DEPLOY_DIR_IMAGE', 'IMAGE_NAME', 'IMAGE_LINK_NAME', 'COMPONENTS_DIR', 'BUILD_ARCH'] |
| 87 | vars.extend((k for k in d.keys() if k.startswith('FVP_'))) |
| 88 | return " ".join(vars) |
| 89 | |
| 90 | do_write_fvpboot_conf[vardeps] += "${@fvpboot_vars(d)}" |