-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
examples: add new qemu x86 FSP examples
- Loading branch information
Showing
14 changed files
with
5,174 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
qemu-x86-fsp-linux/0002-add-W-no-warnings-to-compile-with-gcc-12.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
From d2c998df1e99d1bc5ee2a8ea81ed2c512def1458 Mon Sep 17 00:00:00 2001 | ||
From: Marco Oliverio <marco@wolfssl.com> | ||
Date: Mon, 12 Dec 2022 12:52:15 +0000 | ||
Subject: [PATCH v2] add -W-no warnings to compile with gcc 12 | ||
|
||
--- | ||
BaseTools/Source/C/Makefiles/header.makefile | 3 ++- | ||
1 file changed, 2 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/BaseTools/Source/C/Makefiles/header.makefile b/BaseTools/Source/C/Makefiles/header.makefile | ||
index 0df728f327..0c01c76f3a 100644 | ||
--- a/BaseTools/Source/C/Makefiles/header.makefile | ||
+++ b/BaseTools/Source/C/Makefiles/header.makefile | ||
@@ -94,7 +94,8 @@ else | ||
BUILD_CFLAGS = -MD -fshort-wchar -fno-strict-aliasing -fwrapv \ | ||
-fno-delete-null-pointer-checks -Wall -Werror \ | ||
-Wno-deprecated-declarations -Wno-stringop-truncation -Wno-restrict \ | ||
--Wno-unused-result -nostdlib -g | ||
+-Wno-unused-result -nostdlib -g -Wno-use-after-free -Wno-stringop-overflow \ | ||
+-Wno-dangling-pointer | ||
endif | ||
endif | ||
ifeq ($(CXX), llvm) | ||
-- | ||
2.38.1 | ||
|
50 changes: 50 additions & 0 deletions
50
qemu-x86-fsp-linux/0003-disable-optmizaion-patch-for-edk2.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
From 0b78b085c58d6fa335b6de61f277a26f14b29073 Mon Sep 17 00:00:00 2001 | ||
From: Marco Oliverio <marco@wolfssl.com> | ||
Date: Thu, 15 Dec 2022 17:15:16 +0000 | ||
Subject: [PATCH v2] disable optmizaion patch for edk2 | ||
|
||
--- | ||
IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf | 5 +++++ | ||
IntelFsp2Pkg/IntelFsp2Pkg.dsc | 3 +++ | ||
IntelFsp2Pkg/Library/BaseFspCommonLib/BaseFspCommonLib.inf | 4 ++++ | ||
3 files changed, 12 insertions(+) | ||
|
||
diff --git a/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf b/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf | ||
index 61b7ddca4c..c67a6fbb84 100644 | ||
--- a/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf | ||
+++ b/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf | ||
@@ -63,3 +63,8 @@ | ||
[Ppis] | ||
gEfiTemporaryRamSupportPpiGuid ## PRODUCES | ||
gFspInApiModePpiGuid ## PRODUCES | ||
+ | ||
+[BuildOptions] | ||
+ GCC:*_*_*_CC_FLAGS = -O0 | ||
+ INTEL:*_*_*_CC_FLAGS = /Od | ||
+ MSFT:*_*_*_CC_FLAGS = /Od | ||
diff --git a/IntelFsp2Pkg/IntelFsp2Pkg.dsc b/IntelFsp2Pkg/IntelFsp2Pkg.dsc | ||
index 309411630d..e486b6cf57 100644 | ||
--- a/IntelFsp2Pkg/IntelFsp2Pkg.dsc | ||
+++ b/IntelFsp2Pkg/IntelFsp2Pkg.dsc | ||
@@ -76,3 +76,6 @@ | ||
|
||
[BuildOptions] | ||
*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES | ||
+ GCC:*_*_*_CC_FLAGS = -O0 | ||
+ INTEL:*_*_*_CC_FLAGS = /Od | ||
+ MSFT:*_*_*_CC_FLAGS = /Od | ||
diff --git a/IntelFsp2Pkg/Library/BaseFspCommonLib/BaseFspCommonLib.inf b/IntelFsp2Pkg/Library/BaseFspCommonLib/BaseFspCommonLib.inf | ||
index 8badd924dc..c605cb25ec 100644 | ||
--- a/IntelFsp2Pkg/Library/BaseFspCommonLib/BaseFspCommonLib.inf | ||
+++ b/IntelFsp2Pkg/Library/BaseFspCommonLib/BaseFspCommonLib.inf | ||
@@ -28,3 +28,7 @@ | ||
[Pcd] | ||
gIntelFsp2PkgTokenSpaceGuid.PcdGlobalDataPointerAddress ## CONSUMES | ||
|
||
+[BuildOptions] | ||
+ GCC:*_*_*_CC_FLAGS = -O0 | ||
+ INTEL:*_*_*_CC_FLAGS = /Od | ||
+ MSFT:*_*_*_CC_FLAGS = /Od | ||
-- | ||
2.38.1 | ||
|
26 changes: 26 additions & 0 deletions
26
qemu-x86-fsp-linux/0004-fix-PatchFv-make-regex-match-both-8-and-16-length-ad.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
From 02a7cbecca40b68e0bca684e70f3a1b6ddb8c192 Mon Sep 17 00:00:00 2001 | ||
From: Marco Oliverio <marco@wolfssl.com> | ||
Date: Thu, 26 Jan 2023 10:20:57 +0000 | ||
Subject: [PATCH] fix: PatchFv: make regex match both 8 and 16 length address | ||
on Linux | ||
|
||
--- | ||
IntelFsp2Pkg/Tools/PatchFv.py | 2 +- | ||
1 file changed, 1 insertion(+), 1 deletion(-) | ||
|
||
diff --git a/IntelFsp2Pkg/Tools/PatchFv.py b/IntelFsp2Pkg/Tools/PatchFv.py | ||
index fe6d29426e..74ef586120 100644 | ||
--- a/IntelFsp2Pkg/Tools/PatchFv.py | ||
+++ b/IntelFsp2Pkg/Tools/PatchFv.py | ||
@@ -419,7 +419,7 @@ class Symbols: | ||
if reportLine.strip().find("Archive member included") != -1: | ||
#GCC | ||
# 0x0000000000001d55 IoRead8 | ||
- patchMapFileMatchString = "\s+(0x[0-9a-fA-F]{16})\s+([^\s][^0x][_a-zA-Z0-9\-]+)\s" | ||
+ patchMapFileMatchString = "\s+(0x[0-9a-fA-F]{8,16})\s+([^\s][^0x][_a-zA-Z0-9\-]+)\s" | ||
matchKeyGroupIndex = 2 | ||
matchSymbolGroupIndex = 1 | ||
prefix = '_' | ||
-- | ||
2.39.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
./build_qemu_fsp.sh | ||
(cd linux-image && ./compile_linux.sh) | ||
cp wolfboot-config ../wolfBoot/.config | ||
cp fsp_m.bin fsp_s.bin fsp_t.bin ../wolfBoot/src/x86/fsp/machines/qemu/ | ||
cp linux-image/app.bin ../wolfBoot/ | ||
(cd ../wolfBoot && git submodule init) | ||
(cd ../wolfBoot && git submodule update) | ||
(cd ../wolfBoot && make keytools) | ||
(cd ../wolfBoot && make x86_qemu_flash.bin) | ||
qemu-system-x86_64 -m 256M -machine q35 -serial mon:stdio -nographic -pflash ../wolfBoot/x86_qemu_flash.bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/bin/bash | ||
|
||
WORK_DIR=/tmp/qemu_fsp/ | ||
EDKII_TAG=edk2-stable202011 | ||
EDKII_REPO=https://github.com/tianocore/edk2.git | ||
SBL_COMMIT_ID=c80d8d592cf127616daca5df03ac7731e78ffcc1 | ||
SBL_PATCH_URL=https://github.com/slimbootloader/slimbootloader/raw/${SBL_COMMIT_ID}/Silicon/QemuSocPkg/FspBin/Patches/0001-Build-QEMU-FSP-2.0-binaries.patch | ||
SCRIPT_DIR=$(readlink -f "$(dirname "$0")") | ||
FSP_NAME=QEMU_FSP_DEBUG | ||
CONFIG_FILE=${CONFIG_FILE:-"${SCRIPT_DIR}/wolfboot-config"} | ||
|
||
set -e | ||
|
||
if [ ! -d "$WORK_DIR" ]; then | ||
mkdir -p "$WORK_DIR" | ||
fi | ||
|
||
if [ -f "${CONFIG_FILE}" ] | ||
then | ||
FSP_T_BASE=$(grep -Eo '^FSP_T_BASE=.*' ${CONFIG_FILE} | cut -d "=" -f 2) | ||
FSP_M_BASE=$(grep -Eo '^FSP_M_BASE=.*' ${CONFIG_FILE} | cut -d "=" -f 2) | ||
FSP_S_BASE=$(grep -Eo '^FSP_S_BASE=.*' ${CONFIG_FILE} | cut -d "=" -f 2) | ||
else | ||
echo "Error: ${CONFIG_FILE} file not found in current directory" | ||
exit | ||
fi | ||
|
||
download_edkii() { | ||
(cd "$WORK_DIR" && | ||
git clone "${EDKII_REPO}" edk2 && | ||
cd edk2 && | ||
git checkout "${EDKII_TAG}") | ||
} | ||
|
||
download_sbl_patch_and_patch_edkii() { | ||
(cd "$WORK_DIR/edk2" && | ||
curl -L -o 0001-Build-QEMU-FSP-2.0-binaries.patch ${SBL_PATCH_URL}; | ||
git am --keep-cr --whitespace=nowarn 0001-Build-QEMU-FSP-2.0-binaries.patch) | ||
(cd "$WORK_DIR/edk2" && | ||
git am --keep-cr --whitespace=nowarn "${SCRIPT_DIR}"/*.patch; | ||
mkdir -p MdeModulePkg/Library/BrotliCustomDecompressLib/brotli/c/include/) | ||
} | ||
|
||
build_qemu_fsp() { | ||
(cd "$WORK_DIR/edk2" && | ||
python ./BuildFsp.py && | ||
cd BuildFsp && | ||
python ../IntelFsp2Pkg/Tools/SplitFspBin.py split -f QEMU_FSP_DEBUG.fd) | ||
} | ||
|
||
rebase_fsp_component() { | ||
component=$1 | ||
new_base=$2 | ||
if [ -n "${new_base}" ] | ||
then | ||
(cd "${WORK_DIR}/edk2/BuildFsp" && | ||
python ../IntelFsp2Pkg/Tools/SplitFspBin.py rebase -f "${FSP_NAME}_${component^^}.fd" -b ${new_base} -c ${component,,}) | ||
fi | ||
} | ||
|
||
copy_fsp_component() { | ||
component=$1 | ||
base=$2 | ||
|
||
if [ -n "${base}" ] | ||
then | ||
base_no_prefix=${base#0x} | ||
suffix=${component^^}_${base_no_prefix^^} | ||
else | ||
suffix=${component^^} | ||
fi | ||
|
||
cp "${WORK_DIR}/edk2/BuildFsp/${FSP_NAME}_${suffix}.fd" "fsp_${component,,}.bin" | ||
} | ||
|
||
download_edkii | ||
download_sbl_patch_and_patch_edkii | ||
build_qemu_fsp | ||
rebase_fsp_component "T" ${FSP_T_BASE} | ||
rebase_fsp_component "M" ${FSP_M_BASE} | ||
rebase_fsp_component "S" ${FSP_S_BASE} | ||
copy_fsp_component "T" ${FSP_T_BASE} | ||
copy_fsp_component "M" ${FSP_M_BASE} | ||
copy_fsp_component "S" ${FSP_S_BASE} |
Empty file.
14 changes: 14 additions & 0 deletions
14
qemu-x86-fsp-linux/linux-image/br_ext_dir/configs/tiny_defconfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
BR2_x86_64=y | ||
BR2_x86_corei7=y | ||
# BR2_STRIP_strip is not set | ||
# BR2_COMPILER_PARANOID_UNSAFE_PATH is not set | ||
BR2_TOOLCHAIN_EXTERNAL=y | ||
# BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW is not set | ||
# BR2_ENABLE_LOCALE_PURGE is not set | ||
BR2_LINUX_KERNEL=y | ||
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y | ||
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_TINY_PATH)/linux.config" | ||
# BR2_PACKAGE_IFUPDOWN_SCRIPTS is not set | ||
# BR2_PACKAGE_URANDOM_SCRIPTS is not set | ||
BR2_TARGET_ROOTFS_INITRAMFS=y | ||
# BR2_TARGET_ROOTFS_TAR is not set |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
name: TINY | ||
desc: configuration for building a tiny kernel+initramfs image |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
CONFIG_BLK_DEV_INITRD=y | ||
CONFIG_INITRAMFS_SOURCE="${BR_BINARIES_DIR}/rootfs.cpio" | ||
CONFIG_EXPERT=y | ||
CONFIG_CMDLINE_BOOL=y | ||
CONFIG_CMDLINE="console=ttyS0" | ||
# CONFIG_EFI_CUSTOM_SSDT_OVERLAYS is not set | ||
# CONFIG_GCC_PLUGINS is not set | ||
# CONFIG_BLOCK is not set | ||
CONFIG_PCI=y | ||
CONFIG_PCIEPORTBUS=y | ||
CONFIG_DEVTMPFS=y | ||
CONFIG_DEVTMPFS_MOUNT=y | ||
CONFIG_SERIAL_8250=y | ||
CONFIG_SERIAL_8250_CONSOLE=y | ||
CONFIG_TTY_PRINTK=y | ||
CONFIG_TCG_TPM=y | ||
CONFIG_TCG_TIS=y | ||
CONFIG_TCG_TIS_SPI=y | ||
CONFIG_TCG_TIS_SPI_CR50=y | ||
CONFIG_TCG_NSC=y | ||
CONFIG_TCG_ATMEL=y | ||
CONFIG_TCG_INFINEON=y | ||
CONFIG_TCG_CRB=y | ||
CONFIG_TCG_VTPM_PROXY=y | ||
CONFIG_TCG_TIS_ST33ZP24_SPI=y | ||
CONFIG_SPI=y | ||
# CONFIG_SECURITYFS is not set | ||
CONFIG_CRYPTO_SHA1=y | ||
CONFIG_UNWINDER_GUESS=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/sh | ||
|
||
WORK_DIR=/tmp/br-linux-wolfboot | ||
BR_VER=2022.08.3 | ||
BR_DIR=buildroot-$BR_VER | ||
IMAGE_DIR=$WORK_DIR/output | ||
|
||
if (test ! -d $WORK_DIR);then | ||
mkdir -p $WORK_DIR | ||
fi | ||
|
||
if (test ! -d $WORK_DIR/$BR_DIR);then | ||
curl https://buildroot.org/downloads/$BR_DIR.tar.gz -o $WORK_DIR/$BR_DIR.tar.gz | ||
tar xvf $WORK_DIR/$BR_DIR.tar.gz -C $WORK_DIR | ||
fi | ||
|
||
BR2_EXTERNAL=$(pwd)/br_ext_dir make -C $WORK_DIR/$BR_DIR tiny_defconfig O=$IMAGE_DIR | ||
make -C $WORK_DIR/$BR_DIR O=$IMAGE_DIR | ||
cp $IMAGE_DIR/images/bzImage ./app.bin | ||
|
Oops, something went wrong.