From ad73752f4b39808aa6513846bcfaf346b2b62435 Mon Sep 17 00:00:00 2001 From: Bertrand Marquis Date: Wed, 4 Dec 2019 16:40:45 +0000 Subject: [PATCH] Add support for arm Foundation ARMv8 FVP simulator Add recipes and configuration files to add Yocto support for Foundation armv8 simulator from arm. The following components are supported: - trusted-firmware-a - linux kernel (with specific kernel configuration) - xen (with meta-virtualization layer) - unpacking and starting the generated image directly in Foundation simulator (package must be download from www.arm.com website and put in the directory downloads/licensed/silver.arm.com). After building, the following command can be used to start a generated image in foundation: ./tmp/deploy/tools/start-foundation-armv8.sh Change-Id: Iade343c38f0799ee8523434d555cb3ca42068a86 Signed-off-by: Bertrand Marquis --- .../classes/image_types_disk_img.bbclass | 155 ++++++++++++ meta-arm-bsp/conf/layer.conf | 5 + .../conf/machine/foundation-armv8.conf | 10 + meta-arm-bsp/conf/machine/fvp-common/fvp.inc | 46 ++++ .../documentation/foundation-armv8.md | 36 +++ .../trusted-firmware-a-fvp.inc | 31 +++ .../trusted-firmware-a_2.%.bbappend | 7 + .../files/start-foundation-armv8.sh | 238 ++++++++++++++++++ .../foundation-armv8-native_r11p8-61rel0.bb | 45 ++++ .../fvp-common/fvp-native.inc | 34 +++ .../0001-trace-fix-build-with-gcc9.patch | 56 +++++ .../recipes-extended/xen/files/fvp/defconfig | 73 ++++++ .../recipes-extended/xen/xen_4.%.bbappend | 18 ++ .../recipes-extended/xen/xen_4.12.0.bbappend | 8 + .../bsp/arm-platforms/README.md | 4 + .../bsp/arm-platforms/fvp-standard.scc | 11 + .../bsp/arm-platforms/fvp.scc | 14 ++ .../bsp/arm-platforms/fvp/fvp-board.cfg | 16 ++ .../bsp/arm-platforms/fvp/fvp-cfi.cfg | 3 + .../bsp/arm-platforms/fvp/fvp-drm.cfg | 5 + .../bsp/arm-platforms/fvp/fvp-net.cfg | 2 + .../bsp/arm-platforms/fvp/fvp-rtc.cfg | 2 + .../bsp/arm-platforms/fvp/fvp-serial.cfg | 2 + .../bsp/arm-platforms/fvp/fvp-timer.cfg | 3 + .../bsp/arm-platforms/fvp/fvp-virtio.cfg | 4 + .../bsp/arm-platforms/fvp/fvp-watchdog.cfg | 3 + .../linux/linux-yocto-arm-platforms.inc | 18 ++ .../linux/linux-yocto_4.19.bbappend | 3 + 28 files changed, 852 insertions(+) create mode 100644 meta-arm-bsp/classes/image_types_disk_img.bbclass create mode 100644 meta-arm-bsp/conf/machine/foundation-armv8.conf create mode 100644 meta-arm-bsp/conf/machine/fvp-common/fvp.inc create mode 100644 meta-arm-bsp/documentation/foundation-armv8.md create mode 100644 meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-fvp.inc create mode 100644 meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.%.bbappend create mode 100755 meta-arm-bsp/recipes-devtools/fvp-common/files/start-foundation-armv8.sh create mode 100644 meta-arm-bsp/recipes-devtools/fvp-common/foundation-armv8-native_r11p8-61rel0.bb create mode 100644 meta-arm-bsp/recipes-devtools/fvp-common/fvp-native.inc create mode 100644 meta-arm-bsp/recipes-extended/xen/files/4.12.0/0001-trace-fix-build-with-gcc9.patch create mode 100644 meta-arm-bsp/recipes-extended/xen/files/fvp/defconfig create mode 100644 meta-arm-bsp/recipes-extended/xen/xen_4.%.bbappend create mode 100644 meta-arm-bsp/recipes-extended/xen/xen_4.12.0.bbappend create mode 100644 meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/README.md create mode 100644 meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp-standard.scc create mode 100644 meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp.scc create mode 100644 meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-board.cfg create mode 100644 meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-cfi.cfg create mode 100644 meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-drm.cfg create mode 100644 meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-net.cfg create mode 100644 meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-rtc.cfg create mode 100644 meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-serial.cfg create mode 100644 meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-timer.cfg create mode 100644 meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-virtio.cfg create mode 100644 meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-watchdog.cfg create mode 100644 meta-arm-bsp/recipes-kernel/linux/linux-yocto-arm-platforms.inc create mode 100644 meta-arm-bsp/recipes-kernel/linux/linux-yocto_4.19.bbappend diff --git a/meta-arm-bsp/classes/image_types_disk_img.bbclass b/meta-arm-bsp/classes/image_types_disk_img.bbclass new file mode 100644 index 00000000..57a0549c --- /dev/null +++ b/meta-arm-bsp/classes/image_types_disk_img.bbclass @@ -0,0 +1,155 @@ +# Defines the disk.img image type + +# +# Add an image type 'disk.img' which creates a disk image +# with up to 4 partitions +# +# For partition 1 (replace 1 by 2 for partition 2, and so on for 3 and 4): +# +# * DISK_IMG_PARTITION1_SIZE is the partition size in MB (1024 is 1 GB) +# +# * DISK_IMG_PARTITION1_FSTYPE is the file system to format the partition with. +# We support only ext files systems (ext2, ext3 and ext4) +# If this is empty, the partition will not be formated. +# +# * DISK_IMG_PARTITION1_CONTENT is the content to put in the filesystem. +# Only 'rootfs' is supported and will create a partition with the Yocto +# root filesystem. +# + +# Default values for partition 1 +DISK_IMG_PARTITION1_SIZE ??= "2048" +DISK_IMG_PARTITION1_FSTYPE ??= "ext4" +DISK_IMG_PARTITION1_CONTENT ??= "rootfs" + +# Default values for partition 2 +DISK_IMG_PARTITION2_SIZE ??= "0" +DISK_IMG_PARTITION2_FSTYPE ??= "ext2" +DISK_IMG_PARTITION2_CONTENT ??= "" + +# Default values for partition 3 +DISK_IMG_PARTITION3_SIZE ??= "0" +DISK_IMG_PARTITION3_FSTYPE ??= "ext4" +DISK_IMG_PARTITION3_CONTENT ??= "" + +# Default values for partition 4 +DISK_IMG_PARTITION4_SIZE ??= "0" +DISK_IMG_PARTITION4_FSTYPE ??= "ext4" +DISK_IMG_PARTITION4_CONTENT ??= "" + +# Default disk sector size +DISK_IMG_SECTOR_SIZE ??= "512" + +# We need mkfs.ext and parted tools to create our image (dd is always there) +do_image_disk_img[depends] += " e2fsprogs-native:do_populate_sysroot \ + parted-native:do_populate_sysroot" + +DISK_IMG_FILE = "${IMGDEPLOYDIR}/${IMAGE_NAME}${IMAGE_NAME_SUFFIX}.disk.img" + +# Create one disk partition +disk_img_createpart() { + local imagefile="$1" + local start="$2" + local size="$3" + local fstype="${4:-ext4}" + local content="${5:-}" + local formatargs="" + + set -x + + rm -f $imagefile + + # Create the partition image + dd if=/dev/zero of=$imagefile bs=${DISK_IMG_SECTOR_SIZE} count=0 \ + seek=$(expr $size / ${DISK_IMG_SECTOR_SIZE}) + + if [ -n "$fstype" ]; then + case $content in + rootfs) + formatargs=" -d ${IMAGE_ROOTFS}" + ;; + boot) + echo "Unsupported" + exit 1 + ;; + *) + esac + + # Create the file system (with content if needed) + mkfs.$fstype -F $imagefile $formatargs + fi + + cat $imagefile >> ${DISK_IMG_FILE} + + # Add the partition to the partition table + parted -s ${DISK_IMG_FILE} unit B mkpart primary $start \ + $(expr $start + $realsize - 1) +} + +disk_img_create () { + local currpos + local realsize + + set -x + + currpos=${DISK_IMG_SECTOR_SIZE} + + # Create reserved part for partition table (1MB) + dd if=/dev/zero of=${DISK_IMG_FILE} bs=${DISK_IMG_SECTOR_SIZE} count=0 \ + seek=1 + + parted -s ${DISK_IMG_FILE} mklabel msdos + + if [ ${DISK_IMG_PARTITION1_SIZE} -ne 0 ]; then + + # Reduce the first block size of one sector to make space + # for the partition table + realsize=$(expr ${DISK_IMG_PARTITION1_SIZE} \* 1024 \* 1024 \ + - ${DISK_IMG_SECTOR_SIZE}) + + # Create the partition + disk_img_createpart ${WORKDIR}/part1.img $currpos $realsize \ + "${DISK_IMG_PARTITION1_FSTYPE}" "${DISK_IMG_PARTITION1_CONTENT}" + + currpos=$(expr $currpos + $realsize) + fi + + if [ ${DISK_IMG_PARTITION2_SIZE} -ne 0 ]; then + # Partition size + realsize=$(expr ${DISK_IMG_PARTITION2_SIZE} \* 1024 \* 1024) + + # Create the partition + disk_img_createpart ${WORKDIR}/part2.img $currpos $realsize \ + "${DISK_IMG_PARTITION2_FSTYPE}" "${DISK_IMG_PARTITION2_CONTENT}" + + currpos=$(expr $currpos + $realsize) + + fi + + if [ ${DISK_IMG_PARTITION3_SIZE} -ne 0 ]; then + # Partition size + realsize=$(expr ${DISK_IMG_PARTITION3_SIZE} \* 1024 \* 1024) + + # Create the partition + disk_img_createpart ${WORKDIR}/part3.img $currpos $realsize \ + "${DISK_IMG_PARTITION3_FSTYPE}" "${DISK_IMG_PARTITION3_CONTENT}" + + currpos=$(expr $currpos + $realsize) + + fi + if [ ${DISK_IMG_PARTITION4_SIZE} -ne 0 ]; then + # Partition size + realsize=$(expr ${DISK_IMG_PARTITION4_SIZE} \* 1024 \* 1024) + + # Create the partition + disk_img_createpart ${WORKDIR}/part4.img $currpos $realsize \ + "${DISK_IMG_PARTITION4_FSTYPE}" "${DISK_IMG_PARTITION4_CONTENT}" + + currpos=$(expr $currpos + $realsize) + + fi +} + +IMAGE_CMD_disk.img = "disk_img_create" +IMAGE_TYPES += "disk.img" + diff --git a/meta-arm-bsp/conf/layer.conf b/meta-arm-bsp/conf/layer.conf index ef1e5c10..931b54c1 100644 --- a/meta-arm-bsp/conf/layer.conf +++ b/meta-arm-bsp/conf/layer.conf @@ -11,3 +11,8 @@ BBFILE_PRIORITY_meta-arm-bsp = "6" LAYERDEPENDS_meta-arm-bsp = "core" LAYERSERIES_COMPAT_meta-arm-bsp = "warrior zeus" + +# We have patches for xen but meta-virtualization might not be there so filter +# out recipes-extended/xen unless xen is activated in the features +BBMASK += " ${@bb.utils.contains('DISTRO_FEATURES', 'xen', '', \ + '${LAYERDIR}/recipes-extended/xen/', d)}" diff --git a/meta-arm-bsp/conf/machine/foundation-armv8.conf b/meta-arm-bsp/conf/machine/foundation-armv8.conf new file mode 100644 index 00000000..9a3f43f9 --- /dev/null +++ b/meta-arm-bsp/conf/machine/foundation-armv8.conf @@ -0,0 +1,10 @@ +# Configuration for Armv8-A Foundation + +#@TYPE: Machine +#@NAME: Armv8-A Foundation Platform machine +#@DESCRIPTION: Machine configuration for Armv8-A Foundation Platform model + +require conf/machine/fvp-common/fvp.inc + +KERNEL_DEVICETREE = "arm/foundation-v8-gicv3-psci.dtb" +EXTRA_IMAGEDEPENDS += "foundation-armv8-native" diff --git a/meta-arm-bsp/conf/machine/fvp-common/fvp.inc b/meta-arm-bsp/conf/machine/fvp-common/fvp.inc new file mode 100644 index 00000000..68f5c13e --- /dev/null +++ b/meta-arm-bsp/conf/machine/fvp-common/fvp.inc @@ -0,0 +1,46 @@ +# FVP common parameters + +# +# Capturing FVP common configurations (Armv8-A Base Platform FVP and +# Armv8-A Foundation Platform). +# + +TUNE_FEATURES = "aarch64" + +require conf/machine/include/arm/arch-armv8a.inc + +MACHINE_FEATURES = "optee" + +KERNEL_IMAGETYPE = "Image" + +IMAGE_CLASSES += "image_types_disk_img" +IMAGE_FSTYPES += "disk.img" + +# Disk image configuration +# We don't use the first partition +DISK_IMG_PARTITION1_SIZE = "128" +DISK_IMG_PARTITION1_FSTYPE = "" +DISK_IMG_PARTITION1_CONTENT = "" + +# Second partition is used for rootfs +DISK_IMG_PARTITION2_SIZE = "2048" +DISK_IMG_PARTITION2_FSTYPE = "ext4" +DISK_IMG_PARTITION2_CONTENT = "rootfs" + +SERIAL_CONSOLES = "115200;ttyAMA0" + +PREFERRED_PROVIDER_virtual/kernel = "linux-yocto" +PREFERRED_VERSION_linux-yocto ?= "4.19%" + +EXTRA_IMAGEDEPENDS += "virtual/trusted-firmware-a u-boot" + +# FVP u-boot configuration +UBOOT_MACHINE = "vexpress_aemv8a_dram_defconfig" + +# Xen configuration +XEN_CONFIG_EARLY_PRINTK = "fastmodel" + +# parameters for xen dtb generation in meta-auto +XEN_DOM0_BOOTARGS_append = " root=/dev/vda2" +XEN_XEN_BOOTARGS_append = " console=dtuart dtuart=serial0 bootscrub=0" + diff --git a/meta-arm-bsp/documentation/foundation-armv8.md b/meta-arm-bsp/documentation/foundation-armv8.md new file mode 100644 index 00000000..ea4ec6cb --- /dev/null +++ b/meta-arm-bsp/documentation/foundation-armv8.md @@ -0,0 +1,36 @@ +# Armv8-A Base Platform Support in meta-arm-platforms + +## Howto Build and Run + +### Configuration: +In the local.conf file, MACHINE should be set as follow: +MACHINE ?= "foundation-v8" + +### Build: +```bash$ bitbake core-image-minimal``` + +### Run: +The layer provides a recipe to install the Armv8-A Foundation Platform in your +environment. You must download Armv8-A Foundation Platform from Arm developer +(This might require the user to register) from this address: +https://developer.arm.com/tools-and-software/simulation-models/fixed-virtual-platforms +and put the downloaded tar file in 'downloads/licensed/silver.arm.com/' +directory of your project (or of your Pre-Mirror if you have one). + +Once done, do the following to build and run an image: +```bash$ bitbake core-image-minimal``` +```bash$ ./tmp/deploy/tools/start-foundation-armv8.sh``` + +If you have built a configuration without a ramdisk, you can use the following +command in U-boot to start Linux: +```VExpress64# booti 0x80080000 - 0x83000000``` + +## Devices supported in the kernel +- serial +- virtio disk +- network +- watchdog +- rtc + +## Devices not supported or not functional +None diff --git a/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-fvp.inc b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-fvp.inc new file mode 100644 index 00000000..6e7eba3b --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a-fvp.inc @@ -0,0 +1,31 @@ +# FVP specific TFA parameters + +# +# Armv8-A Base Platform FVP and Armv8-A Foundation Platform uses the same +# TFAs. +# + +COMPATIBLE_MACHINE = "fvp-base|foundation-armv8" +TFA_PLATFORM = "fvp" +TFA_DEBUG = "1" +TFA_MBEDTLS = "1" +TFA_UBOOT = "1" +TFA_BUILD_TARGET = "bl1 bl2 bl31 dtbs fiptool" + +do_deploy[depends] += "virtual/kernel:do_deploy" + +do_deploy_append() { + ./tools/fiptool/fiptool create \ + --tb-fw ${S}/${TFA_BUILD_DIR}/bl2.bin \ + --soc-fw ${S}/${TFA_BUILD_DIR}/bl31.bin \ + --tb-fw-config ${S}/${TFA_BUILD_DIR}/fdts/fvp_tb_fw_config.dtb \ + --soc-fw-config ${S}/${TFA_BUILD_DIR}/fdts/fvp_soc_fw_config.dtb \ + --hw-config ${DEPLOY_DIR_IMAGE}/$(basename ${KERNEL_DEVICETREE}) \ + --nt-fw ${DEPLOY_DIR_IMAGE}/u-boot.bin \ + fip.bin + + ./tools/fiptool/fiptool info fip.bin + + install -m 0644 ${S}/fip.bin ${DEPLOYDIR}/fip-fvp.bin +} + diff --git a/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.%.bbappend b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.%.bbappend new file mode 100644 index 00000000..273d4e4f --- /dev/null +++ b/meta-arm-bsp/recipes-bsp/trusted-firmware-a/trusted-firmware-a_2.%.bbappend @@ -0,0 +1,7 @@ +# Machine specific TFAs + +MACHINE_TFA_REQUIRE ?= "" + +MACHINE_TFA_REQUIRE_foundation-armv8 = "trusted-firmware-a-fvp.inc" + +require ${MACHINE_TFA_REQUIRE} diff --git a/meta-arm-bsp/recipes-devtools/fvp-common/files/start-foundation-armv8.sh b/meta-arm-bsp/recipes-devtools/fvp-common/files/start-foundation-armv8.sh new file mode 100755 index 00000000..4e45a04c --- /dev/null +++ b/meta-arm-bsp/recipes-devtools/fvp-common/files/start-foundation-armv8.sh @@ -0,0 +1,238 @@ +#!/bin/bash +# Script to start a build image using FVP Foundation Platform +# +set -u +set -e + +# Get parameters from bitbake configuration +source <(bitbake -e foundation-armv8-native | grep \ + -e "^STAGING_.*_NATIVE=" \ + -e "^DEPLOY_DIR.*=") + + +# Bitbake image to run +IMAGE_NAME="$(cd $DEPLOY_DIR_IMAGE; ls *-foundation-armv8.manifest | \ + sed -e "s/-foundation-armv8\.manifest//")" + +# BL1 and FIP files +BL1_FILE="bl1-fvp.bin" +BL1_ADDR="0x0" +FIP_FILE="fip-fvp.bin" +FIP_ADDR="0x8000000" + +# Linux kernel file in deploy_dir and load address +KERNEL_FILE="Image" +KERNEL_ADDR="0x80080000" + +# DTB file in deploy_dir and load address +DTB_FILE="foundation-v8-gicv3-psci.dtb" +DTB_ADDR="0x83000000" + +# Xen file in deploy_dir and load address +XEN_FILE="xen-foundation-armv8" +XEN_ADDR="0x84000000" + +# Disk file in deploy_dir +DISK_FILE="" + +# Foundation Platform Executable (Extracted from +# FM000-KT-00035-r11p8-61rel0.tgz from silver.arm.com) +FOUNDATION_PLAT_EXE="Foundation_Platform" + +# Foundation Platform arguments +FOUNDATION_PLAT_ARGS=" \ + --cores=4 \ + --secure-memory \ + --use-real-time \ + --gicv3" + +# Foundation Platform user arguments +EXTRA_ARGS="" + +# Help function +usage() { + cat <&2 + echo "$optarg is not a valid deploy directory" >&2 + exit 1 + fi + DEPLOY_DIR_IMAGE=$optarg + ;; + --no-bl1) + BL1_FILE="" + ;; + --bl1=*) + BL1_FILE="$optarg" + ;; + --no-fip) + FIP_FILE="" + ;; + --fip=*) + FIP_FILE="$optarg" + ;; + --linux=*) + LINUX_FILE="$optarg" + ;; + --linux-addr=*) + LINUX_ADDR="$optarg" + ;; + --dtb=*) + DTB_FILE="$optarg" + ;; + --dtb-addr=*) + DTB_ADDR="$optarg" + ;; + --xen=*) + XEN_FILE="$optarg" + ;; + --xen-addr=*) + XEN_ADDR="$optarg" + ;; + --disk=*) + DISK_FILE="$optarg" + ;; + *) + if [ -z "$IMAGE_NAME" ] + then + IMAGE_NAME="$arg" + else + EXTRA_ARGS="$EXTRA_ARGS $arg" + fi + ;; + esac +done + +if [ -z "${BUILDDIR:-}" ]; then + echo "We are not in a Yocto build project." >&2 + echo "Please source oe-init-build-env first." >&2 + exit 1 +fi + +if [ -z "${IMAGE_NAME:-}" ]; then + IMAGE_NAME="core-image-minimal" +fi + +if [ -z "${DISK_FILE:-}" ]; then + DISK_FILE="${IMAGE_NAME}-foundation-armv8.disk.img" +fi + +# Add bl1 arg +if [ -n "$BL1_FILE" ]; then + if [ ! -f $DEPLOY_DIR_IMAGE/$BL1_FILE ]; then + echo "Could not find bl1 ($BL1_FILE) in $DEPLOY_DIR_IMAGE" >&2 + exit 1 + fi + FOUNDATION_PLAT_ARGS="$FOUNDATION_PLAT_ARGS \ + --data=$DEPLOY_DIR_IMAGE/$BL1_FILE@$BL1_ADDR" +fi + +# Add fip arg +if [ -n "$FIP_FILE" ]; then + if [ ! -f $DEPLOY_DIR_IMAGE/$FIP_FILE ]; then + echo "Could not find fip ($FIP_FILE) in $DEPLOY_DIR_IMAGE" >&2 + exit 1 + fi + FOUNDATION_PLAT_ARGS="$FOUNDATION_PLAT_ARGS \ + --data=$DEPLOY_DIR_IMAGE/$FIP_FILE@$FIP_ADDR" +fi + +# Add Linux kernel +if [ -n "$KERNEL_FILE" ]; then + if [ ! -f $DEPLOY_DIR_IMAGE/$KERNEL_FILE ]; then + echo "Could not find Linux kernel ($KERNEL_FILE) in \ + $DEPLOY_DIR_IMAGE" >&2 + exit 1 + fi + FOUNDATION_PLAT_ARGS="$FOUNDATION_PLAT_ARGS \ + --data=$DEPLOY_DIR_IMAGE/$KERNEL_FILE@$KERNEL_ADDR" +fi + +# Add DTB +if [ -n "$DTB_FILE" ]; then + if [ ! -f $DEPLOY_DIR_IMAGE/$DTB_FILE ]; then + echo "Could not find the DTB ($DTB_FILE) in $DEPLOY_DIR_IMAGE" >&2 + exit 1 + fi + FOUNDATION_PLAT_ARGS="$FOUNDATION_PLAT_ARGS \ + --data=$DEPLOY_DIR_IMAGE/$DTB_FILE@$DTB_ADDR" +fi + +# Add xen if present +if [ -n "$XEN_FILE" -a -f $DEPLOY_DIR_IMAGE/$XEN_FILE ]; then + FOUNDATION_PLAT_ARGS="$FOUNDATION_PLAT_ARGS \ + --data=$DEPLOY_DIR_IMAGE/$XEN_FILE@$XEN_ADDR" +fi + +# Add disk if present +if [ -n "$DISK_FILE" -a -f $DEPLOY_DIR_IMAGE/$DISK_FILE ]; then + FOUNDATION_PLAT_ARGS="$FOUNDATION_PLAT_ARGS \ + --block-device=$DEPLOY_DIR_IMAGE/$DISK_FILE" +fi + +FOUNDATION_PLAT_EXE="${STAGING_BINDIR_NATIVE}/${FOUNDATION_PLAT_EXE}" + +echo "$FOUNDATION_PLAT_EXE $FOUNDATION_PLAT_ARGS $EXTRA_ARGS" +$FOUNDATION_PLAT_EXE $FOUNDATION_PLAT_ARGS $EXTRA_ARGS diff --git a/meta-arm-bsp/recipes-devtools/fvp-common/foundation-armv8-native_r11p8-61rel0.bb b/meta-arm-bsp/recipes-devtools/fvp-common/foundation-armv8-native_r11p8-61rel0.bb new file mode 100644 index 00000000..4c1745dc --- /dev/null +++ b/meta-arm-bsp/recipes-devtools/fvp-common/foundation-armv8-native_r11p8-61rel0.bb @@ -0,0 +1,45 @@ +# Armv8-A Foundation Platform build recipe + +# +# Download and install recipe specific for Armv8-A Foundation Platform build are +# captured in the file. +# + +# The tar file required to build this package must be downloaded from +# https://developer.arm.com/tools-and-software/simulation-models/fixed-virtual-platforms +# and put in the sub-directory 'licensed/silver.arm.com' of one of the +# following locations: +# - in the directory 'files' of this file directory +# - in your Yocto project download directory (DL_DIR parameter of local.conf) +# - in your Download mirror if you have one +SRC_URI = "file://licensed/silver.arm.com/FM000-KT-00035-${PV}.tgz" +SRC_URI += "file://start-foundation-armv8.sh" + +S = "${WORKDIR}/Foundation_Platformpkg" + +# Checksums to compare against downloaded package files' checksums +LIC_FILES_CHKSUM = " \ + file://license_terms/license_agreement.txt;md5=ae7b47c67a033995c6b4510476a50f03 \ + file://license_terms/redistributables.txt;md5=f9fafcaf37ce6c9427568b9dbdbaabe5 \ + file://license_terms/supplementary_terms.txt;md5=26e4b214f639a22c8e7e207abc10eccb \ + file://license_terms/third_party_licenses.txt;md5=6394c171d6657fc195573c4d239341c4 \ + " + +require fvp-native.inc + +do_install_append() { + cp -a --no-preserve=ownership -rf doc license_terms models plugins \ + ${D}/${datadir}/fvp/. + + cat < ${D}${bindir}/Foundation_Platform +#!/bin/bash +basedir=\$(cd \$(dirname \$0)/../../; pwd) +export LD_LIBRARY_PATH="\$basedir/lib:\$basedir/usr/lib" +\$basedir/usr/share/fvp/models/Linux64_GCC-6.4/Foundation_Platform "\$@" +EOF + chmod 755 ${D}${bindir}/Foundation_Platform +} + +do_deploy_append() { + install -m 755 ${WORKDIR}/start-foundation-armv8.sh ${DEPLOYDIR}/. +} diff --git a/meta-arm-bsp/recipes-devtools/fvp-common/fvp-native.inc b/meta-arm-bsp/recipes-devtools/fvp-common/fvp-native.inc new file mode 100644 index 00000000..2cda4569 --- /dev/null +++ b/meta-arm-bsp/recipes-devtools/fvp-common/fvp-native.inc @@ -0,0 +1,34 @@ +# Fixed Virtual Platform (FVP) executable installation recipe + +# +# Package specific information like checksums and source information captured +# in specific bb files. +# + +SUMMARY = "Arm Fixed Virtual Platform" +HOMEPAGE = "https://developer.arm.com/tools-and-software/simulation-models/fixed-virtual-platforms" +LICENSE = "Proprietary & GPL & Apache" + + +inherit native deploy + +do_configure[noexec] = "1" +do_compile[noexec] = "1" + +do_install() { + install -d ${D}/${datadir}/fvp + install -d ${D}${bindir} +} +FILES_${PN} = "${datadir}/fvp/* ${bindir}/*" +INSANE_SKIP_${PN}_append = "already-stripped" + +# This is required so that our binaries are in the sysroot. We need this +# to have both fvp required libraries and fvp in the same sysroot. +addtask addto_recipe_sysroot after do_populate_sysroot before do_build + +do_deploy[sstate-outputdirs] = "${DEPLOY_DIR_TOOLS}" +do_deploy() { + install -d ${DEPLOYDIR} +} +addtask deploy before do_build after do_compile + diff --git a/meta-arm-bsp/recipes-extended/xen/files/4.12.0/0001-trace-fix-build-with-gcc9.patch b/meta-arm-bsp/recipes-extended/xen/files/4.12.0/0001-trace-fix-build-with-gcc9.patch new file mode 100644 index 00000000..8ecc904e --- /dev/null +++ b/meta-arm-bsp/recipes-extended/xen/files/4.12.0/0001-trace-fix-build-with-gcc9.patch @@ -0,0 +1,56 @@ +From 0dcd945a675cd12d283121e9b7f1626104b60bcc Mon Sep 17 00:00:00 2001 +From: Jan Beulich +Date: Tue, 4 Jun 2019 15:32:55 +0200 +Subject: [PATCH] trace: fix build with gcc9 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +While I've not observed this myself, gcc 9 (imo validly) reportedly may +complain + +trace.c: In function '__trace_hypercall': +trace.c:826:19: error: taking address of packed member of 'struct ' may result in an unaligned pointer value [-Werror=address-of-packed-member] + 826 | uint32_t *a = d.args; + +and the fix is rather simple - remove the __packed attribute. Introduce +a BUILD_BUG_ON() as replacement, for the unlikely case that Xen might +get ported to an architecture where array alignment higher that that of +its elements. + +Reported-by: Martin Liška +Signed-off-by: Jan Beulich +Acked-by: George Dunlap +master commit: 3fd3b266d4198c06e8e421ca515d9ba09ccd5155 +master date: 2019-05-13 09:51:23 +0200 +--- + xen/common/trace.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/xen/common/trace.c b/xen/common/trace.c +index cc294fc384..d1ef81407b 100644 +--- a/xen/common/trace.c ++++ b/xen/common/trace.c +@@ -819,12 +819,18 @@ unlock: + void __trace_hypercall(uint32_t event, unsigned long op, + const xen_ulong_t *args) + { +- struct __packed { ++ struct { + uint32_t op; + uint32_t args[6]; + } d; + uint32_t *a = d.args; + ++ /* ++ * In lieu of using __packed above, which gcc9 legitimately doesn't ++ * like in combination with the address of d.args[] taken. ++ */ ++ BUILD_BUG_ON(offsetof(typeof(d), args) != sizeof(d.op)); ++ + #define APPEND_ARG32(i) \ + do { \ + unsigned i_ = (i); \ +-- +2.17.1 + diff --git a/meta-arm-bsp/recipes-extended/xen/files/fvp/defconfig b/meta-arm-bsp/recipes-extended/xen/files/fvp/defconfig new file mode 100644 index 00000000..f13327c1 --- /dev/null +++ b/meta-arm-bsp/recipes-extended/xen/files/fvp/defconfig @@ -0,0 +1,73 @@ +# +# Automatically generated file; DO NOT EDIT. +# Xen/arm 4.12.0 Configuration +# +CONFIG_64BIT=y +CONFIG_ARM_64=y +CONFIG_ARM=y +CONFIG_ARCH_DEFCONFIG="arch/arm/configs/arm64_defconfig" + +# +# Architecture Features +# +CONFIG_NR_CPUS=128 +CONFIG_GICV3=y +CONFIG_HVM=y +# CONFIG_NEW_VGIC is not set +CONFIG_SBSA_VUART_CONSOLE=y +CONFIG_ARM_SSBD=y +CONFIG_HARDEN_BRANCH_PREDICTOR=y + +# +# ARM errata workaround via the alternative framework +# +CONFIG_ARM64_ERRATUM_827319=y +CONFIG_ARM64_ERRATUM_824069=y +CONFIG_ARM64_ERRATUM_819472=y +CONFIG_ARM64_ERRATUM_832075=y +CONFIG_ARM64_ERRATUM_834220=y +CONFIG_ARM64_HARDEN_BRANCH_PREDICTOR=y +CONFIG_ALL_PLAT=y +# CONFIG_QEMU is not set +# CONFIG_RCAR3 is not set +# CONFIG_MPSOC is not set +# CONFIG_NO_PLAT is not set +CONFIG_ALL64_PLAT=y +# CONFIG_ALL32_PLAT is not set +CONFIG_MPSOC_PLATFORM=y + +# +# Common Features +# +CONFIG_HAS_ALTERNATIVE=y +CONFIG_HAS_DEVICE_TREE=y +CONFIG_MEM_ACCESS=y +CONFIG_HAS_PDX=y +# CONFIG_XSM is not set +CONFIG_SCHED_CREDIT=y +CONFIG_SCHED_CREDIT2=y +CONFIG_SCHED_RTDS=y +# CONFIG_SCHED_ARINC653 is not set +CONFIG_SCHED_NULL=y +CONFIG_SCHED_DEFAULT="credit2" +# CONFIG_LIVEPATCH is not set +CONFIG_SUPPRESS_DUPLICATE_SYMBOL_WARNINGS=y +CONFIG_CMDLINE="" +CONFIG_DOM0_MEM="" + +# +# Device Drivers +# +CONFIG_HAS_NS16550=y +CONFIG_HAS_CADENCE_UART=y +CONFIG_HAS_MVEBU=y +CONFIG_HAS_PL011=y +CONFIG_HAS_SCIF=y +CONFIG_HAS_PASSTHROUGH=y +CONFIG_ARM_SMMU=y +CONFIG_DEFCONFIG_LIST="arch/arm/configs/arm64_defconfig" + +# +# Debugging Options +# +# CONFIG_DEBUG is not set diff --git a/meta-arm-bsp/recipes-extended/xen/xen_4.%.bbappend b/meta-arm-bsp/recipes-extended/xen/xen_4.%.bbappend new file mode 100644 index 00000000..c77e9345 --- /dev/null +++ b/meta-arm-bsp/recipes-extended/xen/xen_4.%.bbappend @@ -0,0 +1,18 @@ +# xen settings + +FILESEXTRAPATHS_prepend := "${THISDIR}/files:" + +# +# Define early console based on board parameters +# + +# This should be set in board.conf or local.conf to enable early printk in xen +XEN_CONFIG_EARLY_PRINTK ??= "disable" + +EXTRA_OEMAKE += "${@bb.utils.contains('XEN_CONFIG_EARLY_PRINTK', 'disable', \ + '', ' CONFIG_DEBUG=y CONFIG_EARLY_PRINTK=${XEN_CONFIG_EARLY_PRINTK}',d)}" + +# Foundation-armv8 support +COMPATIBLE_MACHINE_foundation-armv8 = "foundation-armv8" + +SRC_URI_append_foundation-armv8 = " file://fvp/defconfig" diff --git a/meta-arm-bsp/recipes-extended/xen/xen_4.12.0.bbappend b/meta-arm-bsp/recipes-extended/xen/xen_4.12.0.bbappend new file mode 100644 index 00000000..80980747 --- /dev/null +++ b/meta-arm-bsp/recipes-extended/xen/xen_4.12.0.bbappend @@ -0,0 +1,8 @@ +# xen version specific patch information + +FILESEXTRAPATHS_prepend := "${THISDIR}/files:" + +# Solve trace.c compilation error on 4.12.0 +# This should only be applied for 4.12.0 (solved in greater versions) +SRC_URI += "file://4.12.0/0001-trace-fix-build-with-gcc9.patch" + diff --git a/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/README.md b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/README.md new file mode 100644 index 00000000..ba61ca32 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/README.md @@ -0,0 +1,4 @@ +Arm platforms BSPs +================== + +This directory contains Arm platforms definitions and configuration for Linux. diff --git a/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp-standard.scc b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp-standard.scc new file mode 100644 index 00000000..d29e0b81 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp-standard.scc @@ -0,0 +1,11 @@ +define KMACHINE fvp +define KTYPE standard +define KARCH arm64 + +include ktypes/standard/standard.scc + +include fvp.scc + +# default policy for standard kernels +#include features/latencytop/latencytop.scc +#include features/profiling/profiling.scc diff --git a/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp.scc b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp.scc new file mode 100644 index 00000000..79e3a69a --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp.scc @@ -0,0 +1,14 @@ +include features/input/input.scc +include features/net/net.scc +include cfg/timer/no_hz.scc + +kconf hardware fvp/fvp-board.cfg +kconf hardware fvp/fvp-net.cfg +kconf hardware fvp/fvp-rtc.cfg +kconf hardware fvp/fvp-serial.cfg +kconf hardware fvp/fvp-virtio.cfg +kconf hardware fvp/fvp-cfi.cfg +kconf hardware fvp/fvp-drm.cfg +kconf hardware fvp/fvp-timer.cfg +kconf hardware fvp/fvp-virtio.cfg +kconf hardware fvp/fvp-watchdog.cfg diff --git a/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-board.cfg b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-board.cfg new file mode 100644 index 00000000..e10c003d --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-board.cfg @@ -0,0 +1,16 @@ +CONFIG_ARM64=y +CONFIG_ARCH_VEXPRESS=y +CONFIG_SMP=y +CONFIG_NR_CPUS=8 +CONFIG_HOTPLUG_CPU=y + +CONFIG_REGULATOR=y +CONFIG_REGULATOR_FIXED_VOLTAGE=y + +CONFIG_CPU_IDLE=y +CONFIG_ARM_CPUIDLE=y + +# We need to turn off SVE support in the Linux kernel otherwise Xen is stopping +# Linux kernel with a coredump while trying to access ZEN bit of CPACR1 core +# register. +# CONFIG_ARM64_SVE is not set diff --git a/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-cfi.cfg b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-cfi.cfg new file mode 100644 index 00000000..f28e0d92 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-cfi.cfg @@ -0,0 +1,3 @@ +# CFI Flash +CONFIG_MTD=y +CONFIG_MTD_CFI=y diff --git a/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-drm.cfg b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-drm.cfg new file mode 100644 index 00000000..77133a9d --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-drm.cfg @@ -0,0 +1,5 @@ +# DRM CLCD +CONFIG_DRM=y +CONFIG_DRM_PL111=y +CONFIG_FB=y +CONFIG_FB_ARMCLCD=y diff --git a/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-net.cfg b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-net.cfg new file mode 100644 index 00000000..54e3686d --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-net.cfg @@ -0,0 +1,2 @@ +CONFIG_SMSC911X=y +CONFIG_SMC91X=y diff --git a/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-rtc.cfg b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-rtc.cfg new file mode 100644 index 00000000..5d377b39 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-rtc.cfg @@ -0,0 +1,2 @@ +CONFIG_RTC_CLASS=y +CONFIG_RTC_DRV_PL031=y diff --git a/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-serial.cfg b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-serial.cfg new file mode 100644 index 00000000..44571640 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-serial.cfg @@ -0,0 +1,2 @@ +CONFIG_SERIAL_AMBA_PL011=y +CONFIG_SERIAL_AMBA_PL011_CONSOLE=y diff --git a/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-timer.cfg b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-timer.cfg new file mode 100644 index 00000000..144977f2 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-timer.cfg @@ -0,0 +1,3 @@ +# Dual timer module +CONFIG_ARM_TIMER_SP804=y +CONFIG_CLK_SP810=y diff --git a/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-virtio.cfg b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-virtio.cfg new file mode 100644 index 00000000..afc76a09 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-virtio.cfg @@ -0,0 +1,4 @@ +CONFIG_VIRTIO=y +CONFIG_VIRTIO_MMIO=y +CONFIG_BLOCK=y +CONFIG_VIRTIO_BLK=y diff --git a/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-watchdog.cfg b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-watchdog.cfg new file mode 100644 index 00000000..977f317c --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/arm-platforms-kmeta/bsp/arm-platforms/fvp/fvp-watchdog.cfg @@ -0,0 +1,3 @@ +# Watchdog +CONFIG_WATCHDOG=y +CONFIG_ARM_SP805_WATCHDOG=y diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto-arm-platforms.inc b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-arm-platforms.inc new file mode 100644 index 00000000..aef01321 --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto-arm-platforms.inc @@ -0,0 +1,18 @@ +# Kernel configuration and dts specific information + +# +# Kernel configurations and dts (If not using Linux provided ones) are captured +# in this file. Update SRC_URI and do_patch for building images with custom dts +# + +FILESEXTRAPATHS_prepend := "${THISDIR}:${THISDIR}/files:" + +# Arm platforms kmeta +SRC_URI_append = " file://arm-platforms-kmeta;type=kmeta;name=arm-platforms-kmeta;destsuffix=arm-platforms-kmeta" + +# +# FVP FOUNDATION KMACHINE +# +COMPATIBLE_MACHINE_foundation-armv8 = "foundation-armv8" +KMACHINE_foundation-armv8 = "fvp" + diff --git a/meta-arm-bsp/recipes-kernel/linux/linux-yocto_4.19.bbappend b/meta-arm-bsp/recipes-kernel/linux/linux-yocto_4.19.bbappend new file mode 100644 index 00000000..ed6fbc3f --- /dev/null +++ b/meta-arm-bsp/recipes-kernel/linux/linux-yocto_4.19.bbappend @@ -0,0 +1,3 @@ +# Add support for Arm Platforms (boards or simulators) + +require linux-yocto-arm-platforms.inc