From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anup Patel Date: Mon, 29 Jul 2019 14:09:24 +0530 Subject: [U-Boot] [PATCH v2 08/11] riscv: add a generic FIT generator script In-Reply-To: <20190728155723.3412-9-lukas.auer@aisec.fraunhofer.de> References: <20190728155723.3412-1-lukas.auer@aisec.fraunhofer.de> <20190728155723.3412-9-lukas.auer@aisec.fraunhofer.de> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Sun, Jul 28, 2019 at 9:30 PM Lukas Auer wrote: > > 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 > --- > > 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 [ [ + > +[ -z "$OPENSBI" ] && OPENSBI="fw_dynamic.bin" > + > +if [ -z "$UBOOT_LOAD_ADDR" ]; then > + UBOOT_LOAD_ADDR="$(grep "^CONFIG_SYS_TEXT_BASE=" .config | awk 'BEGIN{FS="="} {print $2}')" > +fi > + > +if [ -z "$OPENSBI_LOAD_ADDR" ]; then > + OPENSBI_LOAD_ADDR="$(grep "^CONFIG_SPL_OPENSBI_LOAD_ADDR=" .config | awk 'BEGIN{FS="="} {print $2}')" > +fi > + > +if [ ! -f $OPENSBI ]; then > + echo "WARNING: OpenSBI binary \"$OPENSBI\" not found, resulting binary is not functional." >&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 > -- > 2.21.0 > > _______________________________________________ > U-Boot mailing list > U-Boot at lists.denx.de > https://lists.denx.de/listinfo/u-boot Reviewed-by: Anup Patel Regards, Anup