From nobody Thu Apr 25 09:55:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+100863+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+100863+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1678276793; cv=none; d=zohomail.com; s=zohoarc; b=AX9Pgdh5YV+RBAOjg3+OuLfjl8R3pJizbDvEAFTLSDRMcRD9kJy90xatC9f0hE8N1brw0W8uoijvOx6v8cM6gnJWyv5lgp9LpZZtqZSyU4C7aCYJ/mqrFg62Vl04SWgU7dRbTdZ2wv3/qkmMF112NJCs21ZSzwnHfKk07yotKOQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678276793; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=DJj8VEABEYyQrHEYgQLUwCpfjc7V0r8zsjqqL6ulWWM=; b=W5EEA2FynXC5dG16CuMHDS2dR4W1OlSzWaCl81hggcjvAx2lahWrRW/iTVxwcQJ8nYrbKnIdl0i4Bng+yZYdL6Ax/etlXxzkzRILP2sGznP4LJs7vgvBYNMl0ZAiiXXjeYB4DwoBm6OuYUeMnd5NMutcLv/gpgIR5F4EEnXhoO4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+100863+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1678276793752103.03721212200878; Wed, 8 Mar 2023 03:59:53 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id EBlBYY1788612xpbfMxO43sq; Wed, 08 Mar 2023 03:59:53 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.5111.1678276787176535917 for ; Wed, 08 Mar 2023 03:59:47 -0800 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0F45B1042; Wed, 8 Mar 2023 04:00:30 -0800 (PST) X-Received: from josmar02Desktop.cambridge.arm.com (josmar02Desktop.cambridge.arm.com [10.2.78.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7B8D93F5A1; Wed, 8 Mar 2023 03:59:45 -0800 (PST) From: "Jose Marinho" To: devel@edk2.groups.io Cc: Jose Marinho , nd@arm.com, ardb+tianocore@kernel.org, thomas.abraham@arm.com, Sami Mujawar , Samer El-Haj-Mahmoud Subject: [edk2-devel] [PATCH v2 edk2-platforms] Platform/ARM: Add build docs for Arm plats FVP and Juno Date: Wed, 8 Mar 2023 11:59:23 +0000 Message-Id: <20230308115923.474998-1-jose.marinho@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,jose.marinho@arm.com X-Gm-Message-State: hZPmOgTjJwrILa2H1ozckMwPx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1678276793; bh=cpQyzOWnD9z0IFATj/iuU6+0LuXsaWz053mvdnGTcnc=; h=Cc:Date:From:Reply-To:Subject:To; b=Wj4634SxoLkDUq/CGLC+vwJVEsJv3wbxHRJNeLOAmeq8vbT9UAi8hL7trwI/V1Gn6u1 fmOnNNCByhtHjpuCF+tLjeJuWjGnZCsQIfm7JMl0c52ksoGFLAsrZpCyUnxD+raWQC1x0 BwvsrYNZ9va5YzPZzhdFhJ7oKD04/yXFsEQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1678276794216100002 Content-Type: text/plain; charset="utf-8" This patch updates the documentation for building Arm platforms. Signed-off-by: Jose Marinho Cc: Sami Mujawar Cc: Samer El-Haj-Mahmoud Reviewed-by: Sami Mujawar --- Notes: v2: - Rebased with upstream edk2-platforms master [Jose] Platform/ARM/Readme.md | 329 +++++++++++++++++--- 1 file changed, 292 insertions(+), 37 deletions(-) diff --git a/Platform/ARM/Readme.md b/Platform/ARM/Readme.md index ad2386c0dbb6d0e1ca7232c0cab7e2374dd4e255..8c48bd0d7bd55f076cf679ab7ca= 2b0b632aecd71 100644 --- a/Platform/ARM/Readme.md +++ b/Platform/ARM/Readme.md @@ -1,60 +1,315 @@ # Introduction =20 These instructions explain how to get an edk2/edk2-platforms build running -on the ARM Base FVP, which is a software model provided by ARM (for free) +on the Arm Base FVP and a Juno. The Arm Base FVP is a software model provi= ded by ARM (for free) , which models a Cortex A core with various peripherals. More information -can be found here: -[https://developer.arm.com/products/system-design/fixed-virtual-platforms] +can be found [here](https://developer.arm.com/products/system-design/fixed= -virtual-platforms). =20 -##Requirements -- A 32-bit or 64-bit Linux host machine. +## Build environment setup on Linux or Windows =20 -# Build EDK2 TianoCore +### Initial steps =20 -`build -a AARCH64 -p Platform/ARM/VExpressPkg/ArmVExpress-FVP-AArch64.dsc = -t GCC5` +The first step towards building an EDKII firmware image is to create a wor= king directory. =20 -Once built, the edk2 image is the following file Build/ArmVExpress-FVP-AAr= ch64/DEBUG_GCC5/FV/FVP_AARCH64_EFI.fd +1. Launch a terminal window. +2. Create a directory on your development machine (we willl name it 'sourc= e' in this example). +3. Set the WORKSPACE environment variable to point to this directory. =20 -# Run edk2/edk2-platforms on the ARM Base Platform FVP +#### Example: +In a Linux bash shell: +``` +cd +mkdir source +cd source +export WORKSPACE=3D$PWD +``` =20 -In order to run the binary we have just built there are a few steps we nee= d to -go through, we need to get a model, a set of prebuilts (where we will swap= out -the edk2 image with our own) and the tool with which we will swap out the -prebuilt edk2 image. +OR =20 -We will also rely on the "run_model" script that comes with the prebuilts,= it -is entirely possible to run the model without this but would require quite= a bit -of knowledge regarding the arguments of the ARM fastmodel (documentation c= an be found here: -[https://developer.arm.com/docs/100966/1101/programming-reference-for-base= -fvps/base-platform-revc-features]) -however the manual set of the FVP is outside the scope of this document. I= f you are interested -please consult the documentation. +In a Windows command prompt: =20 -It's recommended you create a folder where you download the prebuilts and -required tool and copy your edk2 image in to it, as the run script expects -the binaries in the same directory. +``` +cd +mkdir source +cd source +set WORKSPACE=3D%CD% +``` =20 -1. Download the Base FVP from here https://developer.arm.com/products/syst= em-design/fixed-virtual-platforms +### Cloning the source code repositories =20 - - Select Armv8-A Base Platform FVP based on Fast Models 11.4 - - It has a click through license but is free. +Note: To clone the repositories you need 'git' to be installed on your dev= elopment PC (see Development Tools). =20 -2. Download the 20.01 Linaro ARM Landing Team release for FVP booting UEFI -https://releases.linaro.org/members/arm/platforms/20.01/fvp-uefi.zip +In the terminal window, change directory to your workspace ('source') fold= er and run the following commands. Install Git if necessary. =20 -3. Clone the trusted firmware repo from https://git.trustedfirmware.org/TF= -A/trusted-firmware-a.git +``` +git clone https://github.com/tianocore/edk2.git +git clone https://github.com/tianocore/edk2-platforms.git +git clone https://github.com/acpica/acpica.git +``` =20 -4. Build fiptool: `make -C trusted-firmware-a/tools/fiptool` +Then go to the edk2 folder and update the submodules. =20 -5. Update the fip.bin image from fvp-uefi.zip by running the following com= mand: +``` +cd edk2 +git submodule update --init +cd .. +``` =20 - `./trusted-firmware-a/tools/fiptool/fiptool update --nt-fw=3D[path to = binary built above] fip.bin` +# Building firmware on a Linux host =20 -6. Execute the FVP run_model.sh script from fvp-uefi.zip and provide a pat= h to the FVP binaries -downloaded in step 1): +## Prerequisites =20 - `MODEL=3D[path to FVP binary] ./run_model.sh` +- A 64-bit development machine. +- Ubuntu 20.04 desktop. +- At least 10GB of free disk space. =20 -This expects the contents of fvp-uefi.zip, the bl1.bin and fip.bin (which = is -the file we modify), to be in the same directory as the run_model.sh scrip= t. +Check the Ubuntu version by typing the following in the terminal window. =20 -This should be sufficient to provide a build/run/debug environment for aar= ch64. +``` +$ uname -srvmpio +Linux 5.4.0-131-generic #147-Ubuntu SMP Fri Oct 14 17:07:22 UTC 2022 x86_6= 4 x86_64 x86_64 GNU/Linux +``` + +### Development Tools + +The following tools must be installed on the development PC. + + +| Sr. No. | Tool | Description = | Install instructions = | +|-----------|---------------------|---------------------------------------= -----------------------|---------------------------------------------------= -------| +| 1 | Python 3 | Python interpreter = | $ sudo apt install python3 python3-distutils = | +| 2 | Git | Git source control tool = | $ sudo apt install git = | +| 3 | uuid-dev | Required for including uuid/uuid.h = | $ sudo apt install uuid-dev = | +| 4 | build-essential | Installs make, gcc, g++, etc = | $ sudo apt install build-essential
$ make -v =
GNU Make 4.2.1
gcc --version
gcc (Ubuntu 9.4.0-1ubuntu1~20.0= 4.1) 9.4.0
$ g++ --version
g++ (Ubuntu 9.4.0-1ubuntu1\~20.04.1) 9= .4.0 | +| 5 | bison | A parser generator required by acpica = tools. | $ sudo apt install bison = | +| 6 | flex | A fast lexical analyzer generator requ= ired by acpica tools | $ sudp apt get install flex = | + +### Setting up the development tools + +Install the required development tools by running the following commands i= n the terminal window. + +``` +$ sudo apt install bison build-essential flex git uuid-dev + ``` + +``` +$ sudo apt install python3 python3-distutils + ``` + +### Arm cross compiler toolchain + +The Arm toolchain to cross compile from x86_64-linux to aarch64-elf is ava= ilable [here](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downl= oads). + +Select the latest toolchain to match the development PC architecture. Sele= ct the little-endian 'AArch64 ELF bare-metal target (aarch64-elf)' GCC cros= s compiler. + +Example: For a x86_64 development PC, download arm-gnu-toolchain-12.2.rel1= -x86_64-aarch64-none-elf.tar.xz + +Create a directory called 'toolchain' under the workspace folder. For exam= ple source\toolchain and extract the toolchain to this directory. + +``` +$ mkdir $WORKSPACE/toolchain +$ cd $WORKSPACE/toolchain +$ wget https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu= /12.2.rel1/binrel/arm-gnu-toolchain-12.2.rel1-x86_64-aarch64-none-elf.tar.xz +$ tar xf arm-gnu-toolchain-12.2.rel1-x86_64-aarch64-none-elf.tar.xz +$ cd $WORKSPACE +``` + +### Build the acpica tools + +The acpica tools implement the latest iasl compiler. To build the acpica t= ools, run the following commands in the terminal window. + +``` +$ make -C $WORKSPACE/acpica +``` + +## Building EDKII firmware + +1. To build the firmware image, follow the steps below and run the command= s in the terminal window. + +2. Set up the environment variables. + +``` +$ export GCC5_AARCH64_PREFIX=3D$WORKSPACE/toolchain/arm-gnu-toolchain-12.2= .rel1-x86_64-aarch64-none-elf/bin/aarch64-none-elf- +$ export PACKAGES_PATH=3D$WORKSPACE/edk2:$WORKSPACE/edk2-platforms +$ export IASL_PREFIX=3D$WORKSPACE/acpica/generate/unix/bin/ +$ export PYTHON_COMMAND=3D/usr/bin/python3 +``` + +3. Configure the EDKII development environment by running the edk2setup ba= sh script. +``` +$ source edk2/edksetup.sh +``` + +4. Build the BaseTools. +``` +$ make -C edk2/BaseTools +``` + +### Build the firmware for Arm FVP Base AEMv8A-AEMv8A Model platform + +Run the following command to build the firmware for FVP Base AEMv8A-AEMv8A= platform. +``` +$ build -a AARCH64 -t GCC5 -p Platform/ARM/VExpressPkg/ArmVExpress-FVP-AAr= ch64.dsc -b < DEBUG | RELEASE > +``` + +The firmware binaries can be found at the following location: +``` +$WORKSPACE/Build/ArmVExpress-FVP-AArch64/_GCC5/FV/FVP_AARCH= 64_EFI.fd +``` + +### Build the firmware for Arm Juno platform + +Run the following command to build the firmware for Arm Juno platform. +``` +$ build -a AARCH64 -t GCC5 -p Platform/ARM/JunoPkg/ArmJuno.dsc -b < DEBUG = | RELEASE > +``` + +The firmware binaries can be found at the following location: +``` +$WORKSPACE/Build/ArmJuno/_GCC5/FV/BL33_AP_UEFI.fd +``` + +# Building firmware on a Windows host using Windows Subsystem for Linux (W= SL) + +The instructions for building the firmware using WSL are similar to that f= or a Linux host. +The prerequisites for setting up the Windows Subsystem for Linux environme= nt are listed below. + +## Prerequisites + +- A x64 development machine with Windows 10 (Version 21H2 - OS Build 19044= .2486). +- At least 10GB of free disk space. +- Install the Windows Subsystem for Linux. Select Ubuntu 20.04 LTS from th= e Microsoft Store. + +Check the Ubuntu version by typing the following on the console. +``` +$ uname -srvmpio +Linux 4.4.0-19041-Microsoft #2311-Microsoft Tue Nov 08 17:09:00 PST 2022 x= 86_64 x86_64 x86_64 GNU/Linux +``` + +The remaining instructions for installing the development tools, configuri= ng the development environment and building firmware are exactly the same a= s those for a Linux host. + +# Building firmware on a x64 Windows host + +#### Prerequisites + +- A 64-bit development machine +- Windows 10 desktop (Version 21H2 - OS Build 19044.2486) +- At least 10GB of free disk space. + +#### Development Tools + +The following tools must be installed on the development machine. + +| Sr. No. | Tool | Description = | Install instructions = | +|-----------|----------------------------------------------|--------------= ------------------------------------------------|--------------------------= --------------------------------| +| 1 | Python 3 | Python interp= reter | Go [here](https://www.pyt= hon.org/downloads/windows/)

Choose the latest Python 3.X release.=

Download and run the Windows x86_64 MSI installer

If n= eeded, add the python executable to your path by executing the following co= mmand:
> set PATH=3D;%PATH% | +| 2 | Git | Git source co= ntrol tool | Go [here](https://git-scm= .com/download/win)

Download and run the 64-bit Git for Windows Se= tup | +| 3 | ASL tools | iasl compiler= and other tools for the ASL language | Go [here](https://www.acp= ica.org/downloads/binary-tools)

Download the iASL Compiler and W= indows ACPI Tools

Extract the content and place it at C:\ASL\
Check that the compiler is at the right place by executing:
> C= :\ASL\iasl.exe -v | +| 4 | Microsoft Visual Studio 2019 Professional | Microsoft IDE= and compiler toolchain. | Go [here](https://visuals= tudio.microsoft.com/downloads/)

Download and install Visual Studi= o 2019 Professional | +| 5 | echo tool | Echo = | See Workaround for echo c= ommand below. | + + +## Setting up the development tools + +Install the required development tools listed above by running the appropr= iate installer applications. + +### Arm cross compiler toolchain +The Arm toolchain Windows (i686-mingw32) hosted cross compilers are availa= ble [here](https://developer.arm.com/downloads/-/arm-gnu-toolchain-download= s). + +Select the latest toolchain for 'AArch64 bare-metal target (aarch64-none-e= lf)' GCC cross compiler. + +Example: Download arm-gnu-toolchain-12.2.rel1-mingw-w64-i686-aarch64-none-= elf + +Create a directory called 'toolchain' under the workspace directory and ex= tract the toolchain to this directory using the downloaded installer. + +The toolchain folder tree should look as below: + +``` +toolchain ++---arm-gnu-toolchain-12.2.rel1-mingw-w64-i686-aarch64-none-elf +| +---aarch64-none-elf +| +---bin +| +---include +| +---lib +| +---libexec +| +---share +``` + +### Workaround for the echo command + +EDKII needs a workaround related to the echo command. A script replacing t= he Windows echo executable must be created, with the name "echo.BAT?: + +- Create a file named "echo.BAT" in the folder of your choice. +- Paste the following lines inside the file: + +``` +rem %~f0 echo.BAT %* +rem This file exists to overcome a problem in the EDKII build where +rem build_rule.template invokes a command as: +rem "$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst} +rem When OBJCOPY is set to echo, this results in the following error: +rem "echo" objcopy not needed for m:\...\PCD\Dxe\Pcd\DEBUG\PcdDxe.dll +rem And CMD.EXE fails to find the DOS echo command because of the quotes +@echo %* +@goto :EOF +``` + +- Add the file to your PATH by executing: +``` +> set PATH=3D;%PATH% +``` + +## Building EDKII firmware + +1. To build the firmware image, follow the steps below and run the command= s in the terminal window. +2. Set up the environment variables. + +``` + set GCC5_AARCH64_PREFIX=3D%WORKSPACE%\toolchain\arm-gnu-toolchain-12.2.re= l1-mingw-w64-i686-aarch64-none-elf\bin\aarch64-none-elf- + set PACKAGES_PATH=3D%WORKSPACE%\edk2;%WORKSPACE%\edk2-platforms + set EDK_TOOLS_PATH=3D%WORKSPACE%\edk2\BaseTools + set GCC_HOST_BIN=3Dn +``` + +Select the python version you wish to use and set the PYTHON_COMMAND envir= onment variable to your Python executable. + +Set the PYTHON_COMMAND to point to the Python3 executable. + +Check that your path is set up as it is stated in the development tools ta= ble above. It should give access to: + +- The make executable +- The echo.BAT script + +3. Configure the EDKII development environment by running the edksetup.bat= script. +The Rebuild option can be skipped if the BaseTools have already been built. + +The ForceRebuild option can be used to do a clean build of the Base tools. +``` +> call %WORKSPACE%\edk2\edksetup.bat [Rebuild | ForceRebuild] +``` + +### Build the firmware for Arm FVP Base AEMv8A-AEMv8A Model platform + +Run the following command to build the firmware for FVP Base AEMv8A-AEMv8A= platform. + +``` +> build -a AARCH64 -t GCC5 -p Platform\ARM\VExpressPkg\ArmVExpress-FVP-AAr= ch64.dsc -b < DEBUG | RELEASE > +``` + +The firmware binaries can be found at the following location: +``` +%WORKSPACE%\Build\ArmVExpress-FVP-AArch64\_GCC5\FV\FVP_AARC= H64_EFI.fd +``` + +### Build the firmware for Arm Juno platform + +Run the following command to build the firmware for Arm Juno platform. + +``` +> build -a AARCH64 -t GCC5 -p Platform\ARM\JunoPkg\ArmJuno.dsc -b < DEBUG = | RELEASE > +``` +The firmware binaries are at the following location: + +``` +%WORKSPACE%\Build\ArmJuno\_GCC5\FV\BL33_AP_UEFI.fd +``` --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#100863): https://edk2.groups.io/g/devel/message/100863 Mute This Topic: https://groups.io/mt/97470584/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-