From patchwork Fri Dec 2 21:03:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1711592 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.a=rsa-sha256 header.s=selector1 header.b=GMKJJaUu; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NP55Z5stlz23n4 for ; Sat, 3 Dec 2022 08:03:46 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B369C82F69; Fri, 2 Dec 2022 22:03:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.b="GMKJJaUu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 792C581A19; Fri, 2 Dec 2022 22:03:38 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0600.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe1f::600]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 92E8A82F69 for ; Fri, 2 Dec 2022 22:03:35 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sean.anderson@seco.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wfv3SDT9BwYphQkFwFSnfhAj2Qde6/3dSQMESd3EFObM8UKAcHDYfzFtW47CgSDFmCyzJ/gAaMKUgHx98g3q6eIL9QJ/7Bs4UN6WB0y3kpLVnPZFfK/kI+sz5V40/FKGUVMp9wiB/7SOUOSilNtc33hjf6/g/xAefXT8s/9wNO8g8NcxLt43jIet2h95ObxO79gkOzipmo6XdyNutMdApfJoAgaE+rWJAYc2Uhf87O2ub0G7/+OdOognH3VmkrDRGXs2MqNc+PynRjWCbrD2JzQWpXGPfOfKSAaLLamfqaeGwxrs6iNdlGYtRHSES//qZ/5t77ZDIG3lH3ffAlzgIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Y9rX4KECfquoQXb1yLugNYds5fQ59XrsVy9a4w56YhQ=; b=NSlX4HuHYs9lbwuHxlev8d4jpOMY5yFxFFIEVGQD5qSkxuduyqp0cX1iuGEhkqutPel0NoIZ0SEg6eGGNM7tFVS0Qs2OH+o1VGTBhFN/sY8eMlVVBaEzmOvot/Ob3PFgsOQzwIXmTHe2rxTLXUBYHmZ077+gOLuvdOc6Z+pU6TIUtvVnx/D3DiquvddBTUIjE3ChiJ+BkSRafoxdauhmjTu/eWGxMfrGT85bwNFYbWMgOTKqZaemdkBKS2+vn3j25pbBD4sTKcMkfmKreLwnXvrCCVSi2QQ8TAZCqAOhTkZaezj+U/+qSdKzqqcsWDsXez1QYN6//BlLc5D5IsgQVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Y9rX4KECfquoQXb1yLugNYds5fQ59XrsVy9a4w56YhQ=; b=GMKJJaUuUYi5RoA7V4EurwVlYMW4LkUtyGUiriVxkRKzYtji9N6DabxLlLBeB8yekp46muJ4f6qS6I6+iw6+N1LlhF8jXXxc036eo0XIDQxWH5K2kMD7Rl+IbOaq7h2HafElbGt90fttL1M6OjbYsiGHJhy1XQINQC1Z2/rYZbZfmvLZgkZ6UZqJtZc9YY1iYGo6JkXuj93IShP0WaWpcS/KMqM6gQflZB3jxUxWEi2NyUdfNCakog2ZvqpJH70Ga6DRNzJa1ZCNt8bknsBLpoIvdEr02FPHaY9PKOhnVYDOgvSsbhiDJsBr2o/2t8yTzJHxm3jY4T5vp37U0WaqBQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB9PR03MB8847.eurprd03.prod.outlook.com (2603:10a6:10:3dd::13) by DB3PR0302MB9207.eurprd03.prod.outlook.com (2603:10a6:10:429::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.21; Fri, 2 Dec 2022 21:03:33 +0000 Received: from DB9PR03MB8847.eurprd03.prod.outlook.com ([fe80::2b95:1fe4:5d8f:22fb]) by DB9PR03MB8847.eurprd03.prod.outlook.com ([fe80::2b95:1fe4:5d8f:22fb%8]) with mapi id 15.20.5857.023; Fri, 2 Dec 2022 21:03:33 +0000 From: Sean Anderson To: Marek Vasut , u-boot@lists.denx.de Cc: Heiko Schocher , Patrick Delaunay , Lukasz Majewski , Sean Anderson Subject: [PATCH v2] fastboot: Add OEM run command Date: Fri, 2 Dec 2022 16:03:23 -0500 Message-Id: <20221202210323.1086933-1-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty X-ClientProxiedBy: MN2PR05CA0061.namprd05.prod.outlook.com (2603:10b6:208:236::30) To DB9PR03MB8847.eurprd03.prod.outlook.com (2603:10a6:10:3dd::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB9PR03MB8847:EE_|DB3PR0302MB9207:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b8e713d-601a-4bb4-2275-08dad4a8abf3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7Y+2N8XETt1gV/uKsR+E2ZHkku4G1ZqT/ATJVJT2XtjWIM+PVv+LZ3cWgXV3tY5eSI4MwqHSUGD+DLE1p8VLJyRK/dHZqMHSI5fVhgTWfrNLvqfqgajZxajX/MIpENCk6aqGRMeU8wUS9Wpqy7UXfPMWu/FkNbqamd0T954hD7RrhQYLZuJg7UpN4NESwVJ0IxNlFIoAl476rSQpTaDZW87F72ZDJ0OYqPYuFQRf2jRNKc9dJ8TnS075mboxkqyUZbb+F0di6CEBlhNOxx3cXy8vfzK7dY4ccwYvOSdAk00jEfNa2jmukhYL00aAq5aZlIx87lQv08h0CqkKuxe/Bl9SMsmXASq6/gN1WIefDj2tIc4kBTWnY6TRX9CqTD1rfrgOn5JBQSOv4wYZIJDUYhIbxy+0OZmb1ziii01Wy9Ohc0D2XOJyM9lyEvxaH4Ge8J794ek0ngEkcYrkx9q2pKu+tu4LMFm9oNxtpJkcccUsfJCB7KxGUf3LGPPlYLZfRUvQODvW29t5Wm+6v9pxBEKgDfD96oklZh3N9pXrpcNaSbqc4QPcvrEarLUrnOVhYvRKFFdMGqaGgxRmnvRFnXi1DZ7zwiiH/yhkMwH2h7i6mOihuqtTw2g7eZDh59ay1MbpX0b7Emd6n9pnSS/O0oFM7UE9nxjrm2gyPQh5A1Tf1ofB7dOgPcKhGGqgUdHU6DvwPYnUpusHu0F9u9eFMGnPLzs0MNQhItSeXWGzJKM= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9PR03MB8847.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(39840400004)(366004)(396003)(346002)(136003)(376002)(451199015)(8936002)(478600001)(66476007)(44832011)(8676002)(66556008)(41300700001)(54906003)(5660300002)(316002)(66946007)(4326008)(6506007)(26005)(38100700002)(1076003)(966005)(6486002)(107886003)(52116002)(2906002)(2616005)(36756003)(186003)(6512007)(6666004)(38350700002)(86362001)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /yxVQ/PocPaaVCF9jiSfmlTMFCmKGk9TDvi3M8OTlxixX69MIbWFrrxlB1PcCtlSMQTiBPVqFzcTHCrUlYweMQzLzHoJW/Drv7Zm4sI9tB5Gint5YzmSz2/fBs4fHMN49XeixyFLmZd/hBP3ZcQNaxwMAeaU8T9A8d88+Z9eqDjwJS7jQfxWD9qBXUM9Uvx+RI93QOj/QbJTuI400b8vrpW97gO8giin8usCErYvkaBEdb2Yd2g5Xsesv2LujcX5e72gTFHta4JIi65lHK771CfLMTWfXUhLgS26Gb9sM/AaFdEZ6DSdP0rJzHoWHmCpoA/b5JlRHkwjoGsPmDh63MwnGAkEUWqyUkoy75MHnWaq9wnuWO7DiC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6BdkX/gsTHqgzcuxQxRxDtnPSc/eqZQzNkYZlufHUHog0L1yq4JSj8oJx1t3wHc3OKV8RILsgJC326++Gqe7ugRqy4ug2TAl4fokXWDJ9qqXU3Ivz0fzp0ZoMOn5cTpXsjt6gTiA9Uhs7RXLWG5iYc8LjOPfh+JAasdmvkw== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b8e713d-601a-4bb4-2275-08dad4a8abf3 X-MS-Exchange-CrossTenant-AuthSource: DB9PR03MB8847.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2022 21:03:33.2184 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: juatLEjrCJvCNlQfA/jJg9Ryo09jTnMOt2mFSSvmozyFqilVPOCNb/+SBKdfXp2MHIlxadO5fhjuy7UOuvpjcw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0302MB9207 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean This adds the UUU UCmd functionality as an OEM command. While the fastboot tool allows sending arbitrary commands as long as they are prefixed with "oem". This allows running generic U-Boot commands over fastboot without UUU, which is especially useful when not using USB. This is really the route we should have gone in the first place when adding these commands. While we're here, clean up the Kconfig a bit. Signed-off-by: Sean Anderson --- Changes in v2: - Document usage - Keep enum in order doc/android/fastboot.rst | 15 +++++++++++++++ drivers/fastboot/Kconfig | 10 +++++----- drivers/fastboot/fb_command.c | 4 ++++ include/fastboot.h | 1 + 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/doc/android/fastboot.rst b/doc/android/fastboot.rst index 7611f07038..7f343d5dfc 100644 --- a/doc/android/fastboot.rst +++ b/doc/android/fastboot.rst @@ -28,6 +28,7 @@ The following OEM commands are supported (if enabled): - ``oem partconf`` - this executes ``mmc partconf %x 0`` to configure eMMC with = boot_ack boot_partition - ``oem bootbus`` - this executes ``mmc bootbus %x %s`` to configure eMMC +- ``oem run`` - this executes an arbitrary U-Boot command Support for both eMMC and NAND devices is included. @@ -127,6 +128,19 @@ Boot command When executing the fastboot ``boot`` command, if ``fastboot_bootcmd`` is set then that will be executed in place of ``bootm ``. +Running Shell Commands +---------------------- + +Normally, arbitrary U-Boot command execution is not enabled. This is so +fastboot can be used to update systems using verified boot. However, such +functionality can be useful for production or when verified boot is not in use. +Enable ``CONFIG_FASTBOOT_UUU_SUPPORT`` to use this functionality. This will +enable the ``UCmd`` and ``ACmd`` commands for use with UUU [3]_. It also +enables the ``oem run`` command, which can be used with the fastboot client. +For example, to print "Hello world", run:: + + $ fastboot oem run:echo Hello world + Partition Names --------------- @@ -232,3 +246,4 @@ References .. [1] :doc:`fastboot-protocol` .. [2] https://developer.android.com/studio/releases/platform-tools +.. [3] https://github.com/NXPmicro/mfgtools diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig index b97c67bf60..8f2d52cb8a 100644 --- a/drivers/fastboot/Kconfig +++ b/drivers/fastboot/Kconfig @@ -80,12 +80,12 @@ config FASTBOOT_FLASH this to enable the "fastboot flash" command. config FASTBOOT_UUU_SUPPORT - bool "Enable FASTBOOT i.MX UUU special command" + bool "Enable running arbitrary commands from FASTBOOT" help - The fastboot protocol includes "UCmd" and "ACmd" command. - Be aware that you provide full access to any U-Boot command, - including working with memory and may open a huge backdoor, - when enabling this option. + This extends the fastboot protocol with the "UCmd" and "ACmd" + commands, as well as the "oem run" command. These commands provide + full access to any U-Boot command, including working with memory. + This may open a huge backdoor if you are using verified boot. choice prompt "Flash provider for FASTBOOT" diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c index 98eccc3455..1732406c18 100644 --- a/drivers/fastboot/fb_command.c +++ b/drivers/fastboot/fb_command.c @@ -123,6 +123,10 @@ static const struct { }, #endif #if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT) + [FASTBOOT_COMMAND_OEM_RUN] = { + .command = "oem run", + .dispatch = run_ucmd, + }, [FASTBOOT_COMMAND_UCMD] = { .command = "UCmd", .dispatch = run_ucmd, diff --git a/include/fastboot.h b/include/fastboot.h index 57daaf1298..8b6b4b934a 100644 --- a/include/fastboot.h +++ b/include/fastboot.h @@ -45,6 +45,7 @@ enum { FASTBOOT_COMMAND_OEM_BOOTBUS, #endif #if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT) + FASTBOOT_COMMAND_OEM_RUN, FASTBOOT_COMMAND_ACMD, FASTBOOT_COMMAND_UCMD, #endif