From 1840ce5f3860673fd935c458148e9ffd84f62a61 Mon Sep 17 00:00:00 2001 From: Johannes Krottmayer Date: Tue, 1 Mar 2022 04:49:50 +0100 Subject: Makefile: Fix doc path in warning message Fix documentation path in warning message about deprecated device driver. Signed-off-by: Johannes Krottmayer Reviewed-by: Heinrich Schuchardt --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8e2441e..14fd286 100644 --- a/Makefile +++ b/Makefile @@ -1080,7 +1080,7 @@ define deprecated echo >&2 "for $(2)). Please update the board to use"; \ echo >&2 "$(firstword $(1)) before the $(3) release. Failure to"; \ 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 "===================================================="; \ 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 "compulsory starting with the v2020.01 release." @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 "====================================================" endif $(call deprecated,CONFIG_WDT,DM watchdog,v2019.10,\ -- cgit v1.1 From 17b8cb635371dc99b1cca26f2a97527c63bdc8a4 Mon Sep 17 00:00:00 2001 From: Johannes Krottmayer Date: Tue, 1 Mar 2022 04:49:51 +0100 Subject: tools: buildman: Fix doc path in warning message Fix documentation path in deprecated warning message about device driver. Signed-off-by: Johannes Krottmayer Reviewed-by: Heinrich Schuchardt --- tools/buildman/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/buildman/test.py b/tools/buildman/test.py index 714bb3e..2728743 100644 --- a/tools/buildman/test.py +++ b/tools/buildman/test.py @@ -37,7 +37,7 @@ migration = '''===================== WARNING ====================== This board does not use CONFIG_DM. CONFIG_DM will be compulsory starting with the v2020.01 release. 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. ==================================================== ''' -- cgit v1.1 From 23f20ef77cb9f9777d05ddc88800d1d38d05202c Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Wed, 2 Mar 2022 10:42:21 +0100 Subject: doc: board: amlogic-p20x: fix FIP generation doc The doc used GXL instructions, which couldn't work on GXBB SoCs. Signed-off-by: Neil Armstrong --- doc/board/amlogic/p200.rst | 57 +++++++++++++++++++++------------------------- doc/board/amlogic/p201.rst | 57 +++++++++++++++++++++------------------------- 2 files changed, 52 insertions(+), 62 deletions(-) diff --git a/doc/board/amlogic/p200.rst b/doc/board/amlogic/p200.rst index c3d6441..1c84f1c 100644 --- a/doc/board/amlogic/p200.rst +++ b/doc/board/amlogic/p200.rst @@ -54,44 +54,39 @@ Go back to mainline U-boot source tree then : $ mkdir fip - $ cp $FIPDIR/gxl/bl2.bin fip/ - $ cp $FIPDIR/gxl/acs.bin fip/ - $ cp $FIPDIR/gxl/bl21.bin fip/ - $ cp $FIPDIR/gxl/bl30.bin fip/ - $ cp $FIPDIR/gxl/bl301.bin fip/ - $ cp $FIPDIR/gxl/bl31.img fip/ + $ cp $FIPDIR/gxb/bl2.bin fip/ + $ cp $FIPDIR/gxb/acs.bin fip/ + $ cp $FIPDIR/gxb/bl21.bin fip/ + $ cp $FIPDIR/gxb/bl30.bin fip/ + $ cp $FIPDIR/gxb/bl301.bin fip/ + $ cp $FIPDIR/gxb/bl31.img fip/ $ cp u-boot.bin fip/bl33.bin $ $FIPDIR/blx_fix.sh \ fip/bl30.bin \ - fip/zero_tmp \ - fip/bl30_zero.bin \ - fip/bl301.bin \ - fip/bl301_zero.bin \ - fip/bl30_new.bin \ - bl30 + fip/zero_tmp \ + fip/bl30_zero.bin \ + fip/bl301.bin \ + fip/bl301_zero.bin \ + fip/bl30_new.bin \ + 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 \ - fip/bl2_acs.bin \ - fip/zero_tmp \ - fip/bl2_zero.bin \ - fip/bl21.bin \ - fip/bl21_zero.bin \ - fip/bl2_new.bin \ - bl2 - - $ $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl30_new.bin - $ $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl31.img - $ $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl33.bin - $ $FIPDIR/gxl/aml_encrypt_gxl --bl2sig --input fip/bl2_new.bin --output fip/bl2.n.bin.sig - $ $FIPDIR/gxl/aml_encrypt_gxl --bootmk \ - --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 + fip/bl2_acs.bin \ + fip/zero_tmp \ + fip/bl2_zero.bin \ + fip/bl21.bin \ + fip/bl21_zero.bin \ + fip/bl2_new.bin \ + bl2 + + $ $FIPDIR/fip_create --bl30 fip/bl30_new.bin --bl31 fip/bl31.img --bl33 fip/bl33.bin fip/fip.bin + + $ cat fip/bl2_new.bin fip/fip.bin >fip/boot_new.bin + + $ $FIPDIR/gxb/aml_encrypt_gxb --bootsig --input fip/boot_new.bin --output fip/u-boot.bin and then write the image to SD with: diff --git a/doc/board/amlogic/p201.rst b/doc/board/amlogic/p201.rst index 06da933..a3d451c 100644 --- a/doc/board/amlogic/p201.rst +++ b/doc/board/amlogic/p201.rst @@ -54,44 +54,39 @@ Go back to mainline U-boot source tree then : $ mkdir fip - $ cp $FIPDIR/gxl/bl2.bin fip/ - $ cp $FIPDIR/gxl/acs.bin fip/ - $ cp $FIPDIR/gxl/bl21.bin fip/ - $ cp $FIPDIR/gxl/bl30.bin fip/ - $ cp $FIPDIR/gxl/bl301.bin fip/ - $ cp $FIPDIR/gxl/bl31.img fip/ + $ cp $FIPDIR/gxb/bl2.bin fip/ + $ cp $FIPDIR/gxb/acs.bin fip/ + $ cp $FIPDIR/gxb/bl21.bin fip/ + $ cp $FIPDIR/gxb/bl30.bin fip/ + $ cp $FIPDIR/gxb/bl301.bin fip/ + $ cp $FIPDIR/gxb/bl31.img fip/ $ cp u-boot.bin fip/bl33.bin $ $FIPDIR/blx_fix.sh \ fip/bl30.bin \ - fip/zero_tmp \ - fip/bl30_zero.bin \ - fip/bl301.bin \ - fip/bl301_zero.bin \ - fip/bl30_new.bin \ - bl30 + fip/zero_tmp \ + fip/bl30_zero.bin \ + fip/bl301.bin \ + fip/bl301_zero.bin \ + fip/bl30_new.bin \ + 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 \ - fip/bl2_acs.bin \ - fip/zero_tmp \ - fip/bl2_zero.bin \ - fip/bl21.bin \ - fip/bl21_zero.bin \ - fip/bl2_new.bin \ - bl2 - - $ $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl30_new.bin - $ $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl31.img - $ $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl33.bin - $ $FIPDIR/gxl/aml_encrypt_gxl --bl2sig --input fip/bl2_new.bin --output fip/bl2.n.bin.sig - $ $FIPDIR/gxl/aml_encrypt_gxl --bootmk \ - --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 + fip/bl2_acs.bin \ + fip/zero_tmp \ + fip/bl2_zero.bin \ + fip/bl21.bin \ + fip/bl21_zero.bin \ + fip/bl2_new.bin \ + bl2 + + $ $FIPDIR/fip_create --bl30 fip/bl30_new.bin --bl31 fip/bl31.img --bl33 fip/bl33.bin fip/fip.bin + + $ cat fip/bl2_new.bin fip/fip.bin >fip/boot_new.bin + + $ $FIPDIR/gxb/aml_encrypt_gxb --bootsig --input fip/boot_new.bin --output fip/u-boot.bin and then write the image to SD with: -- cgit v1.1 From 4c60512ad961d4d8d3193d1156f6d86fa8bc3e48 Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Wed, 2 Mar 2022 10:42:22 +0100 Subject: doc: boards: amlogic: Add documentation on pre-generated FIP files It add documentation on licencing & provides links to the amlogic-boot-fip pre-built files collections. Signed-off-by: Neil Armstrong --- doc/board/amlogic/beelink-gtking.rst | 2 + doc/board/amlogic/beelink-gtkingpro.rst | 2 + doc/board/amlogic/index.rst | 8 +++ doc/board/amlogic/jethub-j100.rst | 2 + doc/board/amlogic/jethub-j80.rst | 2 + doc/board/amlogic/khadas-vim.rst | 2 + doc/board/amlogic/khadas-vim2.rst | 2 + doc/board/amlogic/khadas-vim3.rst | 2 + doc/board/amlogic/khadas-vim3l.rst | 2 + doc/board/amlogic/libretech-ac.rst | 2 + doc/board/amlogic/libretech-cc.rst | 2 + doc/board/amlogic/nanopi-k2.rst | 2 + doc/board/amlogic/odroid-c2.rst | 2 + doc/board/amlogic/odroid-c4.rst | 2 + doc/board/amlogic/odroid-n2.rst | 2 + doc/board/amlogic/p200.rst | 2 + doc/board/amlogic/p201.rst | 2 + doc/board/amlogic/p212.rst | 2 + doc/board/amlogic/pre-generated-fip.rst | 93 +++++++++++++++++++++++++++++++++ doc/board/amlogic/radxa-zero.rst | 2 + doc/board/amlogic/s400.rst | 2 + doc/board/amlogic/sei510.rst | 2 + doc/board/amlogic/sei610.rst | 2 + doc/board/amlogic/u200.rst | 2 + doc/board/amlogic/wetek-core2.rst | 2 + 25 files changed, 147 insertions(+) create mode 100644 doc/board/amlogic/pre-generated-fip.rst diff --git a/doc/board/amlogic/beelink-gtking.rst b/doc/board/amlogic/beelink-gtking.rst index 56ce2cb..2fb50c5 100644 --- a/doc/board/amlogic/beelink-gtking.rst +++ b/doc/board/amlogic/beelink-gtking.rst @@ -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 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 $ wget https://github.com/LibreELEC/amlogic-boot-fip/archive/master.zip diff --git a/doc/board/amlogic/beelink-gtkingpro.rst b/doc/board/amlogic/beelink-gtkingpro.rst index d750351..07bb04b 100644 --- a/doc/board/amlogic/beelink-gtkingpro.rst +++ b/doc/board/amlogic/beelink-gtkingpro.rst @@ -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 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 $ wget https://github.com/LibreELEC/amlogic-boot-fip/archive/master.zip diff --git a/doc/board/amlogic/index.rst b/doc/board/amlogic/index.rst index 189b1ef..9ef1440 100644 --- a/doc/board/amlogic/index.rst +++ b/doc/board/amlogic/index.rst @@ -74,6 +74,14 @@ This matrix concerns the actual source code version. | PCIe (+NVMe) | *N/A* | *N/A* | *N/A* | **Yes** | **Yes** | **Yes** | **Yes** | +-------------------------------+-----------+-----------------+--------------+-------------+------------+-------------+--------------+ +Boot Documentation +------------------ + +.. toctree:: + :maxdepth: 1 + + pre-generated-fip + Board Documentation ------------------- diff --git a/doc/board/amlogic/jethub-j100.rst b/doc/board/amlogic/jethub-j100.rst index 5860278..d54519a 100644 --- a/doc/board/amlogic/jethub-j100.rst +++ b/doc/board/amlogic/jethub-j100.rst @@ -37,6 +37,8 @@ U-Boot compilation 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 to create the bootloader image, so it is necessary to obtain binaries from the git tree published by the board vendor: diff --git a/doc/board/amlogic/jethub-j80.rst b/doc/board/amlogic/jethub-j80.rst index 6b7bdc7..f669a01 100644 --- a/doc/board/amlogic/jethub-j80.rst +++ b/doc/board/amlogic/jethub-j80.rst @@ -33,6 +33,8 @@ U-Boot compilation 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 to create the bootloader image, so it is necessary to obtain binaries from the git tree published by the board vendor: diff --git a/doc/board/amlogic/khadas-vim.rst b/doc/board/amlogic/khadas-vim.rst index bbb61c2..04025d7 100644 --- a/doc/board/amlogic/khadas-vim.rst +++ b/doc/board/amlogic/khadas-vim.rst @@ -30,6 +30,8 @@ U-Boot compilation 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 to create the bootloader image, so it is necessary to obtain them from the git tree published by the board vendor: diff --git a/doc/board/amlogic/khadas-vim2.rst b/doc/board/amlogic/khadas-vim2.rst index c57d96d..7ac3bdc 100644 --- a/doc/board/amlogic/khadas-vim2.rst +++ b/doc/board/amlogic/khadas-vim2.rst @@ -31,6 +31,8 @@ U-Boot compilation 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 to create the bootloader image, so it is necessary to obtain them from the git tree published by the board vendor: diff --git a/doc/board/amlogic/khadas-vim3.rst b/doc/board/amlogic/khadas-vim3.rst index 8b7196d..73dc32b 100644 --- a/doc/board/amlogic/khadas-vim3.rst +++ b/doc/board/amlogic/khadas-vim3.rst @@ -57,6 +57,8 @@ U-Boot compilation 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 to create the bootloader image, so it is necessary to obtain them from the git tree published by the board vendor: diff --git a/doc/board/amlogic/khadas-vim3l.rst b/doc/board/amlogic/khadas-vim3l.rst index aed8955..692ab3d 100644 --- a/doc/board/amlogic/khadas-vim3l.rst +++ b/doc/board/amlogic/khadas-vim3l.rst @@ -57,6 +57,8 @@ U-Boot compilation 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 to create the bootloader image, so it is necessary to obtain them from the git tree published by the board vendor: diff --git a/doc/board/amlogic/libretech-ac.rst b/doc/board/amlogic/libretech-ac.rst index 39bae86..7a915f9 100644 --- a/doc/board/amlogic/libretech-ac.rst +++ b/doc/board/amlogic/libretech-ac.rst @@ -30,6 +30,8 @@ U-Boot compilation 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 to create the bootloader image, so it is necessary to obtain them from the git tree published by the board vendor: diff --git a/doc/board/amlogic/libretech-cc.rst b/doc/board/amlogic/libretech-cc.rst index 94c74c5..596ce45 100644 --- a/doc/board/amlogic/libretech-cc.rst +++ b/doc/board/amlogic/libretech-cc.rst @@ -54,6 +54,8 @@ These binaries and the tools required below have been collected and prebuilt for convenience at . These 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 point to the `fip` subdirectory. diff --git a/doc/board/amlogic/nanopi-k2.rst b/doc/board/amlogic/nanopi-k2.rst index 1222ee4..76ff874 100644 --- a/doc/board/amlogic/nanopi-k2.rst +++ b/doc/board/amlogic/nanopi-k2.rst @@ -30,6 +30,8 @@ U-Boot compilation 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 to create the bootloader image, so it is necessary to obtain them from the git tree published by the board vendor: diff --git a/doc/board/amlogic/odroid-c2.rst b/doc/board/amlogic/odroid-c2.rst index 966c18b..8a1be4b 100644 --- a/doc/board/amlogic/odroid-c2.rst +++ b/doc/board/amlogic/odroid-c2.rst @@ -30,6 +30,8 @@ U-Boot compilation 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 to create the bootloader image, so it is necessary to obtain them from the git tree published by the board vendor: diff --git a/doc/board/amlogic/odroid-c4.rst b/doc/board/amlogic/odroid-c4.rst index f66d60a..b512c6a 100644 --- a/doc/board/amlogic/odroid-c4.rst +++ b/doc/board/amlogic/odroid-c4.rst @@ -34,6 +34,8 @@ U-Boot compilation 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 to create the bootloader image, so it is necessary to obtain them from the git tree published by the board vendor: diff --git a/doc/board/amlogic/odroid-n2.rst b/doc/board/amlogic/odroid-n2.rst index fe63113..7aad36e 100644 --- a/doc/board/amlogic/odroid-n2.rst +++ b/doc/board/amlogic/odroid-n2.rst @@ -29,6 +29,8 @@ U-Boot compilation 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 to create the bootloader image, so it is necessary to obtain them from the git tree published by the board vendor: diff --git a/doc/board/amlogic/p200.rst b/doc/board/amlogic/p200.rst index 1c84f1c..5e7c6b0 100644 --- a/doc/board/amlogic/p200.rst +++ b/doc/board/amlogic/p200.rst @@ -31,6 +31,8 @@ U-Boot compilation 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 to create the bootloader image, so it is necessary to obtain them from the git tree published by the board vendor: diff --git a/doc/board/amlogic/p201.rst b/doc/board/amlogic/p201.rst index a3d451c..2cd2365 100644 --- a/doc/board/amlogic/p201.rst +++ b/doc/board/amlogic/p201.rst @@ -31,6 +31,8 @@ U-Boot compilation 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 to create the bootloader image, so it is necessary to obtain them from the git tree published by the board vendor: diff --git a/doc/board/amlogic/p212.rst b/doc/board/amlogic/p212.rst index e2f3fe3..c1b73e8 100644 --- a/doc/board/amlogic/p212.rst +++ b/doc/board/amlogic/p212.rst @@ -31,6 +31,8 @@ U-Boot compilation 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 to create the bootloader image, so it is necessary to obtain them from the git tree published by the board vendor: diff --git a/doc/board/amlogic/pre-generated-fip.rst b/doc/board/amlogic/pre-generated-fip.rst new file mode 100644 index 0000000..c63ea61 --- /dev/null +++ b/doc/board/amlogic/pre-generated-fip.rst @@ -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 diff --git a/doc/board/amlogic/radxa-zero.rst b/doc/board/amlogic/radxa-zero.rst index 423403f..f5611f5 100644 --- a/doc/board/amlogic/radxa-zero.rst +++ b/doc/board/amlogic/radxa-zero.rst @@ -34,6 +34,8 @@ U-Boot compilation 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 to create the bootloader image, so it is necessary to obtain them from git trees published by the board vendor: diff --git a/doc/board/amlogic/s400.rst b/doc/board/amlogic/s400.rst index 52c7b27..c92817b 100644 --- a/doc/board/amlogic/s400.rst +++ b/doc/board/amlogic/s400.rst @@ -31,6 +31,8 @@ U-Boot compilation 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 to create the bootloader image, so it is necessary to obtain them from the git tree published by the board vendor: diff --git a/doc/board/amlogic/sei510.rst b/doc/board/amlogic/sei510.rst index 2d296b1..c55e778 100644 --- a/doc/board/amlogic/sei510.rst +++ b/doc/board/amlogic/sei510.rst @@ -27,6 +27,8 @@ U-Boot compilation 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 to create the bootloader image, so it is necessary to obtain them from the git tree published by the board vendor: diff --git a/doc/board/amlogic/sei610.rst b/doc/board/amlogic/sei610.rst index 9434e6f..2d75449 100644 --- a/doc/board/amlogic/sei610.rst +++ b/doc/board/amlogic/sei610.rst @@ -29,6 +29,8 @@ U-Boot compilation 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 to create the bootloader image, so it is necessary to obtain them from the git tree published by the board vendor: diff --git a/doc/board/amlogic/u200.rst b/doc/board/amlogic/u200.rst index 5aa3936..53213fd 100644 --- a/doc/board/amlogic/u200.rst +++ b/doc/board/amlogic/u200.rst @@ -32,6 +32,8 @@ U-Boot compilation 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 to create the bootloader image, so it is necessary to obtain them from the git tree published by the board vendor: diff --git a/doc/board/amlogic/wetek-core2.rst b/doc/board/amlogic/wetek-core2.rst index 1012079..0147d5f 100644 --- a/doc/board/amlogic/wetek-core2.rst +++ b/doc/board/amlogic/wetek-core2.rst @@ -29,6 +29,8 @@ U-Boot compilation 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 to create the bootloader image, and WeTek has not publicly shared the precompiled FIP binaries. However the public Khadas VIM2 sources also -- cgit v1.1 From aac01df4f589f31746265fd2b6399ed0a338d51d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Tue, 8 Mar 2022 18:59:56 +0100 Subject: Nokia RX-51: Update documentation about QEMU MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add section how to run U-Boot in n900 qemu machine. Signed-off-by: Pali Rohár Signed-off-by: Heinrich Schuchardt --- doc/board/nokia/rx51.rst | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/doc/board/nokia/rx51.rst b/doc/board/nokia/rx51.rst index 941f78e..061fe76 100644 --- a/doc/board/nokia/rx51.rst +++ b/doc/board/nokia/rx51.rst @@ -160,3 +160,60 @@ UBIFS support add following lines into file ``configs/nokia_rx51_defconfig``:: CONFIG_CMD_UBIFS=y CONFIG_MTD_UBI_FASTMAP=y 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. -- cgit v1.1 From 2899296e5cbbf7e28f5e43025eda74382f44f4ca Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Wed, 16 Mar 2022 12:12:16 +0100 Subject: doc: uefi: Fix reference to CONFIG_EFI_SECURE_BOOT There is no CONFIG_UEFI_SECURE_BOOT, and there was never any. Signed-off-by: Jan Kiszka Reviewed-by: Heinrich Schuchardt --- doc/develop/uefi/uefi.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst index b7bf135..fe337c8 100644 --- a/doc/develop/uefi/uefi.rst +++ b/doc/develop/uefi/uefi.rst @@ -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. 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; In UEFI secure boot the chain trust is defined by the following UEFI variables -- cgit v1.1 From bfffb9f84fdacca12b65048697383d27273d47cb Mon Sep 17 00:00:00 2001 From: Matthias Brugger Date: Mon, 14 Mar 2022 12:03:54 +0100 Subject: doc: board: raspberrypi: Add documentation Add documentation about the different configuration files for the RaspberryPi board family. Signed-off-by: Matthias Brugger Reviewed-by: Simon Glass Reviewed-by: Heinrich Schuchardt --- doc/board/broadcom/index.rst | 10 +++++++ doc/board/broadcom/raspberrypi.rst | 54 ++++++++++++++++++++++++++++++++++++++ doc/board/index.rst | 1 + 3 files changed, 65 insertions(+) create mode 100644 doc/board/broadcom/index.rst create mode 100644 doc/board/broadcom/raspberrypi.rst diff --git a/doc/board/broadcom/index.rst b/doc/board/broadcom/index.rst new file mode 100644 index 0000000..4f0e825 --- /dev/null +++ b/doc/board/broadcom/index.rst @@ -0,0 +1,10 @@ +.. SPDX-License-Identifier: GPL-2.0+ +.. Copyright (C) 2022 Matthias Brugger + +Broadcom +======== + +.. toctree:: + :maxdepth: 2 + + raspberrypi diff --git a/doc/board/broadcom/raspberrypi.rst b/doc/board/broadcom/raspberrypi.rst new file mode 100644 index 0000000..1d00b38 --- /dev/null +++ b/doc/board/broadcom/raspberrypi.rst @@ -0,0 +1,54 @@ +.. SPDX-License-Identifier: GPL-2.0+ +.. Copyright (C) 2022 Matthias Brugger + +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. diff --git a/doc/board/index.rst b/doc/board/index.rst index be9ba4d..f7bfc44 100644 --- a/doc/board/index.rst +++ b/doc/board/index.rst @@ -14,6 +14,7 @@ Board-specific doc apple/index armltd/index atmel/index + broadcom/index congatec/index coreboot/index emulation/index -- cgit v1.1 From 0832dd2900f3ec7bf2ae12866138fc0fd9970168 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Sun, 27 Feb 2022 13:18:56 +0100 Subject: efi_loader: Ignore DT when ACPI is on For targets that enable ACPI, we should not pass Device Trees into the payload. However, our distro boot logic always passes the builtin DT as an argument. To make it easy to use ACPI with distro boot, let's just ignore the DT argument to bootefi when ACPI is enabled. That way, we can successfully distro boot payloads on ACPI enabled targets. Signed-off-by: Alexander Graf Reviewed-by: Mark Kettenis Reviewed-by: Heinrich Schuchardt --- cmd/bootefi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 46eebd5..53d9f0e 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -265,8 +265,8 @@ efi_status_t efi_install_fdt(void *fdt) */ #if CONFIG_IS_ENABLED(GENERATE_ACPI_TABLE) if (fdt) { - log_err("ERROR: can't have ACPI table and device tree.\n"); - return EFI_LOAD_ERROR; + log_warning("WARNING: Can't have ACPI table and device tree - ignoring DT.\n"); + return EFI_SUCCESS; } #else bootm_headers_t img = { 0 }; -- cgit v1.1 From ff6af6eede200503c58250821d1285f94039eef7 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Wed, 16 Mar 2022 17:13:37 +0200 Subject: efi_loader: Set variable attributes when EFI_BUFFER_TOO_SMALL is returned Starting UEFI Spec 2.8 we must fill in the variable attributes when GetVariable() returns EFI_BUFFER_TOO_SMALL and Attributes is non-NULL. This code was written with 2.7 in mind so let's move the code around a bit and fill in the attributes EFI_BUFFER_TOO_SMALL is returned Signed-off-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_variable_tee.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c index 58931c4..dfef184 100644 --- a/lib/efi_loader/efi_variable_tee.c +++ b/lib/efi_loader/efi_variable_tee.c @@ -368,7 +368,7 @@ efi_status_t efi_get_variable_int(const u16 *variable_name, efi_uintn_t name_size; efi_uintn_t tmp_dsize; u8 *comm_buf = NULL; - efi_status_t ret; + efi_status_t ret, tmp; if (!variable_name || !vendor || !data_size) { ret = EFI_INVALID_PARAMETER; @@ -407,23 +407,32 @@ efi_status_t efi_get_variable_int(const u16 *variable_name, /* Communicate */ ret = mm_communicate(comm_buf, payload_size); - 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) + if (ret != EFI_SUCCESS && ret != EFI_BUFFER_TOO_SMALL) 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) { + tmp = get_property_int(variable_name, name_size, vendor, + &var_property); + if (tmp != EFI_SUCCESS) { + ret = tmp; + goto out; + } *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; } + /* return if ret is EFI_BUFFER_TOO_SMALL */ + if (ret != EFI_SUCCESS) + goto out; + if (data) memcpy(data, (u8 *)var_acc->name + var_acc->name_size, var_acc->data_size); -- cgit v1.1 From 8399488672e8717d3aa454f9f67408f96168074f Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 26 Feb 2022 12:10:10 +0100 Subject: efi_loader: export efi_dp_shorten() Rename function shorten_path() to efi_dp_shorten() and export it. Signed-off-by: Heinrich Schuchardt --- include/efi_loader.h | 3 ++- lib/efi_loader/efi_device_path.c | 21 +++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index 110d8ae..1ffcdfc 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -725,7 +725,8 @@ extern void *efi_bounce_buffer; #define EFI_LOADER_BOUNCE_BUFFER_SIZE (64 * 1024 * 1024) #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); int efi_dp_match(const struct efi_device_path *a, const struct efi_device_path *b); diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c index dc787b4..ddd5f13 100644 --- a/lib/efi_loader/efi_device_path.c +++ b/lib/efi_loader/efi_device_path.c @@ -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, * and a few other cases which don't encode the full device path with bus * hierarchy: * - * - MESSAGING:USB_WWID - * - MESSAGING:USB_CLASS - * - MEDIA:FILE_PATH - * - MEDIA:HARD_DRIVE - * - MESSAGING:URI + * * MESSAGING:USB_WWID + * * MESSAGING:USB_CLASS + * * MEDIA:FILE_PATH + * * MEDIA:HARD_DRIVE + * * MESSAGING:URI * * 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) { /* @@ -189,7 +194,7 @@ static struct efi_object *find_obj(struct efi_device_path *dp, bool short_path, } } - obj_dp = shorten_path(efi_dp_next(obj_dp)); + obj_dp = efi_dp_shorten(efi_dp_next(obj_dp)); } while (short_path && obj_dp); } -- cgit v1.1 From c409593d0853da646194b0a3d65c8b45fe7cb6d4 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 4 Mar 2022 08:20:00 +0100 Subject: efi_loader: fix efi_dp_find_obj() efi_dp_find_obj() should not return any handle with a partially matching device path but the handle with the maximum matching device path. Signed-off-by: Heinrich Schuchardt --- include/efi_loader.h | 4 +- lib/efi_loader/efi_device_path.c | 110 ++++++++++++++++++++++----------------- 2 files changed, 63 insertions(+), 51 deletions(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index 1ffcdfc..6271d40 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -730,8 +730,8 @@ 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); int efi_dp_match(const struct efi_device_path *a, const struct efi_device_path *b); -struct efi_object *efi_dp_find_obj(struct efi_device_path *dp, - struct efi_device_path **rem); +efi_handle_t efi_dp_find_obj(struct efi_device_path *dp, + struct efi_device_path **rem); /* get size of the first device path instance excluding end node */ efi_uintn_t efi_dp_instance_size(const struct efi_device_path *dp); /* size of multi-instance device path excluding end node */ diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c index ddd5f13..aeb5264 100644 --- a/lib/efi_loader/efi_device_path.c +++ b/lib/efi_loader/efi_device_path.c @@ -159,69 +159,81 @@ struct efi_device_path *efi_dp_shorten(struct efi_device_path *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 + * + * If @rem is provided, the handle with the longest partial match is returned. + * + * @dp: device path to search + * @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, bool short_path, + struct efi_device_path **rem) { - struct efi_object *efiobj; - efi_uintn_t dp_size = efi_dp_instance_size(dp); + efi_handle_t handle, best_handle = NULL; + efi_uintn_t len, best_len = 0; + + len = efi_dp_instance_size(dp); - list_for_each_entry(efiobj, &efi_obj_list, link) { + list_for_each_entry(handle, &efi_obj_list, link) { 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; - ret = efi_search_protocol(efiobj, - &efi_guid_device_path, &handler); + ret = efi_search_protocol(handle, &efi_guid_device_path, + &handler); if (ret != EFI_SUCCESS) continue; - obj_dp = handler->protocol_interface; - - do { - if (efi_dp_match(dp, obj_dp) == 0) { - if (rem) { - /* - * Allow partial matches, but inform - * the caller. - */ - *rem = ((void *)dp) + - efi_dp_instance_size(obj_dp); - return efiobj; - } else { - /* Only return on exact matches */ - if (efi_dp_instance_size(obj_dp) == - dp_size) - return efiobj; - } - } - - obj_dp = efi_dp_shorten(efi_dp_next(obj_dp)); - } while (short_path && obj_dp); + dp_current = handler->protocol_interface; + if (short_path) { + dp_current = efi_dp_shorten(dp_current); + if (!dp_current) + continue; + } + len_current = efi_dp_instance_size(dp_current); + if (rem) { + if (len_current < len) + continue; + } else { + if (len_current != len) + continue; + } + if (memcmp(dp_current, dp, len)) + continue; + if (!rem) + return handle; + if (len_current > best_len) { + best_len = len_current; + best_handle = handle; + *rem = (void*)((u8 *)dp + len_current); + } } - - return NULL; + return best_handle; } -/* - * Find an efiobj from device-path, if 'rem' is not NULL, returns the - * remaining part of the device path after the matched object. +/** + * efi_dp_find_obj() - find handle by device path + * + * If @rem is provided, the handle with the longest partial match is returned. + * + * @dp: device path to search + * @rem: pointer to receive remaining device path + * Return: matching handle */ -struct efi_object *efi_dp_find_obj(struct efi_device_path *dp, - struct efi_device_path **rem) +efi_handle_t efi_dp_find_obj(struct efi_device_path *dp, + struct efi_device_path **rem) { - struct efi_object *efiobj; - - /* Search for an exact match first */ - efiobj = find_obj(dp, false, NULL); - - /* Then for a fuzzy match */ - if (!efiobj) - efiobj = find_obj(dp, false, rem); + efi_handle_t handle; - /* And now for a fuzzy short match */ - if (!efiobj) - efiobj = find_obj(dp, true, rem); + handle = find_handle(dp, false, rem); + if (!handle) + /* Match short form device path */ + handle = find_handle(dp, true, rem); - return efiobj; + return handle; } /* -- cgit v1.1 From e46ef1db9e2c87d5aa13a04ea2329b8bae7ea9db Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 19 Mar 2022 06:35:43 +0100 Subject: efi_loader: efi_dp_find_obj() add protocol check Let function efi_dp_find_obj() additionally check if a given protocol is installed on the handle relating to the device-path. Signed-off-by: Heinrich Schuchardt --- include/efi_loader.h | 1 + lib/efi_loader/efi_boottime.c | 2 +- lib/efi_loader/efi_capsule.c | 2 +- lib/efi_loader/efi_device_path.c | 23 ++++++++++++++++------- lib/efi_loader/efi_disk.c | 2 +- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index 6271d40..1ae47a8 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -731,6 +731,7 @@ struct efi_device_path *efi_dp_next(const struct efi_device_path *dp); int efi_dp_match(const struct efi_device_path *a, const struct efi_device_path *b); efi_handle_t efi_dp_find_obj(struct efi_device_path *dp, + const efi_guid_t *guid, struct efi_device_path **rem); /* get size of the first device path instance excluding end node */ efi_uintn_t efi_dp_instance_size(const struct efi_device_path *dp); diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index d0f3e05..a7bc371 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1750,7 +1750,7 @@ efi_status_t efi_setup_loaded_image(struct efi_device_path *device_path, info->system_table = &systab; 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); if (!dp) { diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c index 613b531..011942b 100644 --- a/lib/efi_loader/efi_capsule.c +++ b/lib/efi_loader/efi_capsule.c @@ -680,7 +680,7 @@ static bool device_is_present_and_system_part(struct efi_device_path *dp) { efi_handle_t handle; - handle = efi_dp_find_obj(dp, NULL); + handle = efi_dp_find_obj(dp, NULL, NULL); if (!handle) return false; diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c index aeb5264..0a88029 100644 --- a/lib/efi_loader/efi_device_path.c +++ b/lib/efi_loader/efi_device_path.c @@ -160,17 +160,19 @@ struct efi_device_path *efi_dp_shorten(struct efi_device_path *dp) } /** - * find_handle() - find handle by device path + * 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, bool short_path, - struct efi_device_path **rem) +static efi_handle_t find_handle(struct efi_device_path *dp, + const efi_guid_t *guid, bool short_path, + struct efi_device_path **rem) { efi_handle_t handle, best_handle = NULL; efi_uintn_t len, best_len = 0; @@ -183,6 +185,11 @@ static efi_handle_t find_handle(struct efi_device_path *dp, bool short_path, efi_uintn_t len_current; efi_status_t ret; + if (guid) { + 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) @@ -195,13 +202,13 @@ static efi_handle_t find_handle(struct efi_device_path *dp, bool short_path, } len_current = efi_dp_instance_size(dp_current); if (rem) { - if (len_current < len) + if (len_current > len) continue; } else { if (len_current != len) continue; } - if (memcmp(dp_current, dp, len)) + if (memcmp(dp_current, dp, len_current)) continue; if (!rem) return handle; @@ -220,18 +227,20 @@ static efi_handle_t find_handle(struct efi_device_path *dp, bool short_path, * 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 */ efi_handle_t efi_dp_find_obj(struct efi_device_path *dp, + const efi_guid_t *guid, struct efi_device_path **rem) { efi_handle_t handle; - handle = find_handle(dp, false, rem); + handle = find_handle(dp, guid, false, rem); if (!handle) /* Match short form device path */ - handle = find_handle(dp, true, rem); + handle = find_handle(dp, guid, true, rem); return handle; } diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 45127d1..d36a35d 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -302,7 +302,7 @@ efi_fs_from_path(struct efi_device_path *full_path) efi_free_pool(file_path); /* 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); if (!efiobj) return NULL; -- cgit v1.1 From 9cdf470274ff30cda3ce89567a69106a27404c23 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 26 Feb 2022 12:05:30 +0100 Subject: efi_loader: support booting via short-form device-path The boot manager must support loading from boot options using a short-form device-path, e.g. one where the first element is a hard drive media path. See '3.1.2 Load Options Processing' in UEFI specification version 2.9. Fixes: 0e074d12393b ("efi_loader: carve out efi_load_image_from_file()") Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_boottime.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index a7bc371..5bcb825 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1940,7 +1940,7 @@ efi_status_t efi_load_image_from_path(bool boot_policy, { efi_handle_t device; efi_status_t ret; - struct efi_device_path *dp; + struct efi_device_path *dp, *rem; struct efi_load_file_protocol *load_file_protocol = NULL; efi_uintn_t buffer_size; uint64_t addr, pages; @@ -1951,18 +1951,18 @@ efi_status_t efi_load_image_from_path(bool boot_policy, *size = 0; dp = file_path; - ret = EFI_CALL(efi_locate_device_path( - &efi_simple_file_system_protocol_guid, &dp, &device)); + device = efi_dp_find_obj(dp, NULL, &rem); + ret = efi_search_protocol(device, &efi_simple_file_system_protocol_guid, + NULL); if (ret == EFI_SUCCESS) return efi_load_image_from_file(file_path, buffer, size); - ret = EFI_CALL(efi_locate_device_path( - &efi_guid_load_file_protocol, &dp, &device)); + ret = efi_search_protocol(device, &efi_guid_load_file_protocol, NULL); if (ret == EFI_SUCCESS) { guid = &efi_guid_load_file_protocol; } else if (!boot_policy) { 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) return EFI_NOT_FOUND; @@ -1971,9 +1971,9 @@ efi_status_t efi_load_image_from_path(bool boot_policy, if (ret != EFI_SUCCESS) return EFI_NOT_FOUND; buffer_size = 0; - ret = load_file_protocol->load_file(load_file_protocol, dp, - boot_policy, &buffer_size, - NULL); + ret = EFI_CALL(load_file_protocol->load_file( + load_file_protocol, rem, boot_policy, + &buffer_size, NULL)); if (ret != EFI_BUFFER_TOO_SMALL) goto out; pages = efi_size_in_pages(buffer_size); @@ -1984,7 +1984,7 @@ efi_status_t efi_load_image_from_path(bool boot_policy, goto out; } 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)); if (ret != EFI_SUCCESS) efi_free_pages(addr, pages); -- cgit v1.1 From 63276a569d4832d139206d652207663323df46eb Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 26 Feb 2022 12:10:10 +0100 Subject: efi_loader: use short-form DP for load options The GUID of partitions is sufficient for identification and will stay constant in the lifetime of a boot option. The preceding path of the device-path may change due to changes in the enumeration of devices. Therefore it is preferable to use the short-form of device-paths in load options. Adjust the 'efidebug boot add' command accordingly. Signed-off-by: Heinrich Schuchardt --- cmd/efidebug.c | 70 ++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 22 deletions(-) diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 401d13c..51e2850 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -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 - * - * @dev: Device - * @part: Disk partition - * @file: Filename - * Return: Pointer to the device path or ERR_PTR + * create_initrd_dp() - create a special device for our Boot### option * + * @dev: device + * @part: disk partition + * @file: filename + * @shortform: create short form device path + * Return: pointer to the device path or ERR_PTR */ static 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; efi_status_t ret; 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); 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, - tmp_fp); + short_fp); out: 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; u16 *label; 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 *initrd_dp = NULL; struct efi_load_option lo; @@ -826,7 +831,18 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag, argc--; argv++; /* 'add' */ 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) { r = CMD_RET_USAGE; goto out; @@ -849,24 +865,33 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag, /* file path */ ret = efi_dp_from_name(argv[3], argv[4], argv[5], - &device_path, &file_path); + &device_path, &fp_free); if (ret != EFI_SUCCESS) { printf("Cannot create device path for \"%s %s\"\n", argv[3], argv[4]); r = CMD_RET_FAILURE; 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) + sizeof(struct efi_device_path); argc -= 5; argv += 5; - } else if (!strcmp(argv[0], "-i")) { + break; + case 'i': + shortform = 1; + /* fallthrough */ + case 'I': if (argc < 3 || initrd_dp) { r = CMD_RET_USAGE; 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) { printf("Cannot add an initrd\n"); r = CMD_RET_FAILURE; @@ -876,7 +901,8 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, int flag, argv += 3; fp_size += efi_dp_size(initrd_dp) + sizeof(struct efi_device_path); - } else if (!strcmp(argv[0], "-s")) { + break; + case 's': if (argc < 1 || lo.optional_data) { r = CMD_RET_USAGE; 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]; argc -= 1; argv += 1; - } else { + break; + default: r = CMD_RET_USAGE; goto out; } @@ -927,7 +954,7 @@ out: efi_free_pool(final_fp); efi_free_pool(initrd_dp); efi_free_pool(device_path); - efi_free_pool(file_path); + efi_free_pool(fp_free); free(lo.label); return r; @@ -1571,12 +1598,11 @@ static int do_efidebug(struct cmd_tbl *cmdtp, int flag, static char efidebug_help_text[] = " - UEFI Shell-like interface to configure UEFI environment\n" "\n" - "efidebug boot add " - "-b