From patchwork Wed Aug 21 19:14:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Auer X-Patchwork-Id: 1151130 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 46DHSW0Sp6z9s7T for ; Thu, 22 Aug 2019 05:15:54 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id B5DB6C22049; Wed, 21 Aug 2019 19:15:22 +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 24F51C21E0B; Wed, 21 Aug 2019 19:15:09 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A1B9EC21E0B; Wed, 21 Aug 2019 19:15:06 +0000 (UTC) Received: from mail-edgeS23.fraunhofer.de (mail-edges23.fraunhofer.de [153.97.7.23]) by lists.denx.de (Postfix) with ESMTPS id 48DE4C21F29 for ; Wed, 21 Aug 2019 19:15:06 +0000 (UTC) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2GVAAB4l11d/xoHYZlkHgEGBwaBUwkLAYIXbVIgPIdphTKGAoMNgTMBlmGBewkBAQEBAQEBAQEIHxABAYEEgzuCXyM0CQ4CBQEBBQEBAQEBBgQCAmmFJwyEL192AUEFgR4gDoMnAYIJAaxQg3eFF4FJCQGBKgGHFIRZgVg/gRABgl2LGgSOYpxzBwKBOmVfBIYFjUUMG4IxixyKeY8RkmeEGYFQOYFYMxokgzsJiWmHFz0BMo1GAQE X-IPAS-Result: A2GVAAB4l11d/xoHYZlkHgEGBwaBUwkLAYIXbVIgPIdphTKGAoMNgTMBlmGBewkBAQEBAQEBAQEIHxABAYEEgzuCXyM0CQ4CBQEBBQEBAQEBBgQCAmmFJwyEL192AUEFgR4gDoMnAYIJAaxQg3eFF4FJCQGBKgGHFIRZgVg/gRABgl2LGgSOYpxzBwKBOmVfBIYFjUUMG4IxixyKeY8RkmeEGYFQOYFYMxokgzsJiWmHFz0BMo1GAQE X-IronPort-AV: E=Sophos;i="5.64,412,1559512800"; d="scan'208";a="12659887" Received: from mail-mtas26.fraunhofer.de ([153.97.7.26]) by mail-edgeS23.fraunhofer.de with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Aug 2019 21:15:05 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BWAAB4l11dfRBhWMBkHQEBBQEHBQGBUwgBCwGDBFIgPIw7YIkPmBWBewkBAwEBAQEBCB8QAQGEP4MBNAkOAgUBAQQBAQECAQYEFAEBFjqFLgyGAwFBBYEeIA6DJwGCCqxQiQ6BSQkBgSoBhxSGMT+BEAGCXYsaBI5inHMHAoE6ZV8EhgWNRQwbgjGLHIp5jxGXAIFQN4FZMxokgzsJiWmHFz0DMI1GAQE X-IronPort-AV: E=Sophos;i="5.64,412,1559512800"; d="scan'208";a="86123317" Received: from fgdemucivp01ltm.xch.fraunhofer.de (HELO FGDEMUCIMP11EXC.ads.fraunhofer.de) ([192.88.97.16]) by mail-mtaS26.fraunhofer.de with ESMTP/TLS/AES256-SHA; 21 Aug 2019 21:15:04 +0200 Received: from localhost.de (10.80.233.50) by FGDEMUCIMP11EXC.ads.fraunhofer.de (10.80.232.42) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 21 Aug 2019 21:15:03 +0200 From: Lukas Auer To: Date: Wed, 21 Aug 2019 21:14:39 +0200 Message-ID: <20190821191450.14507-1-lukas.auer@aisec.fraunhofer.de> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-11.0.0.4179-8.200.1013-24858.003 X-TM-AS-Result: No--11.230700-8.000000-31 X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No Cc: Alistair Francis Subject: [U-Boot] [RESEND PATCH v4 00/11] SPL support for RISC-V 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" This series adds support for SPL to RISC-V U-Boot. Images can be booted via OpenSBI (FW_DYNAMIC firmware) or by directly jumping to them. In the former case, OpenSBI and U-Boot proper are bundled as a FIT image and made available to U-Boot SPL. Currently, only the QEMU board enables U-Boot SPL with a dedicated configuration. It uses RAM as SPL boot device. On many RISC-V CPUs, the device tree is provided to U-Boot by the first stage bootloader. This requires changes to U-Boot SPL (patches 1, 2 and 3), which modify the behavior on other boards as well. To test this series, OpenSBI has to be compiled first. The fw_dynamic.bin binary must be copied into the U-Boot root directory. Alternatively, the location of the binary can be specified with the OPENSBI environment variable. U-Boot can then be build as normal using the configuration qemu-riscv64_spl_defconfig for 64-bit builds or qemu-riscv32_spl_defconfig for 32-bit builds. The outputs from the build process are the U-Boot SPL binary (spl/u-boot-spl.bin) and the U-Boot FIT image (u-boot.itb) containing U-Boot proper and OpenSBI. U-Boot can be run in QEMU with the following command. qemu-system-riscv64 -nographic -machine virt -kernel spl/u-boot-spl \ -device loader,file=u-boot.itb,addr=0x80200000 Changes in v4: - Also build the device tree if CONFIG_OF_HOSTFILE is selected, otherwise sandbox_spl is broken Changes in v3: - Rebase on u-boot-riscv/master - Update commit message to include minimum version of OpenSBI - Rebase on u-boot/master - Add note on minimum version of OpenSBI Changes in v2: - Rebase on master and format documentation as reStructuredText Lukas Auer (11): fdtdec: make CONFIG_OF_PRIOR_STAGE available in SPL Makefile: support building SPL FIT images without device trees spl: fit: use U-Boot device tree when FIT image has no device tree riscv: add run mode configuration for SPL spl: support booting via RISC-V OpenSBI riscv: add SPL support riscv: support SPL stack and global data relocation riscv: add a generic FIT generator script riscv: set default FIT generator script and build target for SPL builds riscv: qemu: add SPL configuration doc: update QEMU RISC-V documentation Kconfig | 4 +- Makefile | 8 +- arch/Kconfig | 6 ++ arch/riscv/Kconfig | 36 +++++++-- arch/riscv/cpu/ax25/Kconfig | 6 +- arch/riscv/cpu/cpu.c | 6 +- arch/riscv/cpu/generic/Kconfig | 5 +- arch/riscv/cpu/start.S | 62 ++++++++++++++- arch/riscv/cpu/u-boot-spl.lds | 82 +++++++++++++++++++ arch/riscv/include/asm/encoding.h | 2 +- arch/riscv/include/asm/spl.h | 31 ++++++++ arch/riscv/lib/Makefile | 8 +- arch/riscv/lib/mkimage_fit_opensbi.sh | 100 ++++++++++++++++++++++++ arch/riscv/lib/spl.c | 48 ++++++++++++ board/emulation/qemu-riscv/Kconfig | 10 +++ board/emulation/qemu-riscv/MAINTAINERS | 2 + board/emulation/qemu-riscv/qemu-riscv.c | 17 ++++ common/image.c | 1 + common/spl/Kconfig | 17 ++++ common/spl/Makefile | 1 + common/spl/spl.c | 8 +- common/spl/spl_fit.c | 37 ++++++--- common/spl/spl_opensbi.c | 85 ++++++++++++++++++++ configs/qemu-riscv32_spl_defconfig | 11 +++ configs/qemu-riscv64_spl_defconfig | 12 +++ doc/board/emulation/qemu-riscv.rst | 60 +++++++++++++- include/configs/qemu-riscv.h | 14 ++++ include/fdtdec.h | 2 +- include/image.h | 1 + include/opensbi.h | 40 ++++++++++ include/spl.h | 5 ++ lib/fdtdec.c | 6 +- 32 files changed, 691 insertions(+), 42 deletions(-) create mode 100644 arch/riscv/cpu/u-boot-spl.lds create mode 100644 arch/riscv/include/asm/spl.h create mode 100755 arch/riscv/lib/mkimage_fit_opensbi.sh create mode 100644 arch/riscv/lib/spl.c create mode 100644 common/spl/spl_opensbi.c create mode 100644 configs/qemu-riscv32_spl_defconfig create mode 100644 configs/qemu-riscv64_spl_defconfig create mode 100644 include/opensbi.h