From patchwork Wed Jul 13 16:30:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Cherechesu X-Patchwork-Id: 12916961 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B72AFC43334 for ; Wed, 13 Jul 2022 16:31:38 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.366874.597795 (Exim 4.92) (envelope-from ) id 1oBfGg-000391-0D; Wed, 13 Jul 2022 16:31:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 366874.597795; Wed, 13 Jul 2022 16:31:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oBfGf-00038F-Pt; Wed, 13 Jul 2022 16:31:17 +0000 Received: by outflank-mailman (input) for mailman id 366874; Wed, 13 Jul 2022 16:31:16 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oBfGe-00035D-7H for xen-devel@lists.xenproject.org; Wed, 13 Jul 2022 16:31:16 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2067.outbound.protection.outlook.com [40.107.104.67]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 36bf0573-02c9-11ed-bd2d-47488cf2e6aa; Wed, 13 Jul 2022 18:31:15 +0200 (CEST) Received: from VI1PR04MB5056.eurprd04.prod.outlook.com (2603:10a6:803:5a::13) by VI1PR04MB4893.eurprd04.prod.outlook.com (2603:10a6:803:5c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.12; Wed, 13 Jul 2022 16:31:12 +0000 Received: from VI1PR04MB5056.eurprd04.prod.outlook.com ([fe80::c2a:42b9:f908:e991]) by VI1PR04MB5056.eurprd04.prod.outlook.com ([fe80::c2a:42b9:f908:e991%6]) with mapi id 15.20.5417.026; Wed, 13 Jul 2022 16:31:12 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 36bf0573-02c9-11ed-bd2d-47488cf2e6aa ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kdqDrjrPfltX+vj28Yq5YzPy2OIt/4OHk1ktTlhWd0krippHSguVhd8tFktQ0dTO/DCVJtamcahOk+nxWaFVGJlg4BHAlhkjaC07b4ZosAbAvVqQfkfjDbs0cTBz6acN7CCo6DoloSjNQmNcHaeD6IM+l4nHD0eSxlFzDUu/Bm7g6wr87swlyWyCWYnaTl8Bd5HFgFNuAo/QIrgkzr3s6t+HM1wX81a8ve6ANMCRxE7PX5chMJyefonqceMYKzvY3oRg+CSTtvDu50aY0AxywsLo7PS/zPwYp4PqHXz7UYXurOaLGIPXTtQnztkvVFRHoGL56+IKWolPz3d8bm8K5w== 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=0p9WID8wCWme7yTVDlS/nHDHlNEKgtykRbLwYbaQeI4=; b=Emulg3+6T4a3SE2tes00OcPcEfuIyQlVJXu9xPOqBCQyJvFXNHqCgVwIqt6vipKj8Zjpc9CxZXIbza+31qx2nNtZtYccHov2wn984eobkcKz7LVFajQUgPqNB+77O9IGLJ6paQ90LBZRnMBqR+EJGWKWTKk0Dhes185hk2FKtTiu+mNiz/EqPqnOP4m17FZRfTSVNT9CKR/0+EhKZtyL2rIgaBmeXovhVi07G5wTRKK79pEI7aS8YfbgtvQRDARV6MwpiPwShTecgyVTA2+V2lriPnwoYtmAJVJbGhP+lmJqkSGS4RKN5FK8Y8qdb6V2Utms7FxlDA7kmAaq4Snb+g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0p9WID8wCWme7yTVDlS/nHDHlNEKgtykRbLwYbaQeI4=; b=MBOLXsBVERafZbLh7mkeLaZFo2epkrLgUA/HZW1MFs0A6SZ2zt26DRSBFEa1BQ/464BczpJR1H4u1/5OAhakuUVHFj8w+YD5z/bCddeq697DfQJvxU9g9CIAiJBMTmlOUBptaqodKEgSTHHDSoZHt2O3KypqBv1y24GcnCgLoAo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; From: "Andrei Cherechesu (OSS)" To: xen-devel@lists.xenproject.org Cc: viryaos-discuss@lists.sourceforge.net, sstabellini@kernel.org, Andrei Cherechesu Subject: [ImageBuilder][PATCH v3 1/3] uboot-script-gen: Dynamically compute addr and size when loading binaries Date: Wed, 13 Jul 2022 19:30:42 +0300 Message-Id: <20220713163044.3541661-2-andrei.cherechesu@oss.nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220713163044.3541661-1-andrei.cherechesu@oss.nxp.com> References: <20220713163044.3541661-1-andrei.cherechesu@oss.nxp.com> X-ClientProxiedBy: AM0PR08CA0022.eurprd08.prod.outlook.com (2603:10a6:208:d2::35) To VI1PR04MB5056.eurprd04.prod.outlook.com (2603:10a6:803:5a::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9cf94d7b-33f0-47f4-4bbb-08da64ed1918 X-MS-TrafficTypeDiagnostic: VI1PR04MB4893:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AafPFvYV+v5lxHgOj7XIkckOVmNDIuWbDaSt/XJeXaZbr9pGGZC8v8m+z16Bq8HsW2c5W/FEX1PaszfRqvXpTiAphcK896JethKJu4PKUBJfG4vGBPAPYoTGWSTN7retkOFKFUZCNOwQlb6Uuy1AWcQH8SQ8EFQKZ6xUHjT91fhOmuw2x7mZie7HrJLu2rNq5GfRvG5nrP6ATXwlIxncHucxELVQ2FTX2kiz8WBANjvgnvILRqoK7Yd8+y3x53R6zMMwLPBp+f6ZazN5eHYWaC8dj/xbBlpcx4K1LV8sOVa6qN6UNcotnESS3NlFNlnl0eUiUoBhjDxbRjsAp0w0d7bl6ESHAsg06RQIf7Y1bBA5KXEIuEeWH3dN4YtPFm6oQor023SckcNyto3fRh+veoU+B1965Wt7rcnjIm9umBNP44Z2riQ/NEbsnyGNNf3f5NrJR4x9dYf4rqBrN/qSM4Mw81pD+iGYUzDLQELIC6cmXM2YkwxqZjH4orBUk+IkbUfWIhWiS6HQmQwQml5VscDdjNlef/gs5pgYfuU//QvPK7BTquo6+o8H4esbksSqDv5nBmDsuIpiMjyNxct4dYxZgqVL5PIaULWm18VfCB1ozs2j53xUMSWxVCFnGVIXvm+S+T37STCxgXnAMtCiW05Qa5eJclbnwLeIF+gopccyqeU6mKw+a9CsZTuVWB/pdA8qS1LNziwe2ZrAZvGSeI8qMyvill5W0e6kl3NoLGYIHHH3kuIp42xXzLwZgxY4SHIMo4SAgEgMMU49JI1M+XBYUnja4JSWjRs0l1E7Mkwoy79DLEoaRWxAWNcTF/Wd X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5056.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(396003)(376002)(136003)(366004)(346002)(39860400002)(83380400001)(86362001)(38350700002)(38100700002)(8936002)(5660300002)(478600001)(6486002)(30864003)(6666004)(41300700001)(6916009)(6506007)(316002)(52116002)(4326008)(66476007)(66556008)(8676002)(66946007)(186003)(6512007)(2906002)(2616005)(1076003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lg6aoX5P3bHY0og/gSzld682c3Ky/vP+JCeMrimuoCuJYDzGBTSzEKN3jnUoKOzCsDnyUvzTWNlOHOp68V/WuVPh1LQYKme5EqRAvFIjyde/5nE9aWhoAly45mnGWq3O9VnJ0UwLjqoYyblNoNVeRc4iyWCNNbyrFXot5XnR2zFpyX3DLyFxGRYSlwBvawq4H9u8Gt4Zto+A91PcCgncdkhOcTrGoM0gB4miK8/5jKS/s/8A3GZuTGbQU03CfZOQZhXENPCuIxMtTz9sx7VXWC+AUniMKMhG+0R/0Au8T3D6mkgnl0mLGGyUlAoBJ0yrLo/DV5linFDn5RWrPfWM5pyowntaL+8RZRUHTCzk8VYWFW9EVeFRI/Lpn90tmICyDZUE2p7mNJda0kenKvEaeSfZl1lFBaZi0zSwprNxgisBtZS4y0x1rIAB34Wu3MHgrYXWSvpaIp8E8b6ikAP0HFve+m/xjPDddwzFyrXlsTVC96UAbclHlBaDIg/55rKqmASTCSIghePjfBku7iJ7mq040itKTdPfw8xeWDv9snan3XE7tqzVXRmTP982oFrrQj81pSPUqXl048kPCC6sVxmUeC4F/vtp9z+4W2UjwfDB96FsYPMKrQmEDO899EEatazdfU5Al3V1LC79r5NHX8qfm14+20pCPq7ExX8doCM3dIuIkSOlK9JqtiEyFhg4GWoaX31iJzlwnJ/nD1nNSu+mw0R4GlO2ObU310pz19mvx3FSMXn3ewhrVF0waEv0tflJLrebJADsI0Xe5PCTTp6pwI42HRK/gjqVpXA5V4jgjKMxsCr5gt6HsWxTx8rQDoaPrxW4h4OQ9aBK1pjd8mLjqjBHj21SU1TQbQblWj3HM3QBxEuISpwbZv6bfG9vrVBX+lzl3NgXhqAWY6w2vrLpxYV8vwS715jXq4yOhDcFctWPOL2soB3ZSK/Rlw6n7DG295ejYgtb4mXFPS2VKGyBxxxcsQ7hc4u6imHhC5Z+XhTwU+bBzMX2dblmJwWm/NRWCyVAPh4PjuEDrnZbLPmSAvC/Llv3phjTzC9thpRJTc37tgODhNU5CkoAl2w8P73YvuaMDhaDLuax9tHGfH+yWS4NG3T05wy2G7ohcdc/SJswXhHclyalWp0UdVoKmptA3Kp9BPYQXVAKhDrq1iQjUxogk3Jy+F4BVXUceZbYtLr1LBxc+9O/cgyjWcku36AN7pnAFe6VP24o6jCexRSos6Xj9ie5jvj5/0c7UoDnW2sB5Zvr9JwapjJu9BCTOBdbg11EFj0ypJzgi6gzgl4IuvQ8GXG2o29fDqVTgGd0p6LZnx/fgn2jLpOkv+N+/2hrulD/kb2L4qo5WaRkBp1SiyLeWqFhGQ0StyFZMAvhutIWPOM3KVw/MRxDCmVfLDHTZnADGcNAVPvawjA+p8GvxSwDq/Ibg57l1PaqpTxl+ppXfU0+rbvUXkgs16DKbQWdZrRpVlhoaQjY/vwqcGEfepmP9+WMzJOfHO0bZmrcCo95z8YZNb4Ej7lOs4Hxat1AgIu2K/gOYdfXx9ymYAiG+xk2yWyRWSld7ZfXBBAjqUKkmUkxNL8n462ypAh5ra+TGaty2ufgi+S1M/LUlg== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9cf94d7b-33f0-47f4-4bbb-08da64ed1918 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5056.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2022 16:31:11.9270 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: C/4rivODVPS8rlEtcax28qLBlyExKlhpPxp/1P2jNn3Khd1MEptHoQW1iG7/EYF6F97Ibr9tHH6gf/C+VBQzwqMsD28a/ldkQBw5WkicvXM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4893 From: Andrei Cherechesu Normally, the script would precompute the sizes of the loaded binaries and addresses where they are loaded before generating the script, and the sizes and addresses that needed to be provided to Xen via /chosen would be hardcoded in the boot script. Added option via "-s" parameter to use the ${filesize} variable in u-boot, which is set automatically after a *load command. The value stored by filesize is now stored in a u-boot env variable with the name corresponding to the binary that was loaded before. The newly set variables are now used in setting the /chosen node, instead of the hardcoded values. Also, the loading addresses for the files are dynamically computed and aligned to 0x200000 using the `setexpr` u-boot command. Basically, if the option is used, there are zero hardcoded addresses inside the boot script, and everything is determined based on the MEMORY_START parameter and each binary's size. If the "-s" parameter is not used, the script does not store the binaries' sizes and addresses in variables and uses the precomputed ones when advertising them in the /chosen node. Signed-off-by: Andrei Cherechesu --- scripts/uboot-script-gen | 136 ++++++++++++++++++++++++++++++++------- 1 file changed, 114 insertions(+), 22 deletions(-) diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen index 8f08cd6..f8d2fb0 100755 --- a/scripts/uboot-script-gen +++ b/scripts/uboot-script-gen @@ -4,6 +4,9 @@ offset=$((2*1024*1024)) filesize=0 prog_req=(mkimage file fdtput mktemp awk) +padding_mask=`printf "0x%X\n" $(($offset - 1))` +padding_mask_inv=`printf "0x%X\n" $((~$padding_mask))` + function cleanup_and_return_err() { rm -f $UBOOT_SOURCE $UBOOT_SCRIPT @@ -91,10 +94,18 @@ function add_device_tree_kernel() local size=$3 local bootargs=$4 - dt_mknode "$path" "module$addr" - dt_set "$path/module$addr" "compatible" "str_a" "multiboot,kernel multiboot,module" - dt_set "$path/module$addr" "reg" "hex" "0x0 $addr 0x0 $(printf "0x%x" $size)" - dt_set "$path/module$addr" "bootargs" "str" "$bootargs" + if test "$dynamic_loading_opt" + then + dt_mknode "$path" "module\${"$addr"}" + dt_set "$path/module\${"$addr"}" "compatible" "str_a" "multiboot,kernel multiboot,module" + dt_set "$path/module\${"$addr"}" "reg" "hex" "0x0 0x\${"$addr"} 0x0 0x\${"$size"}" + dt_set "$path/module\${"$addr"}" "bootargs" "str" "$bootargs" + else + dt_mknode "$path" "module$addr" + dt_set "$path/module$addr" "compatible" "str_a" "multiboot,kernel multiboot,module" + dt_set "$path/module$addr" "reg" "hex" "0x0 $addr 0x0 $(printf "0x%x" $size)" + dt_set "$path/module$addr" "bootargs" "str" "$bootargs" + fi } @@ -104,9 +115,16 @@ function add_device_tree_ramdisk() local addr=$2 local size=$3 - dt_mknode "$path" "module$addr" - dt_set "$path/module$addr" "compatible" "str_a" "multiboot,ramdisk multiboot,module" - dt_set "$path/module$addr" "reg" "hex" "0x0 $addr 0x0 $(printf "0x%x" $size)" + if test "$dynamic_loading_opt" + then + dt_mknode "$path" "module\${"$addr"}" + dt_set "$path/module\${"$addr"}" "compatible" "str_a" "multiboot,ramdisk multiboot,module" + dt_set "$path/module\${"$addr"}" "reg" "hex" "0x0 0x\${"$addr"} 0x0 0x\${"$size"}" + else + dt_mknode "$path" "module$addr" + dt_set "$path/module$addr" "compatible" "str_a" "multiboot,ramdisk multiboot,module" + dt_set "$path/module$addr" "reg" "hex" "0x0 $addr 0x0 $(printf "0x%x" $size)" + fi } @@ -116,9 +134,16 @@ function add_device_tree_passthrough() local addr=$2 local size=$3 - dt_mknode "$path" "module$addr" - dt_set "$path/module$addr" "compatible" "str_a" "multiboot,device-tree multiboot,module" - dt_set "$path/module$addr" "reg" "hex" "0x0 $addr 0x0 $(printf "0x%x" $size)" + if test "$dynamic_loading_opt" + then + dt_mknode "$path" "module\${"$addr"}" + dt_set "$path/module\${"$addr"}" "compatible" "str_a" "multiboot,device-tree multiboot,module" + dt_set "$path/module\${"$addr"}" "reg" "hex" "0x0 0x\${"$addr"} 0x0 0x\${"$size"}" + else + dt_mknode "$path" "module$addr" + dt_set "$path/module$addr" "compatible" "str_a" "multiboot,device-tree multiboot,module" + dt_set "$path/module$addr" "reg" "hex" "0x0 $addr 0x0 $(printf "0x%x" $size)" + fi } function add_device_tree_mem() @@ -186,7 +211,12 @@ function xen_device_tree_editing() then dt_mknode "/chosen" "dom0" dt_set "/chosen/dom0" "compatible" "str_a" "xen,linux-zimage xen,multiboot-module multiboot,module" - dt_set "/chosen/dom0" "reg" "hex" "0x0 $dom0_kernel_addr 0x0 $(printf "0x%x" $dom0_kernel_size)" + if test "$dynamic_loading_opt" + then + dt_set "/chosen/dom0" "reg" "hex" "0x0 0x\${dom0_linux_addr} 0x0 0x\${dom0_linux_size}" + else + dt_set "/chosen/dom0" "reg" "hex" "0x0 $dom0_kernel_addr 0x0 $(printf "0x%x" $dom0_kernel_size)" + fi dt_set "/chosen" "xen,dom0-bootargs" "str" "$DOM0_CMD" fi @@ -194,7 +224,12 @@ function xen_device_tree_editing() then dt_mknode "/chosen" "dom0-ramdisk" dt_set "/chosen/dom0-ramdisk" "compatible" "str_a" "xen,linux-initrd xen,multiboot-module multiboot,module" - dt_set "/chosen/dom0-ramdisk" "reg" "hex" "0x0 $ramdisk_addr 0x0 $(printf "0x%x" $ramdisk_size)" + if test "$dynamic_loading_opt" + then + dt_set "/chosen/dom0-ramdisk" "reg" "hex" "0x0 0x\${dom0_ramdisk_addr} 0x0 0x\${dom0_ramdisk_size}" + else + dt_set "/chosen/dom0-ramdisk" "reg" "hex" "0x0 $ramdisk_addr 0x0 $(printf "0x%x" $ramdisk_size)" + fi fi i=0 @@ -241,14 +276,29 @@ function xen_device_tree_editing() dt_set "/chosen/domU$i" "colors" "hex" "$(printf "0x%x" $bitcolors)" fi - add_device_tree_kernel "/chosen/domU$i" ${domU_kernel_addr[$i]} ${domU_kernel_size[$i]} "${DOMU_CMD[$i]}" + if test "$dynamic_loading_opt" + then + add_device_tree_kernel "/chosen/domU$i" "domU${i}_kernel_addr" "domU${i}_kernel_size" "${DOMU_CMD[$i]}" + else + add_device_tree_kernel "/chosen/domU$i" ${domU_kernel_addr[$i]} ${domU_kernel_size[$i]} "${DOMU_CMD[$i]}" + fi if test "${domU_ramdisk_addr[$i]}" then - add_device_tree_ramdisk "/chosen/domU$i" ${domU_ramdisk_addr[$i]} ${domU_ramdisk_size[$i]} + if test "$dynamic_loading_opt" + then + add_device_tree_ramdisk "/chosen/domU$i" "domU${i}_ramdisk_addr" "domU${i}_ramdisk_size" + else + add_device_tree_ramdisk "/chosen/domU$i" ${domU_ramdisk_addr[$i]} ${domU_ramdisk_size[$i]} + fi fi if test "${domU_passthrough_dtb_addr[$i]}" then - add_device_tree_passthrough "/chosen/domU$i" ${domU_passthrough_dtb_addr[$i]} ${domU_passthrough_dtb_size[$i]} + if test "$dynamic_loading_opt" + then + add_device_tree_passthrough "/chosen/domU$i" "domU${i}_fdt_addr" "domU${i}_fdt_size" + else + add_device_tree_passthrough "/chosen/domU$i" ${domU_passthrough_dtb_addr[$i]} ${domU_passthrough_dtb_size[$i]} + fi fi i=$(( $i + 1 )) done @@ -271,7 +321,12 @@ function device_tree_editing() if test $UBOOT_SOURCE then - echo "fdt addr $device_tree_addr" >> $UBOOT_SOURCE + if test $dynamic_loading_opt + then + echo "fdt addr \${host_fdt_addr}" >> $UBOOT_SOURCE + else + echo "fdt addr $device_tree_addr" >> $UBOOT_SOURCE + fi echo "fdt resize 1024" >> $UBOOT_SOURCE if test $NUM_DT_OVERLAY && test $NUM_DT_OVERLAY -gt 0 @@ -306,7 +361,7 @@ function add_size() function load_file() { local filename=$1 - local fit_scr_name=$2 + local binary_name=$2 local absolute_path="$(realpath --no-symlinks $filename)" local base="$(realpath $PWD)"/ @@ -314,11 +369,30 @@ function load_file() if test "$FIT" then - echo "imxtract \$fit_addr $fit_scr_name $memaddr" >> $UBOOT_SOURCE + echo "imxtract \$fit_addr $binary_name $memaddr" >> $UBOOT_SOURCE else - echo "$LOAD_CMD $memaddr ${prepend_path:+$prepend_path/}$relative_path" >> $UBOOT_SOURCE + if test "$dynamic_loading_opt" + then + echo "$LOAD_CMD \${curr_addr} ${prepend_path:+$prepend_path/}$relative_path" >> $UBOOT_SOURCE + else + echo "$LOAD_CMD $memaddr ${prepend_path:+$prepend_path/}$relative_path" >> $UBOOT_SOURCE + fi fi add_size $filename + + if test "$dynamic_loading_opt" && test ! "$FIT" + then + # Store each binary's load addr and size + local binary_name_addr="${binary_name}_addr" + local binary_name_size="${binary_name}_size" + echo "setenv $binary_name_addr \${curr_addr}" >> $UBOOT_SOURCE + echo "setenv $binary_name_size \${filesize}" >> $UBOOT_SOURCE + + # Compute load addr for next binary dynamically + echo "setexpr curr_addr \${curr_addr} \+ \${filesize}" >> $UBOOT_SOURCE + echo "setexpr curr_addr \${curr_addr} \+ \${padding_mask}" >> $UBOOT_SOURCE + echo "setexpr curr_addr \${curr_addr} \& \${padding_mask_inv}" >> $UBOOT_SOURCE + fi } function check_file_type() @@ -536,6 +610,14 @@ generate_uboot_images() xen_file_loading() { + if test "$dynamic_loading_opt" + then + local curr_addr=`printf "%x\n" $memaddr` + echo "setenv curr_addr $curr_addr" >> $UBOOT_SOURCE + echo "setenv padding_mask $padding_mask" >> $UBOOT_SOURCE + echo "setenv padding_mask_inv $padding_mask_inv" >> $UBOOT_SOURCE + fi + if test "$DOM0_KERNEL" then check_compressed_file_type $DOM0_KERNEL "executable" @@ -891,7 +973,7 @@ function print_help { script=`basename "$0"` echo "usage:" - echo " $script -c CONFIG_FILE -d DIRECTORY [-t LOAD_CMD] [-o FILE] [-k KEY_DIR/HINT [-u U-BOOT_DTB]] [-e] [-f] [-p PREPEND_PATH]" + echo " $script -c CONFIG_FILE -d DIRECTORY [-t LOAD_CMD] [-o FILE] [-k KEY_DIR/HINT [-u U-BOOT_DTB]] [-e] [-f] [-p PREPEND_PATH] [-s]" echo " $script -h" echo "where:" echo " CONFIG_FILE - configuration file" @@ -908,6 +990,7 @@ function print_help echo " U-BOOT_DTB - u-boot control dtb so that the public key gets added to it" echo " -f - enable generating a FIT image" echo " PREPEND_PATH - path to be appended before file names to match deploy location within rootfs" + echo " -s - enable dynamic loading of binaries by storing their addresses and sizes u-boot env variables" echo " -h - prints out the help message and exits " echo "Defaults:" echo " CONFIG_FILE=$cfg_file, UBOOT_TYPE=\"LOAD_CMD\" env var, DIRECTORY=$uboot_dir" @@ -915,7 +998,7 @@ function print_help echo " $script -c ../config -d ./build42 -t \"scsi load 1:1\"" } -while getopts ":c:t:d:ho:k:u:fp:" opt; do +while getopts ":c:t:d:ho:k:u:fp:s" opt; do case ${opt} in t ) case $OPTARG in @@ -957,6 +1040,9 @@ while getopts ":c:t:d:ho:k:u:fp:" opt; do p ) prepend_path="$OPTARG" ;; + s ) + dynamic_loading_opt=y + ;; h ) print_help exit 0 @@ -1151,7 +1237,13 @@ device_tree_editing $device_tree_addr # disable device tree reloation echo "setenv fdt_high 0xffffffffffffffff" >> $UBOOT_SOURCE -echo "$BOOT_CMD $kernel_addr - $device_tree_addr" >> $UBOOT_SOURCE + +if test "$dynamic_loading_opt" +then + echo "$BOOT_CMD \${host_kernel_addr} - \${host_fdt_addr}" >> $UBOOT_SOURCE +else + echo "$BOOT_CMD $kernel_addr - $device_tree_addr" >> $UBOOT_SOURCE +fi if test "$FIT" then From patchwork Wed Jul 13 16:30:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Cherechesu X-Patchwork-Id: 12916958 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 24616C43334 for ; Wed, 13 Jul 2022 16:31:36 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.366875.597809 (Exim 4.92) (envelope-from ) id 1oBfGi-0003bW-Ae; Wed, 13 Jul 2022 16:31:20 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 366875.597809; Wed, 13 Jul 2022 16:31:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oBfGi-0003bO-6I; Wed, 13 Jul 2022 16:31:20 +0000 Received: by outflank-mailman (input) for mailman id 366875; Wed, 13 Jul 2022 16:31:18 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oBfGg-00035D-Iz for xen-devel@lists.xenproject.org; Wed, 13 Jul 2022 16:31:18 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2041.outbound.protection.outlook.com [40.107.104.41]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 382e66dd-02c9-11ed-bd2d-47488cf2e6aa; Wed, 13 Jul 2022 18:31:17 +0200 (CEST) Received: from VI1PR04MB5056.eurprd04.prod.outlook.com (2603:10a6:803:5a::13) by VI1PR04MB4893.eurprd04.prod.outlook.com (2603:10a6:803:5c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.12; Wed, 13 Jul 2022 16:31:15 +0000 Received: from VI1PR04MB5056.eurprd04.prod.outlook.com ([fe80::c2a:42b9:f908:e991]) by VI1PR04MB5056.eurprd04.prod.outlook.com ([fe80::c2a:42b9:f908:e991%6]) with mapi id 15.20.5417.026; Wed, 13 Jul 2022 16:31:15 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 382e66dd-02c9-11ed-bd2d-47488cf2e6aa ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HR8xtkUATNFYuRzWZKrnDCi8y/1Do2U5afdZaF6ksnyCcc7I0UHUxmmRC7JvpVZ9etHScboqnIRP7i4JJvcHTM3qOsYlHUJ6q8cztR9SsSbIxmudytC1bGsgdSOlucDL0vjQjBnnI+ct6jg+bYSC/EQLlTeIdXF+P8KmAJABouhPuYodbkU9NXuZZkQiOnaKJbdEV02kLLGETSZ566xhuC3JbvFiq04MLrjeXkjwC3FR7D39UTDg3l9Q20LPWHHpXfyl0OaqLSxV5VsOu1SyfiDL0PeHGs4NctErTImPDBbCh061SHbK4zkwVhj2NKeSwuZ8CiQdi3wVPPqaZ1ZwCg== 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=FmqTgyPFFWr6Cy0aMCwaNL1SgYThtx501TxRMDkfl/c=; b=TRgDIP+2NzxZRMJ3Tu0mcTQiA9GVqPSH88x8BTlKzCM+ZdS2ljP0UM9g9euekpThTLy5DSwjKvvlL/8/5xhzU8WKq6HvtTUXmPHXQmdlGSd5hUjK5v/moCdyuwmtdtXvsevfiSMbr16lyLwitkxa4PDOL9gD1248uH4eseaVznqfM2DX/waWsukOzlneAMEUlydlN1ycN5RrFVYQSkk6WsK8SuGurBqrs9mbDRuDNU3bQBbA/nzAd5J4qEyZ0UCc6/On+LMx2cdkZTrq1d7+o+XDXeIRYbOcsfI33wpzKbk1X5mtJPW2cmymSL5ACB0OC3XMvHGFHol0cxTNTu4BKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FmqTgyPFFWr6Cy0aMCwaNL1SgYThtx501TxRMDkfl/c=; b=Uy0YfAtcMIb45xb6Kf+PJ0ObyB15W/Q9rdAzfj7QkidqCXeRSxDqFY24YwiItNIiCZfmHfhU23jAJHiI8wQFLbnMeWY4W3n+lrkYbZsf274ZEL6MnJLIqt45JYYE3fudR8aWaH4o+nR5lf+OIqcHhbNuvJJS5lGiz0YSFwiZ6z0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; From: "Andrei Cherechesu (OSS)" To: xen-devel@lists.xenproject.org Cc: viryaos-discuss@lists.sourceforge.net, sstabellini@kernel.org, Andrei Cherechesu Subject: [ImageBuilder][PATCH v3 2/3] uboot-script-gen: Enable appending extra commands to boot script Date: Wed, 13 Jul 2022 19:30:43 +0300 Message-Id: <20220713163044.3541661-3-andrei.cherechesu@oss.nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220713163044.3541661-1-andrei.cherechesu@oss.nxp.com> References: <20220713163044.3541661-1-andrei.cherechesu@oss.nxp.com> X-ClientProxiedBy: AM0PR08CA0022.eurprd08.prod.outlook.com (2603:10a6:208:d2::35) To VI1PR04MB5056.eurprd04.prod.outlook.com (2603:10a6:803:5a::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2ee13a77-9f45-432e-eba0-08da64ed1b4a X-MS-TrafficTypeDiagnostic: VI1PR04MB4893:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1U1NCAxm426kbrrJSQm+ZUSU+sb7yeRZ/Y1U4e9TzYf/qYpe/4FGct29qXg4T5/Ells4X/K4Hd/4MeZlvpoiWz3HPEvwD/++e48NiA9KAJ1MnrDZ0DMFaf4qo3TyV7ZhGNuAAp214CsIzhzr8st8udITALDLvlhioqMMmRJfzw3QtfbDtfUenNKjDvK3baIDJw7MaJOwTGK4yKeqFNnDqjPsK3MLG5Dx6deU4ouC9EF8SSEEMBz46jriniZR1ZU2DnNAo39hN4RJEzsd6Gq7qEnFh+SQsMrekVz5236iqCEpZRrppUI2q7IrLTclMotvGxboTMeqNP35nIiIH5cyL6LdS+T1yBuLRGBgf0C//U+WtgMSy7pDoaH98Pk83K4XnQ8P1m0gaBQ70O8CbmUTk2PTWeCVOiAf/oxSLrP+NGtgiX6o1eI2y5CC2TrHpwD5DQZuNka98gqpQxExMe4944l3mTpAnDrzJQHuYgRBtcdYqHfT5lUtfaBYZE3xzNcaskn2wi2dlXtP3l6cNcMW9fbU78MDGO2l77vf2phrPUOc2kJRi3uzrZxp1P2Ok/99LsPOA+KIc/REq1FCR1YK4m7p3qp73p8HkNHRXbNXCPjSFLgw45sqy6YQ2+MILCT008iN2ZYk29oS62zpyn28KP8i7jjoc91YUGfm2XRBLFOBSw08aXYMK8dCFPIBAOZupXGRSzJHK/R/zLZ2MXmqXiwvoAmvembrihCdLu874PymoxD8UFcrjmjK/YVw1fgHmbVO3g37Thz31RwOGIw5NNPSL2652zWv6MN9d1i83fm0yP4M8IafQnBuHe0AVH1YABgfDbyHprASGGdUJk2SFA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5056.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(396003)(376002)(136003)(366004)(346002)(39860400002)(86362001)(38350700002)(38100700002)(8936002)(5660300002)(478600001)(6486002)(6666004)(41300700001)(6916009)(6506007)(316002)(52116002)(4326008)(66476007)(66556008)(8676002)(66946007)(186003)(6512007)(2906002)(2616005)(1076003)(26005)(139555002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2dJVpksJKh6Ah6mquzNtwx9fNdnTBLO0eIEi7huZ0oiiGh0U9T0AVmPEW9xLAPf7jfEjrf5luxfXtlEsoBT51LPGDz/8IVWTt9oA1uJcr4B/ECjRioWesE3WnZa4F1q7Imjrb1jk6W175oSKaRbacLxqpTCErgpZyME7mjNMXWVl9WPM3S64xT5ZBjbZKLYOlVVz/HHw/zMvgp9bt2ty2huGmiEQLDqrZeAqsHV/j0RT1LJYZUBK8Co6YkcDJZCdbV3dpKD8TpMUahXCGhOavVvFESDG5CcR+byOs15ovYHmkEPWFU/xfwfaxzbRB14QxfLqdo+NKG++CYg+yPf5y67bQ1tRJ9D6Yt9U4xUJxeON3XmgWxqUHLJdB6mAZqaukFtqD09x5F5VK08I8VP/+197bLPk2igZgPiL5MKg6iNflOvbSujkk0x9FVPGRfEZ4H7uegcR1YPGbDtSIGHG5RhusNX7LZ+iZpUisyCva4M9zS0UoNgACWWQsIubCw1vwKseqIgNCOmMie3Khn15KdWrQ1t30JnnEs+2e90LkJm/LaI+bV5KOFBtLFg6T8KzNoxCvzh+JjRW0KX+q6faodJXod5TBEQAGpOC4NP60MYIeRmqTWDSOmB8olSymstjXZiZ9YmU7Apfks2Da8Rriu3ziP2Im57239IhKMPp/zFwpjkv5FpVxyriLTw56zYZatE0t0YYN0/ILqou5ebockCSO3IaRGofhl5npQ0b7XKkjB5CoizBmIdWwdZN6u6THqN0tmUwvblGU5aOooumNI5whYcIn7aDtrf+v/l/TWpHP31ZP1Ld8hlZV43XX2cEaXt85Om7INyTNv4q51T/sVjL36zH9QNFr7cQkD2vtSkl3xaZv0Rk5iTnzceCYAXHYC4FMsBWDuXxHKqBE0QmQZdw0NSirK4dF7IXxafLcUeJKlrGe2fvvYuCYL7EDUBMMmNmDdNzdjMI/CIxww7rscnhzAxvwkcW3gb1aj4RWG2tFuLyrI5g9d26R1QUQBn4pIz27vjKRhf6bQ0zi8k6tqf6lgczWYGy0lO53BHQmwk32L7k6pSJOV0ZdaViSTIbFssEPkIVTKVqTNKfK0Sp6TcLECM8loJDDOUK1eKO0VpoETLoIqyTNdBFUa47JcMQRBEmUCVjnT5r3ihJ0veSK12mm30f7xwnhgXIed3x6azpBj72viXT7AUIf5+dyp8juUYb+D8b28APHH/0vBMztnIWMuDdFq2yv0XsFyZPDfdhD8a6ahNS7PTftkRZ1JANj9gSoQVNZ7jSFbIAD7Va3/luCNzG+zqZy8CVSOhKV0nO/BvhmJDwEylJlhnXNMEqmSdXJBxyhn8Xx5IsnliRbyG+yM6NbS184IhiwVzqF60kRrKJ87YF2mexS5e2+aiS93pj7PTC0HGxOufEORYaBucnZ3wMy86nXdnL/op5d2ocAXHSti7m05ajGvsz5gxHsgOwD0JDUSM/VMmQgJ+gzLxYC4577VYRkLsyk1+bUP153oP1kwXOc5feEgqeKU17luJ6BPasp1oF/a7qkh/7HoHYewO1nBXCqTLdZSapLiB7w+otxLEiRvIM2yuxnCrasBc/tojiL/LhKnW56oc05Q== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2ee13a77-9f45-432e-eba0-08da64ed1b4a X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5056.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2022 16:31:15.6142 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9g312/3O5qxeaMK1nJ90tWipBRIQs+2SoIKYIFc4VB+XNpgOJfLnnRSCN/5R5aCcOgybJkV0ElolyD32SE9wXrPu34H3+4y2ukLPjP13FKA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4893 From: Andrei Cherechesu Added the parsing for APPEND_EXTRA_CMDS variable, which enables the user to specify the path to a text file that contains, on each line, u-boot commands that will be added to the generated script as "fixups", before the boot command. The file specified by the APPEND_EXTRA_CMDS variable parameter will be copied as-is in the generated script. Signed-off-by: Andrei Cherechesu Reviewed-by: Stefano Stabellini --- README.md | 5 +++++ scripts/uboot-script-gen | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/README.md b/README.md index cb15ca5..3566a6d 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ BOOT_AUX_FILE[1]="uboot.cfg" UBOOT_SOURCE="boot.source" UBOOT_SCRIPT="boot.scr" +APPEND_EXTRA_CMDS="extra.txt" FDTEDIT="imagebuilder.dtb" FIT="boot.fit" FIT_ENC_KEY_DIR="dir/key" @@ -197,6 +198,10 @@ Where: as you can pass -o FILENAME to uboot-script-gen as a command line parameter +- APPEND_EXTRA_CMDS: is optional and specifies the path to a text file + containing extra u-boot commands to be added to the boot script before + the boot command. Useful for running custom fixup commands. + - FDTEDIT is an optional and is off by default. Specifies the output modified dtb, used for reference and fdt_std. diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen index f8d2fb0..f72551a 100755 --- a/scripts/uboot-script-gen +++ b/scripts/uboot-script-gen @@ -416,6 +416,10 @@ function check_file_type() elif [ "$type" = "Device Tree Blob" ] then type="Device Tree Blob\|data" + + elif [ "$type" = "text" ] + then + type="ASCII text" fi file -L $filename | grep "$type" &> /dev/null @@ -1238,6 +1242,13 @@ device_tree_editing $device_tree_addr # disable device tree reloation echo "setenv fdt_high 0xffffffffffffffff" >> $UBOOT_SOURCE +# append extra u-boot commands (fixups) to script before boot command +if test "$APPEND_EXTRA_CMDS" +then + check_file_type "$APPEND_EXTRA_CMDS" "text" + cat $APPEND_EXTRA_CMDS >> $UBOOT_SOURCE +fi + if test "$dynamic_loading_opt" then echo "$BOOT_CMD \${host_kernel_addr} - \${host_fdt_addr}" >> $UBOOT_SOURCE From patchwork Wed Jul 13 16:30:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Cherechesu X-Patchwork-Id: 12916960 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 58004CCA479 for ; Wed, 13 Jul 2022 16:31:39 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.366876.597821 (Exim 4.92) (envelope-from ) id 1oBfGj-0003te-QI; Wed, 13 Jul 2022 16:31:21 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 366876.597821; Wed, 13 Jul 2022 16:31:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oBfGj-0003tR-N7; Wed, 13 Jul 2022 16:31:21 +0000 Received: by outflank-mailman (input) for mailman id 366876; Wed, 13 Jul 2022 16:31:20 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oBfGh-00035D-WD for xen-devel@lists.xenproject.org; Wed, 13 Jul 2022 16:31:20 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2068.outbound.protection.outlook.com [40.107.104.68]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 390a49aa-02c9-11ed-bd2d-47488cf2e6aa; Wed, 13 Jul 2022 18:31:19 +0200 (CEST) Received: from VI1PR04MB5056.eurprd04.prod.outlook.com (2603:10a6:803:5a::13) by VI1PR04MB4893.eurprd04.prod.outlook.com (2603:10a6:803:5c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.12; Wed, 13 Jul 2022 16:31:17 +0000 Received: from VI1PR04MB5056.eurprd04.prod.outlook.com ([fe80::c2a:42b9:f908:e991]) by VI1PR04MB5056.eurprd04.prod.outlook.com ([fe80::c2a:42b9:f908:e991%6]) with mapi id 15.20.5417.026; Wed, 13 Jul 2022 16:31:17 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 390a49aa-02c9-11ed-bd2d-47488cf2e6aa ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DAjRY1aKk49WIgUCzjN5b31/IZaXOTKvzbgaAXnXoBkC/IqTbCcvjubhofKh0YdmRMljEA0ZPvvO+fPum++5Gt43ajl9Xe99eiPk+XRSPpEzqZMIlHRZkB92ecHsldMviPf30FpFk+TS8Pdmvleu4ARcjvguvf6Jg1M6w2EuG1hWH/TxdoXs67PQtX2ECnbHsGOUcEFru/KthMuIPFJhocxutIa2V+AHi2KISwtRH7j6pmWQ4Bj5k62IJXxIbv9XL/mZRjfX/H2Pe5oLo994LKdNEsa0RnOQWAK1O7wfxXZHQYW9QA/2h6CkMWlDct5Zd0lZCjpq1Fw8M7Amyb2jTg== 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=uwKeDBebJwjIYx1Qo5KRUn+UFPyCgLpm22C/91nkWr4=; b=e9cYdKKXgnwoIR3Av1erPKvEdGXSkshryzcHBcfYeegALLH9btawuMkk0wbYIXEmtLzN7mwDIQYYaHGOsgMrHvHm6/WyvM6cq75imrCb1H3ZEQWlSA8VPE8wIjpub+mBwH5Sbg41fWEKR8D4jt38N/o5Q+NXqrAmMe6Q/zOw9OrgF0nDVmwy0x1O3z8KVEf+M1TYnGqPHvnT3lEGD5TufEIzYkigUx4euRw0WpCloKN3arkkzJFJBtOggGgK4b+AWJVWaOWPrl29zIFSAlYry51ibPWrFQoF5DE3zUszt1L3YUgYL480T05k2wFFJRe14e4dD8SDIbvAuxKGTWrAag== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uwKeDBebJwjIYx1Qo5KRUn+UFPyCgLpm22C/91nkWr4=; b=XcMemcdtYKM6RIOzQefMhfarzQGBCgh3BTBFj1OenFQj6PLZZbW+8O+4HPidUjpKJMnFvhDttOCwqY6pZYPtKHbEjkRnRAbaXuNP7oKkUw1b8NHJ4g8VGg1ni8U76u0z6EClLqigOk8G6AP9DwHGsCM2c0Y0wwMeKciUvEYVUWw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; From: "Andrei Cherechesu (OSS)" To: xen-devel@lists.xenproject.org Cc: viryaos-discuss@lists.sourceforge.net, sstabellini@kernel.org, Andrei Cherechesu Subject: [ImageBuilder][PATCH v3 3/3] uboot-script-gen: Enable not adding boot command to script Date: Wed, 13 Jul 2022 19:30:44 +0300 Message-Id: <20220713163044.3541661-4-andrei.cherechesu@oss.nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220713163044.3541661-1-andrei.cherechesu@oss.nxp.com> References: <20220713163044.3541661-1-andrei.cherechesu@oss.nxp.com> X-ClientProxiedBy: AM0PR08CA0022.eurprd08.prod.outlook.com (2603:10a6:208:d2::35) To VI1PR04MB5056.eurprd04.prod.outlook.com (2603:10a6:803:5a::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 38a5bd6a-79c7-4edc-b45b-08da64ed1c3b X-MS-TrafficTypeDiagnostic: VI1PR04MB4893:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jXvn7kw9b3BAlgk70W448MiIJ1FF35LvFMhX5LMWEp7bEnpJOc5uiwMq5XPeCVyIl+7dcrmFlytKgkRoxElZ8YlJY3m9zj+q1woVyBnczV8HDDWEwCwTHm0HYeiWFFCIlOfsH0zxQ4OzGo5hg3Q0n4drfhDb1yBnCttIDHq3unwtrXnelESyk5YR6RgY+AU8sEnytPNIOUcvHvNsZrPd70bWuMpu16ejVL6ZlK+MaUDsU1CtiDQNMa59xYUhldJ8caRUqa2mtQB19kCO9dQS0wKbIr+uj1HUP0pNgElQiw8m7aCarI2NHToqGGmFwrY1v4wS65nn08Vbc9nWpcWtVoA6S60r8U5zeOoaC4Fq97Fq4gfTOhPJmg6RuH+NX2Mgw6Kd6bEhBBkBnh8wRYkvbdGZbyHU5+0CazU5xGe/P3WrvgZq8jO451M1dXXwH58eTt+y2ggbJzKqcUY64XBWcniMrZtGdJ7EleHeFrrjiJw3aCu8WYtRK8P3kLEJ5aQN4U8GMQwEnRWUGmCYm37BamelQc94L5JUo9dkpAiRO5+sPWhKbaPYBS3M6c8gFNL32HNrYgqhzzhd1HpPoIycbvNq/l1eDFaWfJtNBQwoRkr9gNegg6VV/7C9tgvHdtZpxDw1q97yPBkatjBI9Ao670V06yutYEwPeR3+LiQqd6ZgvWwjDjP70X2hH580ql3pC+94PtaTFNrGuFm+fykQ/NH7DYN16swvlmEYDl32380lVZnuD8v5NcMg7e1z62RBM93unjKeWbu3r3nSlR7qLQkwY+1t4U68cqSDlwv6r6urYGPmQhM+jTQkk5TIGRRH X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5056.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(396003)(376002)(136003)(366004)(346002)(39860400002)(83380400001)(86362001)(38350700002)(38100700002)(8936002)(5660300002)(478600001)(6486002)(6666004)(41300700001)(6916009)(6506007)(316002)(52116002)(4326008)(66476007)(66556008)(8676002)(66946007)(186003)(6512007)(2906002)(2616005)(1076003)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0YmgZcCCpqZiq7pxm2LR7EhPrSHzChZZfuj/Hrsz5gaQJI60RyLa0h4pPuGeiS8hG3KQ2uY/gPR1vx1yXhnGa9oSBk080jKVGCg35o8/oW7MQGNrqfZiVyPmAtl5ITez4N2igPFlx24T/ARuwKFTwHpGqAnUp2mA+bELpK229rOTT3Cd8+tP7JurHNt9CJ9RZBM7Bwe/IHPuiXwCmBhHPzpYXZzviLWldiIBcpcH+Zd4Itnvl7XK9Xk/fBEvO964UbtbHyIHrCaQjnOVH0URXJ6J+BWOF9biKdJaKxCz8g1fR60gxeTP/QdZJfpFAHr6g2YDU/v5RNmwjnk/nv2tI8LEUUpcKckyfrfPjofkBCCcai5ojSXGr7JwJz4U/R5J+SH9rlh5laV2h/gkND8MCXY3UUIrPf4VUnJxv3ancvV7Sr81K+fcW5zKO5/t1wsyCaFKJTImgKcC/fZhPi8hM/pIFl/zmmYGQ5GcKmst5Sxcc3TsAoTA2a3JyHTVZ21DlHQIXpDA0vkFohvRoY+ZZFXmIivjF57FUG35rAo/0G6RK74tdWSun5M20laQQ3bhrXQNJKlJHhxiiJYv3l6tVmp8LfnUiB6Ykiu+SFcrYtYyfK+b/jqSxEgUoTIWF9h59Sc1QNpLe46G6+PWOPhdrVFW2AtpEjOJf/R+Mk8gGAee6IjvLaTv94Ryvnan4VK3PAAxSCouKScahGolrB07PNXMh72RMzYn9mx2pvKu0uADwxFd1J4relI9eZeSI78+0uuG5L4eb7gEOI/owmhG1Xk5s01EGNQAu7VEr1zXrcLGOuQRrt9NBsbi2S2bpx7+yNjsS7JybCL32g083s1VJJSprsfOkjhQQcetC9TF1OZhEjV77Q4s1nG+LMPQr/8aggh/K14kTp+OAZHHTDsMGa69D73CZliPKbcVXywm2fkMUQFM4rd8NlE8f8P4TJlRON6A9ZyHkyLpJE/gD2MGWjwG+yCLQAZ+s5+LcL58xRn12tg+ZwnrmpRPpD2pK9ilitoFs7IGuXCXQlSIJ2NS6bKHac5XE6Vl/QUUgMo6NOhEwcqDqY5x/AjGRr2mmvEDJl3QG2J5dg2SDqQYpALC57eBRcednL8ubexBHkWPqflaThkoS0iEpSnZZDtYQK37kDWJwb80CpmdK4bzmFfPSgD88nFhT684QBci7YBijHsaV8VQ09t7dP3Ic3cG3Cq3H6TWIjRTolwoI3tw8GMUoV2bot+oyrwGJg316Un2+3Qlh/m3fxtUkkqbY6QCIxk42L9+WleES/6vBqTGFx60W0drcbjElQlnYTDNzbzjzJY+B4ZadDSuvZ3sBnShynQLaAw1h/ZiL/DkK+GziMrB8yVA3fNdVmpad9La7vN294dS72h+Wo3Z4eR3TMilRevw2c9h4ss4qt2VeatezzamdCw9LZO1Py3/coPmvs5LlgzWs+SDJOi1I63pb74WTiq/JMwHrASZTo98W/HeiN+2L4edeG/jlKade289aoTMrZ50Hub2Mtfml1b27NbZDQhGgv6OaEMurnOUD+svs1JHLEnQRBF7uAZAHVqMxW4bFGGBiUFLcgFny29ZO/YG3a6hDIzEC7wERkIqHJo6peQ7EQ== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 38a5bd6a-79c7-4edc-b45b-08da64ed1c3b X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5056.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2022 16:31:17.1297 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: KuGgE3vq74fc35QzRSq1CGbyOLhwc8k4vQqqEB0KJqmjPFTX1zJaVKDiEgoKyHFkzZQYSgrRJb36nuw/4WpwLbpAmRx37nnVe3F6SY2f5YU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4893 From: Andrei Cherechesu If the "BOOT_CMD" variable is set to "none" inside the config file, the boot command (i.e. "booti") will not by added to the generated script, to allow the user to customize the u-boot env or the device-tree after executing the script commands and before actually booting. Added commands to store the addresses where the Xen image and device-tree file are loaded, in 'host_kernel_addr' and 'host_fdt_addr' variables, if BOOTCMD = "none". The `booti` command can then be executed as part of the 'bootcmd' variable in u-boot, which should contain: 1. fetching the generated u-boot script 2. executing the script 3. running `booti ${host_kernel_addr} - ${host_fdt_addr}` command Signed-off-by: Andrei Cherechesu Reviewed-by: Stefano Stabellini --- README.md | 5 ++++- scripts/uboot-script-gen | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3566a6d..07ad432 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,10 @@ Where: - BOOT_CMD specifies the u-boot command used to boot the binaries. By default, it is 'booti'. The acceptable values are 'booti', 'bootm' - and 'bootefi'. + and 'bootefi' and 'none'. If the value is 'none', the BOOT_CMD is not + added to the boot script, and the addresses for the Xen binary and the + DTB are stored in 'host_kernel_addr' and 'host_fdt_addr' u-boot + env variables respectively, to be used manually when booting. - DEVICE_TREE specifies the DTB file to load. diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen index f72551a..6a8a2b8 100755 --- a/scripts/uboot-script-gen +++ b/scripts/uboot-script-gen @@ -966,7 +966,7 @@ function check_depends() function check_boot_cmd() { - if ! [[ " bootm booti bootefi " =~ " ${BOOT_CMD}" ]] + if ! [[ " bootm booti bootefi none " =~ " ${BOOT_CMD}" ]] then echo "\"BOOT_CMD=$BOOT_CMD\" is not valid" exit 1 @@ -1251,9 +1251,19 @@ fi if test "$dynamic_loading_opt" then - echo "$BOOT_CMD \${host_kernel_addr} - \${host_fdt_addr}" >> $UBOOT_SOURCE + if [ "$BOOT_CMD" != "none" ] + then + echo "$BOOT_CMD \${host_kernel_addr} - \${host_fdt_addr}" >> $UBOOT_SOURCE + fi else - echo "$BOOT_CMD $kernel_addr - $device_tree_addr" >> $UBOOT_SOURCE + if [ "$BOOT_CMD" != "none" ] + then + echo "$BOOT_CMD $kernel_addr - $device_tree_addr" >> $UBOOT_SOURCE + else + # skip boot command but store load addresses to be used later + echo "setenv host_kernel_addr $kernel_addr" >> $UBOOT_SOURCE + echo "setenv host_fdt_addr $device_tree_addr" >> $UBOOT_SOURCE + fi fi if test "$FIT"