From patchwork Sun Jul 28 15:57:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Auer X-Patchwork-Id: 1138036 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=aisec.fraunhofer.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45xSJl3Vn1z9s8m for ; Mon, 29 Jul 2019 02:02:47 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 1ECD3C21E13; Sun, 28 Jul 2019 15:59:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id A818CC21DFB; Sun, 28 Jul 2019 15:59:24 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 64F26C21D72; Sun, 28 Jul 2019 15:57:58 +0000 (UTC) Received: from mail-edgeS23.fraunhofer.de (mail-edges23.fraunhofer.de [153.97.7.23]) by lists.denx.de (Postfix) with ESMTPS id 20020C21DE8 for ; Sun, 28 Jul 2019 15:57:56 +0000 (UTC) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2FpCAB1xT1d/xwBYJllHAEBAQQBAQcEAQGBZ4IXbVIBHzyHaIUyiBqEQAGHIpEoCQEBAQEBAQEBAQgfEAEBgQSDPAKCYyM4EwEDAQEFAQEBAQYCAmmFHgyEL18+BjIBRhBRIRwaBg4FgyIBgWoDHAGrPoN2hBENX4FICQGBKocJhFeBVz+BEAGDUIIaiA0EjkmbbkAHAoE5Y10EhXqJQoNrDBuNNIpalnqDQoZnhBaBZyKBWDMaJIM7CYYjhFGGCz0BMgGPDwEB X-IPAS-Result: A2FpCAB1xT1d/xwBYJllHAEBAQQBAQcEAQGBZ4IXbVIBHzyHaIUyiBqEQAGHIpEoCQEBAQEBAQEBAQgfEAEBgQSDPAKCYyM4EwEDAQEFAQEBAQYCAmmFHgyEL18+BjIBRhBRIRwaBg4FgyIBgWoDHAGrPoN2hBENX4FICQGBKocJhFeBVz+BEAGDUIIaiA0EjkmbbkAHAoE5Y10EhXqJQoNrDBuNNIpalnqDQoZnhBaBZyKBWDMaJIM7CYYjhFGGCz0BMgGPDwEB X-IronPort-AV: E=Sophos;i="5.64,319,1559512800"; d="scan'208";a="12233466" Received: from mail-mtaka28.fraunhofer.de ([153.96.1.28]) by mail-edgeS23.fraunhofer.de with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Jul 2019 17:57:55 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DIAQCvxD1dfRBhWMBlGwEBAQEDAQEBBwMBAQGBZ4MEUiA8jRqTfZEoCQEDAQEBAQEIHxABAYRAAoMFOBMBAwEBBAEBAgEGFAEBFjqFJQyFSwMDMgFGEFEhHBoGDgWDIgGBagMdqz2IBw1fgUgJAYEqhwmGLj+BEAGDUIIaiA0EjkmbbkAHAoE5Y10EhXqJQoNrDBuNNIpalnqDQop9gWcggVkzGiSDOwmGI4RRhgs9AzABjw8BAQ X-IronPort-AV: E=Sophos;i="5.64,319,1559512800"; d="scan'208";a="20209991" Received: from fgdemucivp01ltm.xch.fraunhofer.de (HELO FGDEMUCIMP12EXC.ads.fraunhofer.de) ([192.88.97.16]) by mail-mtaKA28.fraunhofer.de with ESMTP/TLS/AES256-SHA; 28 Jul 2019 17:57:56 +0200 Received: from localhost.de (10.80.233.51) by FGDEMUCIMP12EXC.ads.fraunhofer.de (10.80.232.43) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 28 Jul 2019 17:57:54 +0200 From: Lukas Auer To: Date: Sun, 28 Jul 2019 17:57:20 +0200 Message-ID: <20190728155723.3412-9-lukas.auer@aisec.fraunhofer.de> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190728155723.3412-1-lukas.auer@aisec.fraunhofer.de> References: <20190728155723.3412-1-lukas.auer@aisec.fraunhofer.de> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-11.0.0.4179-8.200.1013-24806.001 X-TM-AS-Result: No--8.874300-8.000000-31 X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No Cc: Alistair Francis Subject: [U-Boot] [PATCH v2 08/11] riscv: add a generic FIT generator script X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add a generic FIT generator script for RISC-V to generate images containing U-Boot, OpenSBI FW_DYNAMIC firmware, and optionally one or more device trees. The location of the OpenSBI firmware binary can be specified with the OPENSBI environment variable. By default, it is assumed to be "fw_dynamic.bin" and located in the U-Boot top-level. Device trees are passed as arguments to the generator script. A separate configuration entry is created for each device tree. The load addresses of U-Boot and OpenSBI are parsed from the U-Boot configuration. They can be overwritten with the UBOOT_LOAD_ADDR and OPENSBI_LOAD_ADDR environment variables. The script is based on the i.MX (arch/arm/mach-imx/mkimage_fit_atf.sh) and Allwinner sunxi (board/sunxi/mksunxi_fit_atf.sh) FIT generator scripts. Signed-off-by: Lukas Auer Reviewed-by: Bin Meng Tested-by: Bin Meng Reviewed-by: Anup Patel --- Changes in v2: None arch/riscv/lib/mkimage_fit_opensbi.sh | 100 ++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100755 arch/riscv/lib/mkimage_fit_opensbi.sh diff --git a/arch/riscv/lib/mkimage_fit_opensbi.sh b/arch/riscv/lib/mkimage_fit_opensbi.sh new file mode 100755 index 0000000000..d6f95e5bfd --- /dev/null +++ b/arch/riscv/lib/mkimage_fit_opensbi.sh @@ -0,0 +1,100 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0+ +# +# script to generate FIT image source for RISC-V boards with OpenSBI +# and, optionally, multiple device trees (given on the command line). +# +# usage: $0 [ [&2 + OPENSBI=/dev/null +fi + +cat << __HEADER_EOF +/dts-v1/; + +/ { + description = "Configuration to load OpenSBI before U-Boot"; + + images { + uboot { + description = "U-Boot"; + data = /incbin/("u-boot-nodtb.bin"); + type = "standalone"; + os = "U-Boot"; + arch = "riscv"; + compression = "none"; + load = <$UBOOT_LOAD_ADDR>; + }; + opensbi { + description = "RISC-V OpenSBI"; + data = /incbin/("$OPENSBI"); + type = "firmware"; + os = "opensbi"; + arch = "riscv"; + compression = "none"; + load = <$OPENSBI_LOAD_ADDR>; + entry = <$OPENSBI_LOAD_ADDR>; + }; +__HEADER_EOF + +cnt=1 +for dtname in $* +do + cat << __FDT_IMAGE_EOF + fdt_$cnt { + description = "$(basename $dtname .dtb)"; + data = /incbin/("$dtname"); + type = "flat_dt"; + compression = "none"; + }; +__FDT_IMAGE_EOF +cnt=$((cnt+1)) +done + +cat << __CONF_HEADER_EOF + }; + configurations { + default = "config_1"; + +__CONF_HEADER_EOF + +if [ $# -eq 0 ]; then +cat << __CONF_SECTION_EOF + config_1 { + description = "U-Boot FIT"; + firmware = "opensbi"; + loadables = "uboot"; + }; +__CONF_SECTION_EOF +else +cnt=1 +for dtname in $* +do +cat << __CONF_SECTION_EOF + config_$cnt { + description = "$(basename $dtname .dtb)"; + firmware = "opensbi"; + loadables = "uboot"; + fdt = "fdt_$cnt"; + }; +__CONF_SECTION_EOF +cnt=$((cnt+1)) +done +fi + +cat << __ITS_EOF + }; +}; +__ITS_EOF