From patchwork Wed Aug 21 19:14:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Auer X-Patchwork-Id: 1151140 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 46DHb914y0z9sBF for ; Thu, 22 Aug 2019 05:21:41 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id BF023C2202F; Wed, 21 Aug 2019 19:20:36 +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 F2AA2C22048; Wed, 21 Aug 2019 19:16:15 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D55C2C21F29; Wed, 21 Aug 2019 19:15:18 +0000 (UTC) Received: from mail-edgeS23.fraunhofer.de (mail-edges23.fraunhofer.de [153.97.7.23]) by lists.denx.de (Postfix) with ESMTPS id 44AF6C22034 for ; Wed, 21 Aug 2019 19:15:15 +0000 (UTC) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2EyAAB4l11d/xoHYZlkGwEBAQEDAQEBBwMBAQGBVQQBAQELAYIXbVIgPI0bhgKDDYhgjzWBPzwJAQEBAQEBAQEBCCMMAQEChD0Cgl0jNgcOAgUBAQUBAQEBAQYEAgJphScMgnQETTswAQEBAQEBAQEBAQEBAQEBGgINZAYyAUYQUSEcGgYOBYMiAYFqAxwBD6xBhEhBgxcNYYFDBgkBgSoBhxSEWYFYP4EQAYJdc4IaRwKBKiOFVSIEjCsSgiWcBi1ABwKBOmVfBIYFiViDbQwbgjGLHIp5jxGGLYF6jlmBVgEygVgzGiSDO4YtB4pVPQEyAYpzASWCLAEB X-IPAS-Result: A2EyAAB4l11d/xoHYZlkGwEBAQEDAQEBBwMBAQGBVQQBAQELAYIXbVIgPI0bhgKDDYhgjzWBPzwJAQEBAQEBAQEBCCMMAQEChD0Cgl0jNgcOAgUBAQUBAQEBAQYEAgJphScMgnQETTswAQEBAQEBAQEBAQEBAQEBGgINZAYyAUYQUSEcGgYOBYMiAYFqAxwBD6xBhEhBgxcNYYFDBgkBgSoBhxSEWYFYP4EQAYJdc4IaRwKBKiOFVSIEjCsSgiWcBi1ABwKBOmVfBIYFiViDbQwbgjGLHIp5jxGGLYF6jlmBVgEygVgzGiSDO4YtB4pVPQEyAYpzASWCLAEB X-IronPort-AV: E=Sophos;i="5.64,412,1559512800"; d="scan'208";a="12659899" 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:14 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0ArAAB4l11dfRBhWMBkGwEBAQEDAQEBBwMBAQGBVQQBAQELAYMEUiA8jRuJD4hgjzWBewkBAwEBAQEBCCMMAQGEPwKCfzYHDgIFAQEEAQEBAgEGBBQBARY6hS4MhUsDAzIBRhBRIRwaBg4FgyIBgWoDHQ+sQYRIQYMXDWGBQwYJAYEqAYcUhjE/gRABgl1zghpHAoEqI4VVIgSMKxKCJZwGLUAHAoE6ZV8EhgWJWINtDBuCMYscinmPEYYtgXqOWYFWATCBWTMaJIM7hi0HilU9AzABinMBJYIsAQE X-IronPort-AV: E=Sophos;i="5.64,412,1559512800"; d="scan'208";a="86123337" 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:14 +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:13 +0200 From: Lukas Auer To: Date: Wed, 21 Aug 2019 21:14:50 +0200 Message-ID: <20190821191450.14507-12-lukas.auer@aisec.fraunhofer.de> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190821191450.14507-1-lukas.auer@aisec.fraunhofer.de> References: <20190821191450.14507-1-lukas.auer@aisec.fraunhofer.de> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-11.0.0.4179-8.200.1013-24858.003 X-TM-AS-Result: No--16.403600-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 11/11] doc: update QEMU RISC-V documentation 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" The available defconfigs for RISC-V QEMU have changed. We now have configurations to compile U-Boot to run in supervisor mode and for U-Boot SPL. Update the QEMU RISC-V documentation to reflect these changes. Signed-off-by: Lukas Auer Reviewed-by: Bin Meng Tested-by: Bin Meng Reviewed-by: Anup Patel --- Changes in v4: None Changes in v3: - Add note on minimum version of OpenSBI Changes in v2: - Rebase on master and format documentation as reStructuredText doc/board/emulation/qemu-riscv.rst | 60 +++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/doc/board/emulation/qemu-riscv.rst b/doc/board/emulation/qemu-riscv.rst index 214833496b..fe7505e201 100644 --- a/doc/board/emulation/qemu-riscv.rst +++ b/doc/board/emulation/qemu-riscv.rst @@ -6,7 +6,8 @@ QEMU RISC-V QEMU for RISC-V supports a special 'virt' machine designed for emulation and virtualization purposes. This document describes how to run U-Boot under it. -Both 32-bit 64-bit targets are supported. +Both 32-bit and 64-bit targets are supported, running in either machine or +supervisor mode. The QEMU virt machine models a generic RISC-V virtual machine with support for the VirtIO standard networking and block storage devices. It has CLINT, PLIC, @@ -28,6 +29,11 @@ Set the CROSS_COMPILE environment variable as usual, and run: make qemu-riscv64_defconfig make +This will compile U-Boot for machine mode. To build supervisor mode binaries, +use the configurations qemu-riscv32_smode_defconfig and +qemu-riscv64_smode_defconfig instead. Note that U-Boot running in supervisor +mode requires a supervisor binary interface (SBI), such as RISC-V OpenSBI. + Running U-Boot -------------- The minimal QEMU command line to get U-Boot up and running is: @@ -46,4 +52,56 @@ parameter. For example, '-m 2G' creates 2GiB memory for the target, and the memory node in the embedded DTB created by QEMU reflects the new setting. +For instructions on how to run U-Boot in supervisor mode on QEMU +with OpenSBI, see the documentation available with OpenSBI: +https://github.com/riscv/opensbi/blob/master/docs/platform/qemu_virt.md + These have been tested in QEMU 3.0.0. + +Running U-Boot SPL +------------------ +In the default SPL configuration, U-Boot SPL starts in machine mode. U-Boot +proper and OpenSBI (FW_DYNAMIC firmware) are bundled as FIT image and made +available to U-Boot SPL. Both are then loaded by U-Boot SPL and the location +of U-Boot proper is passed to OpenSBI. After initialization, U-Boot proper is +started in supervisor mode by OpenSBI. + +OpenSBI must be compiled before compiling U-Boot. Version 0.4 and higher is +supported by U-Boot. Clone the OpenSBI repository and run the following command. + +.. code-block:: console + + git clone https://github.com/riscv/opensbi.git + cd opensbi + make PLATFORM=qemu/virt + +See the OpenSBI documentation for full details: +https://github.com/riscv/opensbi/blob/master/docs/platform/qemu_virt.md + +To make the FW_DYNAMIC binary (build/platform/qemu/virt/firmware/fw_dynamic.bin) +available to U-Boot, either copy it into the U-Boot root directory or specify +its location with the OPENSBI environment variable. Afterwards, compile U-Boot +with the following commands. + +- For 32-bit RISC-V:: + + make qemu-riscv32_spl_defconfig + make + +- For 64-bit RISC-V:: + + make qemu-riscv64_spl_defconfig + make + +The minimal QEMU commands to run U-Boot SPL in both 32-bit and 64-bit +configurations are: + +- For 32-bit RISC-V:: + + qemu-system-riscv32 -nographic -machine virt -kernel spl/u-boot-spl \ + -device loader,file=u-boot.itb,addr=0x80200000 + +- For 64-bit RISC-V:: + + qemu-system-riscv64 -nographic -machine virt -kernel spl/u-boot-spl \ + -device loader,file=u-boot.itb,addr=0x80200000