From 58a83bec1ee645e822393841ad656d551c290b72 Mon Sep 17 00:00:00 2001 From: Dimitrije Pavlov Date: Wed, 22 Jun 2022 08:14:13 -0500 Subject: [PATCH 01/12] SBSA-QEMU: Fix amount of RAM in README --- SBSA-QEMU/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SBSA-QEMU/README.md b/SBSA-QEMU/README.md index 0854a5a..4d39400 100644 --- a/SBSA-QEMU/README.md +++ b/SBSA-QEMU/README.md @@ -40,7 +40,7 @@ x86_64: AArch64: - - 251 GB of RAM + - 256 GB of RAM - 224 threads - Fedora Linux 36 (Server Edition) - GCC 12.1.1 (Red Hat) -- GitLab From f60edf3ede8105c3bb91a94c9243c220feeacc42 Mon Sep 17 00:00:00 2001 From: Dimitrije Pavlov Date: Wed, 22 Jun 2022 08:19:33 -0500 Subject: [PATCH 02/12] SBSA-QEMU: Export path to Go in `ImageBuildscript.sh` The current `InstallGo` exports the path to Go by writing it to `~/.bash_profile` and then sourcing. However, not all Linux distributions have a `~/.bash_profile`. Instead, just export to `PATH` in `ImageBuildscript.sh`. --- SBSA-QEMU/Code/scripts/ImageBuildscript.sh | 2 ++ SBSA-QEMU/Code/scripts/InstallGo.sh | 5 ----- SBSA-QEMU/README.md | 6 +----- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/SBSA-QEMU/Code/scripts/ImageBuildscript.sh b/SBSA-QEMU/Code/scripts/ImageBuildscript.sh index 103cb42..2d06105 100755 --- a/SBSA-QEMU/Code/scripts/ImageBuildscript.sh +++ b/SBSA-QEMU/Code/scripts/ImageBuildscript.sh @@ -34,6 +34,8 @@ # ramdisk is stored. export WORKSPACE=$PWD +export PATH=/usr/local/go/bin/:$PATH + if ! command -v go >/dev/null 2>&1; then echo "$0: You need to install Go 1.17" echo "$0: Visit https://go.dev/dl/" diff --git a/SBSA-QEMU/Code/scripts/InstallGo.sh b/SBSA-QEMU/Code/scripts/InstallGo.sh index 400d73c..817de0a 100755 --- a/SBSA-QEMU/Code/scripts/InstallGo.sh +++ b/SBSA-QEMU/Code/scripts/InstallGo.sh @@ -48,8 +48,3 @@ wget https://go.dev/dl/$archive echo "$0: Installing Go 1.17" sudo tar -C /usr/local/ -xzf $archive rm -f $archive - -# Add to PATH -sed -i '\|export PATH=$PATH:/usr/local/go/bin/|d' ~/.bash_profile -echo 'export PATH=$PATH:/usr/local/go/bin/' >> ~/.bash_profile -source ~/.bash_profile diff --git a/SBSA-QEMU/README.md b/SBSA-QEMU/README.md index 4d39400..37d44c5 100644 --- a/SBSA-QEMU/README.md +++ b/SBSA-QEMU/README.md @@ -91,11 +91,7 @@ Then, download Go 1.17 and extract it to `/usr/local/go/`: $ wget https://go.dev/dl/go1.17.linux-arm64.tar.gz $ sudo tar -C /usr/local/ -xzf go1.17.linux-arm64.tar.gz ``` -Add Go to `PATH` by adding the following line to `~/.bash_profile`: -``` -$ export PATH=$PATH:/usr/local/go/bin/ -``` -and then running `source ~/.bash_profile`. +If you choose to install Go in a location other than `/usr/local/go/`, you will have to modify [`ImageBuildscript.sh`](Code/scripts/ImageBuildscript.sh) by changing the line `export PATH=/usr/local/go/bin/:$PATH` to `export PATH=/bin/:$PATH`. -- GitLab From 3f8249080acbde35956b74c513dc94d0627e56b8 Mon Sep 17 00:00:00 2001 From: Dimitrije Pavlov Date: Wed, 22 Jun 2022 08:43:34 -0500 Subject: [PATCH 03/12] SBSA-QEMU: Update instructions for installing QEMU The current instructions don't list the packages necessary for compiling QEMU from source. Add them to README. In addition, the current README does not mention the possibility of installing QEMU in a custom location. Add this explanation to README. --- SBSA-QEMU/Code/scripts/Run.sh | 9 ++++++++- SBSA-QEMU/README.md | 26 ++++++++++++++++++++------ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/SBSA-QEMU/Code/scripts/Run.sh b/SBSA-QEMU/Code/scripts/Run.sh index 9fffc44..38a08ab 100755 --- a/SBSA-QEMU/Code/scripts/Run.sh +++ b/SBSA-QEMU/Code/scripts/Run.sh @@ -28,6 +28,8 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. +export INSTALL_PATH=/usr/local + # Optionally, if an argument is given, run that image. if [[ $# -gt 0 ]]; then if [[ ! -f "$1" ]]; then @@ -57,4 +59,9 @@ else fi # `set -x` will explicitly print the command that we run -(set -x; qemu-system-aarch64 -m 1024 -M sbsa-ref -pflash SBSA_FLASH0.fd -pflash SBSA_FLASH1.fd -nographic $HDA) +(set -x; $INSTALL_PATH/bin/qemu-system-aarch64 \ + -m 1024 \ + -M sbsa-ref \ + -pflash SBSA_FLASH0.fd \ + -pflash SBSA_FLASH1.fd \ + -nographic $HDA) diff --git a/SBSA-QEMU/README.md b/SBSA-QEMU/README.md index 37d44c5..b0aaf42 100644 --- a/SBSA-QEMU/README.md +++ b/SBSA-QEMU/README.md @@ -103,7 +103,7 @@ Using a different version of Go is likely to produce problems. See [`u-root`](ht To use the sbsa-ref QEMU machine you need QEMU version 4.1.0 or above. To identify what version you have, run: ``` -$ qemu-system-aarch64 --version +$ /bin/qemu-system-aarch64 --version ``` The output should be this or similar: ``` @@ -111,27 +111,41 @@ QEMU emulator version 6.1.50 (v6.1.0-2172-gc88da1f3da) Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers ``` -If you don't have QEMU installed or don't have the right version, we provide a script to build it from source, [`InstallQemu.sh`](Code/scripts/InstallQemu.sh). You can skip this part if you do have an appropriate version of QEMU installed. +If you don't have QEMU installed or don't have the right version, we provide a script to build it from source, [`InstallQemu.sh`](Code/scripts/InstallQemu.sh). You can skip this part if you do have an appropriate version of QEMU installed. Before running the script, you need to install the following packages: + + - git + - make + - build-essential + - libglib2.0-dev + - libfdt-dev + - libpixman-1-dev + - zlib1g-dev + - ninja-build + +Then, you can just navigate to `Code/scripts/` and run +``` +./InstallQemu.sh +```
Click here for manual steps to install QEMU If you wish not to use `InstallQemu.sh` or want to understand how it works, here is a breakdown of the script. -Set `INSTALL_PATH` to `/usr/local` or `$HOME/local` or your preferrred location. +Set `INSTALL_PATH` to `/usr/local` or `$HOME/local` or your preferred location. ``` $ export INSTALL_PATH=/usr/local ``` Run the following to clone and install QEMU at your `INSTALL_PATH`: ``` -$ git clone git@github.com:qemu/qemu.git +$ git clone https://github.com/qemu/qemu $ cd qemu qemu$ mkdir build-native qemu$ cd build-native build-native$ ../configure --target-list=aarch64-softmmu --prefix=$INSTALL_PATH -$ make install +build-native$ make install ``` -Make sure to add the install location to `PATH` if it isn't there already. +If you choose to install QEMU in a location other than `/usr/local/`, you will have to modify [`Run.sh`](Code/scripts/Run.sh) by changing the line `export INSTALL_PATH=/usr/local` to `export INSTALL_PATH=`.
-- GitLab From 7ac74dbcfecda387d563cd5129fd33a1a5b28c8b Mon Sep 17 00:00:00 2001 From: Dimitrije Pavlov Date: Wed, 22 Jun 2022 09:04:13 -0500 Subject: [PATCH 04/12] SBSA-QEMU: Add instructions for custom patch locations --- SBSA-QEMU/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SBSA-QEMU/README.md b/SBSA-QEMU/README.md index b0aaf42..c5baffa 100644 --- a/SBSA-QEMU/README.md +++ b/SBSA-QEMU/README.md @@ -287,6 +287,8 @@ The script will prompt you to choose which method of incorporating LinuxBoot int $ ./Edk2Buildscript.sh 2 ``` +The script assumes that you cloned the repository from `https://gitlab.arm.com/systemready/linuxboot-resources/-/tree/master`. If this is not the case (e.g. you downloaded the files manually), the necessary patches might be in different locations. In that case, you should edit the lines `export PATCH="../../../uefishell.patch"` and `export PATCH="../../../bootmgrlib.patch"` to `export PATCH="/uefishell.patch"` and `export PATCH="/bootmgrlib.patch"`, respectively. +
Click here for an alternative way of incorporating LinuxBoot into EDK II -- GitLab From 39c2fce93bda64bc8cda6aca84135a9f90a7e8ff Mon Sep 17 00:00:00 2001 From: Dimitrije Pavlov Date: Wed, 22 Jun 2022 09:06:13 -0500 Subject: [PATCH 05/12] SBSA-QEMU: Explicitly specify raw format for firmware The current version of `Run.sh` does not explicitly state the format for `SBSA_FLASH0.fd` and `SBSA_FLASH1.fd`, which leads to a warning when QEMU starts. Add explicit statement of raw format to silence the warning. --- SBSA-QEMU/Code/scripts/Run.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SBSA-QEMU/Code/scripts/Run.sh b/SBSA-QEMU/Code/scripts/Run.sh index 38a08ab..c57bf8c 100755 --- a/SBSA-QEMU/Code/scripts/Run.sh +++ b/SBSA-QEMU/Code/scripts/Run.sh @@ -62,6 +62,6 @@ fi (set -x; $INSTALL_PATH/bin/qemu-system-aarch64 \ -m 1024 \ -M sbsa-ref \ - -pflash SBSA_FLASH0.fd \ - -pflash SBSA_FLASH1.fd \ + -drive file=SBSA_FLASH0.fd,format=raw,if=pflash \ + -drive file=SBSA_FLASH1.fd,format=raw,if=pflash \ -nographic $HDA) -- GitLab From 72f99463681a77363d0a2db988a759630dcd636f Mon Sep 17 00:00:00 2001 From: Dimitrije Pavlov Date: Wed, 22 Jun 2022 09:09:56 -0500 Subject: [PATCH 06/12] SBSA-QEMU: Update copyright year for new files --- SBSA-QEMU/Code/scripts/InstallGo.sh | 2 +- SBSA-QEMU/Code/scripts/InstallQemu.sh | 2 +- SBSA-QEMU/Code/scripts/Run.sh | 2 +- SBSA-QEMU/README.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SBSA-QEMU/Code/scripts/InstallGo.sh b/SBSA-QEMU/Code/scripts/InstallGo.sh index 817de0a..d1f9d07 100755 --- a/SBSA-QEMU/Code/scripts/InstallGo.sh +++ b/SBSA-QEMU/Code/scripts/InstallGo.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) 2021, ARM Limited and Contributors. All rights reserved. +# Copyright (c) 2022, ARM Limited and Contributors. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/SBSA-QEMU/Code/scripts/InstallQemu.sh b/SBSA-QEMU/Code/scripts/InstallQemu.sh index 6f17ba7..04feb4a 100755 --- a/SBSA-QEMU/Code/scripts/InstallQemu.sh +++ b/SBSA-QEMU/Code/scripts/InstallQemu.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) 2021, ARM Limited and Contributors. All rights reserved. +# Copyright (c) 2022, ARM Limited and Contributors. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/SBSA-QEMU/Code/scripts/Run.sh b/SBSA-QEMU/Code/scripts/Run.sh index c57bf8c..3559774 100755 --- a/SBSA-QEMU/Code/scripts/Run.sh +++ b/SBSA-QEMU/Code/scripts/Run.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) 2021, ARM Limited and Contributors. All rights reserved. +# Copyright (c) 2022, ARM Limited and Contributors. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/SBSA-QEMU/README.md b/SBSA-QEMU/README.md index c5baffa..26c909b 100644 --- a/SBSA-QEMU/README.md +++ b/SBSA-QEMU/README.md @@ -287,7 +287,7 @@ The script will prompt you to choose which method of incorporating LinuxBoot int $ ./Edk2Buildscript.sh 2 ``` -The script assumes that you cloned the repository from `https://gitlab.arm.com/systemready/linuxboot-resources/-/tree/master`. If this is not the case (e.g. you downloaded the files manually), the necessary patches might be in different locations. In that case, you should edit the lines `export PATCH="../../../uefishell.patch"` and `export PATCH="../../../bootmgrlib.patch"` to `export PATCH="/uefishell.patch"` and `export PATCH="/bootmgrlib.patch"`, respectively. +The script assumes that you cloned the repository from `https://gitlab.arm.com/systemready/linuxboot-resources`. If this is not the case (e.g. you downloaded the files manually), the necessary patches might be in different locations. In that case, you should edit the lines `export PATCH="../../../uefishell.patch"` and `export PATCH="../../../bootmgrlib.patch"` to `export PATCH="/uefishell.patch"` and `export PATCH="/bootmgrlib.patch"`, respectively.
Click here for an alternative way of incorporating LinuxBoot into EDK II -- GitLab From 6c632aa4a067f39ce37e89771103a72dcbbc2acb Mon Sep 17 00:00:00 2001 From: Paul Zhang Date: Wed, 21 Jun 2023 14:57:48 -0500 Subject: [PATCH 07/12] SBSA-QEMU: Add GOPATH/bin to PATH when building initramfs --- SBSA-QEMU/Code/scripts/ImageBuildscript.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SBSA-QEMU/Code/scripts/ImageBuildscript.sh b/SBSA-QEMU/Code/scripts/ImageBuildscript.sh index 2d06105..70e534f 100755 --- a/SBSA-QEMU/Code/scripts/ImageBuildscript.sh +++ b/SBSA-QEMU/Code/scripts/ImageBuildscript.sh @@ -58,7 +58,7 @@ fi # Install u-root echo "$0: Installing u-root" GO111MODULE=off go get github.com/u-root/u-root -export PATH=$PATH:$HOME/go/bin +export PATH=$PATH:$(go env GOPATH)/bin #Generate initramfs and copy to workspace echo "$0: Building initramfs" -- GitLab From db17f7988dd5c554c50f2568fc2479a869361d9c Mon Sep 17 00:00:00 2001 From: Paul Zhang Date: Wed, 21 Jun 2023 16:21:40 -0500 Subject: [PATCH 08/12] SBSA-QEMU: Document workaround for QEMU VGA romfile error --- SBSA-QEMU/Code/scripts/Run.sh | 1 + SBSA-QEMU/README.md | 2 ++ 2 files changed, 3 insertions(+) diff --git a/SBSA-QEMU/Code/scripts/Run.sh b/SBSA-QEMU/Code/scripts/Run.sh index 3559774..ac3cc2e 100755 --- a/SBSA-QEMU/Code/scripts/Run.sh +++ b/SBSA-QEMU/Code/scripts/Run.sh @@ -28,6 +28,7 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. +# Change based on location of QEMU installation export INSTALL_PATH=/usr/local # Optionally, if an argument is given, run that image. diff --git a/SBSA-QEMU/README.md b/SBSA-QEMU/README.md index 26c909b..f3078d4 100644 --- a/SBSA-QEMU/README.md +++ b/SBSA-QEMU/README.md @@ -386,6 +386,8 @@ For instance, you can Boot the Linux portion of the Architecture Compliance Suit $ ./Run.sh es_acs_live_image.img ``` +**Workaround:** If you get the error `qemu-system-aarch64: failed to find romfile "vgabios-stdvga.bin"`, download [vgabios-stdvga.bin](https://gitlab.com/qemu-project/qemu/-/blob/master/pc-bios/vgabios-stdvga.bin) into the current directory and try again. +
Click here for manual steps to run QEMU -- GitLab From 6ee61220093be2d99560a399c5b0f2f873d080ac Mon Sep 17 00:00:00 2001 From: Paul Zhang Date: Wed, 21 Jun 2023 16:22:30 -0500 Subject: [PATCH 09/12] SBSA-QEMU: Ignore build artifacts in Code/scripts --- SBSA-QEMU/Code/scripts/.gitignore | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 SBSA-QEMU/Code/scripts/.gitignore diff --git a/SBSA-QEMU/Code/scripts/.gitignore b/SBSA-QEMU/Code/scripts/.gitignore new file mode 100644 index 0000000..bcbfa4c --- /dev/null +++ b/SBSA-QEMU/Code/scripts/.gitignore @@ -0,0 +1,11 @@ +# From building initramfs +linux +u-root.initramfs.linux_arm64.cpio + +# From building EDK II +sbsa-linuxboot +SBSA_FLASH0.fd +SBSA_FLASH1.fd + +# From running QEMU to boot an Architecture Compliance Suite (ACS) image +es_acs_live_image.img -- GitLab From 0857d72689782a8862c7d26698b17f8672909250 Mon Sep 17 00:00:00 2001 From: Paul Zhang Date: Thu, 22 Jun 2023 17:26:41 -0500 Subject: [PATCH 10/12] SBSA-QEMU: Update docs on installing Go and QEMU Replace manual install scripts for Go and QEMU with the standard installation methods. This is easier to maintain, e.g. u-root changed its minimum supported version of Go but InstallGo.sh was not updated. --- SBSA-QEMU/Code/scripts/InstallGo.sh | 50 -------------- SBSA-QEMU/Code/scripts/InstallQemu.sh | 37 ---------- SBSA-QEMU/Code/scripts/Run.sh | 17 +++-- SBSA-QEMU/README.md | 97 ++++++--------------------- 4 files changed, 33 insertions(+), 168 deletions(-) delete mode 100755 SBSA-QEMU/Code/scripts/InstallGo.sh delete mode 100755 SBSA-QEMU/Code/scripts/InstallQemu.sh diff --git a/SBSA-QEMU/Code/scripts/InstallGo.sh b/SBSA-QEMU/Code/scripts/InstallGo.sh deleted file mode 100755 index d1f9d07..0000000 --- a/SBSA-QEMU/Code/scripts/InstallGo.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2022, ARM Limited and Contributors. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# Neither the name of ARM nor the names of its contributors may be used -# to endorse or promote products derived from this software without specific -# prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - -# Remove old versions of Go -echo "$0: Uninstalling old versions of Go" -sudo rm -rf /usr/local/go/ - -# Download and untar -arch=$(uname -m) -if [[ "$arch" == "aarch64" ]]; then - archive=go1.17.linux-arm64.tar.gz -elif [[ "$arch" == "x86_64" ]]; then - archive=go1.17.linux-amd64.tar.gz -else - echo "$0: Unrecognized architecture" - exit 1 -fi - -echo "$0: Downloading Go 1.17" -wget https://go.dev/dl/$archive -echo "$0: Installing Go 1.17" -sudo tar -C /usr/local/ -xzf $archive -rm -f $archive diff --git a/SBSA-QEMU/Code/scripts/InstallQemu.sh b/SBSA-QEMU/Code/scripts/InstallQemu.sh deleted file mode 100755 index 04feb4a..0000000 --- a/SBSA-QEMU/Code/scripts/InstallQemu.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2022, ARM Limited and Contributors. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# Neither the name of ARM nor the names of its contributors may be used -# to endorse or promote products derived from this software without specific -# prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - -export INSTALL_PATH=/usr/local/ -git clone https://github.com/qemu/qemu -cd qemu -mkdir -p build-native -cd build-native -../configure --target-list=aarch64-softmmu --prefix=$INSTALL_PATH -sudo make install diff --git a/SBSA-QEMU/Code/scripts/Run.sh b/SBSA-QEMU/Code/scripts/Run.sh index ac3cc2e..d141d00 100755 --- a/SBSA-QEMU/Code/scripts/Run.sh +++ b/SBSA-QEMU/Code/scripts/Run.sh @@ -60,9 +60,14 @@ else fi # `set -x` will explicitly print the command that we run -(set -x; $INSTALL_PATH/bin/qemu-system-aarch64 \ - -m 1024 \ - -M sbsa-ref \ - -drive file=SBSA_FLASH0.fd,format=raw,if=pflash \ - -drive file=SBSA_FLASH1.fd,format=raw,if=pflash \ - -nographic $HDA) +# Add manual install location to PATH +( + PATH=$PATH:$INSTALL_PATH/bin/qemu-system-aarch64 + set -x + qemu-system-aarch64 \ + -m 1024 \ + -M sbsa-ref \ + -drive file=SBSA_FLASH0.fd,format=raw,if=pflash \ + -drive file=SBSA_FLASH1.fd,format=raw,if=pflash \ + -nographic $HDA +) diff --git a/SBSA-QEMU/README.md b/SBSA-QEMU/README.md index f3078d4..c0705fe 100644 --- a/SBSA-QEMU/README.md +++ b/SBSA-QEMU/README.md @@ -5,13 +5,12 @@ [[_TOC_]] - - +## Demo Videos + ![Demo: Replacing UEFI shell](DemoMedia/ReplaceUefiShell/LinuxbootOnSbsaqemuDemo.webm) ![Demo: Using Platform Boot Manager and `uinit`](DemoMedia/PlatformBootMgrDemo/automaticRun.webm) - ## 1 Background ### 1.1 What is this guide? @@ -29,16 +28,16 @@ Help to improve this guide! Any comments or questions contact Frances Conboy at These system details purely serve as an outline of the systems this build process was validated on, they are not requirements. -x86_64: +x86_64 (as of June 22, 2023): - 64 GB of RAM - 56 threads - - Ubuntu 18.04 LTS + - Ubuntu 22.04.2 LTS - gcc-linaro-6.2.1-2016.11-x86_64_aarch64-linux-gnu cross compiler - - Go 1.14 - - QEMU emulator version 6.1.50 (v6.1.0-1446-g4d1a525dfa) + - Go 1.19 + - QEMU emulator version 6.2.0 (Debian 1:6.2+dfsg-2ubuntu6.11) -AArch64: +AArch64 (as of May 20, 2022): - 256 GB of RAM - 224 threads @@ -75,80 +74,28 @@ You should be able to install all of these using your package manager, like `apt ### 3.2 Go -It is **highly** recommended that you use Go version 1.17. We provide a script for installing Go, [`InstallGo.sh`](Code/scripts/InstallGo.sh), that will uninstall all previous versions of Go on your system and download Go 1.17, and install it. - -
-Click here for manual steps to install Go - -If you wish not to use `InstallGo.sh` or want to understand how it works, here is a breakdown of the script. +Use a version of Go that is [recommended by u-root](https://github.com/u-root/u-root#usage). Follow the [official installation docs](https://go.dev/doc/install). -Remove the previous versions of Go by running -``` -$ sudo rm -rf /usr/local/go/ -``` -Then, download Go 1.17 and extract it to `/usr/local/go/`: -``` -$ wget https://go.dev/dl/go1.17.linux-arm64.tar.gz -$ sudo tar -C /usr/local/ -xzf go1.17.linux-arm64.tar.gz -``` -If you choose to install Go in a location other than `/usr/local/go/`, you will have to modify [`ImageBuildscript.sh`](Code/scripts/ImageBuildscript.sh) by changing the line `export PATH=/usr/local/go/bin/:$PATH` to `export PATH=/bin/:$PATH`. - -
- -**Caution:** If you wish to keep other versions of Go on your system, do not run [`InstallGo.sh`](Code/scripts/InstallGo.sh), as this script will uninstall everything before installing Go 1.17. Instead, see [here](https://go.dev/doc/manage-install) for having multiple versions of Go installed. If you choose to do this, you will have to modify the scripts so that `go` refers to `go1.17` instead of a different version. +### 3.3 QEMU -Using a different version of Go is likely to produce problems. See [`u-root`](https://github.com/u-root/u-root) for details. +**Warning:** To use the sbsa-ref QEMU machine you need QEMU version 4.1.0 or above. However, QEMU major version 8 hangs indefinitely when invoked with `./Run.sh`. QEMU major version 6 works. -### 3.3 QEMU +On distros with apt (might work for others), the best method is to install the following package: -To use the sbsa-ref QEMU machine you need QEMU version 4.1.0 or above. To identify what version you have, run: +```sh +- qemu-system ``` -$ /bin/qemu-system-aarch64 --version + +To identify what version you have, run: +```sh +$ qemu-system-aarch64 --version ``` The output should be this or similar: -``` +```sh QEMU emulator version 6.1.50 (v6.1.0-2172-gc88da1f3da) Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers ``` -If you don't have QEMU installed or don't have the right version, we provide a script to build it from source, [`InstallQemu.sh`](Code/scripts/InstallQemu.sh). You can skip this part if you do have an appropriate version of QEMU installed. Before running the script, you need to install the following packages: - - - git - - make - - build-essential - - libglib2.0-dev - - libfdt-dev - - libpixman-1-dev - - zlib1g-dev - - ninja-build - -Then, you can just navigate to `Code/scripts/` and run -``` -./InstallQemu.sh -``` - -
-Click here for manual steps to install QEMU - -If you wish not to use `InstallQemu.sh` or want to understand how it works, here is a breakdown of the script. - -Set `INSTALL_PATH` to `/usr/local` or `$HOME/local` or your preferred location. -``` -$ export INSTALL_PATH=/usr/local -``` -Run the following to clone and install QEMU at your `INSTALL_PATH`: -``` -$ git clone https://github.com/qemu/qemu -$ cd qemu -qemu$ mkdir build-native -qemu$ cd build-native -build-native$ ../configure --target-list=aarch64-softmmu --prefix=$INSTALL_PATH -build-native$ make install -``` -If you choose to install QEMU in a location other than `/usr/local/`, you will have to modify [`Run.sh`](Code/scripts/Run.sh) by changing the line `export INSTALL_PATH=/usr/local` to `export INSTALL_PATH=`. - -
- ### 3.4 Cross-compiler If you are building Linux and EDK II on a system that isn't AArch64-based then you will need a suitable cross-compiler. @@ -386,8 +333,6 @@ For instance, you can Boot the Linux portion of the Architecture Compliance Suit $ ./Run.sh es_acs_live_image.img ``` -**Workaround:** If you get the error `qemu-system-aarch64: failed to find romfile "vgabios-stdvga.bin"`, download [vgabios-stdvga.bin](https://gitlab.com/qemu-project/qemu/-/blob/master/pc-bios/vgabios-stdvga.bin) into the current directory and try again. -
Click here for manual steps to run QEMU @@ -499,6 +444,8 @@ linux: tag v5.18 ``` Our scripts reference these commits explicitly. If you want to try newer commits, you can replace tags and commit hashes in the scripts. +**Tip:** Check out the [demo videos](#demo-videos) to see if your manual patching works. +
Click here for manual steps to create patches @@ -508,12 +455,12 @@ To start, within your edk2-platforms repository you need to make a new package f ``` $ mkdir -p $WORKSPACE/edk2-platforms/Platform/Qemu/SbsaQemu/linuxboot -$ cd $WORKSAPCE/edk2-platforms/Platform/Qemu/SbsaQemu +$ cd $WORKSPACE/edk2-platforms/Platform/Qemu/SbsaQemu $ cp SbsaQemu.dsc ./linuxboot $ cp SbsaQemu.fdf ./linuxboot $ cd linuxboot $ mv SbsaQemu.dsc LbootSbsaQemu.dsc -$ mv mv SbsaQemu.fdf LbootSbsaQemu.fdf +$ mv SbsaQemu.fdf LbootSbsaQemu.fdf $ touch linuxboot.inf ``` -- GitLab From bdddcff84c658c0b3d8767cf9c63aa1ecc8c81cc Mon Sep 17 00:00:00 2001 From: Paul Zhang Date: Fri, 23 Jun 2023 11:58:10 -0500 Subject: [PATCH 11/12] SBSA-QEMU: Fix docs for manually building EDK II --- SBSA-QEMU/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SBSA-QEMU/README.md b/SBSA-QEMU/README.md index c0705fe..1e25631 100644 --- a/SBSA-QEMU/README.md +++ b/SBSA-QEMU/README.md @@ -311,10 +311,10 @@ You can omit the cross-compile prefix if running on AArch64. Here is a breakdown -t toolchain version, GCC5 is really GCC5+, in our case GCC 8.3 -p selects machine to compile EDK2 -The build command produces two files, `SBSA_FLASH0.fd` and `SBSA_FLASH1.fd`, as output. Copy these to the top `$WORKSPACE` directory and extend to match the machine flash file size. +The build command produces two files, `SBSA_FLASH0.fd` and `SBSA_FLASH1.fd`, as output. Copy these to the parent directory of `$WORKSPACE` (which would be the scripts directory) and extend to match the machine flash file size. ``` -$ cp Build/SbsaQemu/RELEASE_GCC5/FV/SBSA_FLASH[01].fd . -$ truncate -s 256M SBSA_FLASH[01].fd +$ cp Build/SbsaQemu/RELEASE_GCC5/FV/SBSA_FLASH[01].fd ../ +$ truncate -s 256M ../SBSA_FLASH[01].fd ```
-- GitLab From 6a8a87b92c23bcab07e83e1d12d3074481ea508e Mon Sep 17 00:00:00 2001 From: Paul Zhang Date: Fri, 23 Jun 2023 13:44:16 -0500 Subject: [PATCH 12/12] SBSA-QEMU: Fix section link in docs for BootMgrLib --- SBSA-QEMU/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SBSA-QEMU/README.md b/SBSA-QEMU/README.md index 1e25631..195aa1b 100644 --- a/SBSA-QEMU/README.md +++ b/SBSA-QEMU/README.md @@ -565,7 +565,7 @@ Add the section below to the "Pcd Section - list of all EDK II PCD Entries defin #### 7.2.2 `LbootSbsaQemu.fdf` -See section [6.1.2](#612-lbootsbsaqemufdf) for details. +See section [7.1.2](#712-lbootsbsaqemufdf) for details. #### 7.2.3 `linuxboot.inf` -- GitLab