arm/fvp: add recipes for Ecosystem FVPs
PATCH 1/9 arm/fvp: add recipes for Ecosystem FVPs
Add recipes for the SGI-575 and N1-Edge reference designs from the Ecosystem FVP collection:
These FVPs are free to download and use.
--- meta-arm/recipes-devtools/fvp/fvp-common.inc | 36 +++++++++++++++++++ .../recipes-devtools/fvp/fvp-ecosystem.inc | 25 +++++++++++++ meta-arm/recipes-devtools/fvp/fvp-n1-edge.bb | 7 ++++ meta-arm/recipes-devtools/fvp/fvp-sgi575.bb | 7 ++++ 4 files changed, 75 insertions(+) create mode 100644 meta-arm/recipes-devtools/fvp/fvp-common.inc create mode 100644 meta-arm/recipes-devtools/fvp/fvp-ecosystem.inc create mode 100644 meta-arm/recipes-devtools/fvp/fvp-n1-edge.bb create mode 100644 meta-arm/recipes-devtools/fvp/fvp-sgi575.bb
meta-arm/recipes-devtools/fvp/fvp-common.inc new file +36 -0
@@ -0,0 +1,36 @@ +HOMEPAGE = "https://developer.arm.com/tools-and-software/simulation-models/fixed-virtual-platforms" + +# FVP has an End User License Agreement. Add Arm-FVP-EULA to your +# LICENSE_FLAGS_WHITELIST if you agree to these terms. +LICENSE_FLAGS = "Arm-FVP-EULA" + +LICENSE = "Proprietary & Apache-2.0 & Python-2.0 & GPL-3.0-with-GCC-exception & Zlib & NCSA & LGPLv2+ & MIT & BSD-3-Clause" + +COMPATIBLE_HOST = '(x86_64|i.86).*-linux' +FVP_ARCH = "Linux64_GCC-6.4" + +# The directory the FVP is installed into +FVPDIR = "${libdir}/fvp/${BPN}" + +# Used in do_install to create symlinks in $bindir to $FVPDIR +fvp_link_binaries() { + for FVP in ${D}${FVPDIR}/models/${FVP_ARCH}/FVP_*; do + lnr $FVP ${D}${bindir}/$(basename $FVP) + done + # But not the .so files too + rm -f ${D}${bindir}/*.so +} + +FILES_${PN} = "${bindir} ${FVPDIR}" + +# Prebuilt binaries are already stripped +INSANE_SKIP_${PN} += "already-stripped" +# FVP can optionally have a GUI, but we can use the host libraries in native/nativesdk +INSANE_SKIP_${PN} += "file-rdeps" + +# FVP brings its own standard library so don't let it be used as a shlib provider +PRIVATE_LIBS = "libgcc_s.so.1 libstdc++.so.6" + +INHIBIT_DEFAULT_DEPS = "1" + +BBCLASSEXTEND = "native nativesdk"
meta-arm/recipes-devtools/fvp/fvp-ecosystem.inc new file +25 -0
@@ -0,0 +1,25 @@ +require fvp-common.inc + +# These need to be set +MODEL ?= "unset" +MODEL_CODE ?= "unset" +PV ?= "unset" + +SUMMARY = "Arm Fixed Virtual Platform - ${MODEL} Ecosystem Reference Design" +HOMEPAGE = "https://developer.arm.com/tools-and-software/open-source-software/arm-platforms-software/arm-ecosystem-fvps" + +SRC_URI = "https://developer.arm.com/-/media/Arm%20Developer%20Community/Downloads/OSS/FVP/${MODEL}/${MODEL_CODE}_${PV}.tgz;subdir=${BP}" + +LIC_FILES_CHKSUM = "file://license_terms/license_agreement.txt;md5=1a33828e132ba71861c11688dbb0bd16 \ + file://license_terms/third_party_licenses.txt;md5=47473b1e04b70938cf0a7ffea8ea4cc3" + +do_install() { + mkdir --parents ${D}${FVPDIR} ${D}${bindir} + + ${S}/${MODEL_CODE}.sh \ + --i-agree-to-the-contained-eula \ + --no-interactive \ + --destination ${D}${FVPDIR} + + fvp_link_binaries +}
meta-arm/recipes-devtools/fvp/fvp-n1-edge.bb new file +7 -0
@@ -0,0 +1,7 @@ +require fvp-ecosystem.inc + +MODEL = "Neoverse-N1" +MODEL_CODE = "FVP_RD_N1_edge" +PV = "11.12_43" + +SRC_URI[sha256sum] = "e428cc44db251202bf45ae68d40832d01efbc5d0f1323f1ce46237213dd4f0fa"
meta-arm/recipes-devtools/fvp/fvp-sgi575.bb new file +7 -0
@@ -0,0 +1,7 @@ +require fvp-ecosystem.inc + +MODEL = "SGI-575" +MODEL_CODE = "FVP_CSS_SGI-575" +PV = "11.12_59" + +SRC_URI[sha256sum] = "86c7a16d83b0801278b4a3d05c8d42c4955ed22a0dbea3c583798fb971bc425c"
Signature · 1 line
2.25.1
PATCH 2/9 arm/fvp-base-a-aem: add Architecture Envelope Model FVP for Arm v8-A
Add a recipe for the general purpose Armv-A Base RevC AEM FVP.
This FVP is behind a login-wall so the user has to download it themselves, but the FVP is free to use.
--- .../recipes-devtools/fvp/fvp-base-a-aem.bb | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 meta-arm/recipes-devtools/fvp/fvp-base-a-aem.bb
meta-arm/recipes-devtools/fvp/fvp-base-a-aem.bb new file +26 -0
@@ -0,0 +1,26 @@ +require fvp-common.inc + +SUMMARY = "Arm Fixed Virtual Platform - Armv-A Base RevC Architecture Envelope Model FVP" +HOMEPAGE = "https://developer.arm.com/tools-and-software/simulation-models/fixed-virtual-platforms/arm-ecosystem-models" +LIC_FILES_CHKSUM = "file://license_terms/license_agreement.txt;md5=1a33828e132ba71861c11688dbb0bd16 \ + file://license_terms/third_party_licenses.txt;md5=b40ecbbbd3409d48263437b782df6df9" + +# This FVP cannot be downloaded directly, so download the Armv-A Base RevC AEM +# FVP yourself from the homepage and set FVP_BASE_A_AEM_TARBALL_URI appropriately +# (for example, file:///home/user/FVP_Base_RevC-2xAEMvA_11.14_21.tgz). +FVP_BASE_A_AEM_TARBALL_URI ?= "" +PV = "11.14_21" + +SRC_URI = "${FVP_BASE_A_AEM_TARBALL_URI};subdir=${BP}" +python() { + if not d.getVar("FVP_BASE_A_AEM_TARBALL_URI"): + raise bb.parse.SkipRecipe("FVP_BASE_A_AEM_TARBALL_URI not set") +} + +do_install() { + mkdir --parents ${D}${FVPDIR} ${D}${bindir} + + cp --archive --no-preserve=ownership ${S}/Base_RevC_AEMvA_pkg/* ${D}${FVPDIR}/ + + fvp_link_binaries +}
Signature · 1 line
2.25.1
PATCH 3/9 arm/fvp-library: add recipe for the FVP Library
In reply to Ross BurtonAdd a recipe for the FVP Library:
https://developer.arm.com/tools-and-software/simulation-models/fixed-virtual-platforms
This is free to download but is behind a login-wall, and the FVPs are license managed.
--- meta-arm/recipes-devtools/fvp/fvp-library.bb | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 meta-arm/recipes-devtools/fvp/fvp-library.bb
meta-arm/recipes-devtools/fvp/fvp-library.bb new file +22 -0
@@ -0,0 +1,22 @@ +require fvp-ecosystem.inc + +MODEL = "Library" +MODEL_CODE = "FVP_ARM_Std_Library" +PV = "11.14_21" + +HOMEPAGE = "https://developer.arm.com/tools-and-software/simulation-models/fixed-virtual-platforms" + +LIC_FILES_CHKSUM = "file://license_terms/license_agreement.txt;md5=a50d186fffa51ed55599183aad911298 \ + file://license_terms/third_party_licenses.txt;md5=b40ecbbbd3409d48263437b782df6df9" + + +# The FVP Library tarball cannot be downloaded directly, so download the it +# yourself from from the homepage and set FVP_LIBRARY_TARBALL_URI appropriately +# (for example, "file:///home/user/FVP_ARM_Std_Library_11.14_21.tgz"). +FVP_LIBRARY_TARBALL_URI ?= "" + +SRC_URI = "${FVP_LIBRARY_TARBALL_URI};subdir=${BP}" +python() { + if not d.getVar("FVP_LIBRARY_TARBALL_URI"): + raise bb.parse.SkipRecipe("FVP_LIBRARY_TARBALL_URI not set") +}
Signature · 1 line
2.25.1
PATCH 4/9 arm/fvpboot: add class to write FVP boot configuration
In reply to Ross BurtonThe fvpboot class is used to write a machine-readable file that describes how to boot a given machine image inside a FVP, similar to how qemuboot writes files for runqemu.
BSPs should set the FVP_* variables as appropriate in their machine configuration, but let the user opt-in to adding fvpboot to IMAGE_CLASSES.
--- meta-arm/classes/fvpboot.bbclass | 80 ++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 meta-arm/classes/fvpboot.bbclass
meta-arm/classes/fvpboot.bbclass new file +80 -0
@@ -0,0 +1,80 @@ +# Image class to write .fvpconf files for use with runfvp. If this is desired +# then add fvpboot to IMAGE_CLASSES, and set the variables below in your machine +# configuration as appropriate. + +# Name of recipe providing FVP executable. If unset then the executable must be installed on the host. +FVP_PROVIDER ?= "" +# Name of FVP executable to run +FVP_EXE ?= "" +# Flags for --parameter/-C +FVP_CONFIG ?= "" +# Flags for --data +FVP_DATA ?= "" +# Flags for --application +FVP_APPLICATIONS ?= "" +# Flags to name serial terminals. Flag name is the terminal id (such as +# terminal_0), value is a human-readable name. If the name is not set +# then runfvp will hide the terminal. +FVP_TERMINALS ?= "" +# What terminal should be considered the primary console +FVP_CONSOLE ?= "" +# Arbitrary extra arguments +FVP_EXTRA_ARGS ?= "" + +EXTRA_IMAGEDEPENDS += "${FVP_PROVIDER}" + +inherit image-artifact-names + +addtask do_write_fvpboot_conf after do_rootfs before do_image +python do_write_fvpboot_conf() { + # Note that currently this JSON file is in development and the format may + # change at any point, so it should always be used with a matching runfvp. + + import json, shlex + + if not d.getVar("FVP_EXE"): + return + + conffile = os.path.join(d.getVar("IMGDEPLOYDIR"), d.getVar("IMAGE_NAME") + ".fvpconf") + conffile_link = os.path.join(d.getVar("IMGDEPLOYDIR"), d.getVar("IMAGE_LINK_NAME") + ".fvpconf") + + data = {} + provider = d.getVar("FVP_PROVIDER") + if provider: + data["provider"] = provider + data["fvp-bindir"] = os.path.join(d.getVar("COMPONENTS_DIR"), + d.getVar("BUILD_ARCH"), + provider, + "usr", "bin") + + def getFlags(varname): + flags = d.getVarFlags(varname) + # For unexplained reasons, getVarFlags() returns None if there are no flags + if flags is None: + return {} + # For other reasons, you can't pass expand=True + return {key: d.expand(value) for key, value in flags.items()} + + data["exe"] = d.getVar("FVP_EXE") + data["parameters"] = getFlags("FVP_CONFIG") + data["data"] = shlex.split(d.getVar("FVP_DATA") or "") + data["applications"] = getFlags("FVP_APPLICATIONS") + data["console"] = d.getVar("FVP_CONSOLE") + data["terminals"] = getFlags("FVP_TERMINALS") + data["args"] = shlex.split(d.getVar("FVP_EXTRA_ARGS") or "") + + os.makedirs(os.path.dirname(conffile), exist_ok=True) + with open(conffile, "wt") as f: + json.dump(data, f) + + if conffile_link != conffile: + if os.path.lexists(conffile_link): + os.remove(conffile_link) + os.symlink(os.path.basename(conffile), conffile_link) +} + +def fvpboot_vars(d): + build_vars = ['DEPLOY_DIR_IMAGE', 'IMAGE_NAME', 'IMAGE_LINK_NAME', + 'COMPONENTS_DIR', 'BUILD_ARCH'] + return build_vars + [k for k in d.keys() if k.startswith('FVP_')] +do_write_fvpboot_conf[vardeps] += "${@' '.join(fvpboot_vars(d))}"
Signature · 1 line
2.25.1
PATCH 5/9 scripts: add runfvp
In reply to Ross Burtonrunfvp is a script that reads existing .fvpconf files (as written by fvpboot.bbclass) and executes the FVP binary appropriately.
By default the behaviour is the same as running a FVP by hand, but by passing --console the first serial port is connected to stdin/stdout.
--- scripts/runfvp | 160 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100755 scripts/runfvp
scripts/runfvp new file +160 -0
@@ -0,0 +1,160 @@ +#! /usr/bin/env python3 + +import json +import os +import sys +import subprocess +import pathlib + +import logging +logger = logging.getLogger("RunFVP") + +# TODO: option to switch between telnet and netcat +connect_command = "telnet localhost %port" + +terminal_map = { + "tmux": f"tmux new-window -n \"%title\" \"{connect_command}\"", + "xterm": f"xterm -title \"%title\" -e {connect_command}", + "none": "" + # TODO more terminals +} + +def get_image_directory(machine=None): + """ + Get the DEPLOY_DIR_IMAGE for the specified machine + (or the configured machine if not set). + """ + import bb.tinfoil + + if machine: + os.environ["MACHINE"] = machine + + with bb.tinfoil.Tinfoil() as tinfoil: + tinfoil.prepare(config_only=True) + image_dir = tinfoil.config_data.getVar("DEPLOY_DIR_IMAGE") + logger.debug(f"Got DEPLOY_DIR_IMAGE {image_dir}") + return pathlib.Path(image_dir) + + +def runfvp(args): + import argparse + + parser = argparse.ArgumentParser(description="Run images in a FVP") + parser.add_argument("config", nargs="?", help="Machine name or path to .fvpconf file") + group = parser.add_mutually_exclusive_group() + group.add_argument("-t", "--terminals", choices=terminal_map.keys(), default="xterm", help="Automatically start terminals") + group.add_argument("-c", "--console", action="store_true", help="Attach the first uart to stdin/stdout") + parser.add_argument("-C", "--parameter", action="append", default=[], help="Extra configuration parameters for FVP") + parser.add_argument("--verbose", action="store_true", help="Output verbose logging") + # TODO option for telnet vs netcat + + args = parser.parse_args() + logging.basicConfig(level=args.verbose and logging.DEBUG or logging.WARNING) + logger.debug(f"Parsed arguments are {vars(args)}") + + # If we're hooking up the console, don't start any terminals + if args.console: + args.terminals = "none" + + if args.config and os.path.exists(args.config): + config_file = args.config + else: + image_dir = get_image_directory(args.config) + # All .fvpconf configuration files + configs = image_dir.glob("*.fvpconf") + # Just the files + configs = [p for p in configs if p.is_file() and not p.is_symlink()] + if not configs: + print(f"Cannot find any .fvpconf in {image_dir}") + sys.exit(1) + # Sorted by modification time + configs = sorted(configs, key=lambda p: p.stat().st_mtime) + config_file = configs[-1] + + logger.debug(f"Loading {config_file}") + with open(config_file) as f: + config = json.load(f) + + # Ensure that all expected keys are present + def sanitise(key, value): + if key not in config or config[key] is None: + config[key] = value + sanitise("fvp-bindir", "") + sanitise("exe", "") + sanitise("parameters", {}) + sanitise("data", {}) + sanitise("applications", {}) + sanitise("terminals", {}) + sanitise("args", []) + sanitise("console", "") + + if not config["exe"]: + logger.error("Required value FVP_EXE not set in machine configuration") + sys.exit(1) + + cli = [] + if config["fvp-bindir"]: + cli.append(os.path.join(config["fvp-bindir"], config["exe"])) + else: + cli.append(config["exe"]) + + for param, value in config["parameters"].items(): + cli.extend(["--parameter", f"{param}={value}"]) + + for value in config["data"]: + cli.extend(["--data", value]) + + for param, value in config["applications"].items(): + cli.extend(["--application", f"{param}={value}"]) + + for terminal, name in config["terminals"].items(): + # If terminals are enabled and this terminal has been named + if args.terminals != "none" and name: + # TODO if raw mode + # cli.extend(["--parameter", f"{terminal}.mode=raw"]) + # TODO put name into terminal title + cli.extend(["--parameter", f"{terminal}.terminal_command={terminal_map[args.terminals]}"]) + else: + # Disable terminal + cli.extend(["--parameter", f"{terminal}.start_telnet=0"]) + + cli.extend(config["args"]) + + # Finally add the user's extra arguments + for param in args.parameter: + cli.extend(["--parameter", param]) + + logger.debug(f"Constructed FVP call: {cli}") + if args.console: + expected_terminal = config["console"] + if not expected_terminal: + logger.error("--console used but FVP_CONSOLE not set in machine configuration") + sys.exit(1) + + fvp_process = subprocess.Popen(cli, bufsize=1, universal_newlines=True, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + + import selectors, re + selector = selectors.DefaultSelector() + selector.register(fvp_process.stdout, selectors.EVENT_READ) + output = "" + looking = True + while fvp_process.poll() is None: + # TODO some sort of timeout for 'input never appeared' + events = selector.select(timeout=10) + for key, mask in events: + line = key.fileobj.readline() + output += line + if looking: + m = re.match(fr"^{expected_terminal}: Listening.+port ([0-9]+)$", line) + if m: + port = m.group(1) + subprocess.run(["telnet", "localhost", port]) + looking = False + if fvp_process.returncode: + logger.error(f"{fvp_process.args[0]} quit with code {fvp_process.returncode}:") + logger.error(output) + else: + subprocess.run(cli) + +if __name__ == "__main__": + runfvp(sys.argv)
Signature · 1 line
2.25.1
PATCH 6/9 runfvp: exit with the return code of the FVP binary
In reply to Ross BurtonFrom: Ross Burton <[email protected]>
--- scripts/runfvp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/runfvp +1 -1
@@ -154,7 +154,7 @@ def runfvp(args): logger.error(f"{fvp_process.args[0]} quit with code {fvp_process.returncode}:") logger.error(output) else: - subprocess.run(cli) + sys.exit(subprocess.run(cli).returncode) if __name__ == "__main__": runfvp(sys.argv)
Signature · 1 line
2.25.1
PATCH 7/9 runfvp: pass arbitrary options after -- to the FVP binary
In reply to Ross BurtonFrom: Ross Burton <[email protected]>
To allow passing arbitrary options to the FVP binary, split the passed options on --. Anything before the separator is handled by runfvp, anything afterwards is passed as-is to the FVP binary.
--- scripts/runfvp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
scripts/runfvp +14 -2
@@ -46,9 +46,18 @@ def runfvp(args): group.add_argument("-c", "--console", action="store_true", help="Attach the first uart to stdin/stdout") parser.add_argument("-C", "--parameter", action="append", default=[], help="Extra configuration parameters for FVP") parser.add_argument("--verbose", action="store_true", help="Output verbose logging") + parser.usage = f"{parser.format_usage().strip()} -- [ arguments passed to FVP ]" # TODO option for telnet vs netcat - args = parser.parse_args() + try: + i = sys.argv.index("--") + arguments = sys.argv[1:i] + fvp_args = sys.argv[i+1:] + except ValueError: + arguments = sys.argv[1:] + fvp_args = [] + + args = parser.parse_args(args=arguments) logging.basicConfig(level=args.verbose and logging.DEBUG or logging.WARNING) logger.debug(f"Parsed arguments are {vars(args)}")
@@ -120,10 +129,13 @@ def runfvp(args): cli.extend(config["args"]) - # Finally add the user's extra arguments + # Add any explicit --parameter calls for param in args.parameter: cli.extend(["--parameter", param]) + # Finally add the user's extra arguments + cli.extend(fvp_args) + logger.debug(f"Constructed FVP call: {cli}") if args.console: expected_terminal = config["console"]
Signature · 1 line
2.25.1
PATCH 8/9 runfvp: drop --parameter, users can use -- --parameter
In reply to Ross BurtonFrom: Ross Burton <[email protected]>
Now that arbitrary parameters can be passed to the FVP binary, runfvp doesn't need to handle --parameter itself.
Anyone using runfvp --parameter should simply use runfvp -- --parameter.
--- scripts/runfvp | 5 ----- 1 file changed, 5 deletions(-)
scripts/runfvp +0 -5
@@ -44,7 +44,6 @@ def runfvp(args): group = parser.add_mutually_exclusive_group() group.add_argument("-t", "--terminals", choices=terminal_map.keys(), default="xterm", help="Automatically start terminals") group.add_argument("-c", "--console", action="store_true", help="Attach the first uart to stdin/stdout") - parser.add_argument("-C", "--parameter", action="append", default=[], help="Extra configuration parameters for FVP") parser.add_argument("--verbose", action="store_true", help="Output verbose logging") parser.usage = f"{parser.format_usage().strip()} -- [ arguments passed to FVP ]" # TODO option for telnet vs netcat
@@ -129,10 +128,6 @@ def runfvp(args): cli.extend(config["args"]) - # Add any explicit --parameter calls - for param in args.parameter: - cli.extend(["--parameter", param]) - # Finally add the user's extra arguments cli.extend(fvp_args)
Signature · 1 line
2.25.1
PATCH 9/9 arm-bsp/fvp-base: set FVP_ variables
In reply to Ross BurtonSo that a fvp-base image can be tested easily, set the relevant FVP_* variables.
After setting IMAGE_CLASSES += "fvpboot" in local.conf, this will show the firmware start and Linux boot:
$ MACHINE=fvp-base bitbake core-image-base $ runfvp fvp-base --console
--- meta-arm-bsp/conf/machine/fvp-base.conf | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
meta-arm-bsp/conf/machine/fvp-base.conf +14 -0
@@ -15,3 +15,17 @@ UBOOT_MACHINE = "vexpress_aemv8a_semi_defconfig" KERNEL_IMAGETYPE = "Image" KERNEL_DEVICETREE = "arm/fvp-base-gicv3-psci-custom.dtb" + +FVP_PROVIDER ?= "fvp-base-a-aem-native" +FVP_EXE ?= "FVP_Base_RevC-2xAEMvA" +FVP_CONFIG[cache_state_modelled] ?= "0" +FVP_CONFIG[bp.secureflashloader.fname] ?= "${DEPLOY_DIR_IMAGE}/bl1-fvp.bin" +FVP_CONFIG[bp.flashloader0.fname] ?= "${DEPLOY_DIR_IMAGE}/fip-fvp.bin" +FVP_CONFIG[bp.virtioblockdevice.image_path] ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.wic" +FVP_DATA ?= "cluster0.cpu0=${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}@0x80080000 \ + cluster0.cpu0=${DEPLOY_DIR_IMAGE}/fvp-base-gicv3-psci-custom.dtb@0x83000000" +FVP_CONSOLE ?= "terminal_0" +FVP_TERMINALS[bp.terminal_0] ?= "Console" +FVP_TERMINALS[bp.terminal_1] ?= "" +FVP_TERMINALS[bp.terminal_2] ?= "" +FVP_TERMINALS[bp.terminal_3] ?= ""
Signature · 1 line
2.25.1