Skip to content

Commit ba8c2f0

Browse files
m-iwanickiartur-rs
authored andcommitted
docs: secure-boot: add hello.efi compilation step
Signed-off-by: Michał Iwanicki <[email protected]>
1 parent fb9e298 commit ba8c2f0

File tree

2 files changed

+95
-14
lines changed

2 files changed

+95
-14
lines changed

docs/guides/secure-boot/generate-image.sh

+1-3
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,7 @@ if [ $# -ne 0 ]; then
309309
fi
310310

311311
SCRIPTDIR=$(readlink -f "$(dirname "$0")")
312-
HELLO_EFI="$(mktemp)"
313-
wget -O $HELLO_EFI \
314-
https://github.com/Dasharo/open-source-firmware-validation/raw/refs/heads/encrypted-rootfs-release-rebase/scripts/secure-boot/generate-images/hello.efi
312+
HELLO_EFI="$(realpath hello.efi)"
315313

316314
TEMPDIR=$(mktemp -d)
317315
trap "cleanup" EXIT

docs/guides/secure-boot/secure-boot-verification.md

+94-11
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,107 @@
1919
### USB drive
2020

2121
1. Download [generate-image.sh](./generate-image.sh)
22-
1. Build `LockDown.efi`. To do that install
23-
[needed prerequisites](https://docs.dasharo.com/dasharo-tools-suite/documentation/#prerequisites),
24-
checkout tag `v1.2.23` in `meta-dts`
25-
and then build `efitools` which will build `LockDown.efi` with sample keys
22+
1. Build [LockDown.efi](#lockdownefi) file
23+
1. Build [hello.efi](#helloefi) file
24+
1. Run `generate-image.sh` script. It'll generate `tests.img` file containing
25+
needed files and certificates
26+
1. Flash this file to USB drive
27+
28+
#### LockDown.efi
29+
30+
**Dependencies**
31+
32+
* [kas-container](https://docs.dasharo.com/dasharo-tools-suite/documentation/#prerequisites)
33+
* [git](https://git-scm.com/)
34+
35+
**Steps**
36+
37+
1. Clone and checkout tag `v1.2.23`
38+
39+
```shell
40+
git clone --depth 1 --branch v1.2.23 https://github.com/Dasharo/meta-dts.git
41+
```
42+
43+
1. Build `efitools` recipe which will build `LockDown.efi` with sample keys
2644

2745
```shell
2846
SHELL=/bin/bash kas-container shell meta-dts/kas-uefi-sb.yml -c "bitbake efitools"`
2947
```
3048

31-
1. Copy `LockDown.efi` to directory containing `generate-image.sh` script.
32-
It should be inside `build/tmp/deploy/images/genericx86_64`.
33-
Sample keys and certificates used in `LockDown.efi` are in
49+
1. Copy `LockDown.efi` to directory containing `generate-image.sh` script.</br>
50+
File should be inside `build/tmp/deploy/images/genericx86_64` directory.</br>
51+
Sample keys and certificates used in `LockDown.efi` can be viewed in
3452
`build/tmp/deploy/images/genericx86_64/sample-keys/uefi_sb_keys`
35-
1. Run `generate-image.sh` script. It'll generate `tests.img` file containing
36-
needed files and certificates
37-
1. Flash this file to USB drive
3853

39-
USB directory layout:
54+
#### hello.efi
55+
56+
**Dependencies**
57+
58+
* [Docker](https://docs.docker.com/engine/install/)
59+
* [git](https://git-scm.com/)
60+
61+
**Steps**
62+
63+
1. Pull docker image that'll contain tools needed to build `hello.efi`
64+
<https://github.com/tianocore/containers?tab=readme-ov-file#Current-Status>.
65+
66+
```shell
67+
docker pull ghcr.io/tianocore/containers/fedora-39-build:46802aa
68+
```
69+
70+
1. Get source code for EDK2
71+
72+
```shell
73+
git clone --depth 1 --recurse-submodules --shallow-submodules --branch edk2-stable202408 https://github.com/tianocore/edk2.git
74+
```
75+
76+
1. Add sleep (in this case 2 seconds) to `HelloWorld.c` otherwise output will
77+
disappear too fast for human to see
78+
79+
```shell
80+
cd edk2
81+
git apply <<EOF
82+
diff --git a/MdeModulePkg/Application/HelloWorld/HelloWorld.c b/MdeModulePkg/Application/HelloWorld/HelloWorld.c
83+
index 9b77046e561c..ebd4ad9d6a79 100644
84+
--- a/MdeModulePkg/Application/HelloWorld/HelloWorld.c
85+
+++ b/MdeModulePkg/Application/HelloWorld/HelloWorld.c
86+
@@ -56,5 +56,6 @@ UefiMain (
87+
}
88+
}
89+
90+
+ SystemTable->BootServices->Stall(2000000);
91+
return EFI_SUCCESS;
92+
}
93+
EOF
94+
```
95+
96+
1. Build `HelloWorld.efi`
97+
98+
```shell
99+
docker run -v $(pwd):/edk2 -w /edk2 --entrypoint bash --rm \
100+
ghcr.io/tianocore/containers/fedora-39-build:46802aa -c ' \
101+
source edksetup.sh && make -C BaseTools && build -a X64 -t GCC5 \
102+
-p MdeModulePkg/MdeModulePkg.dsc \
103+
-m MdeModulePkg/Application/HelloWorld/HelloWorld.inf -b RELEASE'
104+
```
105+
106+
Build should complete with
107+
108+
```text
109+
(...)
110+
- Done -
111+
Build end time: 12:51:06, Oct.04 2024
112+
Build total time: 00:00:06
113+
```
114+
115+
1. Copy built `HelloWorld.efi` file to directory with `generate-image.sh` and
116+
rename it to `hello.efi`
117+
118+
```shell
119+
cp Build/MdeModule/RELEASE_GCC5/X64/HelloWorld.efi <replace/this/path/>hello.efi
120+
```
121+
122+
#### USB directory layout
40123
41124
```text
42125
.

0 commit comments

Comments
 (0)