Pull request for efi-2022-04-rc5

Documentation:
 
 * Fix documentation of FIP creation for Amlogic boards
 * Update Nokia RX-51 QEMU documentation
 * Add Raspberry Pi documentation
 
 UEFI:
 
 * Fix booting via short form device paths
 * Support short form device paths in 'efidebug boot add'
 * Fix ESP detection for capsule updates
 * Allow ACPI table usage even if device-tree exists - ignore DT
 * OP-TEE based GetVariable(): return attributes when buffer too small
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEbcT5xx8ppvoGt20zxIHbvCwFGsQFAmI3UAIACgkQxIHbvCwF
 GsRopA/7BLiFUFayMnVL3qCLZKrceKSbz76zSs18zMab4U7FWEiWTLfqhV4PSgT+
 SfcpOCFsodRIGvNKwm/RpVSpwj7NPINUL29Hn70ojN0ckuJZNBj8ILflr7y6iuCX
 OI48rezhvnOMKk0F2JNFCQDzPYJVKm7Ej1M+CfVCuL+iQNEk4l9FI/pgnT8at5D/
 TcmUQIvqEj6wTv2XaT59AKm85R0r14NJHNRgNEEwgeReiZZ/cxK9I/jYTMFxWK0r
 uOEB1jrsRKnTMq3fgg9fOZRQvjavqoqe0evVtBfrkBpYP48AK9c9vXSBfCSUnygl
 lM+JS6keWaKeOH4605UHhxaFjAoW7VEH+a6jubbDoNNTUspRGpY6UViAc7O16DDK
 AjZN6uoUkeREFMokvHsgsh63cRj2WkKnildAIcnRyLhqQuHe+QS8ndiOSV4Q0peO
 ifT8BFF4loN2ttAViKNYeM6ydBabjmwJiuzuUG0tyxiYDXLS0/ErNp7aUwTgc/qP
 1E46PS+f6sZG2oiNk5L2MP689wEBgZpjSck4aH3ba+UrtGXSh/YC5ERaN1Zm7K5M
 GJ3UOL+G+o0Is4gYgp7tvizVfu+8FIC/ilOndmgtwdRoUYrUA2ePx7WPvArnHLc3
 rymR7IJ1yCD5RjVB3lA6eL76ORKNRBe3Gs7zGRK5jg55pw3MFSo=
 =Kn/h
 -----END PGP SIGNATURE-----

Merge tag 'efi-2022-04-rc5' of https://source.denx.de/u-boot/custodians/u-boot-efi

Pull request for efi-2022-04-rc5

Documentation:

* Fix documentation of FIP creation for Amlogic boards
* Update Nokia RX-51 QEMU documentation
* Add Raspberry Pi documentation

UEFI:

* Fix booting via short form device paths
* Support short form device paths in 'efidebug boot add'
* Fix ESP detection for capsule updates
* Allow ACPI table usage even if device-tree exists - ignore DT
* OP-TEE based GetVariable(): return attributes when buffer too small
This commit is contained in:
Tom Rini 2022-03-20 15:14:59 -04:00
commit 5f68470d69
44 changed files with 517 additions and 217 deletions

View file

@ -1080,7 +1080,7 @@ define deprecated
echo >&2 "for $(2)). Please update the board to use"; \ echo >&2 "for $(2)). Please update the board to use"; \
echo >&2 "$(firstword $(1)) before the $(3) release. Failure to"; \ echo >&2 "$(firstword $(1)) before the $(3) release. Failure to"; \
echo >&2 "update by the deadline may result in board removal."; \ echo >&2 "update by the deadline may result in board removal."; \
echo >&2 "See doc/driver-model/migration.rst for more info."; \ echo >&2 "See doc/develop/driver-model/migration.rst for more info."; \
echo >&2 "===================================================="; \ echo >&2 "===================================================="; \
fi; fi fi; fi
@ -1121,7 +1121,7 @@ ifneq ($(CONFIG_DM),y)
@echo >&2 "This board does not use CONFIG_DM. CONFIG_DM will be" @echo >&2 "This board does not use CONFIG_DM. CONFIG_DM will be"
@echo >&2 "compulsory starting with the v2020.01 release." @echo >&2 "compulsory starting with the v2020.01 release."
@echo >&2 "Failure to update may result in board removal." @echo >&2 "Failure to update may result in board removal."
@echo >&2 "See doc/driver-model/migration.rst for more info." @echo >&2 "See doc/develop/driver-model/migration.rst for more info."
@echo >&2 "====================================================" @echo >&2 "===================================================="
endif endif
$(call deprecated,CONFIG_WDT,DM watchdog,v2019.10,\ $(call deprecated,CONFIG_WDT,DM watchdog,v2019.10,\

View file

@ -265,8 +265,8 @@ efi_status_t efi_install_fdt(void *fdt)
*/ */
#if CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE) #if CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE)
if (fdt) { if (fdt) {
log_err("ERROR: can't have ACPI table and device tree.\n"); log_warning("WARNING: Can't have ACPI table and device tree - ignoring DT.\n");
return EFI_LOAD_ERROR; return EFI_SUCCESS;
} }
#else #else
bootm_headers_t img = { 0 }; bootm_headers_t img = { 0 };

View file

@ -734,20 +734,20 @@ static int do_efi_show_tables(struct cmd_tbl *cmdtp, int flag,
} }
/** /**
* create_initrd_dp() - Create a special device for our Boot### option * create_initrd_dp() - create a special device for our Boot### option
*
* @dev: Device
* @part: Disk partition
* @file: Filename
* Return: Pointer to the device path or ERR_PTR
* *
* @dev: device
* @part: disk partition
* @file: filename
* @shortform: create short form device path
* Return: pointer to the device path or ERR_PTR
*/ */
static static
struct efi_device_path *create_initrd_dp(const char *dev, const char *part, struct efi_device_path *create_initrd_dp(const char *dev, const char *part,
const char *file) const char *file, int shortform)
{ {
struct efi_device_path *tmp_dp = NULL, *tmp_fp = NULL; struct efi_device_path *tmp_dp = NULL, *tmp_fp = NULL, *short_fp = NULL;
struct efi_device_path *initrd_dp = NULL; struct efi_device_path *initrd_dp = NULL;
efi_status_t ret; efi_status_t ret;
const struct efi_initrd_dp id_dp = { const struct efi_initrd_dp id_dp = {
@ -771,9 +771,13 @@ struct efi_device_path *create_initrd_dp(const char *dev, const char *part,
printf("Cannot create device path for \"%s %s\"\n", part, file); printf("Cannot create device path for \"%s %s\"\n", part, file);
goto out; goto out;
} }
if (shortform)
short_fp = efi_dp_shorten(tmp_fp);
if (!short_fp)
short_fp = tmp_fp;
initrd_dp = efi_dp_append((const struct efi_device_path *)&id_dp, initrd_dp = efi_dp_append((const struct efi_device_path *)&id_dp,
tmp_fp); short_fp);
out: out:
efi_free_pool(tmp_dp); efi_free_pool(tmp_dp);
@ -807,6 +811,7 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag,
size_t label_len, label_len16; size_t label_len, label_len16;
u16 *label; u16 *label;
struct efi_device_path *device_path = NULL, *file_path = NULL; struct efi_device_path *device_path = NULL, *file_path = NULL;
struct efi_device_path *fp_free = NULL;
struct efi_device_path *final_fp = NULL; struct efi_device_path *final_fp = NULL;
struct efi_device_path *initrd_dp = NULL; struct efi_device_path *initrd_dp = NULL;
struct efi_load_option lo; struct efi_load_option lo;
@ -826,7 +831,18 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag,
argc--; argc--;
argv++; /* 'add' */ argv++; /* 'add' */
for (; argc > 0; argc--, argv++) { for (; argc > 0; argc--, argv++) {
if (!strcmp(argv[0], "-b")) { int shortform;
if (*argv[0] != '-' || strlen(argv[0]) != 2) {
r = CMD_RET_USAGE;
goto out;
}
shortform = 0;
switch (argv[0][1]) {
case 'b':
shortform = 1;
/* fallthrough */
case 'B':
if (argc < 5 || lo.label) { if (argc < 5 || lo.label) {
r = CMD_RET_USAGE; r = CMD_RET_USAGE;
goto out; goto out;
@ -849,24 +865,33 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag,
/* file path */ /* file path */
ret = efi_dp_from_name(argv[3], argv[4], argv[5], ret = efi_dp_from_name(argv[3], argv[4], argv[5],
&device_path, &file_path); &device_path, &fp_free);
if (ret != EFI_SUCCESS) { if (ret != EFI_SUCCESS) {
printf("Cannot create device path for \"%s %s\"\n", printf("Cannot create device path for \"%s %s\"\n",
argv[3], argv[4]); argv[3], argv[4]);
r = CMD_RET_FAILURE; r = CMD_RET_FAILURE;
goto out; goto out;
} }
if (shortform)
file_path = efi_dp_shorten(fp_free);
if (!file_path)
file_path = fp_free;
fp_size += efi_dp_size(file_path) + fp_size += efi_dp_size(file_path) +
sizeof(struct efi_device_path); sizeof(struct efi_device_path);
argc -= 5; argc -= 5;
argv += 5; argv += 5;
} else if (!strcmp(argv[0], "-i")) { break;
case 'i':
shortform = 1;
/* fallthrough */
case 'I':
if (argc < 3 || initrd_dp) { if (argc < 3 || initrd_dp) {
r = CMD_RET_USAGE; r = CMD_RET_USAGE;
goto out; goto out;
} }
initrd_dp = create_initrd_dp(argv[1], argv[2], argv[3]); initrd_dp = create_initrd_dp(argv[1], argv[2], argv[3],
shortform);
if (!initrd_dp) { if (!initrd_dp) {
printf("Cannot add an initrd\n"); printf("Cannot add an initrd\n");
r = CMD_RET_FAILURE; r = CMD_RET_FAILURE;
@ -876,7 +901,8 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag,
argv += 3; argv += 3;
fp_size += efi_dp_size(initrd_dp) + fp_size += efi_dp_size(initrd_dp) +
sizeof(struct efi_device_path); sizeof(struct efi_device_path);
} else if (!strcmp(argv[0], "-s")) { break;
case 's':
if (argc < 1 || lo.optional_data) { if (argc < 1 || lo.optional_data) {
r = CMD_RET_USAGE; r = CMD_RET_USAGE;
goto out; goto out;
@ -884,7 +910,8 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag,
lo.optional_data = (const u8 *)argv[1]; lo.optional_data = (const u8 *)argv[1];
argc -= 1; argc -= 1;
argv += 1; argv += 1;
} else { break;
default:
r = CMD_RET_USAGE; r = CMD_RET_USAGE;
goto out; goto out;
} }
@ -927,7 +954,7 @@ out:
efi_free_pool(final_fp); efi_free_pool(final_fp);
efi_free_pool(initrd_dp); efi_free_pool(initrd_dp);
efi_free_pool(device_path); efi_free_pool(device_path);
efi_free_pool(file_path); efi_free_pool(fp_free);
free(lo.label); free(lo.label);
return r; return r;
@ -1571,12 +1598,11 @@ static int do_efidebug(struct cmd_tbl *cmdtp, int flag,
static char efidebug_help_text[] = static char efidebug_help_text[] =
" - UEFI Shell-like interface to configure UEFI environment\n" " - UEFI Shell-like interface to configure UEFI environment\n"
"\n" "\n"
"efidebug boot add " "efidebug boot add - set UEFI BootXXXX variable\n"
"-b <bootid> <label> <interface> <devnum>[:<part>] <file path> " " -b|-B <bootid> <label> <interface> <devnum>[:<part>] <file path>\n"
"-i <interface> <devnum>[:<part>] <initrd file path> " " -i|-I <interface> <devnum>[:<part>] <initrd file path>\n"
"-s '<optional data>'\n" " (-b, -i for short form device path)\n"
" - set UEFI BootXXXX variable\n" " -s '<optional data>'\n"
" <load options> will be passed to UEFI application\n"
"efidebug boot rm <bootid#1> [<bootid#2> [<bootid#3> [...]]]\n" "efidebug boot rm <bootid#1> [<bootid#2> [<bootid#3> [...]]]\n"
" - delete UEFI BootXXXX variables\n" " - delete UEFI BootXXXX variables\n"
"efidebug boot dump\n" "efidebug boot dump\n"

View file

@ -44,6 +44,8 @@ https://github.com/LibreELEC/amlogic-boot-fip/tree/master/beelink-s922x
NB: Beelink use a common board config for GT-King, GT-King Pro and the NB: Beelink use a common board config for GT-King, GT-King Pro and the
GS-King-X model, hence the "beelink-s922x" name. GS-King-X model, hence the "beelink-s922x" name.
For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `beelink-s922x`
.. code-block:: bash .. code-block:: bash
$ wget https://github.com/LibreELEC/amlogic-boot-fip/archive/master.zip $ wget https://github.com/LibreELEC/amlogic-boot-fip/archive/master.zip

View file

@ -45,6 +45,8 @@ https://github.com/LibreELEC/amlogic-boot-fip/tree/master/beelink-s922x
NB: Beelink use a common board config for GT-King, GT-King Pro and the NB: Beelink use a common board config for GT-King, GT-King Pro and the
GS-King-X model, hence the "beelink-s922x" name. GS-King-X model, hence the "beelink-s922x" name.
For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `beelink-s922x`
.. code-block:: bash .. code-block:: bash
$ wget https://github.com/LibreELEC/amlogic-boot-fip/archive/master.zip $ wget https://github.com/LibreELEC/amlogic-boot-fip/archive/master.zip

View file

@ -74,6 +74,14 @@ This matrix concerns the actual source code version.
| PCIe (+NVMe) | *N/A* | *N/A* | *N/A* | **Yes** | **Yes** | **Yes** | **Yes** | | PCIe (+NVMe) | *N/A* | *N/A* | *N/A* | **Yes** | **Yes** | **Yes** | **Yes** |
+-------------------------------+-----------+-----------------+--------------+-------------+------------+-------------+--------------+ +-------------------------------+-----------+-----------------+--------------+-------------+------------+-------------+--------------+
Boot Documentation
------------------
.. toctree::
:maxdepth: 1
pre-generated-fip
Board Documentation Board Documentation
------------------- -------------------

View file

@ -37,6 +37,8 @@ U-Boot compilation
Image creation Image creation
-------------- --------------
For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `jethub-j100`
Amlogic doesn't provide sources for the firmware and for tools needed Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain binaries to create the bootloader image, so it is necessary to obtain binaries
from the git tree published by the board vendor: from the git tree published by the board vendor:

View file

@ -33,6 +33,8 @@ U-Boot compilation
Image creation Image creation
-------------- --------------
For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `jethub-j80`
Amlogic doesn't provide sources for the firmware and for tools needed Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain binaries to create the bootloader image, so it is necessary to obtain binaries
from the git tree published by the board vendor: from the git tree published by the board vendor:

View file

@ -30,6 +30,8 @@ U-Boot compilation
Image creation Image creation
-------------- --------------
For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `khadas-vim`
Amlogic doesn't provide sources for the firmware and for tools needed Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor: the git tree published by the board vendor:

View file

@ -31,6 +31,8 @@ U-Boot compilation
Image creation Image creation
-------------- --------------
For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `khadas-vim2`
Amlogic doesn't provide sources for the firmware and for tools needed Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor: the git tree published by the board vendor:

View file

@ -57,6 +57,8 @@ U-Boot compilation
Image creation Image creation
-------------- --------------
For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `khadas-vim3`
Amlogic doesn't provide sources for the firmware and for tools needed Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor: the git tree published by the board vendor:

View file

@ -57,6 +57,8 @@ U-Boot compilation
Image creation Image creation
-------------- --------------
For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `khadas-vim3l`
Amlogic doesn't provide sources for the firmware and for tools needed Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor: the git tree published by the board vendor:

View file

@ -30,6 +30,8 @@ U-Boot compilation
Image creation Image creation
-------------- --------------
For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `lafrite`
Amlogic doesn't provide sources for the firmware and for tools needed Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor: the git tree published by the board vendor:

View file

@ -54,6 +54,8 @@ These binaries and the tools required below have been collected and prebuilt
for convenience at <https://github.com/BayLibre/u-boot/releases/>. These for convenience at <https://github.com/BayLibre/u-boot/releases/>. These
apply to both v1 and v2. apply to both v1 and v2.
For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `lepotato`
Download and extract the libretech-cc release from there, and set FIPDIR to Download and extract the libretech-cc release from there, and set FIPDIR to
point to the `fip` subdirectory. point to the `fip` subdirectory.

View file

@ -30,6 +30,8 @@ U-Boot compilation
Image creation Image creation
-------------- --------------
For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `nanopi-k2`
Amlogic doesn't provide sources for the firmware and for tools needed Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor: the git tree published by the board vendor:

View file

@ -30,6 +30,8 @@ U-Boot compilation
Image creation Image creation
-------------- --------------
For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `odroid-c2`
Amlogic doesn't provide sources for the firmware and for tools needed Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor: the git tree published by the board vendor:

View file

@ -34,6 +34,8 @@ U-Boot compilation
Image creation Image creation
-------------- --------------
For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `odroid-c4` or `odroid-hc4`
Amlogic doesn't provide sources for the firmware and for tools needed Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor: the git tree published by the board vendor:

View file

@ -29,6 +29,8 @@ U-Boot compilation
Image creation Image creation
-------------- --------------
For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `odroid-n2` or `odroid-n2-plus`
Amlogic doesn't provide sources for the firmware and for tools needed Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor: the git tree published by the board vendor:

View file

@ -31,6 +31,8 @@ U-Boot compilation
Image creation Image creation
-------------- --------------
For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `p200`
Amlogic doesn't provide sources for the firmware and for tools needed Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor: the git tree published by the board vendor:
@ -54,44 +56,39 @@ Go back to mainline U-boot source tree then :
$ mkdir fip $ mkdir fip
$ cp $FIPDIR/gxl/bl2.bin fip/ $ cp $FIPDIR/gxb/bl2.bin fip/
$ cp $FIPDIR/gxl/acs.bin fip/ $ cp $FIPDIR/gxb/acs.bin fip/
$ cp $FIPDIR/gxl/bl21.bin fip/ $ cp $FIPDIR/gxb/bl21.bin fip/
$ cp $FIPDIR/gxl/bl30.bin fip/ $ cp $FIPDIR/gxb/bl30.bin fip/
$ cp $FIPDIR/gxl/bl301.bin fip/ $ cp $FIPDIR/gxb/bl301.bin fip/
$ cp $FIPDIR/gxl/bl31.img fip/ $ cp $FIPDIR/gxb/bl31.img fip/
$ cp u-boot.bin fip/bl33.bin $ cp u-boot.bin fip/bl33.bin
$ $FIPDIR/blx_fix.sh \ $ $FIPDIR/blx_fix.sh \
fip/bl30.bin \ fip/bl30.bin \
fip/zero_tmp \ fip/zero_tmp \
fip/bl30_zero.bin \ fip/bl30_zero.bin \
fip/bl301.bin \ fip/bl301.bin \
fip/bl301_zero.bin \ fip/bl301_zero.bin \
fip/bl30_new.bin \ fip/bl30_new.bin \
bl30 bl30
$ $FIPDIR/acs_tool.pyc fip/bl2.bin fip/bl2_acs.bin fip/acs.bin 0 $ python $FIPDIR/acs_tool.pyc fip/bl2.bin fip/bl2_acs.bin fip/acs.bin 0
$ $FIPDIR/blx_fix.sh \ $ $FIPDIR/blx_fix.sh \
fip/bl2_acs.bin \ fip/bl2_acs.bin \
fip/zero_tmp \ fip/zero_tmp \
fip/bl2_zero.bin \ fip/bl2_zero.bin \
fip/bl21.bin \ fip/bl21.bin \
fip/bl21_zero.bin \ fip/bl21_zero.bin \
fip/bl2_new.bin \ fip/bl2_new.bin \
bl2 bl2
$ $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl30_new.bin $ $FIPDIR/fip_create --bl30 fip/bl30_new.bin --bl31 fip/bl31.img --bl33 fip/bl33.bin fip/fip.bin
$ $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl31.img
$ $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl33.bin $ cat fip/bl2_new.bin fip/fip.bin >fip/boot_new.bin
$ $FIPDIR/gxl/aml_encrypt_gxl --bl2sig --input fip/bl2_new.bin --output fip/bl2.n.bin.sig
$ $FIPDIR/gxl/aml_encrypt_gxl --bootmk \ $ $FIPDIR/gxb/aml_encrypt_gxb --bootsig --input fip/boot_new.bin --output fip/u-boot.bin
--output fip/u-boot.bin \
--bl2 fip/bl2.n.bin.sig \
--bl30 fip/bl30_new.bin.enc \
--bl31 fip/bl31.img.enc \
--bl33 fip/bl33.bin.enc
and then write the image to SD with: and then write the image to SD with:

View file

@ -31,6 +31,8 @@ U-Boot compilation
Image creation Image creation
-------------- --------------
For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `p201`
Amlogic doesn't provide sources for the firmware and for tools needed Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor: the git tree published by the board vendor:
@ -54,44 +56,39 @@ Go back to mainline U-boot source tree then :
$ mkdir fip $ mkdir fip
$ cp $FIPDIR/gxl/bl2.bin fip/ $ cp $FIPDIR/gxb/bl2.bin fip/
$ cp $FIPDIR/gxl/acs.bin fip/ $ cp $FIPDIR/gxb/acs.bin fip/
$ cp $FIPDIR/gxl/bl21.bin fip/ $ cp $FIPDIR/gxb/bl21.bin fip/
$ cp $FIPDIR/gxl/bl30.bin fip/ $ cp $FIPDIR/gxb/bl30.bin fip/
$ cp $FIPDIR/gxl/bl301.bin fip/ $ cp $FIPDIR/gxb/bl301.bin fip/
$ cp $FIPDIR/gxl/bl31.img fip/ $ cp $FIPDIR/gxb/bl31.img fip/
$ cp u-boot.bin fip/bl33.bin $ cp u-boot.bin fip/bl33.bin
$ $FIPDIR/blx_fix.sh \ $ $FIPDIR/blx_fix.sh \
fip/bl30.bin \ fip/bl30.bin \
fip/zero_tmp \ fip/zero_tmp \
fip/bl30_zero.bin \ fip/bl30_zero.bin \
fip/bl301.bin \ fip/bl301.bin \
fip/bl301_zero.bin \ fip/bl301_zero.bin \
fip/bl30_new.bin \ fip/bl30_new.bin \
bl30 bl30
$ $FIPDIR/acs_tool.pyc fip/bl2.bin fip/bl2_acs.bin fip/acs.bin 0 $ python $FIPDIR/acs_tool.pyc fip/bl2.bin fip/bl2_acs.bin fip/acs.bin 0
$ $FIPDIR/blx_fix.sh \ $ $FIPDIR/blx_fix.sh \
fip/bl2_acs.bin \ fip/bl2_acs.bin \
fip/zero_tmp \ fip/zero_tmp \
fip/bl2_zero.bin \ fip/bl2_zero.bin \
fip/bl21.bin \ fip/bl21.bin \
fip/bl21_zero.bin \ fip/bl21_zero.bin \
fip/bl2_new.bin \ fip/bl2_new.bin \
bl2 bl2
$ $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl30_new.bin $ $FIPDIR/fip_create --bl30 fip/bl30_new.bin --bl31 fip/bl31.img --bl33 fip/bl33.bin fip/fip.bin
$ $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl31.img
$ $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl33.bin $ cat fip/bl2_new.bin fip/fip.bin >fip/boot_new.bin
$ $FIPDIR/gxl/aml_encrypt_gxl --bl2sig --input fip/bl2_new.bin --output fip/bl2.n.bin.sig
$ $FIPDIR/gxl/aml_encrypt_gxl --bootmk \ $ $FIPDIR/gxb/aml_encrypt_gxb --bootsig --input fip/boot_new.bin --output fip/u-boot.bin
--output fip/u-boot.bin \
--bl2 fip/bl2.n.bin.sig \
--bl30 fip/bl30_new.bin.enc \
--bl31 fip/bl31.img.enc \
--bl33 fip/bl33.bin.enc
and then write the image to SD with: and then write the image to SD with:

View file

@ -31,6 +31,8 @@ U-Boot compilation
Image creation Image creation
-------------- --------------
For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `p212`
Amlogic doesn't provide sources for the firmware and for tools needed Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor: the git tree published by the board vendor:

View file

@ -0,0 +1,93 @@
.. SPDX-License-Identifier: GPL-2.0+
Pre-Generated FIP file set
==========================
The Amlogic ARMv8 based SoCs uses a vendor variant of the Trusted Firmware-A
boot architecture.
You can find documentation on the Trusted Firmware-A architecture on: https://www.trustedfirmware.org/projects/tf-a/
The Trusted Firmware-A uses the following boot elements (simplified):
- BL1: First boot step, implemented in ROM on Amlogic SoCs
- BL2: Second boot step, used to initialize the SoC main clocks & DDR interface. The BL21 and ACS board-specific binaries are "inserted" in the BL32 binary before signing/packaging in order to be flashed on the platform.
- BL30: Amlogic Secure Co-Processor (SCP) firmware used to handle all the system management operations (DVFS, suspend/resume, ...)
- BL301: Amlogic Secure Co-Processor (SCP) board-specific firmware "plug-in" to handle custom DVFS & suspend-resume parameters
- BL31: Initializes the interrupt controller and the system management interface (PSCI)
- BL32 (Optional): Is the Trusted Environment Execution (TEE) Operating System to run secure Trusted Apps, e.g. OP-TEE
- BL33: Is the last non-secure step, usually U-Boot which loads Linux
Amlogic provides in binary form:
- bl2.bin
- bl30.bin
- bl30.bin
- bl31.img
- bl32.bin
And for lastest SoCs, Amlogic also provides the DDR drivers used by the BL2 binary.
The licence of these files wasn't clear until recently, the currently Amlogic distribution licence
is the following:
.. code-block:: C
// Copyright (C) 2018 Amlogic, Inc. All rights reserved.
//
// All information contained herein is Amlogic confidential.
//
// This software is provided to you pursuant to Software License
// Agreement (SLA) with Amlogic Inc ("Amlogic"). This software may be
// used only in accordance with the terms of this agreement.
//
// Redistribution and use in source and binary forms, with or without
// modification is strictly prohibited without prior written permission
// from Amlogic.
//
// 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
// OWNER 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.
The following files are generated from the Amlogic U-Boot fork:
- acs.bin: contains the PLL & DDR parameters for the board
- bl301.bin: contains the DVFS & suspend-resume handling code for the board
- bl33.bin: U-boot binary image
The acs.bin & bl301.bin uses the U-Boot GPL-2.0+ headers & build systems, thus those
are considered issued from GPL-2.0+ source code.
The tools used to sign & package those binary files are delivered in binary format
for Intel x86-64 and Python 2.x only.
A collection of pre-built with the corresponding Amlogic binaries for the common
commercially available boards were collected in the https://github.com/LibreELEC/amlogic-boot-fip
repository.
Using this collection for a commercially available board is very easy.
Here considering the Libre Computer AML-S905X-CC, which codename is `lepotato`:
.. code-block:: bash
$ git clone https://github.com/LibreELEC/amlogic-boot-fip --depth=1
$ cd amlogic-boot-fip
$ mkdir my-output-dir
$ ./build-fip.sh lepotato /path/to/u-boot/u-boot.bin my-output-dir
and then write the image to SD with:
.. code-block:: bash
$ DEV=/dev/your_sd_device
$ dd if=my-output-dir/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=512 skip=1 seek=1
$ dd if=my-output-dir/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=1 count=444

View file

@ -34,6 +34,8 @@ U-Boot compilation
Image creation Image creation
-------------- --------------
For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `radxa-zero`
Amlogic does not provide sources for the firmware and for tools needed Amlogic does not provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from to create the bootloader image, so it is necessary to obtain them from
git trees published by the board vendor: git trees published by the board vendor:

View file

@ -31,6 +31,8 @@ U-Boot compilation
Image creation Image creation
-------------- --------------
For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `s400`
Amlogic doesn't provide sources for the firmware and for tools needed Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor: the git tree published by the board vendor:

View file

@ -27,6 +27,8 @@ U-Boot compilation
Image creation Image creation
-------------- --------------
For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `sei510`
Amlogic doesn't provide sources for the firmware and for tools needed Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor: the git tree published by the board vendor:

View file

@ -29,6 +29,8 @@ U-Boot compilation
Image creation Image creation
-------------- --------------
For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `sei610`
Amlogic doesn't provide sources for the firmware and for tools needed Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor: the git tree published by the board vendor:

View file

@ -32,6 +32,8 @@ U-Boot compilation
Image creation Image creation
-------------- --------------
For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `u200`
Amlogic doesn't provide sources for the firmware and for tools needed Amlogic doesn't provide sources for the firmware and for tools needed
to create the bootloader image, so it is necessary to obtain them from to create the bootloader image, so it is necessary to obtain them from
the git tree published by the board vendor: the git tree published by the board vendor:

View file

@ -29,6 +29,8 @@ U-Boot compilation
Image creation Image creation
-------------- --------------
For simplified usage, pleaser refer to :doc:`pre-generated-fip` with codename `wetek-core2`
Amlogic does not provide sources for the firmware or the tools needed Amlogic does not provide sources for the firmware or the tools needed
to create the bootloader image, and WeTek has not publicly shared the to create the bootloader image, and WeTek has not publicly shared the
precompiled FIP binaries. However the public Khadas VIM2 sources also precompiled FIP binaries. However the public Khadas VIM2 sources also

View file

@ -0,0 +1,10 @@
.. SPDX-License-Identifier: GPL-2.0+
.. Copyright (C) 2022 Matthias Brugger <mbrugger@suse.com>
Broadcom
========
.. toctree::
:maxdepth: 2
raspberrypi

View file

@ -0,0 +1,54 @@
.. SPDX-License-Identifier: GPL-2.0+
.. Copyright (C) 2022 Matthias Brugger <mbrugger@suse.com>
Raspberry Pi
============
About this
----------
This document describes the information about Raspberry Pi boards
and it's usage steps.
Raspberry Pi boards
-------------------
List of the supported Rasbperry Pi boards and the corresponding defconfig files:
32 bit
^^^^^^
* rpi_defconfig
- Raspberry Pi
* rpi_0_w_defconfig
- Raspberry Pi 1
- Raspberry Pi zero
* rpi_2_defconfig
- Raspberry Pi 2
* rpi_3_32b_defconfig
- Raspberry Pi 3b
* rpi_4_32b_defconfig
- Raspberry Pi 4b
64 bit
^^^^^^
* rpi_3_defconfig
- Raspberry Pi 3b
* rpi_3_b_plus_defconfig
- Raspberry Pi 3b+
* rpi_4_defconfig
- Raspberry Pi 4b
* rpi_arm64_defconfig
- Raspberry Pi 3b
- Raspberry Pi 3b+
- Raspberry Pi 4b
- Raspberry Pi 400
- Raspberry Pi CM 3
- Raspberry Pi CM 3+
- Raspberry Pi CM 4
- Raspberry Pi zero 2 w
rpi_arm64_defconfig uses the device-tree provided by the firmware instead of
the embedded one. It allows to use the same U-Boot binary to boot different
boards.

View file

@ -14,6 +14,7 @@ Board-specific doc
apple/index apple/index
armltd/index armltd/index
atmel/index atmel/index
broadcom/index
congatec/index congatec/index
coreboot/index coreboot/index
emulation/index emulation/index

View file

@ -160,3 +160,60 @@ UBIFS support add following lines into file ``configs/nokia_rx51_defconfig``::
CONFIG_CMD_UBIFS=y CONFIG_CMD_UBIFS=y
CONFIG_MTD_UBI_FASTMAP=y CONFIG_MTD_UBI_FASTMAP=y
CONFIG_MTD_UBI_FASTMAP_AUTOCONVERT=1 CONFIG_MTD_UBI_FASTMAP_AUTOCONVERT=1
Run in QEMU
-----------
Download and compile Linaro version of qemu which contains ``n900`` qemu
machine. Source code is available in qemu-linaro git repository and the
last working version is at commit 8f8d8e0796efe1a6f34cdd83fb798f3c41217ec1.
Use following commands to compile ``qemu-system-arm`` binary with ``n900``
qemu machine support:
.. code-block:: bash
git clone https://git.linaro.org/qemu/qemu-linaro.git
cd qemu-linaro
git checkout 8f8d8e0796efe1a6f34cdd83fb798f3c41217ec1
./configure --enable-system --target-list=arm-softmmu --disable-werror
make -j4
cd ..
ln -s qemu-linaro/arm-softmmu/qemu-system-arm .
Using ``n900`` qemu machine requires proprietary Nokia qemu ``qflasher`` tool
(in reality it is just generator of qemu MTD images) with first stage images
(``xloader-qemu.bin`` and ``secondary-qemu.bin``), similar what is required
on the real HW. License of flasher and images allows non-commercial
redistribution and it is available at maemo.org website:
.. code-block:: bash
wget -c http://repository.maemo.org/qemu-n900/qemu-n900.tar.gz
tar -xf qemu-n900.tar.gz
To generate qemu bootable MTD image ``mtd.img`` from U-Boot binary
``u-boot.bin`` and unpacked first stage images, run following command:
.. code-block:: bash
./qflasher -v -x xloader-qemu.bin -s secondary-qemu.bin -k u-boot.bin -m rx51 -o mtd.img
Instead of ``u-boot.bin`` binary it is possible to also used combined
U-Boot + kernel binary ``combined.bin``.
Finally, to boot ``mtd.img`` with graphics display and keyboard with optional
serial console on current terminal, run:
.. code-block:: bash
./qemu-system-arm -M n900 -mtdblock mtd.img -serial /dev/tty
Additionally it is possible to emulate also eMMC and uSD card by appending
qemu ``-sd`` arguments:
.. code-block:: bash
./qemu-system-arm -M n900 -mtdblock mtd.img -sd emmc.img -sd sd.img -serial /dev/tty
For more examples, look into the ``test/nokia_rx51_test.sh`` CI testing script.

View file

@ -105,7 +105,7 @@ The UEFI specification[1] defines a secure way of executing UEFI images
by verifying a signature (or message digest) of image with certificates. by verifying a signature (or message digest) of image with certificates.
This feature on U-Boot is enabled with:: This feature on U-Boot is enabled with::
CONFIG_UEFI_SECURE_BOOT=y CONFIG_EFI_SECURE_BOOT=y
To make the boot sequence safe, you need to establish a chain of trust; To make the boot sequence safe, you need to establish a chain of trust;
In UEFI secure boot the chain trust is defined by the following UEFI variables In UEFI secure boot the chain trust is defined by the following UEFI variables

View file

@ -260,6 +260,8 @@ extern const efi_guid_t efi_block_io_guid;
extern const efi_guid_t efi_global_variable_guid; extern const efi_guid_t efi_global_variable_guid;
extern const efi_guid_t efi_guid_console_control; extern const efi_guid_t efi_guid_console_control;
extern const efi_guid_t efi_guid_device_path; extern const efi_guid_t efi_guid_device_path;
/* GUID of the EFI system partition */
extern const efi_guid_t efi_system_partition_guid;
/* GUID of the EFI_DRIVER_BINDING_PROTOCOL */ /* GUID of the EFI_DRIVER_BINDING_PROTOCOL */
extern const efi_guid_t efi_guid_driver_binding_protocol; extern const efi_guid_t efi_guid_driver_binding_protocol;
/* event group ExitBootServices() invoked */ /* event group ExitBootServices() invoked */
@ -539,8 +541,6 @@ efi_status_t tcg2_measure_pe_image(void *efi, u64 efi_size,
int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc, int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc,
const char *if_typename, int diskid, const char *if_typename, int diskid,
const char *pdevname); const char *pdevname);
/* Check if it is EFI system partition */
bool efi_disk_is_system_part(efi_handle_t handle);
/* Called by bootefi to make GOP (graphical) interface available */ /* Called by bootefi to make GOP (graphical) interface available */
efi_status_t efi_gop_register(void); efi_status_t efi_gop_register(void);
/* Called by bootefi to make the network interface available */ /* Called by bootefi to make the network interface available */
@ -725,12 +725,14 @@ extern void *efi_bounce_buffer;
#define EFI_LOADER_BOUNCE_BUFFER_SIZE (64 * 1024 * 1024) #define EFI_LOADER_BOUNCE_BUFFER_SIZE (64 * 1024 * 1024)
#endif #endif
/* shorten device path */
struct efi_device_path *efi_dp_shorten(struct efi_device_path *dp);
struct efi_device_path *efi_dp_next(const struct efi_device_path *dp); struct efi_device_path *efi_dp_next(const struct efi_device_path *dp);
int efi_dp_match(const struct efi_device_path *a, int efi_dp_match(const struct efi_device_path *a,
const struct efi_device_path *b); const struct efi_device_path *b);
struct efi_object *efi_dp_find_obj(struct efi_device_path *dp, efi_handle_t efi_dp_find_obj(struct efi_device_path *dp,
struct efi_device_path **rem); const efi_guid_t *guid,
struct efi_device_path **rem);
/* get size of the first device path instance excluding end node */ /* get size of the first device path instance excluding end node */
efi_uintn_t efi_dp_instance_size(const struct efi_device_path *dp); efi_uintn_t efi_dp_instance_size(const struct efi_device_path *dp);
/* size of multi-instance device path excluding end node */ /* size of multi-instance device path excluding end node */

View file

@ -14,12 +14,24 @@ CFLAGS_efi_boottime.o += \
-DFW_PATCHLEVEL="0x$(PATCHLEVEL)" -DFW_PATCHLEVEL="0x$(PATCHLEVEL)"
CFLAGS_helloworld.o := $(CFLAGS_EFI) -Os -ffreestanding CFLAGS_helloworld.o := $(CFLAGS_EFI) -Os -ffreestanding
CFLAGS_REMOVE_helloworld.o := $(CFLAGS_NON_EFI) CFLAGS_REMOVE_helloworld.o := $(CFLAGS_NON_EFI)
CFLAGS_dtbdump.o := $(CFLAGS_EFI) -Os -ffreestanding
CFLAGS_REMOVE_dtbdump.o := $(CFLAGS_NON_EFI)
CFLAGS_initrddump_exit.o := $(CFLAGS_EFI) -Os -ffreestanding
CFLAGS_REMOVE_initrddump.o := $(CFLAGS_NON_EFI)
ifneq ($(CONFIG_CMD_BOOTEFI_HELLO_COMPILE),) ifneq ($(CONFIG_CMD_BOOTEFI_HELLO_COMPILE),)
always += helloworld.efi always += helloworld.efi
targets += helloworld.o targets += helloworld.o
endif endif
ifeq ($(CONFIG_GENERATE_ACPI_TABLE),)
always += dtbdump.efi
endif
ifdef CONFIG_EFI_LOAD_FILE2_INITRD
always += initrddump.efi
endif
obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o
obj-$(CONFIG_CMD_BOOTEFI_BOOTMGR) += efi_bootmgr.o obj-$(CONFIG_CMD_BOOTEFI_BOOTMGR) += efi_bootmgr.o
obj-y += efi_boottime.o obj-y += efi_boottime.o

View file

@ -1750,7 +1750,7 @@ efi_status_t efi_setup_loaded_image(struct efi_device_path *device_path,
info->system_table = &systab; info->system_table = &systab;
if (device_path) { if (device_path) {
info->device_handle = efi_dp_find_obj(device_path, NULL); info->device_handle = efi_dp_find_obj(device_path, NULL, NULL);
dp = efi_dp_append(device_path, file_path); dp = efi_dp_append(device_path, file_path);
if (!dp) { if (!dp) {
@ -1940,7 +1940,7 @@ efi_status_t efi_load_image_from_path(bool boot_policy,
{ {
efi_handle_t device; efi_handle_t device;
efi_status_t ret; efi_status_t ret;
struct efi_device_path *dp; struct efi_device_path *dp, *rem;
struct efi_load_file_protocol *load_file_protocol = NULL; struct efi_load_file_protocol *load_file_protocol = NULL;
efi_uintn_t buffer_size; efi_uintn_t buffer_size;
uint64_t addr, pages; uint64_t addr, pages;
@ -1951,18 +1951,18 @@ efi_status_t efi_load_image_from_path(bool boot_policy,
*size = 0; *size = 0;
dp = file_path; dp = file_path;
ret = EFI_CALL(efi_locate_device_path( device = efi_dp_find_obj(dp, NULL, &rem);
&efi_simple_file_system_protocol_guid, &dp, &device)); ret = efi_search_protocol(device, &efi_simple_file_system_protocol_guid,
NULL);
if (ret == EFI_SUCCESS) if (ret == EFI_SUCCESS)
return efi_load_image_from_file(file_path, buffer, size); return efi_load_image_from_file(file_path, buffer, size);
ret = EFI_CALL(efi_locate_device_path( ret = efi_search_protocol(device, &efi_guid_load_file_protocol, NULL);
&efi_guid_load_file_protocol, &dp, &device));
if (ret == EFI_SUCCESS) { if (ret == EFI_SUCCESS) {
guid = &efi_guid_load_file_protocol; guid = &efi_guid_load_file_protocol;
} else if (!boot_policy) { } else if (!boot_policy) {
guid = &efi_guid_load_file2_protocol; guid = &efi_guid_load_file2_protocol;
ret = EFI_CALL(efi_locate_device_path(guid, &dp, &device)); ret = efi_search_protocol(device, guid, NULL);
} }
if (ret != EFI_SUCCESS) if (ret != EFI_SUCCESS)
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
@ -1971,9 +1971,9 @@ efi_status_t efi_load_image_from_path(bool boot_policy,
if (ret != EFI_SUCCESS) if (ret != EFI_SUCCESS)
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
buffer_size = 0; buffer_size = 0;
ret = load_file_protocol->load_file(load_file_protocol, dp, ret = EFI_CALL(load_file_protocol->load_file(
boot_policy, &buffer_size, load_file_protocol, rem, boot_policy,
NULL); &buffer_size, NULL));
if (ret != EFI_BUFFER_TOO_SMALL) if (ret != EFI_BUFFER_TOO_SMALL)
goto out; goto out;
pages = efi_size_in_pages(buffer_size); pages = efi_size_in_pages(buffer_size);
@ -1984,7 +1984,7 @@ efi_status_t efi_load_image_from_path(bool boot_policy,
goto out; goto out;
} }
ret = EFI_CALL(load_file_protocol->load_file( ret = EFI_CALL(load_file_protocol->load_file(
load_file_protocol, dp, boot_policy, load_file_protocol, rem, boot_policy,
&buffer_size, (void *)(uintptr_t)addr)); &buffer_size, (void *)(uintptr_t)addr));
if (ret != EFI_SUCCESS) if (ret != EFI_SUCCESS)
efi_free_pages(addr, pages); efi_free_pages(addr, pages);

View file

@ -669,22 +669,29 @@ static efi_status_t get_dp_device(u16 *boot_var,
/** /**
* device_is_present_and_system_part - check if a device exists * device_is_present_and_system_part - check if a device exists
* @dp Device path
* *
* Check if a device pointed to by the device path, @dp, exists and is * Check if a device pointed to by the device path, @dp, exists and is
* located in UEFI system partition. * located in UEFI system partition.
* *
* @dp device path
* Return: true - yes, false - no * Return: true - yes, false - no
*/ */
static bool device_is_present_and_system_part(struct efi_device_path *dp) static bool device_is_present_and_system_part(struct efi_device_path *dp)
{ {
efi_handle_t handle; efi_handle_t handle;
struct efi_device_path *rem;
handle = efi_dp_find_obj(dp, NULL); /* Check device exists */
handle = efi_dp_find_obj(dp, NULL, NULL);
if (!handle) if (!handle)
return false; return false;
return efi_disk_is_system_part(handle); /* Check device is on system partition */
handle = efi_dp_find_obj(dp, &efi_system_partition_guid, &rem);
if (!handle)
return false;
return true;
} }
/** /**

View file

@ -122,20 +122,25 @@ int efi_dp_match(const struct efi_device_path *a,
} }
} }
/* /**
* efi_dp_shorten() - shorten device-path
*
* We can have device paths that start with a USB WWID or a USB Class node, * We can have device paths that start with a USB WWID or a USB Class node,
* and a few other cases which don't encode the full device path with bus * and a few other cases which don't encode the full device path with bus
* hierarchy: * hierarchy:
* *
* - MESSAGING:USB_WWID * * MESSAGING:USB_WWID
* - MESSAGING:USB_CLASS * * MESSAGING:USB_CLASS
* - MEDIA:FILE_PATH * * MEDIA:FILE_PATH
* - MEDIA:HARD_DRIVE * * MEDIA:HARD_DRIVE
* - MESSAGING:URI * * MESSAGING:URI
* *
* See UEFI spec (section 3.1.2, about short-form device-paths) * See UEFI spec (section 3.1.2, about short-form device-paths)
*
* @dp: original devie-path
* @Return: shortened device-path or NULL
*/ */
static struct efi_device_path *shorten_path(struct efi_device_path *dp) struct efi_device_path *efi_dp_shorten(struct efi_device_path *dp)
{ {
while (dp) { while (dp) {
/* /*
@ -154,69 +159,90 @@ static struct efi_device_path *shorten_path(struct efi_device_path *dp)
return dp; return dp;
} }
static struct efi_object *find_obj(struct efi_device_path *dp, bool short_path, /**
struct efi_device_path **rem) * find_handle() - find handle by device path and installed protocol
*
* If @rem is provided, the handle with the longest partial match is returned.
*
* @dp: device path to search
* @guid: GUID of protocol that must be installed on path or NULL
* @short_path: use short form device path for matching
* @rem: pointer to receive remaining device path
* Return: matching handle
*/
static efi_handle_t find_handle(struct efi_device_path *dp,
const efi_guid_t *guid, bool short_path,
struct efi_device_path **rem)
{ {
struct efi_object *efiobj; efi_handle_t handle, best_handle = NULL;
efi_uintn_t dp_size = efi_dp_instance_size(dp); efi_uintn_t len, best_len = 0;
list_for_each_entry(efiobj, &efi_obj_list, link) { len = efi_dp_instance_size(dp);
list_for_each_entry(handle, &efi_obj_list, link) {
struct efi_handler *handler; struct efi_handler *handler;
struct efi_device_path *obj_dp; struct efi_device_path *dp_current;
efi_uintn_t len_current;
efi_status_t ret; efi_status_t ret;
ret = efi_search_protocol(efiobj, if (guid) {
&efi_guid_device_path, &handler); ret = efi_search_protocol(handle, guid, &handler);
if (ret != EFI_SUCCESS)
continue;
}
ret = efi_search_protocol(handle, &efi_guid_device_path,
&handler);
if (ret != EFI_SUCCESS) if (ret != EFI_SUCCESS)
continue; continue;
obj_dp = handler->protocol_interface; dp_current = handler->protocol_interface;
if (short_path) {
do { dp_current = efi_dp_shorten(dp_current);
if (efi_dp_match(dp, obj_dp) == 0) { if (!dp_current)
if (rem) { continue;
/* }
* Allow partial matches, but inform len_current = efi_dp_instance_size(dp_current);
* the caller. if (rem) {
*/ if (len_current > len)
*rem = ((void *)dp) + continue;
efi_dp_instance_size(obj_dp); } else {
return efiobj; if (len_current != len)
} else { continue;
/* Only return on exact matches */ }
if (efi_dp_instance_size(obj_dp) == if (memcmp(dp_current, dp, len_current))
dp_size) continue;
return efiobj; if (!rem)
} return handle;
} if (len_current > best_len) {
best_len = len_current;
obj_dp = shorten_path(efi_dp_next(obj_dp)); best_handle = handle;
} while (short_path && obj_dp); *rem = (void*)((u8 *)dp + len_current);
}
} }
return best_handle;
return NULL;
} }
/* /**
* Find an efiobj from device-path, if 'rem' is not NULL, returns the * efi_dp_find_obj() - find handle by device path
* remaining part of the device path after the matched object. *
* If @rem is provided, the handle with the longest partial match is returned.
*
* @dp: device path to search
* @guid: GUID of protocol that must be installed on path or NULL
* @rem: pointer to receive remaining device path
* Return: matching handle
*/ */
struct efi_object *efi_dp_find_obj(struct efi_device_path *dp, efi_handle_t efi_dp_find_obj(struct efi_device_path *dp,
struct efi_device_path **rem) const efi_guid_t *guid,
struct efi_device_path **rem)
{ {
struct efi_object *efiobj; efi_handle_t handle;
/* Search for an exact match first */ handle = find_handle(dp, guid, false, rem);
efiobj = find_obj(dp, false, NULL); if (!handle)
/* Match short form device path */
handle = find_handle(dp, guid, true, rem);
/* Then for a fuzzy match */ return handle;
if (!efiobj)
efiobj = find_obj(dp, false, rem);
/* And now for a fuzzy short match */
if (!efiobj)
efiobj = find_obj(dp, true, rem);
return efiobj;
} }
/* /*

View file

@ -302,7 +302,7 @@ efi_fs_from_path(struct efi_device_path *full_path)
efi_free_pool(file_path); efi_free_pool(file_path);
/* Get the EFI object for the partition */ /* Get the EFI object for the partition */
efiobj = efi_dp_find_obj(device_path, NULL); efiobj = efi_dp_find_obj(device_path, NULL, NULL);
efi_free_pool(device_path); efi_free_pool(device_path);
if (!efiobj) if (!efiobj)
return NULL; return NULL;
@ -587,32 +587,3 @@ efi_status_t efi_disk_register(void)
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/**
* efi_disk_is_system_part() - check if handle refers to an EFI system partition
*
* @handle: handle of partition
*
* Return: true if handle refers to an EFI system partition
*/
bool efi_disk_is_system_part(efi_handle_t handle)
{
struct efi_handler *handler;
struct efi_disk_obj *diskobj;
struct disk_partition info;
efi_status_t ret;
int r;
/* check if this is a block device */
ret = efi_search_protocol(handle, &efi_block_io_guid, &handler);
if (ret != EFI_SUCCESS)
return false;
diskobj = container_of(handle, struct efi_disk_obj, header);
r = part_get_info(diskobj->desc, diskobj->part, &info);
if (r)
return false;
return !!(info.bootable & PART_EFI_SYSTEM_PARTITION);
}

View file

@ -368,7 +368,7 @@ efi_status_t efi_get_variable_int(const u16 *variable_name,
efi_uintn_t name_size; efi_uintn_t name_size;
efi_uintn_t tmp_dsize; efi_uintn_t tmp_dsize;
u8 *comm_buf = NULL; u8 *comm_buf = NULL;
efi_status_t ret; efi_status_t ret, tmp;
if (!variable_name || !vendor || !data_size) { if (!variable_name || !vendor || !data_size) {
ret = EFI_INVALID_PARAMETER; ret = EFI_INVALID_PARAMETER;
@ -407,23 +407,32 @@ efi_status_t efi_get_variable_int(const u16 *variable_name,
/* Communicate */ /* Communicate */
ret = mm_communicate(comm_buf, payload_size); ret = mm_communicate(comm_buf, payload_size);
if (ret == EFI_SUCCESS || ret == EFI_BUFFER_TOO_SMALL) { if (ret != EFI_SUCCESS && ret != EFI_BUFFER_TOO_SMALL)
/* Update with reported data size for trimmed case */
*data_size = var_acc->data_size;
}
if (ret != EFI_SUCCESS)
goto out;
ret = get_property_int(variable_name, name_size, vendor, &var_property);
if (ret != EFI_SUCCESS)
goto out; goto out;
/* Update with reported data size for trimmed case */
*data_size = var_acc->data_size;
/*
* UEFI > 2.7 needs the attributes set even if the buffer is
* smaller
*/
if (attributes) { if (attributes) {
tmp = get_property_int(variable_name, name_size, vendor,
&var_property);
if (tmp != EFI_SUCCESS) {
ret = tmp;
goto out;
}
*attributes = var_acc->attr; *attributes = var_acc->attr;
if (var_property.property & VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY) if (var_property.property &
VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY)
*attributes |= EFI_VARIABLE_READ_ONLY; *attributes |= EFI_VARIABLE_READ_ONLY;
} }
/* return if ret is EFI_BUFFER_TOO_SMALL */
if (ret != EFI_SUCCESS)
goto out;
if (data) if (data)
memcpy(data, (u8 *)var_acc->name + var_acc->name_size, memcpy(data, (u8 *)var_acc->name + var_acc->name_size,
var_acc->data_size); var_acc->data_size);

View file

@ -420,7 +420,7 @@ efi_status_t EFIAPI efi_main(efi_handle_t image_handle,
cout->set_attribute(cout, EFI_LIGHTBLUE | EFI_BACKGROUND_BLACK); cout->set_attribute(cout, EFI_LIGHTBLUE | EFI_BACKGROUND_BLACK);
cout->clear_screen(cout); cout->clear_screen(cout);
cout->set_attribute(cout, EFI_WHITE | EFI_BACKGROUND_BLACK); cout->set_attribute(cout, EFI_WHITE | EFI_BACKGROUND_BLACK);
print(u"INITRD Dump\r\n========\r\n\r\n"); print(u"INITRD Dump\r\n===========\r\n\r\n");
cout->set_attribute(cout, EFI_LIGHTBLUE | EFI_BACKGROUND_BLACK); cout->set_attribute(cout, EFI_LIGHTBLUE | EFI_BACKGROUND_BLACK);
for (;;) { for (;;) {

View file

@ -8,16 +8,12 @@
asflags-y += -DHOST_ARCH="$(HOST_ARCH)" asflags-y += -DHOST_ARCH="$(HOST_ARCH)"
ccflags-y += -DHOST_ARCH="$(HOST_ARCH)" ccflags-y += -DHOST_ARCH="$(HOST_ARCH)"
CFLAGS_dtbdump.o := $(CFLAGS_EFI) -Os -ffreestanding
CFLAGS_REMOVE_dtbdump.o := $(CFLAGS_NON_EFI)
CFLAGS_efi_selftest_miniapp_exception.o := $(CFLAGS_EFI) -Os -ffreestanding CFLAGS_efi_selftest_miniapp_exception.o := $(CFLAGS_EFI) -Os -ffreestanding
CFLAGS_REMOVE_efi_selftest_miniapp_exception.o := $(CFLAGS_NON_EFI) CFLAGS_REMOVE_efi_selftest_miniapp_exception.o := $(CFLAGS_NON_EFI)
CFLAGS_efi_selftest_miniapp_exit.o := $(CFLAGS_EFI) -Os -ffreestanding CFLAGS_efi_selftest_miniapp_exit.o := $(CFLAGS_EFI) -Os -ffreestanding
CFLAGS_REMOVE_efi_selftest_miniapp_exit.o := $(CFLAGS_NON_EFI) CFLAGS_REMOVE_efi_selftest_miniapp_exit.o := $(CFLAGS_NON_EFI)
CFLAGS_efi_selftest_miniapp_return.o := $(CFLAGS_EFI) -Os -ffreestanding CFLAGS_efi_selftest_miniapp_return.o := $(CFLAGS_EFI) -Os -ffreestanding
CFLAGS_REMOVE_efi_selftest_miniapp_return.o := $(CFLAGS_NON_EFI) CFLAGS_REMOVE_efi_selftest_miniapp_return.o := $(CFLAGS_NON_EFI)
CFLAGS_initrddump_exit.o := $(CFLAGS_EFI) -Os -ffreestanding
CFLAGS_REMOVE_initrddump.o := $(CFLAGS_NON_EFI)
obj-y += \ obj-y += \
efi_selftest.o \ efi_selftest.o \
@ -83,14 +79,6 @@ efi_selftest_miniapp_exception.efi \
efi_selftest_miniapp_exit.efi \ efi_selftest_miniapp_exit.efi \
efi_selftest_miniapp_return.efi efi_selftest_miniapp_return.efi
ifeq ($(CONFIG_GENERATE_ACPI_TABLE),)
always += dtbdump.efi
endif
ifdef CONFIG_EFI_LOAD_FILE2_INITRD
always += initrddump.efi
endif
$(obj)/efi_miniapp_file_image_exception.h: $(obj)/efi_selftest_miniapp_exception.efi $(obj)/efi_miniapp_file_image_exception.h: $(obj)/efi_selftest_miniapp_exception.efi
$(obj)/../../tools/file2include $(obj)/efi_selftest_miniapp_exception.efi > \ $(obj)/../../tools/file2include $(obj)/efi_selftest_miniapp_exception.efi > \
$(obj)/efi_miniapp_file_image_exception.h $(obj)/efi_miniapp_file_image_exception.h

View file

@ -37,7 +37,7 @@ migration = '''===================== WARNING ======================
This board does not use CONFIG_DM. CONFIG_DM will be This board does not use CONFIG_DM. CONFIG_DM will be
compulsory starting with the v2020.01 release. compulsory starting with the v2020.01 release.
Failure to update may result in board removal. Failure to update may result in board removal.
See doc/driver-model/migration.rst for more info. See doc/develop/driver-model/migration.rst for more info.
==================================================== ====================================================
''' '''