From patchwork Thu Jun 30 14:00:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Cherechesu X-Patchwork-Id: 12901851 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 3A8BDCCA47B for ; Thu, 30 Jun 2022 14:05:23 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.358511.587765 (Exim 4.92) (envelope-from ) id 1o6umr-0004V7-6b; Thu, 30 Jun 2022 14:04:53 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 358511.587765; Thu, 30 Jun 2022 14:04:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o6umr-0004UL-25; Thu, 30 Jun 2022 14:04:53 +0000 Received: by outflank-mailman (input) for mailman id 358511; Thu, 30 Jun 2022 14:04:19 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o6umJ-0004O6-3c for xen-devel@lists.xenproject.org; Thu, 30 Jun 2022 14:04:19 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70059.outbound.protection.outlook.com [40.107.7.59]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 821adbf6-f87d-11ec-bdce-3d151da133c5; Thu, 30 Jun 2022 16:04:08 +0200 (CEST) Received: from VI1PR04MB5056.eurprd04.prod.outlook.com (2603:10a6:803:5a::13) by DU0PR04MB9322.eurprd04.prod.outlook.com (2603:10a6:10:355::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.18; Thu, 30 Jun 2022 14:04:14 +0000 Received: from VI1PR04MB5056.eurprd04.prod.outlook.com ([fe80::1549:6f15:1949:f1a5]) by VI1PR04MB5056.eurprd04.prod.outlook.com ([fe80::1549:6f15:1949:f1a5%6]) with mapi id 15.20.5395.015; Thu, 30 Jun 2022 14:04:13 +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: 821adbf6-f87d-11ec-bdce-3d151da133c5 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iXY1k/P0bk3m/GfBSMjWRH/ulnetKmgn6JNt09emUVtWhvCIDRzeOG6JjBVuQRWJ09l2t24WvRmzC35k2VlcOUfN21SyrHOkeZyBb+jy1PqhN0xcj6/37merMNIV+Q6ChDuo7cYzz41W5iPUhPJ8voMXymuIQ/9ki7lEa2bmqSJmLDnv5eccTSQZikjvYHDOFY8TJd7L3llcKEKsYC8DK99G18z+wtUsb0yKILxjmSP1U0/XjvKDnIPx9NGTO81Qm9T1yTJ4/MnCVi1A0Mm2e7NSd2cnoZYFENFtEs0jh1319cKecuO1CFeDVFlWGD/w2auZbHWrBIkLBNAht8y8Pg== 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=7giP8A1iOXK4r5YaK7UVvP9/j+xU4cgR7sxpc6z2ONI=; b=GieAOesNy7rYgjEKVCPDOMjUvJJGdkNuuuwBavfMGjHZmzQBdcD2CU/caecYoLhwNgwcNdXPxI/1TQuPOm22vIEZfgMegA+prtPy/Z2M8TZvBXsi2BnH2vouskn/SVmBX9ikYuMU6ndd7VMQTu7EVYqFYmwpNLzx+gpg2+g10pZONnn6+qVQN3r0fCdycrEGCaVTNHZH+TZYyppr3cblXOTVxBcUkyZKHxaDFN1kIfmj00BivrFSqrGecYo8k5BcydqU2YluCIPAP5hu6nRPYeJ0ExtL9VanNVQc4mW0nQHz6tz1iyKjAMJ0eqowcJj7gzWqR8ewS0ATSMspRBogow== 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=7giP8A1iOXK4r5YaK7UVvP9/j+xU4cgR7sxpc6z2ONI=; b=b3bKox2luCJh3uG9LYknIigWafyWSjOli0Y1SR+sOoYxuYYO4VE80EM4bW2FgjZA3SBpTSv8tmd8PNPpXL531DKapfJl2+HlUfcuxA9NSkMKgcPXH136zTsGKEL3RWAo0QCz+JiHfHca7yFvku/8Eidimf8yjPLy8d3glCKB6HE= 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 v2 1/4] scripts: Add support for prepending path to file names Date: Thu, 30 Jun 2022 17:00:26 +0300 Message-Id: <20220630140028.3227385-2-andrei.cherechesu@oss.nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220630140028.3227385-1-andrei.cherechesu@oss.nxp.com> References: <20220630140028.3227385-1-andrei.cherechesu@oss.nxp.com> X-ClientProxiedBy: AM0PR03CA0089.eurprd03.prod.outlook.com (2603:10a6:208:69::30) 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: 933f6104-b5ca-4a51-6275-08da5aa169be X-MS-TrafficTypeDiagnostic: DU0PR04MB9322: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: BdocNINpiOuxSxtoTht6KPhwqlNKePMkfJSIq6FOuxQaVDoFCP4nhhSeplKZyQBDHPKzePTYt8JSzFfsR1RcEAhHKerSto06RXCpgV0BcOl6YMOlEVCpDlvHaVD2e97+59Xs7AiFAgo1QCTWVLF7b2/DqzLbbLCIHUzZq6KkQ4zNAdrdKQuN689lSILZ1bewSKCSovQniv5N7HQDr2lj6cMXTfpWCT5YzhD/nJs5QUHioiLgdv41epBZhk/yIvcY0nnu+HzZVob/6E6qc9LlsAgxfeh7uipVoyY8zT9i+7Yr+HSTjvUK2W7g6U6LCVlJES3IBkuAIw92AQWBNr4oRj5iZ8YproCIr4lGCNqtFh1Wz2WmSSms5HS0XfmKPexBBrhzv8PcaILo2tKHdX4ENvLP27d4vklv0LW9fT802z1d1YJRfPZUJkRVvM7A3MUtNP1yGCzz3X6jZdAfTZJr2KOmfC8F+nyX5SH+jn69eeK8Pz92iuMvcKFH2x6wa1yRPF6rN65hVGZ9Fmxz4aQLGLdYQcYpgtOTC1XVCqwZC2DuzP6L81Eoy4btk7TGLag1mfu6aPXN4rPGa6Rykn0xCwm/WuheL5PERneR/NwQ4P4iIzT4qfEVBq14/pH5FqyM1Xzj0dCJ6wFUJPAzph2yk0ssQWTfjE2pe8tvBVDn+85EV1uQATR7vwbhCDEWnSH+sw1aV+Jq6bdk29uAVkyIrOItiCOjQflFe19yPAWE088dz+gq0xblpFUUdVosl9f3yxo9SIKbR/tS8CDHk1Gy15htYOiG1sUm/l/SocVqhKJG1k95jszzM2NEggVU+u9U 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)(346002)(366004)(136003)(396003)(39860400002)(376002)(478600001)(41300700001)(5660300002)(6666004)(186003)(6486002)(6512007)(52116002)(1076003)(86362001)(26005)(8936002)(2906002)(2616005)(66946007)(4326008)(38100700002)(8676002)(6506007)(316002)(66476007)(66556008)(38350700002)(83380400001)(6916009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /6inGlVl0mxGbVn8w8PbvLkPDC4AUGE/pgfQHpesNPuYCCLAmpi29Cl0t/NQ9BRCqJXQdNDdv3A4H2LtWzF5xAB168Kv/LXTXZ26XDitkWhJbB/tQ1Xck4zAEOJvU9ijtrnP/ZuYHU4Sbjnkzz2DSsJ3R8pV/PMSNMfgrnuEEHraEK0Lb5jBXr16uPHmzT2RdEbmKcYzcAJWEaB4/Vbl2mGeWNOFggRkYQv5lTF1fyz37bOOQMW4vl78MElFaxW6+DqBU/lhMQ8sQlCe8tcIZv3JS5mDtXYWRfQMPQNQ/cDl8TxWSZE9Ss//ZFZsgf1GCkXJt2CTMjPy+hwvNl9cqCfycU4qlu3fulJ+ENetHQAVNRApL+CH7WcSDu+d1pzUPFNRj0wqu50YU6cGXMP5KuGY6Gyq4vnvumtiFAme0Uus9injZihicHZNWMonB1RprOKiFkqcmdv9SOYz6NZLhlFSWxaP9VpqNEdGaOSBpzNFns+1Rq1dZI3n61karxUD0VuFjoaQAUc2c6kM943PMMEgv974X/eATYref4q9X4mzdGCNEhpLi+tEZMG97rEy7BhvRL997LGg7//Ipyy+4gxlKJLWBc0N9SGls7xtYQxkrTJPWK2E70WWmvSdMYDAcckU9YePq0lwARLkdeYGmbhtc9SCf+nEx9SNkTkxt9powzvvoMpI6Cp9X083qrhtN8M/xfWG1YpF0PxKSmp5i2SXfUsMFHqFaUCPPC8kmEGNEX3QST4+SLeHHt0k1U+n5fgrfG778yFDAg+JhCwtOb7cyW8JetoQmZnBebWWxkYutJBUUrshPLuvWEaPJkvcOaCmMwRauk/CNRxzj8DbmiRmo1XjYEJjvNv+kikR32akLjDrBQPqVmfd9C3iQmIsRhCsiOAf4HFS1LQJ4tm+9juTOKDvyLmX2dKJXj6a0DriZPXu77e+/322ptosY0JYOA8jBNbQgH67LwEjOMTe+8aM060GK9bWWHt/PeeG33Rw9IID6uujRvCwz7jYziiZf5KrgeMQAVXHwA8vdp9todO6BF+W8d9KvPrEBNYn6or8B64JqhmTxZscXfyWywGvAeYxFno+4PKWOH9PhePPrquFz9Reke1pTWWDf2oSP78YLGChElfTRk1ieXapFdw9bSN31QIOtkVWI1wF52naLgIdVYtGTeX7aEDoiJuKqeOuhkBEnb0UhBxwlhjTxXDYbqYYkoBnO1D63wvFCYclT6ZRdRXl+u3zlCv2ulaEqe4sXJj7XdFrPuNs2w/2I9dHLoe2OBYvfMZruBt9o3XDVnY1nt0u/riGjipA+NYLfzdB15ProqVY9G2a9fcrB8ohtp+fuIoJUwQHhUmuItkthA9HOoMgqS0U+gN/7U8wpzfXAWoGW/L/zV3vT8lZ4Hod1kNpIqZbCU3AUH14S98KWqa7OkvRg15wMAk5Syzf4pGwN3lHi+8PlfD37Yg1s1ZgtuJwdsi79OUKzrgQ1GeOz9lRWwWPs9XUz4tbesTk6WL2HTToEREiV/ypz+C26qTUORz+JgMw+v7aPB5JsyyUA59YFElrY4T8MJC+3r1P+BcDC9AFQyY0fRX22XtiixNp+Er4MgAm1A01iLDRs+Mgxg== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 933f6104-b5ca-4a51-6275-08da5aa169be X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5056.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2022 14:04:13.8853 (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: zk+Jo9wKlfQGj/dT1D9pz1hszik6zTfmW5Y20Lc2T+4qz7HCqHjB50M18gYJcUbIp8kFVcNJ4rbfvoTArrghYEZJhAvbAkOzzhO1YIdwfxc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9322 From: Andrei Cherechesu Added support for prepending path to file names in the final generated u-boot script, for the use-case where we have the files in a separate folder that can be accessed with a given $LOAD_CMD. For example, we can have "fatload mmc 0:2" as LOAD_CMD but the files would need to be loaded from the /boot folder within the 2nd partition, not from the root ("/"). By specifying the "-p " parameter when running the script, paths like "/boot" can be automatically prepended to the generated u-boot commands used to load the files in board's memory. Also added the support to disk_image script, to enable generating a FAT partition with the binaries deployed in a custom folder within it, if the "-p" parameter is specified. Signed-off-by: Andrei Cherechesu Reviewed-by: Stefano Stabellini --- scripts/disk_image | 37 +++++++++++++++++++++++-------------- scripts/uboot-script-gen | 12 ++++++++---- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/scripts/disk_image b/scripts/disk_image index 12fb06b..97e798f 100755 --- a/scripts/disk_image +++ b/scripts/disk_image @@ -539,7 +539,7 @@ function write_rootfs() function print_help { echo "usage:" - echo " $0 -c CONFIG_FILE -d UBOOT_DIRECTORY -t UBOOT_TYPE <-w WORK_DIRECTORY> <-s SLACK> <-a> -o IMG_FILE" + echo " $0 -c CONFIG_FILE -d UBOOT_DIRECTORY -t UBOOT_TYPE <-w WORK_DIRECTORY> <-s SLACK> <-a> -o IMG_FILE <-p PREPEND_PATH>" echo " $0 -h" echo "where:" echo " -c CONFIG_FILE - configuration file" @@ -553,6 +553,7 @@ function print_help echo " -s SLACK - free MB to add to each partition, default 128" echo " -a specifies that the size of IMG_FILE has to be aligned to the nearest power of two" echo " -o IMG_FILE - the output img file " + echo " -p PREPEND_PATH - path to be appended before file names to customize deploy location within rootfs" echo "Example:" echo " $0 -c ../config -d ./build42 -w tmp -o disk.img" } @@ -564,7 +565,7 @@ then exit 1 fi -while getopts ":w:d:c:t:s:o:ah" opt +while getopts ":w:d:c:t:s:o:ahp:" opt do case ${opt} in t ) @@ -606,6 +607,9 @@ do a ) ALIGN=1 ;; + p ) + PREPEND_PATH="$OPTARG" + ;; h ) print_help exit 0 @@ -828,56 +832,61 @@ mount /dev/mapper/diskimage1 $DESTDIR/part/disk1 # only copy over files that were counted for the partition size cd "$UBOOT_OUT" -cp --parents "$DOM0_KERNEL" "${DESTDIR_ABS}/part/disk1/" -cp --parents "$DEVICE_TREE" "${DESTDIR_ABS}/part/disk1/" -cp --parents "$UBOOT_SCRIPT" "${DESTDIR_ABS}/part/disk1/" +if [ -n "$PREPEND_PATH" ] +then + mkdir -p "${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}" +fi + +cp --parents "$DOM0_KERNEL" "${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}" +cp --parents "$DEVICE_TREE" "${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}" +cp --parents "$UBOOT_SCRIPT" "${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}" if test "${DOM0_RAMDISK}" then - cp --parents "$DOM0_RAMDISK" "${DESTDIR_ABS}/part/disk1/" + cp --parents "$DOM0_RAMDISK" "${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}" fi if test "$NUM_DT_OVERLAY" && test "$NUM_DT_OVERLAY" -gt 0 then i=0 while test $i -lt "$NUM_DT_OVERLAY" do - cp --parents "${DT_OVERLAY[$i]}" "${DESTDIR_ABS}/part/disk1/" + cp --parents "${DT_OVERLAY[$i]}" "${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}" i=$(( $i + 1 )) done fi if test "${UBOOT_SOURCE}" then - cp --parents "$UBOOT_SOURCE" "${DESTDIR_ABS}/part/disk1/" + cp --parents "$UBOOT_SOURCE" "${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}" fi if test "${XEN}" then - cp --parents "$XEN" "${DESTDIR_ABS}/part/disk1/" + cp --parents "$XEN" "${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}" fi if test "$NUM_BOOT_AUX_FILE" && test "$NUM_BOOT_AUX_FILE" -gt 0 then i=0 while test $i -lt "$NUM_BOOT_AUX_FILE" do - cp --parents "${BOOT_AUX_FILE[$i]}" "${DESTDIR_ABS}/part/disk1/" + cp --parents "${BOOT_AUX_FILE[$i]}" "${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}" i=$(( $i + 1 )) done fi if test "${BITSTREAM}" then - cp --parents "$BITSTREAM" "${DESTDIR_ABS}/part/disk1/" + cp --parents "$BITSTREAM" "${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}" fi i=0 while test $i -lt $NUM_DOMUS do - cp --parents "${DOMU_KERNEL[$i]}" "${DESTDIR_ABS}/part/disk1/" + cp --parents "${DOMU_KERNEL[$i]}" "${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}" if test "${DOMU_RAMDISK[$i]}" then - cp --parents "${DOMU_RAMDISK[$i]}" "${DESTDIR_ABS}/part/disk1/" + cp --parents "${DOMU_RAMDISK[$i]}" "${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}" fi if test "${DOMU_PASSTHROUGH_DTB[$i]}" then - cp --parents "${DOMU_PASSTHROUGH_DTB[$i]}" "${DESTDIR_ABS}/part/disk1/" + cp --parents "${DOMU_PASSTHROUGH_DTB[$i]}" "${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}" fi i=$(( $i + 1 )) done diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen index 085e29f..8f08cd6 100755 --- a/scripts/uboot-script-gen +++ b/scripts/uboot-script-gen @@ -316,7 +316,7 @@ function load_file() then echo "imxtract \$fit_addr $fit_scr_name $memaddr" >> $UBOOT_SOURCE else - echo "$LOAD_CMD $memaddr $relative_path" >> $UBOOT_SOURCE + echo "$LOAD_CMD $memaddr ${prepend_path:+$prepend_path/}$relative_path" >> $UBOOT_SOURCE fi add_size $filename } @@ -891,7 +891,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]" + 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 -h" echo "where:" echo " CONFIG_FILE - configuration file" @@ -907,6 +907,7 @@ function print_help echo " HINT - the file name of the crt and key file minus the suffix (ex, hint.crt and hint.key)" 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 " -h - prints out the help message and exits " echo "Defaults:" echo " CONFIG_FILE=$cfg_file, UBOOT_TYPE=\"LOAD_CMD\" env var, DIRECTORY=$uboot_dir" @@ -914,7 +915,7 @@ function print_help echo " $script -c ../config -d ./build42 -t \"scsi load 1:1\"" } -while getopts ":c:t:d:ho:k:u:f" opt; do +while getopts ":c:t:d:ho:k:u:fp:" opt; do case ${opt} in t ) case $OPTARG in @@ -953,6 +954,9 @@ while getopts ":c:t:d:ho:k:u:f" opt; do f ) fit_opt=y ;; + p ) + prepend_path="$OPTARG" + ;; h ) print_help exit 0 @@ -1179,5 +1183,5 @@ then echo "$LOAD_CMD $fit_addr $FIT; source $fit_addr:boot_scr" else echo "Generated uboot script $UBOOT_SCRIPT, to be loaded at address $uboot_addr:" - echo "$LOAD_CMD $uboot_addr $UBOOT_SCRIPT; source $uboot_addr" + echo "$LOAD_CMD $uboot_addr ${prepend_path:+$prepend_path/}$UBOOT_SCRIPT; source $uboot_addr" fi From patchwork Thu Jun 30 14:00:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Cherechesu X-Patchwork-Id: 12901852 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 27678CCA481 for ; Thu, 30 Jun 2022 14:05:23 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.358512.587772 (Exim 4.92) (envelope-from ) id 1o6umr-0004br-GV; Thu, 30 Jun 2022 14:04:53 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 358512.587772; Thu, 30 Jun 2022 14:04:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o6umr-0004Zn-B5; Thu, 30 Jun 2022 14:04:53 +0000 Received: by outflank-mailman (input) for mailman id 358512; Thu, 30 Jun 2022 14:04:19 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o6umJ-0004O6-OP for xen-devel@lists.xenproject.org; Thu, 30 Jun 2022 14:04:19 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70059.outbound.protection.outlook.com [40.107.7.59]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8319805a-f87d-11ec-bdce-3d151da133c5; Thu, 30 Jun 2022 16:04:09 +0200 (CEST) Received: from VI1PR04MB5056.eurprd04.prod.outlook.com (2603:10a6:803:5a::13) by DU0PR04MB9322.eurprd04.prod.outlook.com (2603:10a6:10:355::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.18; Thu, 30 Jun 2022 14:04:15 +0000 Received: from VI1PR04MB5056.eurprd04.prod.outlook.com ([fe80::1549:6f15:1949:f1a5]) by VI1PR04MB5056.eurprd04.prod.outlook.com ([fe80::1549:6f15:1949:f1a5%6]) with mapi id 15.20.5395.015; Thu, 30 Jun 2022 14:04: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: 8319805a-f87d-11ec-bdce-3d151da133c5 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g0TPi6aWJw0SO7x+DuRH21xHOnECvpwd0r0ZTSN/0C+JhUd8zMpFDTT9eZUTMQHK6+uxz04snj/mFZ5Hwcr/WD7rWEvVE5RvSFNZFs58sLW4oG0OpWDPCuBKjZlwXOe6BNuSQkVw2wbpfp4xNYLMoXMAb17gou6LzD3TcAIShzuzyfAefit0i4iH2m8/k5xR0GDJoGeCUt4d5FKGIl6+6SZ+utgoPiMhEhOBa7/9l8z3mOgFQHGl+Ja8ZtGmBh/qvn8cl0BKUzV89WjVWExpXtFzlr0Fq/uQFgEsmYABjnlq3Izp7hdZkSTVgAyy6BPSrrZ5l/WJPf5EkpkoeoPQIA== 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=mfbrWwedUKkeHZ6Vzec50C9Ikd+SBPs+wJbOhcnk7gjpJFkuSMl8fCTm5iURExowkUzuP4fDtjcJX6kb0sBJ9AhqZ0+W8gY4LYfFM1AP6fzYM1/tybx4DeB/PUOwqtAL9S5AIegQxgpcICifnfOZwkeUGPnSWelqDfFpZQ5inK1tyLY+0dstNax/rnoQiHj1eAYbbsWCanowMDxm9RqhgJadC7fX7vQM2fKzzI3nsUAuYZk+FeLAiliu6KFozvtWwCc8lg1h04OarUR8puEYXHyLGW1qXU+oZG/jmziGx/IMqW0cXqoZXYxuYA/J7fpbU0hX6exXzY/EyFTWHWHvng== 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=FpqiTeDycGl20L854ENWpvCiRyWibKzqfc8uPwHzhnDd5BNm7EoF+ZiLiwuLzP/REW/T7F8aBlp+IVeQ3FyojFetGjaFRbd/q4gjYCJNpUYxqSRdUmSGHTHoTYZW0w5y/d5CWg2+zzxq/EdV9DvhWIKBcukOQEjkvCIz5XSG57A= 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 v2 2/4] uboot-script-gen: Dynamically compute addr and size when loading binaries Date: Thu, 30 Jun 2022 17:00:27 +0300 Message-Id: <20220630140028.3227385-3-andrei.cherechesu@oss.nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220630140028.3227385-1-andrei.cherechesu@oss.nxp.com> References: <20220630140028.3227385-1-andrei.cherechesu@oss.nxp.com> X-ClientProxiedBy: AM0PR03CA0089.eurprd03.prod.outlook.com (2603:10a6:208:69::30) 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: d9c75e5c-1b4c-4582-c8fa-08da5aa16aac X-MS-TrafficTypeDiagnostic: DU0PR04MB9322: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: N59m1XvfonJiMTpf+UpG/yzpCE7zOaAYt3GjBy5A1i+bySQs6loarS8kvi4osTx1MKoDYVagDkAO78BJ07t+yVBfTNGsyhS6lJBjfXebx+woEGOewxF7DQDV3RhokQpT2CifvB+NM8Ke+y+nErbhnjf/a8ogGxDkGYKrBoBzvSHfpzJLOH/9jPFwbXTGf5bhT0t9ViDhJ+NDwCmlV0zcVb0WXWix4jkdmicD1U+LeE+6VZMUsUpuUNEhw3t2jZwWHFOUzmySpFb5IT0alpQMumuSg7IhBL2qtUMv717hx9LDzLtqfQJaw1+1pjuw+r34x3B5cOHs8H2O0INJjoSAma7IlbSPTEgG2IY5MbaFVEycQiDZ5t23DN60mBqAdmjEGRn2FAmbg0ItOgg0e37AgzS+zs6UjCLNfI30PcKvMLYeCrtLqxlhtPfdznWupMp2trUJ54QQl0BeWjV4X6/qTQmgLftOgd0PSZVcLjfzUqQDOozRYV/CGBnnuORDrG3pYSiLqtlutlqMWIpAlmhPFVo5cBiAO03XZ5u5nvf8ynMACiuppq6QcqsQmd9Hb9bZZaDu/NWniycjpFAvEelgolT99uI3FHngUwuOnCiXyWDq9jOYvKH4ZPmz09d7p3HtxT1m/8UQQD8VuEYdhgK7UiOGLlE7J6xAd82myKsj34AmOhhr291Ismo8pxqN8I7IBuWMUFN0lmwLoXpg4eamT5nwRRpojbHTpA18w4wvjYBSIEQGSfxnXVfVJfMfZAGPHKL5GMFwoVnJSS4XCibaDkJ4gRBxeBAQIlrRh1OkQ0ohfNooMN0iAOv/KGZExZtV 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)(346002)(366004)(136003)(396003)(39860400002)(376002)(478600001)(41300700001)(5660300002)(6666004)(186003)(6486002)(6512007)(52116002)(1076003)(86362001)(26005)(8936002)(2906002)(2616005)(30864003)(66946007)(4326008)(38100700002)(8676002)(6506007)(316002)(66476007)(66556008)(38350700002)(83380400001)(6916009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UqVlQVeYBSBgjIjgqtGzIINuDHvlUtdBkhqdpht7W1WhNJvjwmMQp0/VKFTBXrJ2yAsG8Gz0wId8uNdO5dmrHs/Rj0F3zt4XMab3rhceNjzEGa44Vhfxi+ZEHYcjIKvo92FWvHNlTYHdpE3fk/yKssE4kQLyZUv+HM9+ztSSuzz95wsRguixKxbcF8zIKUaZqmSay5u9MzC19noNw6iCXBPhxVhcyfseDpgxrw+InLaegPTi3FxiyQTzY7jFt+6IIPmvTg8H98IZHqAF7jPkgLrSQfghjka5JwV2ue2WmMRVUIZqH//uO5HmkpIs03iW0b4HbWaH1Y13BRH5egrs+SCSNt7Y9nRzO2cjxm6w/97SSSvDuMq7b07e4ALbdzIEwrbgQ9cl+njU/NOGVYEg8jQJ/ltAr9BfGMm5K9bR+J33uPkggcOYIPPYuXVoAPOAxzkCTYeNhhC2yNzu7ZrsESJuOHeqYlSlno0yXVsHCgBcs/8GLGKpzEl4SXmgXdU960rSzUbreat0zgpf3WaARm6d3+2yNxj49R+dX46q09ahzlT0V2SBM5cuueaU/R06vgPzYz5YWWq7joyConCnNMgz0OFQ25MgxkzdI5VSDo3jnLIc1BeZ2ZKuXttR6eMsqIM8I4jn4ElGZ9V1/cO4LllIcFfTtNvN38ACAz281ex4i/R+nnibl0XwMtEvb/cA/KOo9LTThfBPpwBnsrh7mZ99lNIjAWO2NHbfXTz7tZs5rFxq5Na0IZTJQkwNX8zc834+VRDdK4O4XAHpgj/Q55/5XAo4kveJIRkeuxqZq9nvEWb+CX6pkf5zoMAHIcpvtTrI2aHzy/rlkiaWj6ChxzzPVOyeRlFZgSWZWuNjcj4RWqL/YT5aI055EWeLJO7A0ElGy5EapPm84aVgZy5LAdHv0Dxiqzx7P36C6k9Fnf9yaWsK7+G7JYdVHJkezL8GH4qg2gJSzvehwjK7YwEUjMLwFd2z7DkDIq1lvDtMQ1kRU4hJL184ZtRiTJJR7xm11C3uY4fR57X+EIV1chYiZx7cLYYSrwA1RI5Burctg6EN0LUZtNgEBH6oKRslUvkvL3FkL4QMzXu3E173txSMvK/FU97ZIsabbO23xNVHr5hZT3lnW9n6YJbc/jVyGWerYM2t1yuWhhU37BI22uKNOaA60IJiqz+YQeyiOUnFOeIrpgO+ofOOGcq6kCclhHYuVXSeLzAryQCbhuJu9Ef48bsCn9Rp+W3wZr+FL/hPQ7PFxbX/qvevfIpupq8q6FK2mKsa32P1dtAW4Anm4GcBQJRJ0tZDquNg5MROX3nn5QAeuyK83JAPtFf2eBPXYK/T4xDJwFuszzt4vLovdNfFFrNjh8WR2s6RBb8+OVupmjUplCAKVVipxvdWfxVAWb9yzqHEhzhe+6o53iE6/9r5oY0i3LHjjlcQTjXSxIgKL56VhadpgzkEDRoUuS5ncRcls/WtlPO1gmqpdv4ODbmg0n3PPaY9Ih4hv3oFli26sHJ9Zz4BbVy5WNiqfe7ubSqraZnv3txb5g0pu5z2sRZhU0DKKC+aW+iCSqI2/Pdr9BQyzkAgXBRkkDiW3uaRlwsPqTfddf/89EEafv8EwX3CZQ== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d9c75e5c-1b4c-4582-c8fa-08da5aa16aac X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5056.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2022 14:04:15.3851 (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: VoCm1R/4Tv579CrJBDiUZo5DW0flBwP9NdKGmmPYGSSNxoNrEVX9HE67SqbzQrhxC7/QLlMjZYXhpPlxVqRrd8x7fGFj7biLyLNlyleLIuI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9322 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 Thu Jun 30 14:00:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Cherechesu X-Patchwork-Id: 12901849 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 11D49C43334 for ; Thu, 30 Jun 2022 14:05:22 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.358513.587779 (Exim 4.92) (envelope-from ) id 1o6umr-0004hB-Pu; Thu, 30 Jun 2022 14:04:53 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 358513.587779; Thu, 30 Jun 2022 14:04:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o6umr-0004fP-Jc; Thu, 30 Jun 2022 14:04:53 +0000 Received: by outflank-mailman (input) for mailman id 358513; Thu, 30 Jun 2022 14:04:20 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o6umK-0004O6-9U for xen-devel@lists.xenproject.org; Thu, 30 Jun 2022 14:04:20 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70059.outbound.protection.outlook.com [40.107.7.59]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8398080f-f87d-11ec-bdce-3d151da133c5; Thu, 30 Jun 2022 16:04:10 +0200 (CEST) Received: from VI1PR04MB5056.eurprd04.prod.outlook.com (2603:10a6:803:5a::13) by DU0PR04MB9322.eurprd04.prod.outlook.com (2603:10a6:10:355::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.18; Thu, 30 Jun 2022 14:04:16 +0000 Received: from VI1PR04MB5056.eurprd04.prod.outlook.com ([fe80::1549:6f15:1949:f1a5]) by VI1PR04MB5056.eurprd04.prod.outlook.com ([fe80::1549:6f15:1949:f1a5%6]) with mapi id 15.20.5395.015; Thu, 30 Jun 2022 14:04:16 +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: 8398080f-f87d-11ec-bdce-3d151da133c5 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N28HQzeyfEkoXNgIyh6g3bG4X1wzaLamMZwAcohnVXQ76Q/PKm2TxVyE8p9EpQPr3hhSudVf2+RWX9J1U7cZ96DSdVO21i5R8Jc19xbTBGZvmaTL4qJK/pbNMC1YfxyDHTKDdCyNsqu5oWpqp8OeWNz33V5b0L+olVnT+3o0eHc1DrP2aGopaU2NzL6DA9xmq7QAYTcLLPWho/QU6gaZmBdsDhHZfMolcIywrZefEGbqsAzGbv69NaWZBLzgQRDhixk/HpKWZRZUc8xndf1L+KsX6L3LKaoi/7bKLJbCmlrZF1l7GSdkHzJz9ARXi7p0O//TRFAeYV4DbZshQAhgiA== 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=slRq7QSM4ixKn2x0tNbd2VGZDBfK2EupasNiNNU+x2c=; b=nkBLdNbmNoyQ3V0LM2eNHDA8otlqnWNCEGLxyU09082a7HtXThmCqyQTilYT+WarAbuJbupVsN1yqDGSeg83bvJAinKmxm1XeIkJgp9Gv4buU4EMWFMANG8bHNiodEPpU3nJZT7oUPAKaqzFQ63dlbJbqm3bZkYpuaCQtQ2ZI2VU3zHaRZx9ffW69VbL1EXR4xb4sK9h3pJ+4nMxcLAATF3+OF3Iu+84eTIhyCJYSyoL9rUW4V38hgQV/rqB0zHUVQQFXCn+0i7uD5o7qBRwRVeDg2QxuA6UJ5dv8xQNX6hgMmUy5VGRHSwnRXsCsWuTcXvZ5vDOj0XGeLBR/eqTeA== 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=slRq7QSM4ixKn2x0tNbd2VGZDBfK2EupasNiNNU+x2c=; b=KqRcy4Z6BEh5Ei+OsiD3dQNyV5WK6l2weeqhYIlP4UknJm5B1EF5KFj3mwvj30nSkBg4fRGl20g5BQdsRVXWa/fuEOdcy7HaTRt+99SATXSA/V8BkHQwgzPPxioGLQokrzsLelZyfVCt1aY4OU7a8R7Vg2nVTmz3D29SsCymI5Y= 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 v2 3/4] uboot-script-gen: Enable appending extra commands to boot script Date: Thu, 30 Jun 2022 17:00:28 +0300 Message-Id: <20220630140028.3227385-4-andrei.cherechesu@oss.nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220630140028.3227385-1-andrei.cherechesu@oss.nxp.com> References: <20220630140028.3227385-1-andrei.cherechesu@oss.nxp.com> X-ClientProxiedBy: AM0PR03CA0089.eurprd03.prod.outlook.com (2603:10a6:208:69::30) 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: 3acbee7f-13ba-46e9-6d00-08da5aa16b77 X-MS-TrafficTypeDiagnostic: DU0PR04MB9322: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: 8hu0YU/b5vU/Au3Dw7O9H3DsUtx/yMPpoUQUu7/TS2HaVc6vxDmJVL2EbGtmNSglIRVSTJmr4WfBp8KbpOYuFs7SmHJ7J3EeDzxFnHxcOcaVW3QVBKltR9fvH0JHaErKhRpIYJU/7voixjiTZhr5b7gWM58OkTQd2uXznnt7bYAEAxAbl3qkRxJZA9GxOsX5biCKWn6RbpQUBLSZBJ5ABa6KiUwj6kqcEA18wppzAWT+l7E9GYJls9+nRLmQH6+albhqB4vE1bEE7JSUvIeaSPQVOk7Ydj/qJRgzzQ4Y4w4+LfkqMIhtrHc3wu0lkKlq35t8I/s3u7dpYJHT3FrkqiSHGJsmSDC1B5I6em2eLQZKj4E/cDRqFRQTSP7eKCDYfOjHkfaXq5i8tP+bWvVcOXOuDZenil25vLW5q7NYffBVrH5Y00ANE9vd5HbQ28ALfblZTPyKAzp/wHT7lOfP+m/GBQrDw+Zx3FSbtVb72S0KLb/AWGWeHfxz1EiDPES1X+CuNbrDpCDzQ68TqYOpDj1oc6RkLrZHXWy/WXYqOwlcrC0Wr0YbMxTfoK31gav4TCT+91TZKE6aPbk3aoUSxFsUzhMdAT8T+jbRUUCOJ3nf4kTiAmZqjCS+mipVlPNa9LdqkK4g7SmxJl2on3cm+D4MktG65DjuzDrnnHY2XQUNMO0ktLVlaBXhfsI2MlE06HGoph+bJVLnrY/5JZWX5SJuFF6uUFU6/5PNM5Vikayba2jh95V/NC21B2zIWz7hQzQxK1lGMNe3AIGyO2VCOzXRSEFYf7wCQ8kl7mvFWvmhaj4w1Lkg4c23pLy20TZ2 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)(346002)(366004)(136003)(396003)(39860400002)(376002)(478600001)(41300700001)(5660300002)(6666004)(186003)(6486002)(6512007)(52116002)(1076003)(86362001)(26005)(8936002)(2906002)(2616005)(66946007)(4326008)(38100700002)(8676002)(6506007)(316002)(66476007)(66556008)(38350700002)(83380400001)(6916009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tOqvql/MD4ejQ4kO7mo54xgh9ZR7tORA7n1HzA+7Kjzk+vWBcQopMhSvOPsZ2Q1Atdo/vQx2ZXhBRwoTMKRN/KPtuRaE+LPnJc8qI9UcsJkT17WBeuJ2tf2fYxUt46KlEHTeTfFvFKmSBNyeBB1VRSvZbscHdReKMBw9Zm6e6bqhuFZitFeNFfoSSekMwY4qx9MbAv8U7UZGz86ZHdUc2XjBD60ixXKpoQtksxp39JLZ/qkOY78dYOeet4Oalyu+kIcI8K2M2ZdKY98eevpMc7q9z8UIsfPUHmbcrzlBqSTQmBOP6odYYJNURjsUBhw5KQi8rEDDG/R1aaVcWNdOMAsr1x8r8gjBZkD1cUxOLWu/UTW5BkmJ0qVEvpROO12/D5pT3WSA1DyjLYpxRIBk3Ykkmq7wYbqs42sUkj2VdYgQbyJ7fhfkKi/CrNSo29czF0Qi1p7+kuOO/gyimlolicrvg2f0LR/48EGh/UX4VTH/AD2O9BxOl/MZqvTqJ6G0rfphuCvc477kVGWTZiuvcus4slLTyUWGGRQigviByUI61GwQvRMyxWT7BF4EkG1ia+FnsdzRNh2/75WkOfCRWX1wtP7fzl7YZHeTGBntZIW0W1rDiGk/z7GPIRTPqD+ctg//7pUZS73f1ZAJFgl/Q1Ycr+ZHHtxaWdMd91ceq4c5vbgtwTQg9Jee8KRC7W3lJsk2cnqIYIR8P8mW4kP+qABetjiltYOL7Vp1bLp3PmuHJq7YzoDp6n/23PbjVJ0+zQZhwpsUsdvNwh7rlNVoELA3KRZWIIk9b+MyMB4KTyIJ7BOvFgPhv1V7Qk/GtFCKCxllLeJIu55eDP9o33NjKC0Sucj9XNa64RygyesoHCwkhiW94Uot4apJVXo9cNMUReyqYH4FiZGnQ/yYIvXT1KNtgQ0eKFt+GjSN4UKbLGbAlDn2jMucVF6CnMXH40E5D4FVN8QZI1BKElWA4bKDKlEvfTAhQlOQ+99wYE05Unnn+Fml0ecAq32nArRfHVocK0IwCp7URTYd63syUs0Yy1gHC3JSB6dqZcysEeCYgSPFNrTQAXhjR8tJVv/NSCr6MobaI4iXVAcVXY8Iescot7ETM2WhMOkF5Ml4nAJYRdRrbW0tB07UGVy59pDLrusq0HE1iRQzHHvGhdXKoYR4FOAVXdkvtAA8DkEtrWRzREdOAArms7DkXhNaKZmyxYH28v9Uw3HFQH4fKsIjapJV2kQTBrB07oZhd47z7Ynms4lkoQY8zwaZ0TIhxDbVifU0Z+Sh45TgRJ6YcMeYgQpGARJNomLanWGs4/musL2bhtyfN3nP6dtyiTOHApCc7YEbHe50mqUHPgyiS/csu4XoiEkx8rzOiwWINa/cslZoAvogKBRAJn57VQsONeRNFLSIOfrUoHtPZbcnWmw3REtmzQzXjXi4qo8oiSfYMjKtgi82ATihtxPzFx4qyz615f8O0OQ6mSE1ViGorerg3i+2yFduFc3clhBDbOu+VyjZWph1azu2mTh8eRFBwjvfKTaiyYc81IAL7xLpaWrwbNphCmo8qhk5g4D7CZC4boemWWwoKbmE5FIRK8Bk8CprNJ0yZY4Q0xvPgUCDsb5AKoTSrg== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3acbee7f-13ba-46e9-6d00-08da5aa16b77 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5056.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2022 14:04:16.7132 (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: 7ACarorNNtrjb3ap2HLw+RmQDTul/TZbMMNGeyHQS2j8KwlE5RZR9ONyJ5qxnsTPJbo2nOui4rgbjN1cEZcDyVWi1PApoNKHu/guKoTyyfM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9322 From: Andrei Cherechesu Added the "-a" parameter which stands for APPEND_EXTRA_CMDS option, 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 via the "-a" parameter will be copied as-is in the generated script. Signed-off-by: Andrei Cherechesu --- scripts/uboot-script-gen | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen index f8d2fb0..444c65a 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 @@ -973,7 +977,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] [-s]" + 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] [-a APPEND_EXTRA_CMDS]" echo " $script -h" echo "where:" echo " CONFIG_FILE - configuration file" @@ -991,6 +995,7 @@ function print_help 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 " APPEND_EXTRA_CMDS - absolute path to file containing extra u-boot cmds (fixups) to be run before booting" 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" @@ -998,7 +1003,7 @@ function print_help echo " $script -c ../config -d ./build42 -t \"scsi load 1:1\"" } -while getopts ":c:t:d:ho:k:u:fp:s" opt; do +while getopts ":c:t:d:ho:k:u:fp:sa:" opt; do case ${opt} in t ) case $OPTARG in @@ -1043,6 +1048,9 @@ while getopts ":c:t:d:ho:k:u:fp:s" opt; do s ) dynamic_loading_opt=y ;; + a ) + extra_cmds_file=$OPTARG + ;; h ) print_help exit 0 @@ -1235,6 +1243,13 @@ load_file $DEVICE_TREE "host_fdt" bitstream_load_and_config # bitstream is loaded last but used first device_tree_editing $device_tree_addr +# append extra u-boot commands (fixups) to script before boot command +if test "$extra_cmds_file" +then + check_file_type "$extra_cmds_file" "text" + cat $extra_cmds_file >> $UBOOT_SOURCE +fi + # disable device tree reloation echo "setenv fdt_high 0xffffffffffffffff" >> $UBOOT_SOURCE From patchwork Thu Jun 30 14:00:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrei Cherechesu X-Patchwork-Id: 12901848 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 E606DC433EF for ; Thu, 30 Jun 2022 14:05:21 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.358515.587784 (Exim 4.92) (envelope-from ) id 1o6ums-0004pm-3o; Thu, 30 Jun 2022 14:04:54 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 358515.587784; Thu, 30 Jun 2022 14:04:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o6umr-0004nh-Ti; Thu, 30 Jun 2022 14:04:53 +0000 Received: by outflank-mailman (input) for mailman id 358515; Thu, 30 Jun 2022 14:04:21 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o6umL-0004O6-5X for xen-devel@lists.xenproject.org; Thu, 30 Jun 2022 14:04:21 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70057.outbound.protection.outlook.com [40.107.7.57]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 845c74a2-f87d-11ec-bdce-3d151da133c5; Thu, 30 Jun 2022 16:04:12 +0200 (CEST) Received: from VI1PR04MB5056.eurprd04.prod.outlook.com (2603:10a6:803:5a::13) by DU0PR04MB9322.eurprd04.prod.outlook.com (2603:10a6:10:355::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.18; Thu, 30 Jun 2022 14:04:18 +0000 Received: from VI1PR04MB5056.eurprd04.prod.outlook.com ([fe80::1549:6f15:1949:f1a5]) by VI1PR04MB5056.eurprd04.prod.outlook.com ([fe80::1549:6f15:1949:f1a5%6]) with mapi id 15.20.5395.015; Thu, 30 Jun 2022 14:04:18 +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: 845c74a2-f87d-11ec-bdce-3d151da133c5 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iaNeOhHqZRiDSLBjIYipfklZW9Ie3cfyB6qlqKLAY9+osIwNHCX2Z4oV6garVDFhCFPTZDj9Jc8/bBI3F4JhMwB9QVg/LjHaA06d+/gw2Pl/UlyKemZfw8O2EKruZGpH+oUVhIyWZCA0mxVGdn9nPqnu+b0P3Rx6+PvsQ3gA4ve3oDVj2bASEReS9W/lHB1IUihBAkM9tS3J1v2u41U8mJIyMaV69LySbl3BWiQeGS2Ww0ns6NdudVumlR454V61FW4wc9oicKlgSp698atFQntRKlyg2/9r8SPwuVGgmL7DO9FQmwEBq/AbVfzkUbYVNOOZwHfar0Dl6eOWlncifg== 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=IEOir/TcWxDepJgogJp+rLWOzXH0RRWLH/R0bAwSxes=; b=Y3Gd2hQrS94vwh16oJ2N70W43LWmaZtdvJKE2Zt2VcuxgbRYqMxnzMu0TSdDgPoUshpeRFDTp1fWXCll9q2BwXXwyVk03PPQ6Cu/Z4ucfbEgQZNJBMQ+Bw0HKSi9qcFKdffbDtDBoHn5cIjmhHtkygrGytwYwm7fj/Z9CJ1rtcFJ15nVr+oCeNVMprMZXXkCgOyYvMyNISLOtC+M36qNO8mOxUn2wqYszwkF1udHbPw6t1iBLmLYzaI6AepV+FH1FMpqvGbfzw98amyrLPTw13fafU3CrBn4Wk88Tmm3ZujTZEs1oXm3K+Fw5TYsix74/ALQuGK+Pp5paGE3k8Eh7Q== 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=IEOir/TcWxDepJgogJp+rLWOzXH0RRWLH/R0bAwSxes=; b=Z4ij3h4QhH+o8FEfpit/cKJUDNqRo4BGo6jBHrPyoDNLC6on4wf1xChSgB7itEzIvKd9uLcFIvWP+26hflWlmB+4UEyl3q5mMaaNUc0E9wstB/kaL7bwKsN6jSMqp3+4QAzXQ9Uz1roOo1Hcv5jLBNZ4ClD6Wn2FIcmuSFx4qGQ= 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 v2 4/4] uboot-script-gen: Enable not adding boot command to script Date: Thu, 30 Jun 2022 17:00:29 +0300 Message-Id: <20220630140028.3227385-5-andrei.cherechesu@oss.nxp.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220630140028.3227385-1-andrei.cherechesu@oss.nxp.com> References: <20220630140028.3227385-1-andrei.cherechesu@oss.nxp.com> X-ClientProxiedBy: AM0PR03CA0089.eurprd03.prod.outlook.com (2603:10a6:208:69::30) 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: 91ed6371-c465-42ee-1f5a-08da5aa16c93 X-MS-TrafficTypeDiagnostic: DU0PR04MB9322: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: 2R0yvQkVV0ZbmP+qQBWaoy+eo1ecg8F5/ZC0MyL1ZxXepCy83RY8kHeCzfOSoQR52FNG+xrOJH3ls4Adbnq8GYOGXJN1+DkvK689YcJSbzGkfbvvpxrFhg6oYqWnWhBKe/0L/+C+OfH9S7ycSK2BHClF5pxACUeljsI3JgVc6duED8+upYjopZfJ7KiZ/KsVCgMzVHwDBbxM6cMNRudm73qrv8SCyzpIkl2paCPNMhea44pivSRFfMA03c39VJKB2PL+zYWKCkZ2EC9PSJ5xxpOBW2i1R7Y0f8VRfcivwhNfuQQ+ynivlqPVF1x8r69skFcOWZX72iEAFf3wbZJomta0H/KbenL3YezO1BcUmo/6J//E8beFlpAl1k4sz1df2Ewa+pjIZizdiVzUACenrVcjKVPp9/EmwlUlE0erhzQh3rm6o57xSi22aiZEwoPL3Bq08qFB5w+cZnCKV0xkIvycc+YoAh0UgQsO9he9VVJlEaUEMRNK9//w9wNAkqWNo22LRyyBjbpCImNcuJiEED778/uyAAO5j1yrBbx+Ov7/RrUy/DJFwsNsRNOi6vLai5M/j+BfpZRY3BGY0UxSP9u78YWMU4IxkTxIaOpxeiS3VXL/x5UQBRrSDOTWmuaLTXDAe+wpDGMsALhbQ7KqettF2OprRgZskZqZsEXGRaxlzRcMtgz/oSZ95SNFpwnPDAe85vHR2RnSsvAKPToDp4sAyx6+SFaO34gwz6nM06U7Nzjuvs3Fh0VVZYMdz919h+Pqp1a+MIXIMgYz+cH6y2kSasO7mHQ9xBd/uCmO7Y/jCcY6PUdKQ0BDDZveI9x9 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)(346002)(366004)(136003)(396003)(39860400002)(376002)(478600001)(41300700001)(5660300002)(6666004)(186003)(6486002)(6512007)(52116002)(1076003)(86362001)(26005)(8936002)(2906002)(2616005)(66946007)(4326008)(38100700002)(8676002)(6506007)(316002)(66476007)(66556008)(38350700002)(83380400001)(6916009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LsaCxl+YMIsKgAg1h9c7B4CTIvi+WIDV/juo2j+mf04+HNBfGNa75fFtUkAaDadxhNl+NTWCNRPX1trj8/VIQRypK38xVKtcrDnJI2I9bydO9veYf7XtvT8Ca9jgs/vtXS5o8V9lGUcM85H0h4U2FCCdmjHJ5AihbtIqviRxXICppYyqP0XEanWu921kndKGTXFOIkDBxW3YT7csh7OiTxltvjVHksR8NuDPhPoAnmqwatVD0D9sjJy+qjLCBjbWl/QUshgQc79kGYO9S1Fl11fjEDaGPTKCw0fnsL5h9Oxve3M+pb6HewoP2m89fb3YOwulmSDLHvlBgKU6fL8J/nM2TTXbuL7X0BckCrbzReT5isJqfs1bj/KvqPHqYkt4DtPuzBb20itLXyjb4P0b+8d64c4Pb1iBK/ykF1pu1hqxf+en04Vv5BTNrf7wU14Wo5FGOtxyJeb4SKxX4QWvApHfqFCr8V/4aJTXsg628vMokulEsUfSXnaCwgDNwMlnbu7/tXLfV1VM/oIpkWzdTt4KwhgAgvEKRLHHzMlHp/niiicZUB2Hq1LUlAiSXedvuRvGFJPj8NBtq+LzU+qTUhq6xgLqcm5g9uh6YVzvoevNyz+v7aTbH7EvvStrdKy7nZ3x0YU00K5q78K/BYI+s0nxgnBTNF6MXdb6CiKLf4q8tZkwjUfdsE73NT1klGTxru6ESujv1/0I7UvlIYa3HPm/GmVJB1A6mppbWo1L6MEnhnGUlcI9gmTPwALGx0S7AseSGl0mMhWlsOasHUrTz0MTmGV2/qmiua3PdwFhy5F+j6xHjh05SNWj85CA2gAhQCJARV9n1eDFV2SYd0BKLqjpXhjlHDoMxtHGJgFJKEz+UvPc4UAyC/wEnxbFgSklVZ8KI5fsg+31uwqhkab26yLtUIQNpgH+JH8HD+mGSaaf40JKEG7pt4PNkEWbpi0ccgt04z3CAKGyhb80KVkGrdGEgZYWTbmSHj9nb7eZ7cUHU2Xdre4WjQoOUAugzr+/0p6dWBDisnCxB2kI2ll9MIaJRjfUWXMsMVh8Zx+CJIEetS5rC+p3dKRoV66HOoDKQnjdDswXMHbudbfLkHCj/4+E5jfAGlCJIMeHG7OpoafHe24QfmGkyRr/IMSDMTEDf2ZTNNsHqFoEJv0Gl6YPi+M5J327UKJq9woP1BD0U0Q7oQ/cKg5d8ptlzoqpekqc+cOKQcI8GgoZ6aUI3k5HlVwO1dwgxn9v1qszJntJhfjiJ2E6k4pm2MN7Icq8mlhEmiggKDwAzy7F9ERHXX9ueJ7rW1KsYRtvesHu+CNv0+6PXy6SXr4zulaUqrpiuVVyR7sCdztZ1bgh7v/qj41Zcf5OlDZbsxtFxAy+BMSF4cBxIgzf5VZZA5HDRH7RTvc7+m0OeK5iMKYD76J0S3Eu4QUCtyI7mWJk7l1hwkS5ey2iEgP7ikmFT5dVES+6RJwHAjCqEzSH7ffBkWUCO8LIz54rmYtKEfqWM1fIhchUm4PVbaoPJDCH67NqMyFU/YEmD4mj6LHpr01/3rjuPx5rSCDJXSAQ+sjGWfz2dFSBLl50rGoNsLuIPjlWbT8KHtw0X1bdONFULNvIw6GHUMWPZw== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 91ed6371-c465-42ee-1f5a-08da5aa16c93 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5056.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2022 14:04:18.5412 (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: L5vxLpA8FjH1rw/tAW8CEsO+tDdQA1nyED8JOKEL42MJf7Nfu/7+s7bZfFo4Mi52c0QS64OJH5O5P263s4OJBwADWDPF1LdIGluXou/pYos= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9322 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 the boot command is skipped and the "-s" parameter is not used. 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 cb15ca5..b1a9b9d 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,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 444c65a..994369c 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 @@ -1255,9 +1255,19 @@ echo "setenv fdt_high 0xffffffffffffffff" >> $UBOOT_SOURCE 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"