blob: f27cabbcce8af2a720393161c8bd134f298c4815 [file] [log] [blame]
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +02001.. SPDX-License-Identifier: GPL-2.0+
2.. Copyright (c) 2018 Heinrich Schuchardt
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +01003
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +02004UEFI on U-Boot
5==============
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +01006
7The Unified Extensible Firmware Interface Specification (UEFI) [1] has become
8the default for booting on AArch64 and x86 systems. It provides a stable API for
9the interaction of drivers and applications with the firmware. The API comprises
10access to block storage, network, and console to name a few. The Linux kernel
11and boot loaders like GRUB or the FreeBSD loader can be executed.
12
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +020013Development target
14------------------
Heinrich Schuchardta28d0732019-03-28 08:09:16 +010015
Heinrich Schuchardt9ec8f5e2019-04-10 08:04:38 +020016The implementation of UEFI in U-Boot strives to reach the requirements described
Vincent Stehléc53cec62022-12-16 17:55:04 +010017in the "Embedded Base Boot Requirements (EBBR) Specification - Release v2.1.0"
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +020018[2]. The "Server Base Boot Requirements System Software on ARM Platforms" [3]
Heinrich Schuchardt9ec8f5e2019-04-10 08:04:38 +020019describes a superset of the EBBR specification and may be used as further
20reference.
Heinrich Schuchardta28d0732019-03-28 08:09:16 +010021
22A full blown UEFI implementation would contradict the U-Boot design principle
23"keep it small".
24
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +020025Building U-Boot for UEFI
26------------------------
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +010027
Heinrich Schuchardt10288402018-12-30 12:54:36 +010028The UEFI standard supports only little-endian systems. The UEFI support can be
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +020029activated for ARM and x86 by specifying::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +010030
31 CONFIG_CMD_BOOTEFI=y
32 CONFIG_EFI_LOADER=y
33
34in the .config file.
35
36Support for attaching virtual block devices, e.g. iSCSI drives connected by the
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +020037loaded UEFI application [4], requires::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +010038
39 CONFIG_BLK=y
40 CONFIG_PARTITIONS=y
41
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +020042Executing a UEFI binary
43~~~~~~~~~~~~~~~~~~~~~~~
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +010044
45The bootefi command is used to start UEFI applications or to install UEFI
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +020046drivers. It takes two parameters::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +010047
48 bootefi <image address> [fdt address]
49
50* image address - the memory address of the UEFI binary
51* fdt address - the memory address of the flattened device tree
52
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +020053Below you find the output of an example session starting GRUB::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +010054
55 => load mmc 0:2 ${fdt_addr_r} boot/dtb
56 29830 bytes read in 14 ms (2 MiB/s)
57 => load mmc 0:1 ${kernel_addr_r} efi/debian/grubaa64.efi
58 reading efi/debian/grubaa64.efi
59 120832 bytes read in 7 ms (16.5 MiB/s)
60 => bootefi ${kernel_addr_r} ${fdt_addr_r}
61
Heinrich Schuchardt6b821592021-01-12 12:46:24 +010062When booting from a memory location it is unknown from which file it was loaded.
63Therefore the bootefi command uses the device path of the block device partition
64or the network adapter and the file name of the most recently loaded PE-COFF
65file when setting up the loaded image protocol.
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +010066
Cristian Ciocaltea62bb8902019-12-24 18:05:41 +020067Launching a UEFI binary from a FIT image
68~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
69
70A signed FIT image can be used to securely boot a UEFI image via the
71bootm command. This feature is available if U-Boot is configured with::
72
73 CONFIG_BOOTM_EFI=y
74
75A sample configuration is provided as file doc/uImage.FIT/uefi.its.
76
77Below you find the output of an example session starting GRUB::
78
79 => load mmc 0:1 ${kernel_addr_r} image.fit
80 4620426 bytes read in 83 ms (53.1 MiB/s)
81 => bootm ${kernel_addr_r}#config-grub-nofdt
82 ## Loading kernel from FIT Image at 40400000 ...
83 Using 'config-grub-nofdt' configuration
84 Verifying Hash Integrity ... sha256,rsa2048:dev+ OK
85 Trying 'efi-grub' kernel subimage
86 Description: GRUB EFI Firmware
87 Created: 2019-11-20 8:18:16 UTC
88 Type: Kernel Image (no loading done)
89 Compression: uncompressed
90 Data Start: 0x404000d0
91 Data Size: 450560 Bytes = 440 KiB
92 Hash algo: sha256
93 Hash value: 4dbee00021112df618f58b3f7cf5e1595533d543094064b9ce991e8b054a9eec
94 Verifying Hash Integrity ... sha256+ OK
95 XIP Kernel Image (no loading done)
96 ## Transferring control to EFI (at address 404000d0) ...
97 Welcome to GRUB!
98
99See doc/uImage.FIT/howto.txt for an introduction to FIT images.
100
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900101Configuring UEFI secure boot
102~~~~~~~~~~~~~~~~~~~~~~~~~~~~
103
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200104The UEFI specification[1] defines a secure way of executing UEFI images
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900105by verifying a signature (or message digest) of image with certificates.
106This feature on U-Boot is enabled with::
107
Jan Kiszka21913902022-03-16 12:12:16 +0100108 CONFIG_EFI_SECURE_BOOT=y
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900109
110To make the boot sequence safe, you need to establish a chain of trust;
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200111In UEFI secure boot the chain trust is defined by the following UEFI variables
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900112
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200113* PK - Platform Key
114* KEK - Key Exchange Keys
115* db - white list database
116* dbx - black list database
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900117
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200118An in depth description of UEFI secure boot is beyond the scope of this
119document. Please, refer to the UEFI specification and available online
120documentation. Here is a simple example that you can follow for your initial
121attempt (Please note that the actual steps will depend on your system and
122environment.):
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900123
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200124Install the required tools on your host
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900125
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200126* openssl
127* efitools
128* sbsigntool
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900129
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200130Create signing keys and the key database on your host:
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900131
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200132The platform key
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900133
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200134.. code-block:: bash
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900135
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200136 openssl req -x509 -sha256 -newkey rsa:2048 -subj /CN=TEST_PK/ \
137 -keyout PK.key -out PK.crt -nodes -days 365
138 cert-to-efi-sig-list -g 11111111-2222-3333-4444-123456789abc \
139 PK.crt PK.esl;
140 sign-efi-sig-list -c PK.crt -k PK.key PK PK.esl PK.auth
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900141
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200142The key exchange keys
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900143
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200144.. code-block:: bash
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900145
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200146 openssl req -x509 -sha256 -newkey rsa:2048 -subj /CN=TEST_KEK/ \
147 -keyout KEK.key -out KEK.crt -nodes -days 365
148 cert-to-efi-sig-list -g 11111111-2222-3333-4444-123456789abc \
149 KEK.crt KEK.esl
150 sign-efi-sig-list -c PK.crt -k PK.key KEK KEK.esl KEK.auth
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900151
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200152The whitelist database
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900153
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200154.. code-block:: bash
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900155
Heinrich Schuchardt200584c2020-12-12 09:15:12 +0100156 openssl req -x509 -sha256 -newkey rsa:2048 -subj /CN=TEST_db/ \
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200157 -keyout db.key -out db.crt -nodes -days 365
Heinrich Schuchardt200584c2020-12-12 09:15:12 +0100158 cert-to-efi-sig-list -g 11111111-2222-3333-4444-123456789abc \
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200159 db.crt db.esl
Heinrich Schuchardt200584c2020-12-12 09:15:12 +0100160 sign-efi-sig-list -c KEK.crt -k KEK.key db db.esl db.auth
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900161
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200162Copy the \*.auth files to media, say mmc, that is accessible from U-Boot.
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900163
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200164Sign an image with one of the keys in "db" on your host
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900165
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200166.. code-block:: bash
167
168 sbsign --key db.key --cert db.crt helloworld.efi
169
170Now in U-Boot install the keys on your board::
171
172 fatload mmc 0:1 <tmpaddr> PK.auth
Heinrich Schuchardtfa11c862020-08-24 08:27:49 +0200173 setenv -e -nv -bs -rt -at -i <tmpaddr>:$filesize PK
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200174 fatload mmc 0:1 <tmpaddr> KEK.auth
Heinrich Schuchardtfa11c862020-08-24 08:27:49 +0200175 setenv -e -nv -bs -rt -at -i <tmpaddr>:$filesize KEK
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200176 fatload mmc 0:1 <tmpaddr> db.auth
Heinrich Schuchardtfa11c862020-08-24 08:27:49 +0200177 setenv -e -nv -bs -rt -at -i <tmpaddr>:$filesize db
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200178
179Set up boot parameters on your board::
180
Ilias Apalodimas773c0902021-03-17 21:55:01 +0200181 efidebug boot add -b 1 HELLO mmc 0:1 /helloworld.efi.signed ""
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200182
Ilias Apalodimasc92aa4b2021-03-17 21:55:02 +0200183Since kernel 5.7 there's an alternative way of loading an initrd using
184LoadFile2 protocol if CONFIG_EFI_LOAD_FILE2_INITRD is enabled.
185The initrd path can be specified with::
186
187 efidebug boot add -b ABE0 'kernel' mmc 0:1 Image -i mmc 0:1 initrd
188
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200189Now your board can run the signed image via the boot manager (see below).
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900190You can also try this sequence by running Pytest, test_efi_secboot,
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200191on the sandbox
192
193.. code-block:: bash
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900194
Heinrich Schuchardt664ad182020-04-16 20:31:56 +0200195 cd <U-Boot source directory>
196 pytest.py test/py/tests/test_efi_secboot/test_signed.py --bd sandbox
AKASHI Takahiroe674d8d2020-04-14 11:51:54 +0900197
Heinrich Schuchardt87f43de2020-07-14 12:52:51 +0200198UEFI binaries may be signed by Microsoft using the following certificates:
199
200* KEK: Microsoft Corporation KEK CA 2011
201 http://go.microsoft.com/fwlink/?LinkId=321185.
202* db: Microsoft Windows Production PCA 2011
203 http://go.microsoft.com/fwlink/p/?linkid=321192.
204* db: Microsoft Corporation UEFI CA 2011
205 http://go.microsoft.com/fwlink/p/?linkid=321194.
206
Ilias Apalodimasef8bd412020-05-17 22:25:47 +0300207Using OP-TEE for EFI variables
208~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
209
210Instead of implementing UEFI variable services inside U-Boot they can
211also be provided in the secure world by a module for OP-TEE[1]. The
212interface between U-Boot and OP-TEE for variable services is enabled by
213CONFIG_EFI_MM_COMM_TEE=y.
214
215Tianocore EDK II's standalone management mode driver for variables can
216be linked to OP-TEE for this purpose. This module uses the Replay
217Protected Memory Block (RPMB) of an eMMC device for persisting
218non-volatile variables. When calling the variable services via the
219OP-TEE API U-Boot's OP-TEE supplicant relays calls to the RPMB driver
220which has to be enabled via CONFIG_SUPPORT_EMMC_RPMB=y.
221
Ilias Apalodimasa300e442021-04-01 13:35:38 +0300222EDK2 Build instructions
223***********************
224
225.. code-block:: bash
226
227 $ git clone https://github.com/tianocore/edk2.git
228 $ git clone https://github.com/tianocore/edk2-platforms.git
229 $ cd edk2
230 $ git submodule init && git submodule update --init --recursive
231 $ cd ..
232 $ export WORKSPACE=$(pwd)
233 $ export PACKAGES_PATH=$WORKSPACE/edk2:$WORKSPACE/edk2-platforms
234 $ export ACTIVE_PLATFORM="Platform/StandaloneMm/PlatformStandaloneMmPkg/PlatformStandaloneMmRpmb.dsc"
235 $ export GCC5_AARCH64_PREFIX=aarch64-linux-gnu-
236 $ source edk2/edksetup.sh
237 $ make -C edk2/BaseTools
238 $ build -p $ACTIVE_PLATFORM -b RELEASE -a AARCH64 -t GCC5 -n `nproc`
239
240OP-TEE Build instructions
241*************************
242
243.. code-block:: bash
244
245 $ git clone https://github.com/OP-TEE/optee_os.git
246 $ cd optee_os
247 $ ln -s ../Build/MmStandaloneRpmb/RELEASE_GCC5/FV/BL32_AP_MM.fd
248 $ export ARCH=arm
249 $ CROSS_COMPILE32=arm-linux-gnueabihf- make -j32 CFG_ARM64_core=y \
250 PLATFORM=<myboard> CFG_STMM_PATH=BL32_AP_MM.fd CFG_RPMB_FS=y \
Ilias Apalodimas63cc27a2021-12-27 10:08:15 +0200251 CFG_RPMB_FS_DEV_ID=0 CFG_CORE_HEAP_SIZE=524288 CFG_RPMB_WRITE_KEY=y \
252 CFG_CORE_DYN_SHM=y CFG_RPMB_TESTKEY=y CFG_REE_FS=n \
253 CFG_CORE_ARM64_PA_BITS=48 CFG_TEE_CORE_LOG_LEVEL=1 \
Ilias Apalodimasa300e442021-04-01 13:35:38 +0300254 CFG_TEE_TA_LOG_LEVEL=1 CFG_SCTLR_ALIGNMENT_CHECK=n
255
256U-Boot Build instructions
257*************************
258
259Although the StandAloneMM binary comes from EDK2, using and storing the
260variables is currently available in U-Boot only.
261
262.. code-block:: bash
263
264 $ git clone https://github.com/u-boot/u-boot.git
265 $ cd u-boot
266 $ export CROSS_COMPILE=aarch64-linux-gnu-
267 $ export ARCH=<arch>
268 $ make <myboard>_defconfig
269 $ make menuconfig
270
271Enable ``CONFIG_OPTEE``, ``CONFIG_CMD_OPTEE_RPMB`` and ``CONFIG_EFI_MM_COMM_TEE``
272
273.. warning::
274
275 - Your OP-TEE platform port must support Dynamic shared memory, since that's
276 the only kind of memory U-Boot supports for now.
277
278[1] https://optee.readthedocs.io/en/latest/building/efi_vars/stmm.html
Ilias Apalodimasef8bd412020-05-17 22:25:47 +0300279
Sughosh Ganub08b8572022-10-21 18:16:08 +0530280.. _uefi_capsule_update_ref:
281
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900282Enabling UEFI Capsule Update feature
283~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
284
285Support has been added for the UEFI capsule update feature which
286enables updating the U-Boot image using the UEFI firmware management
287protocol (FMP). The capsules are not passed to the firmware through
288the UpdateCapsule runtime service. Instead, capsule-on-disk
AKASHI Takahiroa7159db2022-02-09 19:10:37 +0900289functionality is used for fetching capsules from the EFI System
290Partition (ESP) by placing capsule files under the directory::
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900291
AKASHI Takahiroa7159db2022-02-09 19:10:37 +0900292 \EFI\UpdateCapsule
293
294The directory is checked for capsules only within the
295EFI system partition on the device specified in the active boot option,
296which is determined by BootXXXX variable in BootNext, or if not, the highest
297priority one within BootOrder. Any BootXXXX variables referring to devices
298not present are ignored when determining the active boot option.
299
300Please note that capsules will be applied in the alphabetic order of
301capsule file names.
302
303Creating a capsule file
304***********************
305
306A capsule file can be created by using tools/mkeficapsule.
307To build this tool, enable::
308
309 CONFIG_TOOLS_MKEFICAPSULE=y
310 CONFIG_TOOLS_LIBCRYPTO=y
311
312Run the following command
313
314.. code-block:: console
315
316 $ mkeficapsule \
Sughosh Ganu50ec4722022-04-15 11:29:41 +0530317 --index <index> --instance 0 \
318 --guid <image GUID> \
AKASHI Takahiroa7159db2022-02-09 19:10:37 +0900319 <capsule_file_name>
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900320
Sughosh Ganu80f68e62023-08-22 23:10:01 +0530321Capsule with firmware version
322*****************************
323
Masahisa Kojimad20d4c42023-06-07 14:41:57 +0900324The UEFI specification does not define the firmware versioning mechanism.
325EDK II reference implementation inserts the FMP Payload Header right before
326the payload. It coutains the fw_version and lowest supported version,
327EDK II reference implementation uses these information to implement the
328firmware versioning and anti-rollback protection, the firmware version and
329lowest supported version is stored into EFI non-volatile variable.
330
331In U-Boot, the firmware versioning is implemented utilizing
332the FMP Payload Header same as EDK II reference implementation,
333reads the FMP Payload Header and stores the firmware version into
334"FmpStateXXXX" EFI non-volatile variable. XXXX indicates the image index,
335since FMP protocol handles multiple image indexes.
336
337To add the fw_version into the FMP Payload Header,
338add --fw-version option in mkeficapsule tool.
339
340.. code-block:: console
341
342 $ mkeficapsule \
343 --index <index> --instance 0 \
344 --guid <image GUID> \
345 --fw-version 5 \
346 <capsule_file_name>
347
348If the --fw-version option is not set, FMP Payload Header is not inserted
349and fw_version is set as 0.
350
Sughosh Ganu80f68e62023-08-22 23:10:01 +0530351Capsule Generation through binman
352*********************************
353
354Support has also been added to generate capsules during U-Boot build
355through binman. This requires the platform's DTB to be populated with
356the capsule entry nodes for binman. The capsules then can be generated
357by specifying the capsule parameters as properties in the capsule
358entry node.
359
360Check the test/py/tests/test_efi_capsule/capsule_gen_binman.dts file
361as reference for how a typical binman node for capsule generation
362looks like. For generating capsules as part of the platform's build, a
363capsule node would then have to be included into the platform's
364devicetree.
365
366A typical binman node for generating a capsule would look like::
367
368 capsule {
369 filename = "u-boot.capsule";
370 efi-capsule {
371 image-index = <0x1>;
372 image-guid = "09d7cf52-0720-4710-91d1-08469b7fe9c8";
373
374 u-boot {
375 };
376 };
377 };
378
379In the above example, a capsule file named u-boot.capsule will be
380generated with u-boot.bin as it's input payload. The capsule
381generation parameters like image-index and image-guid are being
382specified as properties. Similarly, other properties like the private
383and public key certificate can be specified for generating signed
384capsules. Refer :ref:`etype_efi_capsule` for documentation about the
385efi-capsule binman entry type, which describes all the properties that
386can be specified.
387
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900388Performing the update
389*********************
390
AKASHI Takahiroa7159db2022-02-09 19:10:37 +0900391Put capsule files under the directory mentioned above.
392Then, following the UEFI specification, you'll need to set
393the EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED
394bit in OsIndications variable with
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900395
AKASHI Takahiroa7159db2022-02-09 19:10:37 +0900396.. code-block:: console
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900397
Sughosh Ganufddb1362022-05-31 12:45:35 +0530398 => setenv -e -nv -bs -rt -v OsIndications =0x0000000000000004
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900399
Michal Simek50fa1182023-05-17 09:17:16 +0200400Since U-Boot doesn't currently support SetVariable at runtime, its value
AKASHI Takahiroa7159db2022-02-09 19:10:37 +0900401won't be taken over across the reboot. If this is the case, you can skip
402this feature check with the Kconfig option (CONFIG_EFI_IGNORE_OSINDICATIONS)
403set.
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900404
Sughosh Ganu50ec4722022-04-15 11:29:41 +0530405A few values need to be defined in the board file for performing the
406capsule update. These values are defined in the board file by
407initialisation of a structure which provides information needed for
408capsule updates. The following structures have been defined for
409containing the image related information
410
411.. code-block:: c
412
413 struct efi_fw_image {
414 efi_guid_t image_type_id;
415 u16 *fw_name;
416 u8 image_index;
417 };
418
419 struct efi_capsule_update_info {
420 const char *dfu_string;
421 struct efi_fw_image *images;
422 };
423
424
425A string is defined which is to be used for populating the
426dfu_alt_info variable. This string is used by the function
427set_dfu_alt_info. Instead of taking the variable from the environment,
428the capsule update feature requires that the variable be set through
429the function, since that is more robust. Allowing the user to change
430the location of the firmware updates is not a very secure
431practice. Getting this information from the firmware itself is more
432secure, assuming the firmware has been verified by a previous stage
433boot loader.
434
435The firmware images structure defines the GUID values, image index
436values and the name of the images that are to be updated through
437the capsule update feature. These values are to be defined as part of
438an array. These GUID values would be used by the Firmware Management
439Protocol(FMP) to populate the image descriptor array and also
440displayed as part of the ESRT table. The image index values defined in
441the array should be one greater than the dfu alt number that
442corresponds to the firmware image. So, if the dfu alt number for an
443image is 2, the value of image index in the fw_images array for that
444image should be 3. The dfu alt number can be obtained by running the
445following command::
446
447 dfu list
448
Sughosh Ganub08b8572022-10-21 18:16:08 +0530449When the FWU Multi Bank Update feature is enabled on the platform, the
450image index is used only to identify the image index with the image
451GUID. The image index would not correspond to the dfu alt number. This
452is because the FWU feature supports multiple partitions(banks) of
453updatable images, and the actual dfu alt number to which the image is
454to be written to is determined at runtime, based on the value of the
455update bank to which the image is to be written. For more information
Vincent Stehléecf21512023-02-20 15:37:29 +0100456on the FWU Multi Bank Update feature, please refer to
457:doc:`/develop/uefi/fwu_updates`.
Sughosh Ganub08b8572022-10-21 18:16:08 +0530458
Sughosh Ganu50ec4722022-04-15 11:29:41 +0530459When using the FMP for FIT images, the image index value needs to be
460set to 1.
461
AKASHI Takahiroa7159db2022-02-09 19:10:37 +0900462Finally, the capsule update can be initiated by rebooting the board.
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900463
Sughosh Ganu50ec4722022-04-15 11:29:41 +0530464An example of setting the values in the struct efi_fw_image and
465struct efi_capsule_update_info is shown below
466
467.. code-block:: c
468
469 struct efi_fw_image fw_images[] = {
470 {
471 .image_type_id = DEVELOPERBOX_UBOOT_IMAGE_GUID,
472 .fw_name = u"DEVELOPERBOX-UBOOT",
473 .image_index = 1,
474 },
475 {
476 .image_type_id = DEVELOPERBOX_FIP_IMAGE_GUID,
477 .fw_name = u"DEVELOPERBOX-FIP",
478 .image_index = 2,
479 },
480 {
481 .image_type_id = DEVELOPERBOX_OPTEE_IMAGE_GUID,
482 .fw_name = u"DEVELOPERBOX-OPTEE",
483 .image_index = 3,
484 },
485 };
486
487 struct efi_capsule_update_info update_info = {
488 .dfu_string = "mtd nor1=u-boot.bin raw 200000 100000;"
489 "fip.bin raw 180000 78000;"
490 "optee.bin raw 500000 100000",
491 .images = fw_images,
492 };
493
494Platforms must declare a variable update_info of type struct
495efi_capsule_update_info as shown in the example above. The platform
496will also define a fw_images array which contains information of all
497the firmware images that are to be updated through capsule update
498mechanism. The dfu_string is the string that is to be set as
499dfu_alt_info. In the example above, the image index to be set for
500u-boot.bin binary is 0x1, for fip.bin is 0x2 and for optee.bin is 0x3.
501
502As an example, for generating the capsule for the optee.bin image, the
503following command can be issued
504
505.. code-block:: bash
506
507 $ ./tools/mkeficapsule \
508 --index 0x3 --instance 0 \
509 --guid c1b629f1-ce0e-4894-82bf-f0a38387e630 \
510 optee.bin optee.capsule
511
512
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900513Enabling Capsule Authentication
514*******************************
515
516The UEFI specification defines a way of authenticating the capsule to
517be updated by verifying the capsule signature. The capsule signature
518is computed and prepended to the capsule payload at the time of
519capsule generation. This signature is then verified by using the
520public key stored as part of the X509 certificate. This certificate is
AKASHI Takahiroa7159db2022-02-09 19:10:37 +0900521in the form of an efi signature list (esl) file, which is embedded in
522a device tree.
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900523
524The capsule authentication feature can be enabled through the
525following config, in addition to the configs listed above for capsule
526update::
527
528 CONFIG_EFI_CAPSULE_AUTHENTICATE=y
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900529
530The public and private keys used for the signing process are generated
AKASHI Takahiroa7159db2022-02-09 19:10:37 +0900531and used by the steps highlighted below.
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900532
AKASHI Takahiroa7159db2022-02-09 19:10:37 +09005331. Install utility commands on your host
534 * openssl
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900535 * efitools
536
AKASHI Takahiroa7159db2022-02-09 19:10:37 +09005372. Create signing keys and certificate files on your host
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900538
AKASHI Takahiroa7159db2022-02-09 19:10:37 +0900539.. code-block:: console
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900540
AKASHI Takahiroa7159db2022-02-09 19:10:37 +0900541 $ openssl req -x509 -sha256 -newkey rsa:2048 -subj /CN=CRT/ \
542 -keyout CRT.key -out CRT.crt -nodes -days 365
543 $ cert-to-efi-sig-list CRT.crt CRT.esl
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900544
AKASHI Takahiroa7159db2022-02-09 19:10:37 +09005453. Run the following command to create and sign the capsule file
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900546
AKASHI Takahiroa7159db2022-02-09 19:10:37 +0900547.. code-block:: console
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900548
AKASHI Takahiroa7159db2022-02-09 19:10:37 +0900549 $ mkeficapsule --monotonic-count 1 \
550 --private-key CRT.key \
551 --certificate CRT.crt \
552 --index 1 --instance 0 \
AKASHI Takahiroba212432022-02-09 19:10:39 +0900553 [--fit | --raw | --guid <guid-string] \
554 <image_blob> <capsule_file_name>
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900555
AKASHI Takahiroa7159db2022-02-09 19:10:37 +09005564. Insert the signature list into a device tree in the following format::
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900557
AKASHI Takahiroa7159db2022-02-09 19:10:37 +0900558 {
559 signature {
560 capsule-key = [ <binary of signature list> ];
561 }
562 ...
563 }
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900564
AKASHI Takahiroa7159db2022-02-09 19:10:37 +0900565You can do step-4 manually with
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900566
AKASHI Takahiroa7159db2022-02-09 19:10:37 +0900567.. code-block:: console
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900568
AKASHI Takahiroa7159db2022-02-09 19:10:37 +0900569 $ dtc -@ -I dts -O dtb -o signature.dtbo signature.dts
570 $ fdtoverlay -i orig.dtb -o new.dtb -v signature.dtbo
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900571
AKASHI Takahiroa7159db2022-02-09 19:10:37 +0900572where signature.dts looks like::
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900573
AKASHI Takahiroa7159db2022-02-09 19:10:37 +0900574 &{/} {
575 signature {
576 capsule-key = /incbin/("CRT.esl");
577 };
578 };
AKASHI Takahiro60fc0c62021-10-07 15:23:31 +0900579
Masahisa Kojima475a4f72023-06-07 14:41:58 +0900580Anti-rollback Protection
581************************
582
583Anti-rollback prevents unintentional installation of outdated firmware.
584To enable anti-rollback, you must add the lowest-supported-version property
585to dtb and specify --fw-version when creating a capsule file with the
586mkeficapsule tool.
587When executing capsule update, U-Boot checks if fw_version is greater than
588or equal to lowest-supported-version. If fw_version is less than
589lowest-supported-version, the update will fail.
590For example, if lowest-supported-version is set to 7 and you run capsule
591update using a capsule file with --fw-version of 5, the update will fail.
592When the --fw-version in the capsule file is updated, lowest-supported-version
593in the dtb might be updated accordingly.
594
Masahisa Kojima68e23f42023-06-22 17:06:29 +0900595If user needs to enforce anti-rollback to any older version,
596the lowest-supported-version property in dtb must be always updated manually.
597
598Note that the lowest-supported-version property specified in U-Boot's control
599device tree can be changed by U-Boot fdt command.
600Secure systems should not enable this command.
601
Masahisa Kojima475a4f72023-06-07 14:41:58 +0900602To insert the lowest supported version into a dtb
603
604.. code-block:: console
605
606 $ dtc -@ -I dts -O dtb -o version.dtbo version.dts
607 $ fdtoverlay -i orig.dtb -o new.dtb -v version.dtbo
608
609where version.dts looks like::
610
611 /dts-v1/;
612 /plugin/;
613 &{/} {
614 firmware-version {
615 image1 {
616 image-type-id = "09D7CF52-0720-4710-91D1-08469B7FE9C8";
617 image-index = <1>;
618 lowest-supported-version = <3>;
619 };
620 };
621 };
622
623The properties of image-type-id and image-index must match the value
624defined in the efi_fw_image array as image_type_id and image_index.
625
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200626Executing the boot manager
627~~~~~~~~~~~~~~~~~~~~~~~~~~
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100628
Heinrich Schuchardt8d343f82020-08-16 12:27:19 +0200629The UEFI specification foresees to define boot entries and boot sequence via
630UEFI variables. Booting according to these variables is possible via::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100631
632 bootefi bootmgr [fdt address]
633
Heinrich Schuchardt8d343f82020-08-16 12:27:19 +0200634As of U-Boot v2020.10 UEFI variables cannot be set at runtime. The U-Boot
635command 'efidebug' can be used to set the variables.
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100636
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200637Executing the built in hello world application
638~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100639
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200640A hello world UEFI application can be built with::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100641
642 CONFIG_CMD_BOOTEFI_HELLO_COMPILE=y
643
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200644It can be embedded into the U-Boot binary with::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100645
646 CONFIG_CMD_BOOTEFI_HELLO=y
647
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200648The bootefi command is used to start the embedded hello world application::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100649
650 bootefi hello [fdt address]
651
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200652Below you find the output of an example session::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100653
654 => bootefi hello ${fdtcontroladdr}
655 ## Starting EFI application at 01000000 ...
656 WARNING: using memory device/image path, this may confuse some payloads!
657 Hello, world!
658 Running on UEFI 2.7
659 Have SMBIOS table
660 Have device tree
661 Load options: root=/dev/sdb3 init=/sbin/init rootwait ro
662 ## Application terminated, r = 0
663
664The environment variable fdtcontroladdr points to U-Boot's internal device tree
665(if available).
666
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200667Executing the built-in self-test
668~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100669
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200670An UEFI self-test suite can be embedded in U-Boot by building with::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100671
672 CONFIG_CMD_BOOTEFI_SELFTEST=y
673
674For testing the UEFI implementation the bootefi command can be used to start the
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200675self-test::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100676
677 bootefi selftest [fdt address]
678
679The environment variable 'efi_selftest' can be used to select a single test. If
680it is not provided all tests are executed except those marked as 'on request'.
681If the environment variable is set to 'list' a list of all tests is shown.
682
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200683Below you can find the output of an example session::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100684
685 => setenv efi_selftest simple network protocol
686 => bootefi selftest
687 Testing EFI API implementation
688 Selected test: 'simple network protocol'
689 Setting up 'simple network protocol'
690 Setting up 'simple network protocol' succeeded
691 Executing 'simple network protocol'
692 DHCP Discover
693 DHCP reply received from 192.168.76.2 (52:55:c0:a8:4c:02)
694 as broadcast message.
695 Executing 'simple network protocol' succeeded
696 Tearing down 'simple network protocol'
697 Tearing down 'simple network protocol' succeeded
698 Boot services terminated
699 Summary: 0 failures
700 Preparing for reset. Press any key.
701
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200702The UEFI life cycle
703-------------------
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100704
705After the U-Boot platform has been initialized the UEFI API provides two kinds
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200706of services:
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100707
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200708* boot services
709* runtime services
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100710
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200711The API can be extended by loading UEFI drivers which come in two variants:
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100712
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200713* boot drivers
714* runtime drivers
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100715
716UEFI drivers are installed with U-Boot's bootefi command. With the same command
717UEFI applications can be executed.
718
719Loaded images of UEFI drivers stay in memory after returning to U-Boot while
720loaded images of applications are removed from memory.
721
722An UEFI application (e.g. an operating system) that wants to take full control
723of the system calls ExitBootServices. After a UEFI application calls
724ExitBootServices
725
726* boot services are not available anymore
727* timer events are stopped
728* the memory used by U-Boot except for runtime services is released
729* the memory used by boot time drivers is released
730
731So this is a point of no return. Afterwards the UEFI application can only return
732to U-Boot by rebooting.
733
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200734The UEFI object model
735---------------------
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100736
737UEFI offers a flexible and expandable object model. The objects in the UEFI API
738are devices, drivers, and loaded images. These objects are referenced by
739handles.
740
741The interfaces implemented by the objects are referred to as protocols. These
742are identified by GUIDs. They can be installed and uninstalled by calling the
743appropriate boot services.
744
745Handles are created by the InstallProtocolInterface or the
746InstallMultipleProtocolinterfaces service if NULL is passed as handle.
747
748Handles are deleted when the last protocol has been removed with the
749UninstallProtocolInterface or the UninstallMultipleProtocolInterfaces service.
750
751Devices offer the EFI_DEVICE_PATH_PROTOCOL. A device path is the concatenation
752of device nodes. By their device paths all devices of a system are arranged in a
753tree.
754
755Drivers offer the EFI_DRIVER_BINDING_PROTOCOL. This protocol is used to connect
756a driver to devices (which are referenced as controllers in this context).
757
758Loaded images offer the EFI_LOADED_IMAGE_PROTOCOL. This protocol provides meta
759information about the image and a pointer to the unload callback function.
760
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200761The UEFI events
762---------------
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100763
764In the UEFI terminology an event is a data object referencing a notification
765function which is queued for calling when the event is signaled. The following
766types of events exist:
767
768* periodic and single shot timer events
769* exit boot services events, triggered by calling the ExitBootServices() service
770* virtual address change events
771* memory map change events
772* read to boot events
773* reset system events
774* system table events
775* events that are only triggered programmatically
776
777Events can be created with the CreateEvent service and deleted with CloseEvent
778service.
779
780Events can be assigned to an event group. If any of the events in a group is
781signaled, all other events in the group are also set to the signaled state.
782
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200783The UEFI driver model
784---------------------
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100785
786A driver is specific for a single protocol installed on a device. To install a
787driver on a device the ConnectController service is called. In this context
788controller refers to the device for which the driver is installed.
789
790The relevant drivers are identified using the EFI_DRIVER_BINDING_PROTOCOL. This
791protocol has has three functions:
792
793* supported - determines if the driver is compatible with the device
794* start - installs the driver by opening the relevant protocol with
795 attribute EFI_OPEN_PROTOCOL_BY_DRIVER
796* stop - uninstalls the driver
797
798The driver may create child controllers (child devices). E.g. a driver for block
799IO devices will create the device handles for the partitions. The child
800controllers will open the supported protocol with the attribute
801EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
802
803A driver can be detached from a device using the DisconnectController service.
804
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200805U-Boot devices mapped as UEFI devices
806-------------------------------------
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100807
808Some of the U-Boot devices are mapped as UEFI devices
809
810* block IO devices
811* console
812* graphical output
813* network adapter
814
815As of U-Boot 2018.03 the logic for doing this is hard coded.
816
817The development target is to integrate the setup of these UEFI devices with the
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200818U-Boot driver model [5]. So when a U-Boot device is discovered a handle should
819be created and the device path protocol and the relevant IO protocol should be
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100820installed. The UEFI driver then would be attached by calling ConnectController.
821When a U-Boot device is removed DisconnectController should be called.
822
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200823UEFI devices mapped as U-Boot devices
824-------------------------------------
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100825
826UEFI drivers binaries and applications may create new (virtual) devices, install
827a protocol and call the ConnectController service. Now the matching UEFI driver
828is determined by iterating over the implementations of the
829EFI_DRIVER_BINDING_PROTOCOL.
830
831It is the task of the UEFI driver to create a corresponding U-Boot device and to
832proxy calls for this U-Boot device to the controller.
833
834In U-Boot 2018.03 this has only been implemented for block IO devices.
835
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200836UEFI uclass
837~~~~~~~~~~~
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100838
839An UEFI uclass driver (lib/efi_driver/efi_uclass.c) has been created that
840takes care of initializing the UEFI drivers and providing the
841EFI_DRIVER_BINDING_PROTOCOL implementation for the UEFI drivers.
842
843A linker created list is used to keep track of the UEFI drivers. To create an
844entry in the list the UEFI driver uses the U_BOOT_DRIVER macro specifying
Simon Glass15c4d672021-12-04 08:56:30 -0700845UCLASS_EFI_LOADER as the ID of its uclass, e.g::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100846
847 /* Identify as UEFI driver */
848 U_BOOT_DRIVER(efi_block) = {
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200849 .name = "EFI block driver",
Simon Glass15c4d672021-12-04 08:56:30 -0700850 .id = UCLASS_EFI_LOADER,
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200851 .ops = &driver_ops,
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100852 };
853
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200854The available operations are defined via the structure struct efi_driver_ops::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100855
856 struct efi_driver_ops {
857 const efi_guid_t *protocol;
858 const efi_guid_t *child_protocol;
859 int (*bind)(efi_handle_t handle, void *interface);
860 };
861
862When the supported() function of the EFI_DRIVER_BINDING_PROTOCOL is called the
863uclass checks if the protocol GUID matches the protocol GUID of the UEFI driver.
864In the start() function the bind() function of the UEFI driver is called after
865checking the GUID.
866The stop() function of the EFI_DRIVER_BINDING_PROTOCOL disconnects the child
867controllers created by the UEFI driver and the UEFI driver. (In U-Boot v2013.03
868this is not yet completely implemented.)
869
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200870UEFI block IO driver
871~~~~~~~~~~~~~~~~~~~~
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100872
873The UEFI block IO driver supports devices exposing the EFI_BLOCK_IO_PROTOCOL.
874
875When connected it creates a new U-Boot block IO device with interface type
Simon Glassdbfa32c2022-08-11 19:34:59 -0600876UCLASS_EFI_LOADER, adds child controllers mapping the partitions, and installs
Simon Glass15c4d672021-12-04 08:56:30 -0700877the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL on these. This can be used together with the
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200878software iPXE to boot from iSCSI network drives [4].
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100879
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200880This driver is only available if U-Boot is configured with::
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100881
882 CONFIG_BLK=y
883 CONFIG_PARTITIONS=y
884
Heinrich Schuchardtc4d45422020-02-22 07:47:20 +0100885Miscellaneous
886-------------
887
888Load file 2 protocol
889~~~~~~~~~~~~~~~~~~~~
890
891The load file 2 protocol can be used by the Linux kernel to load the initial
892RAM disk. U-Boot can be configured to provide an implementation with::
893
894 EFI_LOAD_FILE2_INITRD=y
Ilias Apalodimasc92aa4b2021-03-17 21:55:02 +0200895
896When the option is enabled the user can add the initrd path with the efidebug
897command.
898
899Load options Boot#### have a FilePathList[] member. The first element of
900the array (FilePathList[0]) is the EFI binary to execute. When an initrd
901is specified the Device Path for the initrd is denoted by a VenMedia node
902with the EFI_INITRD_MEDIA_GUID. Each entry of the array is terminated by the
903'end of entire device path' subtype (0xff). If a user wants to define multiple
904initrds, those must by separated by the 'end of this instance' identifier of
905the end node (0x01).
906
907So our final format of the FilePathList[] is::
908
909 Loaded image - end node (0xff) - VenMedia - initrd_1 - [end node (0x01) - initrd_n ...] - end node (0xff)
Heinrich Schuchardtc4d45422020-02-22 07:47:20 +0100910
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200911Links
912-----
Heinrich Schuchardt5fa03de2018-03-02 19:58:50 +0100913
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200914* [1] http://uefi.org/specifications - UEFI specifications
Vincent Stehléc53cec62022-12-16 17:55:04 +0100915* [2] https://github.com/ARM-software/ebbr/releases/download/v2.1.0/ebbr-v2.1.0.pdf -
916 Embedded Base Boot Requirements (EBBR) Specification - Release v2.1.0
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200917* [3] https://developer.arm.com/docs/den0044/latest/server-base-boot-requirements-system-software-on-arm-platforms-version-11 -
Heinrich Schuchardta28d0732019-03-28 08:09:16 +0100918 Server Base Boot Requirements System Software on ARM Platforms - Version 1.1
Heinrich Schuchardtfd0b53f2019-07-26 06:46:08 +0200919* [4] :doc:`iscsi`
920* [5] :doc:`../driver-model/index`