From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 51BE6C433EF for ; Mon, 28 Mar 2022 20:59:43 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4DA8284026; Mon, 28 Mar 2022 22:58:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=softathome.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=softathome1.onmicrosoft.com header.i=@softathome1.onmicrosoft.com header.b="kPuVc4lf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BCDF883C7B; Mon, 28 Mar 2022 22:57:29 +0200 (CEST) Received: from FRA01-PR2-obe.outbound.protection.outlook.com (mail-pr2fra01on062c.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e18::62c]) (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 3322883F8C for ; Mon, 28 Mar 2022 22:57:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=softathome.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=philippe.reynes@softathome.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nzTRy6lh2l+p1n3hXGGUd/uLpqi3zQt9GfN9kY8xLkwiV5x0bRCJNg271k4TFEHsrdvio6BZezORfh6vMuwLU5TcTFM038aYCu+Wwc9vsoBBxOTdB8qcn57mgSxq54/kx7kl3cawNvPbflARdxD02sbq/2k2aIYBYK86KYv/Bs+mj6djK/ZJ9Q6nLmqzYNaFWZr24w2VQMsy+qNaOR1yF6hGpcbhT+mrTAxLsR7u9sBd7W32jlmN9FaEkNtzuThANdSjl8XbLtwbXX+71KR0is5PDqfrxpCI+WgmVpCh/dZjzv9yoCUanOfEtF9tDCiCq4pdWJBUqoH+eALSnWLuUA== 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=AhyCW7XkpI8Bgt8v5Cg8KBFxnBLCAAV8O1PtuTY6ONU=; b=gw+WsQeUObqXUkmwXwmTH2vQB+baS7XDulBP/h2RuswMLrqvJE+dwOtQYI5QZI5wM1jngVjskT5rWjyAD9HBNk/H3a1vAJDUJH4VHomm+SvqxnTakG6v2Eke9B069FoAB3QnMY6JS3/FFh70llSC1C7RjAsNxbR1csTSnL4c6f781oEvQ8pseNT3wbnvvS3Zk7w5D5vwB7if2uo30cEURJtNEqi0bVc1DHq4pHs6+v9oj9mAdiFDRJVZxK3HmtdL+3wmKL6/QV7LmtF17XdU9bwFKApKjFu0zeaeiXH9YtIoFACE/okZc+W49MXUM6PUH+51olqyh0Jslz/FvsFsOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.6.166.170) smtp.rcpttodomain=chromium.org smtp.mailfrom=softathome.com; dmarc=bestguesspass action=none header.from=softathome.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=softathome1.onmicrosoft.com; s=selector1-softathome1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AhyCW7XkpI8Bgt8v5Cg8KBFxnBLCAAV8O1PtuTY6ONU=; b=kPuVc4lfji2iwHIdRzm/M3o8elgKVNBbSTQ1/Juzsqgp56pLKBPnI/p3npJ1PkEvJGYEnH30c6LdntbUtUAfNTwH0VuuOwVgY2vB7vR/WAG+wBE/sn40GsTnTwYXcbO0+2bzCTq0AyoB2mLvAz0JioSObgUcR4ewq2XRoDOz3uQVdiYJUqFjcSHFBQ8oHjT/DzK+JCznUX3tfh+l8ukI2wIoZdabOTazMeeDyLzk/aMtKoMMZrivH9vRyMlCHT7BLs4v43badgsrjnWeBHH47AMDCTsoA+/y6bnz5FETvbdx0DMVFoYAEDr6V7g3ky5nFm0DazCHVlclYWkD3KTAig== Received: from AS9PR04CA0104.eurprd04.prod.outlook.com (2603:10a6:20b:50e::17) by PR0P264MB4204.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:25f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Mon, 28 Mar 2022 20:57:14 +0000 Received: from PR2FRA01FT010.eop-fra01.prod.protection.outlook.com (2603:10a6:20b:50e:cafe::45) by AS9PR04CA0104.outlook.office365.com (2603:10a6:20b:50e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.18 via Frontend Transport; Mon, 28 Mar 2022 20:57:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.6.166.170) smtp.mailfrom=softathome.com; dkim=none (message not signed) header.d=none;dmarc=bestguesspass action=none header.from=softathome.com; Received-SPF: Pass (protection.outlook.com: domain of softathome.com designates 149.6.166.170 as permitted sender) receiver=protection.outlook.com; client-ip=149.6.166.170; helo=proxy.softathome.com; Received: from proxy.softathome.com (149.6.166.170) by PR2FRA01FT010.mail.protection.outlook.com (10.152.48.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17 via Frontend Transport; Mon, 28 Mar 2022 20:57:14 +0000 Received: from localhost.localdomain (unknown [192.168.72.32]) by proxy.softathome.com (Postfix) with ESMTPSA id 7DCC91FD92; Mon, 28 Mar 2022 22:57:13 +0200 (CEST) From: Philippe Reynes To: sjg@chromium.org, rasmus.villemoes@prevas.dk Cc: u-boot@lists.denx.de, Philippe Reynes Subject: [PATCH v8 15/15] cmd: bootm: add subcommand preload Date: Mon, 28 Mar 2022 22:57:07 +0200 Message-Id: <20220328205707.348270-16-philippe.reynes@softathome.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220328205707.348270-1-philippe.reynes@softathome.com> References: <20220328205707.348270-1-philippe.reynes@softathome.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 5e33ce18-df1e-4b9b-88c3-08da10fd894d X-MS-TrafficTypeDiagnostic: PR0P264MB4204:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cDjOeriVV6dKiS/tDf6ODlF9gxBZdY48Q8Vc8N39YSCmqpTUPr7Zh7B/Yhz8yX3hf+waY65FEtkiwfUxddW6vDkn2uU5USweWkGsYBghK3bxMnuT5tOi+aXtuuDDYln8O05Ab1nQABtiDriM44/RLZCT6spXk/gkLO+L1/AN+wpC+XxNLHN33V0NFb7cDvWUPplJ8YKrkJm79/bVHTP0SGELlWQH9u3/I5PGnEzyuLrn0HkxYav3xGoAmjgDoIrBVBl1c/tUXaPolScvz9dmc7Jagf/eEau3DNRpV01IkD0sEHOLwWaiCseKxqiqBBAb8BKewm9/nB548S1AGJiDrQNEdkFomKjTIJnVvytc/DnZnpzU0OtmQjHIGn4ZXUc6YMt051IQnN3M3DLgw3nxbnAPwSB9VjVu4rmc2qIKqUaVic6lixNeOIKjicNDw8VvHnEYgUnJo08CZFZ148i54vYYj3qdbsT4hnlGHkQTNlDHu+iEQCLSGVdpPA3+ddoWuurgC1KXYwrZUgN91qEHu/QX/Vyn7YRYO8qvK8GWbDcxAMtkzxwo10qtBjx9Ky8riBcRIL/hUgnhEH8EPpsDBEWQoth6E0dyUGfoiqIPoWjlEp6wZSG7mdGGFJ8F9fgcrIdkPqLcT26Yni0nZm4/GPFDtpcRLtJ54OwDmOoGdrByT9m1B41rotlGhUQHLT9gT45i86HHxWLIQ+I+cJ+x3Q== X-Forefront-Antispam-Report: CIP:149.6.166.170; CTRY:FR; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:proxy.softathome.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(107886003)(508600001)(81166007)(356005)(6966003)(316002)(82310400004)(4326008)(8676002)(83380400001)(36860700001)(70206006)(70586007)(86362001)(2906002)(6666004)(47076005)(36756003)(5660300002)(40460700003)(1076003)(6266002)(2616005)(44832011)(26005)(336012)(186003)(426003)(8936002)(82960400001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: softathome.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Mar 2022 20:57:14.2207 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5e33ce18-df1e-4b9b-88c3-08da10fd894d X-MS-Exchange-CrossTenant-Id: aa10e044-e405-4c10-8353-36b4d0cce511 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=aa10e044-e405-4c10-8353-36b4d0cce511; Ip=[149.6.166.170]; Helo=[proxy.softathome.com] X-MS-Exchange-CrossTenant-AuthSource: PR2FRA01FT010.eop-fra01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR0P264MB4204 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.5 at phobos.denx.de X-Virus-Status: Clean Add a subcommand preload to bootm that execute the preload stage on the image. Right now, it checks the signature of the image with the pre-load header. If the check succeed, the u-boot env variable 'loadaddr_verified' is set to the address of the image (without the header). It allows to run such commands: tftp script.img && bootm preload $loadaddr && source $loadaddr_verified Signed-off-by: Philippe Reynes --- cmd/bootm.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/cmd/bootm.c b/cmd/bootm.c index 87d40d494c..1f70ee9e91 100644 --- a/cmd/bootm.c +++ b/cmd/bootm.c @@ -44,6 +44,9 @@ static int do_imls(struct cmd_tbl *cmdtp, int flag, int argc, static struct cmd_tbl cmd_bootm_sub[] = { U_BOOT_CMD_MKENT(start, 0, 1, (void *)BOOTM_STATE_START, "", ""), U_BOOT_CMD_MKENT(loados, 0, 1, (void *)BOOTM_STATE_LOADOS, "", ""), +#ifdef CONFIG_CMD_BOOTM_PRE_LOAD + U_BOOT_CMD_MKENT(preload, 0, 1, (void *)BOOTM_STATE_PRE_LOAD, "", ""), +#endif #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH U_BOOT_CMD_MKENT(ramdisk, 0, 1, (void *)BOOTM_STATE_RAMDISK, "", ""), #endif @@ -57,6 +60,20 @@ static struct cmd_tbl cmd_bootm_sub[] = { U_BOOT_CMD_MKENT(go, 0, 1, (void *)BOOTM_STATE_OS_GO, "", ""), }; +#if defined(CONFIG_CMD_BOOTM_PRE_LOAD) +static ulong bootm_get_addr(int argc, char *const argv[]) +{ + ulong addr; + + if (argc > 0) + addr = hextoul(argv[0], NULL); + else + addr = image_load_addr; + + return addr; +} +#endif + static int do_bootm_subcommand(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { @@ -72,6 +89,10 @@ static int do_bootm_subcommand(struct cmd_tbl *cmdtp, int flag, int argc, if (state == BOOTM_STATE_START) state |= BOOTM_STATE_PRE_LOAD | BOOTM_STATE_FINDOS | BOOTM_STATE_FINDOTHER; +#if defined(CONFIG_CMD_BOOTM_PRE_LOAD) + if (state == BOOTM_STATE_PRE_LOAD) + state |= BOOTM_STATE_START; +#endif } else { /* Unrecognized command */ return CMD_RET_USAGE; @@ -85,6 +106,12 @@ static int do_bootm_subcommand(struct cmd_tbl *cmdtp, int flag, int argc, ret = do_bootm_states(cmdtp, flag, argc, argv, state, &images, 0); +#if defined(CONFIG_CMD_BOOTM_PRE_LOAD) + if (!ret && (state & BOOTM_STATE_PRE_LOAD)) + env_set_hex("loadaddr_verified", + bootm_get_addr(argc, argv) + image_load_offset); +#endif + return ret; } @@ -177,6 +204,9 @@ static char bootm_help_text[] = "must be\n" "issued in the order below (it's ok to not issue all sub-commands):\n" "\tstart [addr [arg ...]]\n" +#if defined(CONFIG_CMD_BOOTM_PRE_LOAD) + "\tpreload [addr [arg ..]] - run only the preload stage\n" +#endif "\tloados - load OS image\n" #if defined(CONFIG_SYS_BOOT_RAMDISK_HIGH) "\tramdisk - relocate initrd, set env initrd_start/initrd_end\n" -- 2.25.1