RITY boot environments invoke dtbprobe before EFI boot, or fdtprobe when devicetree authentication is enabled. These command names and their positional arguments form part of the RITY image interface.
Register compatibility aliases beside mtk_fdt_prepare in cmd/mediatek and share the common argument parser and preparation service. Expose only the alias appropriate to the selected security mode. Keep the authenticated fdtprobe failure policy: failure to authenticate a signed DTB or DTBO wrapper is fatal and panics with the established diagnostic. Other preparation failures return to the caller, and mtk_fdt_prepare remains recoverable for interactive diagnosis. Document both aliases, their shared syntax and the authentication-failure behavior. Signed-off-by: Carlo Caione <[email protected]> --- cmd/mediatek/Kconfig | 4 ++++ cmd/mediatek/fdt_prepare.c | 47 ++++++++++++++++++++++++++++++++++----- doc/usage/cmd/mtk_fdt_prepare.rst | 11 +++++++++ 3 files changed, 56 insertions(+), 6 deletions(-) diff --git a/cmd/mediatek/Kconfig b/cmd/mediatek/Kconfig index 777b9778e1f..31fa6e8d528 100644 --- a/cmd/mediatek/Kconfig +++ b/cmd/mediatek/Kconfig @@ -17,4 +17,8 @@ config CMD_MTK_FDT_PREPARE arguments the command uses storage, storage_dev and dtb_path from the environment. It also accepts the interface, device and path arguments explicitly. + + Also provide the RITY-compatible dtbprobe command, or fdtprobe + when devicetree authentication is enabled. + endif diff --git a/cmd/mediatek/fdt_prepare.c b/cmd/mediatek/fdt_prepare.c index a861fe8804e..482deb0d581 100644 --- a/cmd/mediatek/fdt_prepare.c +++ b/cmd/mediatek/fdt_prepare.c @@ -4,20 +4,31 @@ */ #include <command.h> +#include <vsprintf.h> #include <asm/arch-mediatek/fdt_prepare.h> +#include <linux/errno.h> -static int do_mtk_fdt_prepare(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]) +static int run_mtk_fdt_prepare(int argc, char *const argv[], int *retp) { - int ret; - if (argc == 1) - ret = mtk_fdt_prepare(); + *retp = mtk_fdt_prepare(); else if (argc == 4) - ret = mtk_fdt_prepare_from(argv[1], argv[2], argv[3]); + *retp = mtk_fdt_prepare_from(argv[1], argv[2], argv[3]); else return CMD_RET_USAGE; + return CMD_RET_SUCCESS; +} + +static int do_mtk_fdt_prepare(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + int ret, status; + + status = run_mtk_fdt_prepare(argc, argv, &ret); + if (status) + return status; + return ret ? CMD_RET_FAILURE : CMD_RET_SUCCESS; } @@ -28,3 +39,27 @@ static int do_mtk_fdt_prepare(struct cmd_tbl *cmdtp, int flag, int argc, U_BOOT_CMD(mtk_fdt_prepare, 4, 1, do_mtk_fdt_prepare, "load and assemble the MediaTek RITY devicetree", MTK_FDT_PREPARE_USAGE); + +#if CONFIG_IS_ENABLED(MTK_FDT_AUTH) +static int do_mtk_fdt_prepare_auth(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + int ret, status; + + status = run_mtk_fdt_prepare(argc, argv, &ret); + if (status) + return status; + if (ret == -EKEYREJECTED) + panic("Invalid dtb/dtbo."); + + return ret ? CMD_RET_FAILURE : CMD_RET_SUCCESS; +} + +U_BOOT_CMD(fdtprobe, 4, 1, do_mtk_fdt_prepare_auth, + "load and assemble an authenticated MediaTek RITY devicetree", + MTK_FDT_PREPARE_USAGE); +#else +U_BOOT_CMD(dtbprobe, 4, 1, do_mtk_fdt_prepare, + "load and assemble a MediaTek RITY devicetree", + MTK_FDT_PREPARE_USAGE); +#endif diff --git a/doc/usage/cmd/mtk_fdt_prepare.rst b/doc/usage/cmd/mtk_fdt_prepare.rst index aa10516c2b1..35b505a068a 100644 --- a/doc/usage/cmd/mtk_fdt_prepare.rst +++ b/doc/usage/cmd/mtk_fdt_prepare.rst @@ -3,6 +3,8 @@ .. index:: single: mtk_fdt_prepare (command) + single: dtbprobe (command) + single: fdtprobe (command) mtk_fdt_prepare command ======================= @@ -72,6 +74,15 @@ default image contains the flat devicetree payload. The command loads the FIT at ``fw_fdt_wrapper_addr_r``, verifies the selected image and extracts it before assembly. +Compatibility commands +---------------------- + +RITY environments use the same positional arguments with compatibility +command names. Without ``CONFIG_MTK_FDT_AUTH``, ``dtbprobe`` is an alias for +``mtk_fdt_prepare``. With authentication enabled, ``fdtprobe`` provides the +same interface and panics if a DTB or DTBO fails authentication. Other errors +are returned to the caller. + Configuration ------------- -- 2.55.0
